From f70ec1fa75ef526266ad359d2db0e25f2635c182 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 18 Jul 2007 09:36:47 +0000 Subject: [PATCH] * Added a FileSystemObject to SimpleApp * Added Some ShapeTypes (shapes doesn't work though!) * Fixed some \0 issues --- OpenSim/Framework/General/Types/PrimData.cs | 58 +++++++-------- .../General/Types/PrimitiveBaseShape.cs | 74 ++++++++++++------- OpenSim/Region/ClientStack/ClientView.API.cs | 4 +- .../Examples/SimpleApp/FileSystemObject.cs | 31 ++++++++ OpenSim/Region/Examples/SimpleApp/Program.cs | 26 ++++++- 5 files changed, 131 insertions(+), 62 deletions(-) create mode 100644 OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs diff --git a/OpenSim/Framework/General/Types/PrimData.cs b/OpenSim/Framework/General/Types/PrimData.cs index 6b8fa3a1d8..9b24c0f1b1 100644 --- a/OpenSim/Framework/General/Types/PrimData.cs +++ b/OpenSim/Framework/General/Types/PrimData.cs @@ -194,35 +194,35 @@ namespace OpenSim.Framework.Types return bytes; } - public static PrimData DefaultCube() - { - PrimData primData = new PrimData(); - primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - primData.FullID = LLUUID.Random(); - primData.Scale = new LLVector3(0.5f, 0.5f, 0.5f); - primData.Rotation = new LLQuaternion(0, 0, 0, 1); - primData.PCode = 9; - primData.ParentID = 0; - primData.PathBegin = 0; - primData.PathEnd = 0; - primData.PathScaleX = 0; - primData.PathScaleY = 0; - primData.PathShearX = 0; - primData.PathShearY = 0; - primData.PathSkew = 0; - primData.ProfileBegin = 0; - primData.ProfileEnd = 0; - primData.PathCurve = 16; - primData.ProfileCurve = 1; - primData.ProfileHollow = 0; - primData.PathRadiusOffset = 0; - primData.PathRevolutions = 0; - primData.PathTaperX = 0; - primData.PathTaperY = 0; - primData.PathTwist = 0; - primData.PathTwistBegin = 0; + //public static PrimData DefaultCube() + //{ + // PrimData primData = new PrimData(); + // primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + // primData.FullID = LLUUID.Random(); + // primData.Scale = new LLVector3(0.5f, 0.5f, 0.5f); + // primData.Rotation = new LLQuaternion(0, 0, 0, 1); + // primData.PCode = 9; + // primData.ParentID = 0; + // primData.PathBegin = 0; + // primData.PathEnd = 0; + // primData.PathScaleX = 0; + // primData.PathScaleY = 0; + // primData.PathShearX = 0; + // primData.PathShearY = 0; + // primData.PathSkew = 0; + // primData.ProfileBegin = 0; + // primData.ProfileEnd = 0; + // primData.PathCurve = 16; + // primData.ProfileCurve = 1; + // primData.ProfileHollow = 0; + // primData.PathRadiusOffset = 0; + // primData.PathRevolutions = 0; + // primData.PathTaperX = 0; + // primData.PathTaperY = 0; + // primData.PathTwist = 0; + // primData.PathTwistBegin = 0; - return primData; - } + // return primData; + //} } } diff --git a/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs index e058c07203..9ab6071c8b 100644 --- a/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs @@ -19,7 +19,7 @@ namespace OpenSim.Framework.Types public class PrimitiveBaseShape { - private ShapeType type = ShapeType.Unknown; + protected ShapeType type = ShapeType.Unknown; public byte PCode; public ushort PathBegin; @@ -72,38 +72,56 @@ namespace OpenSim.Framework.Types public PrimitiveBaseShape Copy() { - return (PrimitiveBaseShape) this.MemberwiseClone(); + return (PrimitiveBaseShape)this.MemberwiseClone(); + } + } + + public class BoxShape : PrimitiveBaseShape + { + public BoxShape() + { + type = ShapeType.Box; } - public static PrimitiveBaseShape DefaultBox() + public static BoxShape Default { - PrimitiveBaseShape primShape = new PrimitiveBaseShape(); + get + { + BoxShape primShape = new BoxShape(); - primShape.type = ShapeType.Box; - primShape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); - primShape.PCode = 9; - primShape.PathBegin = 0; - primShape.PathEnd = 0; - primShape.PathScaleX = 0; - primShape.PathScaleY = 0; - primShape.PathShearX = 0; - primShape.PathShearY = 0; - primShape.PathSkew = 0; - primShape.ProfileBegin = 0; - primShape.ProfileEnd = 0; - primShape.PathCurve = 16; - primShape.ProfileCurve = 1; - primShape.ProfileHollow = 0; - primShape.PathRadiusOffset = 0; - primShape.PathRevolutions = 0; - primShape.PathTaperX = 0; - primShape.PathTaperY = 0; - primShape.PathTwist = 0; - primShape.PathTwistBegin = 0; - LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")); - primShape.TextureEntry = ntex.ToBytes(); + primShape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); + primShape.PCode = 9; + primShape.PathBegin = 0; + primShape.PathEnd = 0; + primShape.PathScaleX = 0; + primShape.PathScaleY = 0; + primShape.PathShearX = 0; + primShape.PathShearY = 0; + primShape.PathSkew = 0; + primShape.ProfileBegin = 0; + primShape.ProfileEnd = 0; + primShape.PathCurve = 16; + primShape.ProfileCurve = 1; + primShape.ProfileHollow = 0; + primShape.PathRadiusOffset = 0; + primShape.PathRevolutions = 0; + primShape.PathTaperX = 0; + primShape.PathTaperY = 0; + primShape.PathTwist = 0; + primShape.PathTwistBegin = 0; + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")); + primShape.TextureEntry = ntex.ToBytes(); - return primShape; + return primShape; + } + } + } + + public class SphereShape : PrimitiveBaseShape + { + public SphereShape() + { + type = ShapeType.Sphere; } } } diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 2ac10006be..044ad6863a 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -779,7 +779,7 @@ namespace OpenSim.Region.ClientStack outPacket.ObjectData[0].ID = localID; outPacket.ObjectData[0].FullID = objectID; outPacket.ObjectData[0].OwnerID = ownerID; - outPacket.ObjectData[0].Text = enc.GetBytes(text); + outPacket.ObjectData[0].Text = Helpers.StringToField( text ); outPacket.ObjectData[0].ParentID = parentID; byte[] pb = pos.GetBytes(); Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); @@ -798,7 +798,7 @@ namespace OpenSim.Region.ClientStack outPacket.ObjectData[0].ID = localID; outPacket.ObjectData[0].FullID = objectID; outPacket.ObjectData[0].OwnerID = ownerID; - outPacket.ObjectData[0].Text = enc.GetBytes(text); + outPacket.ObjectData[0].Text = Helpers.StringToField( text ); outPacket.ObjectData[0].ParentID = parentID; byte[] pb = pos.GetBytes(); Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); diff --git a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs new file mode 100644 index 0000000000..2e43fe6ab5 --- /dev/null +++ b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes; +using libsecondlife; +using OpenSim.Framework.Types; +using System.Timers; +using System.Diagnostics; +using System.IO; +using Primitive=OpenSim.Region.Environment.Scenes.Primitive; + +namespace SimpleApp +{ + public class FileSystemObject : SceneObject + { + public FileSystemObject(Scene world, FileInfo fileInfo, LLVector3 pos) + : base( world, world.EventManager, LLUUID.Zero, world.NextLocalId, pos, BoxShape.Default ) + { + + + float size = (float)Math.Pow((double)fileInfo.Length, (double) 1 / 3) / 5; + rootPrimitive.ResizeGoup(new LLVector3(size, size, size)); + rootPrimitive.Text = fileInfo.Name; + } + + public override void Update() + { + base.Update(); + } + } +} diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 4dae4618e4..82dba0e845 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -17,6 +17,7 @@ using System.Timers; using OpenSim.Region.Environment.Scenes; using OpenSim.Framework.Data; using OpenSim.Region.Environment; +using System.IO; namespace SimpleApp { @@ -58,16 +59,35 @@ namespace SimpleApp udpServer.ServerListener(); - PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox(); + PrimitiveBaseShape shape = BoxShape.Default; shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); LLVector3 pos = new LLVector3(138, 129, 27); - SceneObject m_sceneObject = new CpuCounterObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape); - scene.AddEntity(m_sceneObject); + SceneObject sceneObject = new CpuCounterObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape); + scene.AddEntity(sceneObject); MyNpcCharacter m_character = new MyNpcCharacter( scene.EventManager ); scene.AddNewClient(m_character, false); + DirectoryInfo dirInfo = new DirectoryInfo( "." ); + + float x = 0; + float z = 0; + + foreach( FileInfo fileInfo in dirInfo.GetFiles()) + { + LLVector3 filePos = new LLVector3(100 + x, 129, 27 + z); + x = x + 2; + if( x > 50 ) + { + x = 0; + z = z + 2; + } + + FileSystemObject fileObject = new FileSystemObject( scene, fileInfo, filePos ); + scene.AddEntity(fileObject); + } + m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit."); m_log.ReadLine(); }