コード例 #1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public Primitive()
 {
     Flexible     = new FlexibleData();
     Light        = new LightData();
     LightMap     = new LightImage();
     Sculpt       = new SculptData();
     PrimData     = new ConstructionData();
     PhysicsProps = new PhysicsProperties();
 }
コード例 #2
0
ファイル: Prims.cs プロジェクト: chrbayer84/SLAgentCSServer
            public static SculptData FromLLSD(LLSD llsd)
            {
                SculptData sculpt = new SculptData();

                if (llsd.Type == LLSDType.Map)
                {
                    LLSDMap map = (LLSDMap)llsd;

                    sculpt.SculptTexture = map["texture"].AsUUID();
                    sculpt.Type          = (SculptType)map["type"].AsInteger();
                }

                return(sculpt);
            }
コード例 #3
0
            public static SculptData FromOSD(OSD osd)
            {
                SculptData sculpt = new SculptData();

                if (osd.Type == OSDType.Map)
                {
                    OSDMap map = (OSDMap)osd;

                    sculpt.SculptTexture = map["texture"].AsUUID();
                    sculpt.type          = (byte)map["type"].AsInteger();
                }

                return(sculpt);
            }
コード例 #4
0
ファイル: Prims.cs プロジェクト: chrbayer84/SLAgentCSServer
        internal int SetExtraParamsFromBytes(byte[] data, int pos)
        {
            int i           = pos;
            int totalLength = 1;

            if (data.Length == 0 || pos >= data.Length)
            {
                return(0);
            }

            try
            {
                byte extraParamCount = data[i++];

                for (int k = 0; k < extraParamCount; k++)
                {
                    ExtraParamType type = (ExtraParamType)Helpers.BytesToUInt16(data, i);
                    i += 2;

                    uint paramLength = Helpers.BytesToUIntBig(data, i);
                    i += 4;

                    if (type == ExtraParamType.Flexible)
                    {
                        Flexible = new FlexibleData(data, i);
                    }
                    else if (type == ExtraParamType.Light)
                    {
                        Light = new LightData(data, i);
                    }
                    else if (type == ExtraParamType.Sculpt)
                    {
                        Sculpt = new SculptData(data, i);
                    }

                    i           += (int)paramLength;
                    totalLength += (int)paramLength + 6;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return(totalLength);
        }
コード例 #5
0
        public int SetExtraParamsFromBytes(byte[] data, int pos)
        {
            int i           = pos;
            int totalLength = 1;

            if (data.Length == 0 || pos >= data.Length)
            {
                return(0);
            }

            byte extraParamCount = data[i++];

            for (int k = 0; k < extraParamCount; k++)
            {
                ExtraParamType type = (ExtraParamType)Utils.BytesToUInt16(data, i);
                i += 2;

                uint paramLength = Utils.BytesToUInt(data, i);
                i += 4;

                if (type == ExtraParamType.Flexible)
                {
                    Flexible = new FlexibleData(data, i);
                }
                else if (type == ExtraParamType.Light)
                {
                    Light = new LightData(data, i);
                }
                else if (type == ExtraParamType.LightImage)
                {
                    LightMap = new LightImage(data, i);
                }
                else if (type == ExtraParamType.Sculpt || type == ExtraParamType.Mesh)
                {
                    Sculpt = new SculptData(data, i);
                }

                i           += (int)paramLength;
                totalLength += (int)paramLength + 6;
            }

            return(totalLength);
        }
コード例 #6
0
 public Primitive(Primitive prim)
 {
     CollisionPlane = prim.CollisionPlane;
     Flexible       = prim.Flexible;
     Light          = prim.Light;
     LightMap       = prim.LightMap;
     Sculpt         = prim.Sculpt;
     PrimData       = prim.PrimData;
     // FIXME: Get a real copy constructor for TextureEntry instead of serializing to bytes and back
     if (prim.Textures != null)
     {
         byte[] textureBytes = prim.Textures.GetBytes();
         Textures = new TextureEntry(textureBytes, 0, textureBytes.Length);
     }
     else
     {
         Textures = null;
     }
     TextureAnim = prim.TextureAnim;
     //ParticleSys = prim.ParticleSys;
 }
コード例 #7
0
ファイル: Prims.cs プロジェクト: chrbayer84/SLAgentCSServer
        public static Primitive FromLLSD(LLSD llsd)
        {
            Primitive prim = new Primitive();

            LLObject.ObjectData data = new ObjectData();

            LLSDMap map     = (LLSDMap)llsd;
            LLSDMap volume  = (LLSDMap)map["volume"];
            LLSDMap path    = (LLSDMap)volume["path"];
            LLSDMap profile = (LLSDMap)volume["profile"];

            #region Path/Profile

            data.PathBegin        = (float)path["begin"].AsReal();
            data.PathCurve        = (PathCurve)path["curve"].AsInteger();
            data.PathEnd          = (float)path["end"].AsReal();
            data.PathRadiusOffset = (float)path["radius_offset"].AsReal();
            data.PathRevolutions  = (float)path["revolutions"].AsReal();
            data.PathScaleX       = (float)path["scale_x"].AsReal();
            data.PathScaleY       = (float)path["scale_y"].AsReal();
            data.PathShearX       = (float)path["shear_x"].AsReal();
            data.PathShearY       = (float)path["shear_y"].AsReal();
            data.PathSkew         = (float)path["skew"].AsReal();
            data.PathTaperX       = (float)path["taper_x"].AsReal();
            data.PathTaperY       = (float)path["taper_y"].AsReal();
            data.PathTwist        = (float)path["twist"].AsReal();
            data.PathTwistBegin   = (float)path["twist_begin"].AsReal();

            data.ProfileBegin  = (float)profile["begin"].AsReal();
            data.ProfileCurve  = (ProfileCurve)profile["curve"].AsInteger();
            data.ProfileHole   = (HoleType)profile["hole"].AsInteger();
            data.ProfileEnd    = (float)profile["end"].AsReal();
            data.ProfileHollow = (float)profile["hollow"].AsReal();

            #endregion Path/Profile

            prim.Data = data;

            if (map["phantom"].AsBoolean())
            {
                prim.Flags |= ObjectFlags.Phantom;
            }

            if (map["physical"].AsBoolean())
            {
                prim.Flags |= ObjectFlags.Physics;
            }

            if (map["shadows"].AsBoolean())
            {
                prim.Flags |= ObjectFlags.CastShadows;
            }

            prim.ParentID = (uint)map["parentid"].AsInteger();
            prim.Position.FromLLSD(map["position"]);
            prim.Rotation.FromLLSD(map["rotation"]);
            prim.Scale.FromLLSD(map["scale"]);
            prim.Data.Material = (MaterialType)map["material"].AsInteger();
            prim.Flexible      = FlexibleData.FromLLSD(map["flex"]);
            prim.Light         = LightData.FromLLSD(map["light"]);
            prim.Sculpt        = SculptData.FromLLSD(map["sculpt"]);
            prim.Textures      = TextureEntry.FromLLSD(map["textures"]);
            if (!string.IsNullOrEmpty(map["name"].AsString()))
            {
                prim.Properties.Name = map["name"].AsString();
            }

            if (!string.IsNullOrEmpty(map["description"].AsString()))
            {
                prim.Properties.Description = map["description"].AsString();
            }

            return(prim);
        }
コード例 #8
0
ファイル: Prims.cs プロジェクト: RavenB/gridsearch
        internal int SetExtraParamsFromBytes(byte[] data, int pos)
        {
            int i = pos;
            int totalLength = 1;

            if (data.Length == 0 || pos >= data.Length)
                return 0;

            try
            {
                byte extraParamCount = data[i++];

                for (int k = 0; k < extraParamCount; k++)
                {
                    ExtraParamType type = (ExtraParamType)Helpers.BytesToUInt16(data, i);
                    i += 2;

                    uint paramLength = Helpers.BytesToUIntBig(data, i);
                    i += 4;

                    if (type == ExtraParamType.Flexible)
                        Flexible = new FlexibleData(data, i);
                    else if (type == ExtraParamType.Light)
                        Light = new LightData(data, i);
                    else if (type == ExtraParamType.Sculpt)
                        Sculpt = new SculptData(data, i);

                    i += (int)paramLength;
                    totalLength += (int)paramLength + 6;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return totalLength;
        }
コード例 #9
0
ファイル: Prims.cs プロジェクト: chrbayer84/SLAgentCSServer
            public static SculptData FromLLSD(LLSD llsd)
            {
                SculptData sculpt = new SculptData();

                if (llsd.Type == LLSDType.Map)
                {
                    LLSDMap map = (LLSDMap)llsd;

                    sculpt.SculptTexture = map["texture"].AsUUID();
                    sculpt.Type = (SculptType)map["type"].AsInteger();
                }

                return sculpt;
            }
コード例 #10
0
        public static Primitive FromOSD(OSD osd)
        {
            Primitive prim = new Primitive();

            Primitive.ConstructionData data;

            OSDMap map     = (OSDMap)osd;
            OSDMap volume  = (OSDMap)map["volume"];
            OSDMap path    = (OSDMap)volume["path"];
            OSDMap profile = (OSDMap)volume["profile"];

            #region Path/Profile

            data.profileCurve = (byte)0;
            data.State        = 0;
            data.Material     = (Material)map["material"].AsInteger();
            data.PCode        = PCode.Prim; // TODO: Put this in SD

            data.PathBegin        = (float)path["begin"].AsReal();
            data.PathCurve        = (PathCurve)path["curve"].AsInteger();
            data.PathEnd          = (float)path["end"].AsReal();
            data.PathRadiusOffset = (float)path["radius_offset"].AsReal();
            data.PathRevolutions  = (float)path["revolutions"].AsReal();
            data.PathScaleX       = (float)path["scale_x"].AsReal();
            data.PathScaleY       = (float)path["scale_y"].AsReal();
            data.PathShearX       = (float)path["shear_x"].AsReal();
            data.PathShearY       = (float)path["shear_y"].AsReal();
            data.PathSkew         = (float)path["skew"].AsReal();
            data.PathTaperX       = (float)path["taper_x"].AsReal();
            data.PathTaperY       = (float)path["taper_y"].AsReal();
            data.PathTwist        = (float)path["twist"].AsReal();
            data.PathTwistBegin   = (float)path["twist_begin"].AsReal();

            data.ProfileBegin  = (float)profile["begin"].AsReal();
            data.ProfileEnd    = (float)profile["end"].AsReal();
            data.ProfileHollow = (float)profile["hollow"].AsReal();
            data.ProfileCurve  = (ProfileCurve)profile["curve"].AsInteger();
            data.ProfileHole   = (HoleType)profile["hole"].AsInteger();

            #endregion Path/Profile

            prim.PrimData = data;

            if (map["phantom"].AsBoolean())
            {
                prim.Flags |= PrimFlags.Phantom;
            }

            if (map["physical"].AsBoolean())
            {
                prim.Flags |= PrimFlags.Physics;
            }

            if (map["shadows"].AsBoolean())
            {
                prim.Flags |= PrimFlags.CastShadows;
            }

            prim.ParentID   = (uint)map["parentid"].AsInteger();
            prim.Position   = ((OSDArray)map["position"]).AsVector3();
            prim.Rotation   = ((OSDArray)map["rotation"]).AsQuaternion();
            prim.Scale      = ((OSDArray)map["scale"]).AsVector3();
            prim.Flexible   = FlexibleData.FromOSD(map["flex"]);
            prim.Light      = LightData.FromOSD(map["light"]);
            prim.Sculpt     = SculptData.FromOSD(map["sculpt"]);
            prim.Textures   = TextureEntry.FromOSD(map["textures"]);
            prim.Properties = new ObjectProperties();

            if (!string.IsNullOrEmpty(map["name"].AsString()))
            {
                prim.Properties.Name = map["name"].AsString();
            }

            if (!string.IsNullOrEmpty(map["description"].AsString()))
            {
                prim.Properties.Description = map["description"].AsString();
            }

            return(prim);
        }
コード例 #11
0
 public Primitive(Primitive prim)
 {
     ID           = prim.ID;
     GroupID      = prim.GroupID;
     LocalID      = prim.LocalID;
     ParentID     = prim.ParentID;
     RegionHandle = prim.RegionHandle;
     Flags        = prim.Flags;
     TreeSpecies  = prim.TreeSpecies;
     if (prim.ScratchPad != null)
     {
         ScratchPad = new byte[prim.ScratchPad.Length];
         Buffer.BlockCopy(prim.ScratchPad, 0, ScratchPad, 0, ScratchPad.Length);
     }
     else
     {
         ScratchPad = Utils.EmptyBytes;
     }
     Position          = prim.Position;
     Scale             = prim.Scale;
     Rotation          = prim.Rotation;
     Velocity          = prim.Velocity;
     AngularVelocity   = prim.AngularVelocity;
     Acceleration      = prim.Acceleration;
     CollisionPlane    = prim.CollisionPlane;
     Flexible          = prim.Flexible;
     Light             = prim.Light;
     Sculpt            = prim.Sculpt;
     ClickAction       = prim.ClickAction;
     Sound             = prim.Sound;
     OwnerID           = prim.OwnerID;
     SoundFlags        = prim.SoundFlags;
     SoundGain         = prim.SoundGain;
     SoundRadius       = prim.SoundRadius;
     Text              = prim.Text;
     TextColor         = prim.TextColor;
     MediaURL          = prim.MediaURL;
     Joint             = prim.Joint;
     JointPivot        = prim.JointPivot;
     JointAxisOrAnchor = prim.JointAxisOrAnchor;
     if (prim.NameValues != null)
     {
         if (NameValues == null || NameValues.Length != prim.NameValues.Length)
         {
             NameValues = new NameValue[prim.NameValues.Length];
         }
         Array.Copy(prim.NameValues, NameValues, prim.NameValues.Length);
     }
     else
     {
         NameValues = null;
     }
     PrimData   = prim.PrimData;
     Properties = prim.Properties;
     // FIXME: Get a real copy constructor for TextureEntry instead of serializing to bytes and back
     if (prim.Textures != null)
     {
         byte[] textureBytes = prim.Textures.GetBytes();
         Textures = new TextureEntry(textureBytes, 0, textureBytes.Length);
     }
     else
     {
         Textures = null;
     }
     TextureAnim = prim.TextureAnim;
     ParticleSys = prim.ParticleSys;
 }