예제 #1
0
        /// <summary>
        /// Delink the given prim from this group.  The delinked prim is established as
        /// an independent SceneObjectGroup.
        /// </summary>
        /// <param name="partID"></param>
        /// <param name="sendEvents"></param>
        /// <returns>The object group of the newly delinked prim.</returns>
        public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents)
        {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
//                    linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);

            Quaternion worldRot = linkPart.GetWorldRotation();

            // Remove the part from this object
            m_scene.SceneGraph.DeLinkPartFromEntity(this, linkPart);

            /* this is already done in DeLinkPartFromEntity
                        if (m_partsList.Count == 1 && RootPart != null) //Single prim is left
                            RootPart.LinkNum = 0;
                        else
                        {
                            lock (m_partsLock)
                            {
                                foreach (SceneObjectPart p in m_partsList)
                                {
                                    if (p.LinkNum > linkPart.LinkNum)
                                        p.LinkNum--;
                                }
                            }
                        }
            */
            linkPart.SetParentLocalId(0);
            linkPart.LinkNum = 0;

            if (linkPart.PhysActor != null)
            {
                m_scene.SceneGraph.PhysicsScene.RemovePrim(linkPart.PhysActor);
//            linkPart.PhysActor.delink();
            }

            // We need to reset the child part's position
            // ready for life as a separate object after being a part of another object
            Quaternion parentRot = m_rootPart.RotationOffset;

            Vector3 axPos = linkPart.OffsetPosition;

            axPos *= parentRot;
            linkPart.SetOffsetPosition(axPos);
            linkPart.FixGroupPosition(AbsolutePosition + linkPart.OffsetPosition,false);
            linkPart.FixOffsetPosition(Vector3.Zero, false);

            linkPart.RotationOffset = worldRot;

            SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart, Scene);
            m_scene.SceneGraph.DelinkPartToScene(objectGroup);

            if (sendEvents)
                linkPart.TriggerScriptChangedEvent(Changed.LINK);

            linkPart.Rezzed = RootPart.Rezzed;

 

            //This is already set multiple places, no need to do it again
            //HasGroupChanged = true;
            //We need to send this so that we don't have issues with the client not realizing that the prims were unlinked
            ScheduleGroupUpdate(PrimUpdateFlags.FullUpdate);

            return objectGroup;
        }
예제 #2
0
        private SceneObjectPart BuildPrim(IDataReader row, Scene scene)
        {
            object[] o = new object[row.FieldCount];
            row.GetValues(o);
            SceneObjectPart prim = new SceneObjectPart(scene);
            int ColorA = 0;
            int ColorR = 0;
            int ColorG = 0;
            int ColorB = 0;

            float PositionX = 0;
            float PositionY = 0;
            float PositionZ = 0;

            float GroupPositionX = 0;
            float GroupPositionY = 0;
            float GroupPositionZ = 0;

            float VelocityX = 0;
            float VelocityY = 0;
            float VelocityZ = 0;

            float AngularVelocityX = 0;
            float AngularVelocityY = 0;
            float AngularVelocityZ = 0;

            float AccelerationX = 0;
            float AccelerationY = 0;
            float AccelerationZ = 0;

            float RotationX = 0;
            float RotationY = 0;
            float RotationZ = 0;
            float RotationW = 0;

            float SitTargetOffsetX = 0;
            float SitTargetOffsetY = 0;
            float SitTargetOffsetZ = 0;

            float SitTargetOrientX = 0;
            float SitTargetOrientY = 0;
            float SitTargetOrientZ = 0;
            float SitTargetOrientW = 0;

            float OmegaX = 0;
            float OmegaY = 0;
            float OmegaZ = 0;

            float CameraEyeOffsetX = 0;
            float CameraEyeOffsetY = 0;
            float CameraEyeOffsetZ = 0;

            float CameraAtOffsetX = 0;
            float CameraAtOffsetY = 0;
            float CameraAtOffsetZ = 0;

            PrimitiveBaseShape s = new PrimitiveBaseShape();

            float ScaleX = 0;
            float ScaleY = 0;
            float ScaleZ = 0;

            try
            {
                for (int i = 0; i < o.Length; i++)
                {
                    string name = row.GetName(i);

                    #region Switch

                    switch (name)
                    {
                        case "UUID":
                            prim.UUID = DBGuid.FromDB(o[i].ToString());
                            break;
                        case "CreatorID":
                            prim.CreatorID = DBGuid.FromDB(o[i].ToString());
                            break;
                        case "OwnerID":
                            prim.OwnerID = DBGuid.FromDB(o[i].ToString());
                            break;
                        case "GroupID":
                            prim.GroupID = DBGuid.FromDB(o[i].ToString());
                            break;
                        case "LastOwnerID":
                            prim.LastOwnerID = DBGuid.FromDB(o[i].ToString());
                            break;
                        case "CreationDate":
                            prim.CreationDate = Convert.ToInt32(o[i].ToString());
                            break;
                        case "Name":
                            if (!(o[i] is DBNull))
                                prim.Name = o[i].ToString();
                            break;
                        case "Text":
                            prim.Text = o[i].ToString();
                            break;
                        case "ColorA":
                            ColorA = Convert.ToInt32(o[i].ToString());
                            break;
                        case "ColorR":
                            ColorR = Convert.ToInt32(o[i].ToString());
                            break;
                        case "ColorG":
                            ColorG = Convert.ToInt32(o[i].ToString());
                            break;
                        case "ColorB":
                            ColorB = Convert.ToInt32(o[i].ToString());
                            break;
                        case "Description":
                            prim.Description = o[i].ToString();
                            break;
                        case "SitName":
                            prim.SitName = o[i].ToString();
                            break;
                        case "TouchName":
                            prim.TouchName = o[i].ToString();
                            break;
                        case "ObjectFlags":
                            prim.Flags = (PrimFlags)Convert.ToUInt32(o[i].ToString());
                            break;
                        case "OwnerMask":
                            prim.OwnerMask = Convert.ToUInt32(o[i].ToString());
                            break;
                        case "NextOwnerMask":
                            prim.NextOwnerMask = Convert.ToUInt32(o[i].ToString());
                            break;
                        case "GroupMask":
                            prim.GroupMask = Convert.ToUInt32(o[i].ToString());
                            break;
                        case "EveryoneMask":
                            prim.EveryoneMask = Convert.ToUInt32(o[i].ToString());
                            break;
                        case "BaseMask":
                            prim.BaseMask = Convert.ToUInt32(o[i].ToString());
                            break;
                        case "PositionX":
                            PositionX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "PositionY":
                            PositionY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "PositionZ":
                            PositionZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "GroupPositionX":
                            GroupPositionX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "GroupPositionY":
                            GroupPositionY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "GroupPositionZ":
                            GroupPositionZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "VelocityX":
                            VelocityX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "VelocityY":
                            VelocityY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "VelocityZ":
                            VelocityZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "AngularVelocityX":
                            AngularVelocityX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "AngularVelocityY":
                            AngularVelocityY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "AngularVelocityZ":
                            AngularVelocityZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "AccelerationX":
                            AccelerationX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "AccelerationY":
                            AccelerationY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "AccelerationZ":
                            AccelerationZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "RotationX":
                            RotationX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "RotationY":
                            RotationY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "RotationZ":
                            RotationZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "RotationW":
                            RotationW = Convert.ToSingle(o[i].ToString());
                            break;
                        case "SitTargetOffsetX":
                            SitTargetOffsetX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "SitTargetOffsetY":
                            SitTargetOffsetY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "SitTargetOffsetZ":
                            SitTargetOffsetZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "SitTargetOrientX":
                            SitTargetOrientX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "SitTargetOrientY":
                            SitTargetOrientY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "SitTargetOrientZ":
                            SitTargetOrientZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "SitTargetOrientW":
                            SitTargetOrientW = Convert.ToSingle(o[i].ToString());
                            break;
                        case "PayPrice":
                            prim.PayPrice[0] = Convert.ToInt32(o[i].ToString());
                            break;
                        case "PayButton1":
                            prim.PayPrice[1] = Convert.ToInt32(o[i].ToString());
                            break;
                        case "PayButton2":
                            prim.PayPrice[2] = Convert.ToInt32(o[i].ToString());
                            break;
                        case "PayButton3":
                            prim.PayPrice[3] = Convert.ToInt32(o[i].ToString());
                            break;
                        case "PayButton4":
                            prim.PayPrice[4] = Convert.ToInt32(o[i].ToString());
                            break;
                        case "LoopedSound":
                            prim.Sound = DBGuid.FromDB(o[i].ToString());
                            break;
                        case "LoopedSoundGain":
                            prim.SoundGain = Convert.ToSingle(o[i].ToString());
                            break;
                        case "TextureAnimation":
                            if (!(row[i] is DBNull))
                                prim.TextureAnimation = (byte[])o[i];
                            break;
                        case "ParticleSystem":
                            if (!(row[i] is DBNull))
                                prim.ParticleSystem = (byte[])o[i];
                            break;
                        case "OmegaX":
                            OmegaX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "OmegaY":
                            OmegaY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "OmegaZ":
                            OmegaZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "CameraEyeOffsetX":
                            CameraEyeOffsetX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "CameraEyeOffsetY":
                            CameraEyeOffsetY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "CameraEyeOffsetZ":
                            CameraEyeOffsetZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "CameraAtOffsetX":
                            CameraAtOffsetX = Convert.ToSingle(o[i].ToString());
                            break;
                        case "CameraAtOffsetY":
                            CameraAtOffsetY = Convert.ToSingle(o[i].ToString());
                            break;
                        case "CameraAtOffsetZ":
                            CameraAtOffsetZ = Convert.ToSingle(o[i].ToString());
                            break;
                        case "ForceMouselook":
                            prim.ForceMouselook = Convert.ToInt32(o[i].ToString()) != 0;
                            break;
                        case "ScriptAccessPin":
                            prim.ScriptAccessPin = Convert.ToInt32(o[i].ToString());
                            break;
                        case "AllowedDrop":
                            prim.AllowedDrop = Convert.ToInt32(o[i].ToString()) != 0;
                            break;
                        case "DieAtEdge":
                            prim.DIE_AT_EDGE = Convert.ToInt32(o[i].ToString()) != 0;
                            break;
                        case "SalePrice":
                            prim.SalePrice = Convert.ToInt32(o[i].ToString());
                            break;
                        case "SaleType":
                            prim.ObjectSaleType = Convert.ToByte(o[i].ToString());
                            break;
                        case "Material":
                            prim.Material = Convert.ToByte(o[i].ToString());
                            break;
                        case "ClickAction":
                            if (!(row[i] is DBNull))
                                prim.ClickAction = Convert.ToByte(o[i].ToString());
                            break;
                        case "CollisionSound":
                            prim.CollisionSound = DBGuid.FromDB(o[i].ToString());
                            break;
                        case "CollisionSoundVolume":
                            prim.CollisionSoundVolume = Convert.ToSingle(o[i].ToString());
                            break;
                        case "PassTouches":
                            prim.PassTouch = (int)Convert.ToSingle(o[i].ToString());
                            break;
                        case "VolumeDetect":
                            if (!(row[i] is DBNull))
                                prim.VolumeDetectActive = Convert.ToInt32(o[i].ToString()) == 1;
                            break;
                        case "LinkNumber":
                            prim.LinkNum = int.Parse(o[i].ToString());
                            break;
                        case "Generic":
                            prim.GenericData = o[i].ToString();
                            break;
                        case "MediaURL":
                            if (!(o[i] is System.DBNull))
                                prim.MediaUrl = (string)o[i];
                            break;
                        case "SceneGroupID":
                            break;
                        case "RegionUUID":
                            break;
                        case "Shape":
                            break;
                        case "ScaleX":
                            ScaleX = Convert.ToSingle(o[i]);
                            break;
                        case "ScaleY":
                            ScaleY = Convert.ToSingle(o[i]);
                            break;
                        case "ScaleZ":
                            ScaleZ = Convert.ToSingle(o[i]);
                            break;
                        case "PCode":
                            s.PCode = Convert.ToByte(o[i]);
                            break;
                        case "PathBegin":
                            s.PathBegin = Convert.ToUInt16(o[i]);
                            break;
                        case "PathEnd":
                            s.PathEnd = Convert.ToUInt16(o[i]);
                            break;
                        case "PathScaleX":
                            s.PathScaleX = Convert.ToByte(o[i]);
                            break;
                        case "PathScaleY":
                            s.PathScaleY = Convert.ToByte(o[i]);
                            break;
                        case "PathShearX":
                            s.PathShearX = Convert.ToByte(o[i]);
                            break;
                        case "PathShearY":
                            s.PathShearY = Convert.ToByte(o[i]);
                            break;
                        case "PathSkew":
                            s.PathSkew = Convert.ToSByte(o[i]);
                            break;
                        case "PathCurve":
                            s.PathCurve = Convert.ToByte(o[i]);
                            break;
                        case "PathRadiusOffset":
                            s.PathRadiusOffset = Convert.ToSByte(o[i]);
                            break;
                        case "PathRevolutions":
                            s.PathRevolutions = Convert.ToByte(o[i]);
                            break;
                        case "PathTaperX":
                            s.PathTaperX = Convert.ToSByte(o[i]);
                            break;
                        case "PathTaperY":
                            s.PathTaperY = Convert.ToSByte(o[i]);
                            break;
                        case "PathTwist":
                            s.PathTwist = Convert.ToSByte(o[i]);
                            break;
                        case "PathTwistBegin":
                            s.PathTwistBegin = Convert.ToSByte(o[i]);
                            break;
                        case "ProfileBegin":
                            s.ProfileBegin = Convert.ToUInt16(o[i]);
                            break;
                        case "ProfileEnd":
                            s.ProfileEnd = Convert.ToUInt16(o[i]);
                            break;
                        case "ProfileCurve":
                            s.ProfileCurve = Convert.ToByte(o[i]);
                            break;
                        case "ProfileHollow":
                            s.ProfileHollow = Convert.ToUInt16(o[i]);
                            break;
                        case "State":
                            s.State = Convert.ToByte(o[i]);
                            break;
                        case "Texture":
                            byte[] textureEntry = (byte[])o[i];
                            s.TextureEntry = textureEntry;
                            break;
                        case "ExtraParams":
                            s.ExtraParams = (byte[])o[i];
                            break;
                        case "Media":
                            if (!(o[i] is System.DBNull))
                                s.Media = PrimitiveBaseShape.MediaList.FromXml((string)o[i]);
                            break;
                        default:
                            m_log.Warn("[MySQL]: Unknown database row: " + name);
                            break;
                    }

                    #endregion
                }
            }
            catch(Exception ex)
            {
                m_log.Warn("[MySQL]: Exception loading a SceneObject, " + ex.ToString() + ", deleting..");
                this.RemoveObject(prim.UUID, UUID.Zero);
            }
            s.Scale = new Vector3(ScaleX, ScaleY, ScaleZ);
            prim.Shape = s;
            prim.SoundFlags = 1; // If it's persisted at all, it's looped

            prim.Color = Color.FromArgb(ColorA, ColorR, ColorG, ColorB);
            prim.FixOffsetPosition(new Vector3(PositionX, PositionY, PositionZ),true);
            prim.FixGroupPosition( new Vector3(GroupPositionX, GroupPositionY, GroupPositionZ),true);
            prim.Velocity = new Vector3(VelocityX, VelocityY, VelocityZ);
            prim.AngularVelocity = new Vector3(AngularVelocityX, AngularVelocityY, AngularVelocityZ);
            prim.RotationOffset = new Quaternion(RotationX, RotationY, RotationZ, RotationW);
            prim.SitTargetPositionLL = new Vector3(SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ);
            prim.SitTargetOrientationLL = new Quaternion(SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, SitTargetOrientW);
            prim.AngularVelocity = new Vector3(OmegaX, OmegaY, OmegaZ);
            prim.CameraEyeOffset = new Vector3(CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ);
            prim.CameraAtOffset = new Vector3(CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ);

            return prim;
        }
예제 #3
0
        /// <summary>
        /// Builds the prim from a datarecord.
        /// </summary>
        /// <param name="primRow">datarecord</param>
        /// <returns></returns>
        private static SceneObjectPart BuildPrim(IDataRecord primRow, IScene scene)
        {
            SceneObjectPart prim = new SceneObjectPart(scene);

            prim.UUID = new UUID((Guid)primRow["UUID"]);
            // explicit conversion of integers is required, which sort
            // of sucks.  No idea if there is a shortcut here or not.
            prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]);
            prim.Name = (string)primRow["Name"];
            // various text fields
            prim.Text = (string)primRow["Text"];
            prim.Color = Color.FromArgb(Convert.ToInt32(primRow["ColorA"]),
                                        Convert.ToInt32(primRow["ColorR"]),
                                        Convert.ToInt32(primRow["ColorG"]),
                                        Convert.ToInt32(primRow["ColorB"]));
            prim.Description = (string)primRow["Description"];
            prim.SitName = (string)primRow["SitName"];
            prim.TouchName = (string)primRow["TouchName"];
            // permissions
            prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]);
            prim.CreatorID = new UUID((Guid)primRow["CreatorID"]);
            prim.OwnerID = new UUID((Guid)primRow["OwnerID"]);
            prim.GroupID = new UUID((Guid)primRow["GroupID"]);
            prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]);
            prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]);
            prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]);
            prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]);
            prim.EveryoneMask = Convert.ToUInt32(primRow["EveryoneMask"]);
            prim.BaseMask = Convert.ToUInt32(primRow["BaseMask"]);
            // vectors
            prim.FixOffsetPosition ( new Vector3(
                                    Convert.ToSingle(primRow["PositionX"]),
                                    Convert.ToSingle(primRow["PositionY"]),
                                    Convert.ToSingle(primRow["PositionZ"]))
                                    ,true);

            prim.FixGroupPosition (new Vector3(
                                    Convert.ToSingle(primRow["GroupPositionX"]),
                                    Convert.ToSingle(primRow["GroupPositionY"]),
                                    Convert.ToSingle(primRow["GroupPositionZ"]))
                                    ,true);

            prim.Velocity = new Vector3(
                                Convert.ToSingle(primRow["VelocityX"]),
                                Convert.ToSingle(primRow["VelocityY"]),
                                Convert.ToSingle(primRow["VelocityZ"]));

            prim.AngularVelocity = new Vector3(
                                    Convert.ToSingle(primRow["AngularVelocityX"]),
                                    Convert.ToSingle(primRow["AngularVelocityY"]),
                                    Convert.ToSingle(primRow["AngularVelocityZ"]));

            prim.Acceleration = new Vector3(
                                Convert.ToSingle(primRow["AccelerationX"]),
                                Convert.ToSingle(primRow["AccelerationY"]),
                                Convert.ToSingle(primRow["AccelerationZ"]));

            // quaternions
            prim.RotationOffset = new Quaternion(
                                Convert.ToSingle(primRow["RotationX"]),
                                Convert.ToSingle(primRow["RotationY"]),
                                Convert.ToSingle(primRow["RotationZ"]),
                                Convert.ToSingle(primRow["RotationW"]));

            prim.SitTargetPositionLL = new Vector3(
                                Convert.ToSingle(primRow["SitTargetOffsetX"]),
                                Convert.ToSingle(primRow["SitTargetOffsetY"]),
                                Convert.ToSingle(primRow["SitTargetOffsetZ"]));

            prim.SitTargetOrientationLL = new Quaternion(
                                Convert.ToSingle(primRow["SitTargetOrientX"]),
                                Convert.ToSingle(primRow["SitTargetOrientY"]),
                                Convert.ToSingle(primRow["SitTargetOrientZ"]),
                                Convert.ToSingle(primRow["SitTargetOrientW"]));

            prim.PayPrice[0] = Convert.ToInt32(primRow["PayPrice"]);
            prim.PayPrice[1] = Convert.ToInt32(primRow["PayButton1"]);
            prim.PayPrice[2] = Convert.ToInt32(primRow["PayButton2"]);
            prim.PayPrice[3] = Convert.ToInt32(primRow["PayButton3"]);
            prim.PayPrice[4] = Convert.ToInt32(primRow["PayButton4"]);

            prim.Sound = new UUID((Guid)primRow["LoopedSound"]);
            prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]);
            prim.SoundFlags = 1; // If it's persisted at all, it's looped

            if (!(primRow["TextureAnimation"] is DBNull))
                prim.TextureAnimation = (Byte[])primRow["TextureAnimation"];
            if (!(primRow["ParticleSystem"] is DBNull))
                prim.ParticleSystem = (Byte[])primRow["ParticleSystem"];

            prim.AngularVelocity = new Vector3(
                                        Convert.ToSingle(primRow["OmegaX"]),
                                        Convert.ToSingle(primRow["OmegaY"]),
                                        Convert.ToSingle(primRow["OmegaZ"]));

            prim.CameraEyeOffset = new Vector3(
                                        Convert.ToSingle(primRow["CameraEyeOffsetX"]),
                                        Convert.ToSingle(primRow["CameraEyeOffsetY"]),
                                        Convert.ToSingle(primRow["CameraEyeOffsetZ"])
                                        );

            prim.CameraAtOffset = new Vector3(
                                       Convert.ToSingle(primRow["CameraAtOffsetX"]),
                                       Convert.ToSingle(primRow["CameraAtOffsetY"]),
                                       Convert.ToSingle(primRow["CameraAtOffsetZ"])
                                       );

            if (Convert.ToInt16(primRow["ForceMouselook"]) != 0)
                prim.ForceMouselook = (true);

            prim.ScriptAccessPin = Convert.ToInt32(primRow["ScriptAccessPin"]);

            if (Convert.ToInt16(primRow["AllowedDrop"]) != 0)
                prim.AllowedDrop = true;

            if (Convert.ToInt16(primRow["DieAtEdge"]) != 0)
                prim.DIE_AT_EDGE = true;

            prim.SalePrice = Convert.ToInt32(primRow["SalePrice"]);
            prim.ObjectSaleType = Convert.ToByte(primRow["SaleType"]);

            prim.Material = Convert.ToByte(primRow["Material"]);

            if (!(primRow["ClickAction"] is DBNull))
                prim.ClickAction = Convert.ToByte(primRow["ClickAction"]);

            prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]);
            prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]);
            prim.PassTouch = Convert.ToInt32(primRow["PassTouches"]);
            prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]);
            prim.GenericData = (string)primRow["Generic"];
            if (!(primRow["MediaURL"] is System.DBNull))
                prim.MediaUrl = (string)primRow["MediaURL"];

            return prim;
        }
예제 #4
0
 private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader)
 {
     obj.FixOffsetPosition(ReadVector(reader, "OffsetPosition"),true);
 }
예제 #5
0
        protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
        {
            // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
            LSL_Vector currentPos = GetPartLocalPos(part);
            float ground = 0;
            bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true);

            ITerrainChannel heightmap = World.RequestModuleInterface<ITerrainChannel>();
            if(heightmap != null)
                ground = heightmap.GetNormalizedGroundHeight((float)targetPos.x, (float)targetPos.y);
            if (part.ParentGroup == null)
            {
                if (ground != 0 && (targetPos.z < ground) && disable_underground_movement && m_host.AttachmentPoint == 0)
                    targetPos.z = ground;
                    LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos);
                    part.UpdateOffSet(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z));
            }
            else if (part.ParentGroup.RootPart == part)
            {
                SceneObjectGroup parent = part.ParentGroup;
                if (!part.IsAttachment)
                {
                    if (ground != 0 && (targetPos.z < ground) && disable_underground_movement)
                        targetPos.z = ground;
                }
                LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos);
                parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z), true);
            }
            else
            {
                LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos);
                part.FixOffsetPosition((new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z)),true);
                SceneObjectGroup parent = part.ParentGroup;
                parent.HasGroupChanged = true;
                parent.ScheduleGroupTerseUpdate();
            }
        }
예제 #6
0
        public void PlaybackState(SceneObjectPart part)
        {
            if (part != null)
            {
                part.Undoing = true;

                bool ChangedScale = false;
                bool ChangedRot = false;
                bool ChangedPos = false;

                if (part.UUID == part.ParentGroup.UUID)
                {
                    if (Position != Vector3.Zero)
                    {
                        ChangedPos = true;
                        part.ParentGroup.AbsolutePosition = Position;
                    }
                    ChangedRot = true;
                    part.RotationOffset = Rotation;
                    if (Scale != Vector3.Zero)
                    {
                        ChangedScale = true;
                        part.Scale = Scale;
                    }

#if (!ISWIN)
                    foreach (SceneObjectPart child in part.ParentGroup.ChildrenList)
                    {
                        if (child.UUID != part.UUID)
                        {
                            child.Undo(); //No updates here, child undo will do it on their own
                        }
                    }
#else
                    foreach (SceneObjectPart child in part.ParentGroup.ChildrenList.Where(child => child.UUID != part.UUID))
                    {
                        child.Undo(); //No updates here, child undo will do it on their own
                    }
#endif
                }
                else
                {
                    if (Position != Vector3.Zero)
                    {
                        ChangedPos = true;
                        part.FixOffsetPosition(Position, false);
                    }
                    ChangedRot = true;
                    part.UpdateRotation(Rotation);
                    if (Scale != Vector3.Zero)
                    {
                        ChangedScale = true;
                        part.Resize(Scale);
                    }
                }
                part.Undoing = false;
                part.ScheduleUpdate((ChangedScale ? PrimUpdateFlags.Shape : PrimUpdateFlags.None) |
                                    (ChangedPos ? PrimUpdateFlags.Position : PrimUpdateFlags.None) |
                                    (ChangedRot ? PrimUpdateFlags.Rotation : PrimUpdateFlags.None));
            }
        }
        /***********************************************************************
         *
         *  Convert between ADO.NET <=> OpenSim Objects
         *
         *  These should be database independant
         *
         **********************************************************************/

        /// <summary>
        ///
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        private SceneObjectPart buildPrim(IDataReader row, IScene scene)
        {
            // Code commented.  Uncomment to test the unit test inline.
            
            // The unit test mentions this commented code for the purposes 
            // of debugging a unit test failure
            
            // SceneObjectGroup sog = new SceneObjectGroup();
            // SceneObjectPart sop = new SceneObjectPart();
            // sop.LocalId = 1;
            // sop.Name = "object1";
            // sop.Description = "object1";
            // sop.Text = "";
            // sop.SitName = "";
            // sop.TouchName = "";
            // sop.UUID = UUID.Random();
            // sop.Shape = PrimitiveBaseShape.Default;
            // sog.SetRootPart(sop);
            // Add breakpoint in above line.  Check sop fields.

            // TODO: this doesn't work yet because something more
            // interesting has to be done to actually get these values
            // back out.  Not enough time to figure it out yet.

            object[] o = new object[row.FieldCount];
            row.GetValues(o);
            SceneObjectPart prim = new SceneObjectPart(scene);
            int ColorA = 0;
            int ColorR = 0;
            int ColorG = 0;
            int ColorB = 0;

            float PositionX = 0;
            float PositionY = 0;
            float PositionZ = 0;

            float GroupPositionX = 0;
            float GroupPositionY = 0;
            float GroupPositionZ = 0;

            float VelocityX = 0;
            float VelocityY = 0;
            float VelocityZ = 0;

            float AngularVelocityX = 0;
            float AngularVelocityY = 0;
            float AngularVelocityZ = 0;

            float AccelerationX = 0;
            float AccelerationY = 0;
            float AccelerationZ = 0;

            float RotationX = 0;
            float RotationY = 0;
            float RotationZ = 0;
            float RotationW = 0;

            float SitTargetOffsetX = 0;
            float SitTargetOffsetY = 0;
            float SitTargetOffsetZ = 0;

            float SitTargetOrientX = 0;
            float SitTargetOrientY = 0;
            float SitTargetOrientZ = 0;
            float SitTargetOrientW = 0;

            float OmegaX = 0;
            float OmegaY = 0;
            float OmegaZ = 0;

            float CameraEyeOffsetX = 0;
            float CameraEyeOffsetY = 0;
            float CameraEyeOffsetZ = 0;

            float CameraAtOffsetX = 0;
            float CameraAtOffsetY = 0;
            float CameraAtOffsetZ = 0;

            for (int i = 0; i < o.Length; i++)
            {
                string name = row.GetName(i);

                #region Switch

                switch (name)
                {
                    case "UUID":
                        prim.UUID = DBGuid.FromDB(o[i]);
                        break;
                    case "CreatorID":
                        prim.CreatorID = DBGuid.FromDB (o[i].ToString ());
                        break;
                    case "OwnerID":
                        prim.OwnerID = DBGuid.FromDB (o[i].ToString ());
                        break;
                    case "GroupID":
                        prim.GroupID = DBGuid.FromDB (o[i].ToString ());
                        break;
                    case "LastOwnerID":
                        prim.LastOwnerID = DBGuid.FromDB (o[i].ToString ());
                        break;
                    case "CreationDate":
                        prim.CreationDate = Convert.ToInt32(o[i].ToString());
                        break;
                    case "Name":
                        if(!(o[i] is DBNull))
                            prim.Name = o[i].ToString();
                        break;
                    case "Text":
                        prim.Text = o[i].ToString();
                        break;
                    case "ColorA":
                        ColorA = Convert.ToInt32(o[i].ToString());
                        break;
                    case "ColorR":
                        ColorR = Convert.ToInt32(o[i].ToString());
                        break;
                    case "ColorG":
                        ColorG = Convert.ToInt32(o[i].ToString());
                        break;
                    case "ColorB":
                        ColorB = Convert.ToInt32(o[i].ToString());
                        break;
                    case "Description":
                        prim.Description = o[i].ToString();
                        break;
                    case "SitName":
                        prim.SitName = o[i].ToString();
                        break;
                    case "TouchName":
                        prim.TouchName = o[i].ToString();
                        break;
                    case "ObjectFlags":
                        prim.Flags = (PrimFlags)Convert.ToUInt32(o[i].ToString());
                        break;
                    case "OwnerMask":
                        prim.OwnerMask = Convert.ToUInt32(o[i].ToString());
                        break;
                    case "NextOwnerMask":
                        prim.NextOwnerMask = Convert.ToUInt32(o[i].ToString());
                        break;
                    case "GroupMask":
                        prim.GroupMask = Convert.ToUInt32(o[i].ToString());
                        break;
                    case "EveryoneMask":
                        prim.EveryoneMask = Convert.ToUInt32(o[i].ToString());
                        break;
                    case "BaseMask":
                        prim.BaseMask = Convert.ToUInt32(o[i].ToString());
                        break;
                    case "PositionX":
                        PositionX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "PositionY":
                        PositionY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "PositionZ":
                        PositionZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "GroupPositionX":
                        GroupPositionX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "GroupPositionY":
                        GroupPositionY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "GroupPositionZ":
                        GroupPositionZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "VelocityX":
                        VelocityX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "VelocityY":
                        VelocityY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "VelocityZ":
                        VelocityZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "AngularVelocityX":
                        AngularVelocityX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "AngularVelocityY":
                        AngularVelocityY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "AngularVelocityZ":
                        AngularVelocityZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "AccelerationX":
                        AccelerationX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "AccelerationY":
                        AccelerationY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "AccelerationZ":
                        AccelerationZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "RotationX":
                        RotationX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "RotationY":
                        RotationY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "RotationZ":
                        RotationZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "RotationW":
                        RotationW = Convert.ToSingle(o[i].ToString());
                        break;
                    case "SitTargetOffsetX":
                        SitTargetOffsetX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "SitTargetOffsetY":
                        SitTargetOffsetY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "SitTargetOffsetZ":
                        SitTargetOffsetZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "SitTargetOrientX":
                        SitTargetOrientX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "SitTargetOrientY":
                        SitTargetOrientY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "SitTargetOrientZ":
                        SitTargetOrientZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "SitTargetOrientW":
                        SitTargetOrientW = Convert.ToSingle(o[i].ToString());
                        break;
                    case "PayPrice":
                        prim.PayPrice[0] = Convert.ToInt32(o[i].ToString());
                        break;
                    case "PayButton1":
                        prim.PayPrice[1] = Convert.ToInt32(o[i].ToString());
                        break;
                    case "PayButton2":
                        prim.PayPrice[2] = Convert.ToInt32(o[i].ToString());
                        break;
                    case "PayButton3":
                        prim.PayPrice[3] = Convert.ToInt32(o[i].ToString());
                        break;
                    case "PayButton4":
                        prim.PayPrice[4] = Convert.ToInt32(o[i].ToString());
                        break;
                    case "LoopedSound":
                        prim.Sound = new UUID(o[i].ToString());
                        break;
                    case "LoopedSoundGain":
                        prim.SoundGain = Convert.ToSingle(o[i].ToString());
                        break;
                    case "TextureAnimation":
                        if(!(row[i] is DBNull))
                            prim.TextureAnimation = Convert.FromBase64String(o[i].ToString());
                        break;
                    case "ParticleSystem":
                        if (!(row[i] is DBNull))
                            prim.ParticleSystem = Convert.FromBase64String(o[i].ToString());
                        break;
                    case "OmegaX":
                        OmegaX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "OmegaY":
                        OmegaY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "OmegaZ":
                        OmegaZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "CameraEyeOffsetX":
                        CameraEyeOffsetX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "CameraEyeOffsetY":
                        CameraEyeOffsetY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "CameraEyeOffsetZ":
                        CameraEyeOffsetZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "CameraAtOffsetX":
                        CameraAtOffsetX = Convert.ToSingle(o[i].ToString());
                        break;
                    case "CameraAtOffsetY":
                        CameraAtOffsetY = Convert.ToSingle(o[i].ToString());
                        break;
                    case "CameraAtOffsetZ":
                        CameraAtOffsetZ = Convert.ToSingle(o[i].ToString());
                        break;
                    case "ForceMouselook":
                        prim.ForceMouselook = Convert.ToInt32(o[i].ToString()) != 0;
                        break;
                    case "ScriptAccessPin":
                        prim.ScriptAccessPin = Convert.ToInt32(o[i].ToString());
                        break;
                    case "AllowedDrop":
                        prim.AllowedDrop = Convert.ToInt32(o[i].ToString()) != 0;
                        break;
                    case "DieAtEdge":
                        prim.DIE_AT_EDGE = Convert.ToInt32(o[i].ToString()) != 0;
                        break;
                    case "SalePrice":
                        prim.SalePrice = Convert.ToInt32(o[i].ToString());
                        break;
                    case "SaleType":
                        prim.ObjectSaleType = Convert.ToByte(o[i].ToString());
                        break;
                    case "Material":
                        prim.Material = Convert.ToByte(o[i].ToString());
                        break;
                    case "ClickAction":
                        if (!(row[i] is DBNull))
                            prim.ClickAction = Convert.ToByte(o[i].ToString());
                        break;
                    case "CollisionSound":
                        prim.CollisionSound = new UUID(o[i].ToString());
                        break;
                    case "CollisionSoundVolume":
                        prim.CollisionSoundVolume = Convert.ToSingle(o[i].ToString());
                        break;
                    case "PassTouches":
                        prim.PassTouch = (int)Convert.ToSingle(o[i].ToString());
                        break;
                    case "VolumeDetect":
                        if(!(row[i] is DBNull))
                            prim.VolumeDetectActive = Convert.ToInt32(o[i].ToString()) == 1;
                        break;
                    case "LinkNumber":
                        prim.LinkNum = int.Parse(o[i].ToString());
                        break;
                    case "Generic":
                        prim.GenericData = o[i].ToString();
                        break;
                    case "SceneGroupID":
                        break;
                    case "RegionUUID":
                        break;
                    default:
                        m_log.Warn("[NXGSQLite]: Unknown database row: " + name);
                        break;
                }

                #endregion
            }
            prim.SoundFlags = 1; // If it's persisted at all, it's looped

            prim.Color = Color.FromArgb(ColorA, ColorR, ColorG, ColorB);
            prim.FixOffsetPosition ( new Vector3(PositionX, PositionY, PositionZ),true);
            prim.FixGroupPosition(new Vector3(GroupPositionX, GroupPositionY, GroupPositionZ),true);
            prim.Velocity = new Vector3(VelocityX, VelocityY, VelocityZ);
            prim.AngularVelocity = new Vector3(AngularVelocityX, AngularVelocityY, AngularVelocityZ);
            prim.RotationOffset = new Quaternion(RotationX, RotationY, RotationZ, RotationW);
            prim.SitTargetPositionLL = new Vector3(SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ);
            prim.SitTargetOrientationLL = new Quaternion(SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, SitTargetOrientW);
            prim.AngularVelocity = new Vector3(OmegaX, OmegaY, OmegaZ);
            prim.CameraEyeOffset = new Vector3(CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ);
            prim.CameraAtOffset = new Vector3 (CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ);
            prim.Acceleration = new Vector3 (AccelerationX, AccelerationY, AccelerationZ);

            return prim;
        }
예제 #8
0
        public void PlayfwdState(SceneObjectPart part)
        {
            if (part != null)
            {
                bool ChangedScale = false;
                bool ChangedRot = false;
                bool ChangedPos = false;
                part.Undoing = true;

                if (part.UUID == part.ParentGroup.UUID)
                {
                    if (Position != Vector3.Zero)
                    {
                        ChangedPos = true;
                        part.ParentGroup.AbsolutePosition = Position;
                    }
                    if (Rotation != Quaternion.Identity)
                    {
                        ChangedRot = true;
                        part.UpdateRotation(Rotation);
                    }
                    if (Scale != Vector3.Zero)
                    {
                        ChangedScale = true;
                        part.Resize(Scale);
                    }

                    foreach (SceneObjectPart child in part.ParentGroup.ChildrenList)
                    {
                        if (child.UUID != part.UUID)
                            child.Redo(); //No updates here, child redo will do it on their own
                    }
                }
                else
                {
                    if (Position != Vector3.Zero)
                    {
                        ChangedPos = true;
                        part.FixOffsetPosition(Position,false);
                    }
                    if (Rotation != Quaternion.Identity)
                    {
                        ChangedRot = true;
                        part.ParentGroup.Rotation = (Rotation);
                    }
                    if (Scale != Vector3.Zero)
                    {
                        ChangedScale = true;
                        part.Resize(Scale);
                    }
                }

                part.ScheduleUpdate((ChangedScale ? PrimUpdateFlags.Shape : PrimUpdateFlags.None) |
                    (ChangedPos ? PrimUpdateFlags.Position : PrimUpdateFlags.None) | 
                    (ChangedRot ? PrimUpdateFlags.Rotation : PrimUpdateFlags.None));
                part.Undoing = false;
            }
        }