Beispiel #1
0
        //Separate thread
        private void Objects_OnNewPrim(Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation)
        {
            if (prim.ParentID != 0) return;

            lock (listItems)
            {
                if (listItems.ContainsKey(prim.LocalID)) return;

                BeginInvoke(new MethodInvoker(delegate()
                {
                    ObjectsListItem item = new ObjectsListItem(prim, client, lbxPrims);
                    listItems.Add(prim.LocalID, item);

                    item.PropertiesReceived += new EventHandler(item_PropertiesReceived);
                    item.RequestProperties();
                }));
            }
        }
Beispiel #2
0
        void Objects_OnNewPrim(Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation)
        {
            if ((prim.Flags & LLObject.ObjectFlags.CreateSelected) == 0)
                return; // We received an update for an object we didn't create

            switch (state)
            {
                case ImporterState.RezzingParent:
                    rootLocalID = prim.LocalID;
                    goto case ImporterState.RezzingChildren;
                case ImporterState.RezzingChildren:
                    if (!primsCreated.Contains(prim))
                    {
                        Console.WriteLine("Setting properties for " + prim.LocalID);
                        // TODO: Is there a way to set all of this at once, and update more ObjectProperties stuff?
                        currentClient.Objects.SetPosition(simulator, prim.LocalID, currentPosition);
                        currentClient.Objects.SetTextures(simulator, prim.LocalID, currentPrim.Textures);
                        currentClient.Objects.SetLight(simulator, prim.LocalID, currentPrim.Light);
                        currentClient.Objects.SetFlexible(simulator, prim.LocalID, currentPrim.Flexible);

                        if (!String.IsNullOrEmpty(currentPrim.Properties.Name))
                            currentClient.Objects.SetName(simulator, prim.LocalID, currentPrim.Properties.Name);
                        if (!String.IsNullOrEmpty(currentPrim.Properties.Description))
                            currentClient.Objects.SetDescription(simulator, prim.LocalID,
                                currentPrim.Properties.Description);

                        primsCreated.Add(prim);
                        primDone.Set();
                    }
                    break;
                case ImporterState.Linking:
                    lock (linkQueue)
                    {
                        int index = linkQueue.IndexOf(prim.LocalID);
                        if (index != -1)
                        {
                            linkQueue.RemoveAt(index);
                            if (linkQueue.Count == 0)
                                primDone.Set();
                        }
                    }
                    break;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Set additional primitive parameters on an object
        /// </summary>
        /// <param name="simulator">A reference to the <seealso cref="libsecondlife.Simulator"/> object where the object resides</param>
        /// <param name="localID">The objects ID which is local to the simulator the object is in</param>
        /// <param name="type">The extra parameters to set</param>
        public void SetExtraParamOff(Simulator simulator, uint localID, Primitive.ExtraParamType type)
        {
            ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket();

            extra.AgentData.AgentID = Client.Self.AgentID;
            extra.AgentData.SessionID = Client.Self.SessionID;
            extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1];
            extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock();
            extra.ObjectData[0].ObjectLocalID = localID;
            extra.ObjectData[0].ParamType = (byte)type;
            extra.ObjectData[0].ParamInUse = false;
            extra.ObjectData[0].ParamData = new byte[0];
            extra.ObjectData[0].ParamSize = 0;

            Client.Network.SendPacket(extra, simulator);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
 public bool TryGetPrimitive(uint primLocalID, out Primitive prim)
 {
     return Prims.TryGetValue(primLocalID, out prim);
 }
Beispiel #6
0
        /// <summary>
        /// Set the sculptie texture and data on an object
        /// </summary>
        /// <param name="simulator">A reference to the <seealso cref="libsecondlife.Simulator"/> object where the object resides</param>
        /// <param name="localID">The objects ID which is local to the simulator the object is in</param>
        /// <param name="sculpt">A <seealso cref="Primitive.SculptData"/> object containing the data to set</param>
        public void SetSculpt(Simulator simulator, uint localID, Primitive.SculptData sculpt)
        {
            ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket();

            extra.AgentData.AgentID = Client.Self.AgentID;
            extra.AgentData.SessionID = Client.Self.SessionID;

            extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1];
            extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock();
            extra.ObjectData[0].ObjectLocalID = localID;
            extra.ObjectData[0].ParamType = (byte)Primitive.ExtraParamType.Sculpt;
            extra.ObjectData[0].ParamInUse = true;
            extra.ObjectData[0].ParamData = sculpt.GetBytes();
            extra.ObjectData[0].ParamSize = (uint)extra.ObjectData[0].ParamData.Length;

            Client.Network.SendPacket(extra, simulator);

            // Not sure why, but if you don't send this the sculpted prim disappears
            ObjectShapePacket shape = new ObjectShapePacket();

            shape.AgentData.AgentID = Client.Self.AgentID;
            shape.AgentData.SessionID = Client.Self.SessionID;

            shape.ObjectData = new libsecondlife.Packets.ObjectShapePacket.ObjectDataBlock[1];
            shape.ObjectData[0] = new libsecondlife.Packets.ObjectShapePacket.ObjectDataBlock();
            shape.ObjectData[0].ObjectLocalID = localID;
            shape.ObjectData[0].PathScaleX = 100;
            shape.ObjectData[0].PathScaleY = 150;
            shape.ObjectData[0].PathCurve = 32;

            Client.Network.SendPacket(shape, simulator);
        }
Beispiel #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="simulator"></param>
 /// <param name="prim"></param>
 /// <param name="RegionHandle"></param>
 /// <param name="TimeDilation"></param>
 protected void FireOnNewAttachment(Simulator simulator, Primitive prim, ulong RegionHandle, ushort TimeDilation)
 {
     if (OnNewAttachment != null)
     {
         try { OnNewAttachment(simulator, prim, RegionHandle, TimeDilation); }
         catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); }
     }
 }
Beispiel #8
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
                return "Usage: import inputfile.xml";

            string filename = args[0];
            Dictionary<uint, Primitive> prims = new Dictionary<uint, Primitive>(); ;

            currentClient = Client;

            return "This command is currently under construction";

            try
            {
                //XmlReader reader = XmlReader.Create(filename);
                //List<Primitive> listprims = Helpers.PrimListFromXml(reader);
                //reader.Close();

                // Create a dictionary indexed by the old local ID of the prims
                //foreach (Primitive prim in listprims)
                //{
                //    prims.Add(prim.LocalID, prim);
                //}
            }
            catch (Exception)
            {
                return "Failed to import the object XML file, maybe it doesn't exist or is in the wrong format?";
            }

            if (!registeredCreateEvent)
            {
                Client.Objects.OnNewPrim += new ObjectManager.NewPrimCallback(Objects_OnNewPrim);
                registeredCreateEvent = true;
            }

            // Build an organized structure from the imported prims
            Dictionary<uint, Linkset> linksets = new Dictionary<uint, Linkset>();
            foreach (Primitive prim in prims.Values)
            {
                if (prim.ParentID == 0)
                {
                    if (linksets.ContainsKey(prim.LocalID))
                        linksets[prim.LocalID].RootPrim = prim;
                    else
                        linksets[prim.LocalID] = new Linkset(prim);
                }
                else
                {
                    if (!linksets.ContainsKey(prim.ParentID))
                        linksets[prim.ParentID] = new Linkset();

                    linksets[prim.ParentID].Children.Add(prim);
                }
            }

            primsCreated = new List<Primitive>();
            Console.WriteLine("Importing " + linksets.Count + " structures.");

            foreach (Linkset linkset in linksets.Values)
            {
                if (linkset.RootPrim.LocalID != 0)
                {
                    state = ImporterState.RezzingParent;
                    currentPrim = linkset.RootPrim;
                    // HACK: Offset the root prim position so it's not lying on top of the original
                    // We need a more elaborate solution for importing with relative or absolute offsets
                    linkset.RootPrim.Position = Client.Self.SimPosition;
                    linkset.RootPrim.Position.Z += 3.0f;
                    currentPosition = linkset.RootPrim.Position;
                    // A better solution would move the bot to the desired position.
                    // or to check if we are within a certain distance of the desired position.

                    // Rez the root prim with no rotation
                    LLQuaternion rootRotation = linkset.RootPrim.Rotation;
                    linkset.RootPrim.Rotation = LLQuaternion.Identity;

                    Client.Objects.AddPrim(Client.Network.CurrentSim, linkset.RootPrim.Data, LLUUID.Zero,
                        linkset.RootPrim.Position, linkset.RootPrim.Scale, linkset.RootPrim.Rotation);

                    if (!primDone.WaitOne(10000, false))
                        return "Rez failed, timed out while creating the root prim.";

                    state = ImporterState.RezzingChildren;

                    // Rez the child prims
                    foreach (Primitive prim in linkset.Children)
                    {
                        currentPrim = prim;
                        currentPosition = prim.Position + linkset.RootPrim.Position;

                        Client.Objects.AddPrim(Client.Network.CurrentSim, prim.Data, LLUUID.Zero, currentPosition,
                            prim.Scale, prim.Rotation);

                        if (!primDone.WaitOne(10000, false))
                            return "Rez failed, timed out while creating child prim.";
                    }

                    if (linkset.Children.Count != 0)
                    {
                        // Create a list of the local IDs of the newly created prims
                        List<uint> primIDs = new List<uint>(primsCreated.Count);
                        primIDs.Add(rootLocalID); // Root prim is first in list.
                        foreach (Primitive prim in primsCreated)
                        {
                            if (prim.LocalID != rootLocalID)
                                primIDs.Add(prim.LocalID);
                        }
                        linkQueue = new List<uint>(primIDs.Count);
                        linkQueue.AddRange(primIDs);

                        // Link and set the permissions + rotation
                        state = ImporterState.Linking;
                        Client.Objects.LinkPrims(Client.Network.CurrentSim, linkQueue);
                        if (primDone.WaitOne(100000 * linkset.Children.Count, false))
                        {
                            Client.Objects.SetPermissions(Client.Network.CurrentSim, primIDs,
                                PermissionWho.Everyone | PermissionWho.Group | PermissionWho.NextOwner,
                                PermissionMask.All, true);

                            Client.Objects.SetRotation(Client.Network.CurrentSim, rootLocalID, rootRotation);
                        }
                        else
                        {
                            Console.WriteLine("Warning: Failed to link {0} prims", linkQueue.Count);
                        }
                    }
                    else
                    {
                        Client.Objects.SetRotation(Client.Network.CurrentSim, rootLocalID, rootRotation);
                    }
                    state = ImporterState.Idle;
                }
                else
                {
                    // Skip linksets with a missing root prim
                    Console.WriteLine("WARNING: Skipping a linkset with a missing root prim");
                }

                // Reset everything for the next linkset
                primsCreated.Clear();
            }

            return "Import complete.";
        }
Beispiel #9
0
        private void Objects_OnNewPrim(Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation)
        {
            lock (SimPrims)
            {
                if (!SimPrims.ContainsKey(simulator))
                {
                    SimPrims[simulator] = new Dictionary<uint, Primitive>(10000);
                }

                SimPrims[simulator][prim.LocalID] = prim;
            }

            if ((prim.Flags & LLObject.ObjectFlags.CreateSelected) != 0 && OnPrimCreated != null)
            {
                OnPrimCreated(simulator, prim);
            }
        }
Beispiel #10
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
                return "Usage: import inputfile.xml [usegroup]";

            string filename = args[0];
            LLUUID GroupID = (args.Length > 1) ? Client.GroupID : LLUUID.Zero;
            string xml;
            List<Primitive> prims;

            try { xml = File.ReadAllText(filename); }
            catch (Exception e) { return e.Message; }

            try { prims = Helpers.LLSDToPrimList(LLSDParser.DeserializeXml(xml)); }
            catch (Exception e) { return "Failed to deserialize " + filename + ": " + e.Message; }

            // Build an organized structure from the imported prims
            Dictionary<uint, Linkset> linksets = new Dictionary<uint, Linkset>();
            for (int i = 0; i < prims.Count; i++)
            {
                Primitive prim = prims[i];

                if (prim.ParentID == 0)
                {
                    if (linksets.ContainsKey(prim.LocalID))
                        linksets[prim.LocalID].RootPrim = prim;
                    else
                        linksets[prim.LocalID] = new Linkset(prim);
                }
                else
                {
                    if (!linksets.ContainsKey(prim.ParentID))
                        linksets[prim.ParentID] = new Linkset();

                    linksets[prim.ParentID].Children.Add(prim);
                }
            }

            primsCreated = new List<Primitive>();
            Console.WriteLine("Importing " + linksets.Count + " structures.");

            foreach (Linkset linkset in linksets.Values)
            {
                if (linkset.RootPrim.LocalID != 0)
                {
                    state = ImporterState.RezzingParent;
                    currentPrim = linkset.RootPrim;
                    // HACK: Import the structure just above our head
                    // We need a more elaborate solution for importing with relative or absolute offsets
                    linkset.RootPrim.Position = Client.Self.SimPosition;
                    linkset.RootPrim.Position.Z += 3.0f;
                    currentPosition = linkset.RootPrim.Position;

                    // Rez the root prim with no rotation
                    LLQuaternion rootRotation = linkset.RootPrim.Rotation;
                    linkset.RootPrim.Rotation = LLQuaternion.Identity;

                    Client.Objects.AddPrim(Client.Network.CurrentSim, linkset.RootPrim.Data, GroupID,
                        linkset.RootPrim.Position, linkset.RootPrim.Scale, linkset.RootPrim.Rotation);

                    if (!primDone.WaitOne(10000, false))
                        return "Rez failed, timed out while creating the root prim.";

                    state = ImporterState.RezzingChildren;

                    // Rez the child prims
                    foreach (Primitive prim in linkset.Children)
                    {
                        currentPrim = prim;
                        currentPosition = prim.Position + linkset.RootPrim.Position;

                        Client.Objects.AddPrim(Client.Network.CurrentSim, prim.Data, GroupID, currentPosition,
                            prim.Scale, prim.Rotation);

                        if (!primDone.WaitOne(10000, false))
                            return "Rez failed, timed out while creating child prim.";
                    }

                    if (linkset.Children.Count != 0)
                    {
                        // Create a list of the local IDs of the newly created prims
                        List<uint> primIDs = new List<uint>(primsCreated.Count);
                        primIDs.Add(rootLocalID); // Root prim is first in list.
                        foreach (Primitive prim in primsCreated)
                        {
                            if (prim.LocalID != rootLocalID)
                                primIDs.Add(prim.LocalID);
                        }
                        linkQueue = new List<uint>(primIDs.Count);
                        linkQueue.AddRange(primIDs);

                        // Link and set the permissions + rotation
                        state = ImporterState.Linking;
                        Client.Objects.LinkPrims(Client.Network.CurrentSim, linkQueue);

                        if (primDone.WaitOne(1000 * linkset.Children.Count, false))
                            Client.Objects.SetRotation(Client.Network.CurrentSim, rootLocalID, rootRotation);
                        else
                            Console.WriteLine("Warning: Failed to link {0} prims", linkQueue.Count);

                        Client.Objects.SetPermissions(Client.Network.CurrentSim, primIDs,
                            PermissionWho.Everyone | PermissionWho.Group | PermissionWho.NextOwner,
                            PermissionMask.All, true);
                    }
                    else
                    {
                        Client.Objects.SetRotation(Client.Network.CurrentSim, rootLocalID, rootRotation);
                    }
                    state = ImporterState.Idle;
                }
                else
                {
                    // Skip linksets with a missing root prim
                    Console.WriteLine("WARNING: Skipping a linkset with a missing root prim");
                }

                // Reset everything for the next linkset
                primsCreated.Clear();
            }

            return "Import complete.";
        }
        /// <summary>
        /// Set the Light data on an object
        /// </summary>
        /// <param name="simulator">A reference to the <seealso cref="libsecondlife.Simulator"/> object where the object resides</param>
        /// <param name="localID">The objects ID which is local to the simulator the object is in</param>
        /// <param name="light">A <seealso cref="Primitive.LightData"/> object containing the data to set</param>
        public void SetLight(Simulator simulator, uint localID, Primitive.LightData light)
        {
            ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket();

            extra.AgentData.AgentID = Client.Self.AgentID;
            extra.AgentData.SessionID = Client.Self.SessionID;
            extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1];
            extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock();
            extra.ObjectData[0].ObjectLocalID = localID;
            extra.ObjectData[0].ParamType = (byte)Primitive.ExtraParamType.Light;
            if (light.Intensity == 0.0f) 
            {
                // Disables the light if intensity is 0
                extra.ObjectData[0].ParamInUse = false;
            } 
            else 
            {
                extra.ObjectData[0].ParamInUse = true;
            }
            extra.ObjectData[0].ParamData = light.GetBytes();
            extra.ObjectData[0].ParamSize = (uint)extra.ObjectData[0].ParamData.Length;

            Client.Network.SendPacket(extra, simulator);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="simulator"></param>
 /// <param name="prim"></param>
 /// <param name="RegionHandle"></param>
 /// <param name="TimeDilation"></param>
 protected void FireOnNewFoliage(Simulator simulator, Primitive prim, ulong RegionHandle, ushort TimeDilation)
 {
     if (OnNewFoliage != null)
     {
         try { OnNewFoliage(simulator, prim, RegionHandle, TimeDilation); }
         catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
     }
 }
Beispiel #13
0
 public ObjectsListItem(Primitive prim, SecondLife client, ListBox listBox)
 {
     this.prim = prim;
     this.client = client;
     this.listBox = listBox;
 }
Beispiel #14
0
 public Linkset()
 {
     RootPrim = new Primitive();
 }
Beispiel #15
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="simulator"></param>
        /// <param name="localID"></param>
        /// <param name="fullID"></param>
        /// <returns></returns>
        protected Primitive GetPrimitive(Simulator simulator, uint localID, LLUUID fullID)
        {
            if (Client.Settings.OBJECT_TRACKING)
            {
                Primitive prim;

                if (simulator.ObjectsPrimitives.TryGetValue(localID, out prim))
                {
                    return prim;
                }
                else
                {
                    prim = new Primitive();
                    prim.LocalID = localID;
                    prim.ID = fullID;
                    lock (simulator.ObjectsPrimitives.Dictionary)
                        simulator.ObjectsPrimitives.Dictionary[localID] = prim;

                    return prim;
                }
            }
            else
            {
                return new Primitive();
            }
        }
Beispiel #16
0
 public Linkset(Primitive rootPrim)
 {
     RootPrim = rootPrim;
 }
Beispiel #17
0
        /// <summary>
        /// Set the flexible data on an object
        /// </summary>
        /// <param name="simulator">A reference to the <seealso cref="libsecondlife.Simulator"/> object where the object resides</param>
        /// <param name="localID">The objects ID which is local to the simulator the object is in</param>
        /// <param name="flexible">A <seealso cref="Primitive.FlexibleData"/> object containing the data to set</param>
        public void SetFlexible(Simulator simulator, uint localID, Primitive.FlexibleData flexible)
        {
            ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket();

            extra.AgentData.AgentID = Client.Self.AgentID;
            extra.AgentData.SessionID = Client.Self.SessionID;
            extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1];
            extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock();
            extra.ObjectData[0].ObjectLocalID = localID;
            extra.ObjectData[0].ParamType = (byte)Primitive.ExtraParamType.Flexible;
            extra.ObjectData[0].ParamInUse = true;
            extra.ObjectData[0].ParamData = flexible.GetBytes();
            extra.ObjectData[0].ParamSize = (uint)extra.ObjectData[0].ParamData.Length;

            Client.Network.SendPacket(extra, simulator);
        }
Beispiel #18
0
        static void Objects_OnNewPrim(Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation)
        {
            if (CurrentSculpt != null && (prim.Flags & LLObject.ObjectFlags.CreateSelected) != 0 &&
                !RezzedPrims.Contains(prim.LocalID))
            {
                lock (RezzedPrims) RezzedPrims.Add(prim.LocalID);

                Console.WriteLine("Rezzed prim " + CurrentSculpt.Name + ", setting properties");

                // Deselect the prim
                Client.Objects.DeselectObject(Client.Network.CurrentSim, prim.LocalID);

                // Set the prim position
                Client.Objects.SetPosition(Client.Network.CurrentSim, prim.LocalID,
                    RootPosition + CurrentSculpt.Offset);

                // Set the texture
                LLObject.TextureEntry textures = new LLObject.TextureEntry(CurrentSculpt.TextureID);
                Client.Objects.SetTextures(Client.Network.CurrentSim, prim.LocalID, textures);

                // Turn it in to a sculpted prim
                Primitive.SculptData sculpt = new Primitive.SculptData();
                sculpt.SculptTexture = CurrentSculpt.SculptID;
                sculpt.Type = Primitive.SculptType.Sphere;
                Client.Objects.SetSculpt(Client.Network.CurrentSim, prim.LocalID, sculpt);

                // Set the prim name
                if (!String.IsNullOrEmpty(CurrentSculpt.Name))
                    Client.Objects.SetName(Client.Network.CurrentSim, prim.LocalID, CurrentSculpt.Name);

                RezzedEvent.Set();
            }
        }
Beispiel #19
0
        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        = path["twist"].AsInteger();
            data.PathTwistBegin   = path["twist_begin"].AsInteger();

            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 = LLVector3.FromLLSD(map["position"]);
            prim.Rotation = LLQuaternion.FromLLSD(map["rotation"]);
            prim.Scale    = LLVector3.FromLLSD(map["scale"]);
            prim.Flexible = FlexibleData.FromLLSD(map["flexible"]);
            prim.Light    = LightData.FromLLSD(map["light"]);
            prim.Sculpt   = SculptData.FromLLSD(map["sculpt"]);
            prim.Textures = TextureEntry.FromLLSD(map["textures"]);

            return(prim);
        }