SetParent() public method

public SetParent ( SceneObjectGroup parent ) : void
parent SceneObjectGroup
return void
Exemplo n.º 1
0
        // This links an SOP from a previous linkset into my linkset.
        // The trick is that the SOP's position and rotation are relative to the old root SOP's
        //    so we are passed in the position and rotation of the old linkset so this can
        //    unjigger this SOP's position and rotation from the previous linkset and
        //    then make them relative to my linkset root.
        private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum)
        {
            Quaternion parentRot = oldGroupRotation;
            Quaternion oldRot = part.RotationOffset;

            // Move our position to not be relative to the old parent
            Vector3 axPos = part.OffsetPosition;
            axPos *= parentRot;
            part.OffsetPosition = axPos;
            part.GroupPosition = oldGroupPosition + part.OffsetPosition;
            part.OffsetPosition = Vector3.Zero;

            // Compution our rotation to be not relative to the old parent
            Quaternion worldRot = parentRot * oldRot;
            part.RotationOffset = worldRot;

            // Add this SOP to our linkset
            part.SetParent(this);
            part.ParentID = m_rootPart.LocalId;
            m_parts.Add(part.UUID, part);

            part.LinkNum = linkNum;

            // Compute the new position of this SOP relative to the group position
            part.OffsetPosition = part.GroupPosition - AbsolutePosition;

            // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times.
            //   It would have the affect of setting the physics engine position multiple 
            //   times. In theory, that is not necessary but I don't have a good linkset
            //   test to know that cleaning up this code wouldn't break things.)

            // Rotate the relative position by the rotation of the group
            Quaternion rootRotation = m_rootPart.RotationOffset;
            Vector3 pos = part.OffsetPosition;
            pos *= Quaternion.Inverse(rootRotation);
            part.OffsetPosition = pos;

            // Compute the SOP's rotation relative to the rotation of the group.
            parentRot = m_rootPart.RotationOffset;
            oldRot = part.RotationOffset;
            Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot;
            part.RotationOffset = newRot;

            // Since this SOP's state has changed, push those changes into the physics engine
            //    and the simulator.
            part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set a part to act as the root part for this scene object
        /// </summary>
        /// <param name="part"></param>
        public void SetRootPart(SceneObjectPart part)
        {
            if (part == null)
                throw new ArgumentNullException("Cannot give SceneObjectGroup a null root SceneObjectPart");

            part.SetParent(this);
            m_rootPart = part;
            if (!IsAttachment)
                part.ParentID = 0;
            part.LinkNum = 0;
            
            m_parts.Add(m_rootPart.UUID, m_rootPart);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Add a new part to this scene object.  The part must already be correctly configured.
 /// </summary>
 /// <param name="part"></param>
 public void AddPart(SceneObjectPart part)
 {
     part.SetParent(this);
     part.LinkNum = m_parts.Add(part.UUID, part);
     if (part.LinkNum == 2)
         RootPart.LinkNum = 1;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Add a new part to this scene object.  The part must already be correctly configured.
        /// </summary>
        /// <param name="part"></param>
        public void AddPart(SceneObjectPart part)
        {
            lock (m_parts)
            {
                part.SetParent(this);
                m_parts.Add(part.UUID, part);

                part.LinkNum = m_parts.Count;

                if (part.LinkNum == 2 && RootPart != null)
                    RootPart.LinkNum = 1;
            }
        }
Exemplo n.º 5
0
        private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum)
        {
            Quaternion parentRot = oldGroupRotation;
            Quaternion oldRot = part.RotationOffset;
            Quaternion worldRot = parentRot * oldRot;

            parentRot = oldGroupRotation;

            Vector3 axPos = part.OffsetPosition;

            axPos *= parentRot;
            part.OffsetPosition = axPos;
            part.GroupPosition = oldGroupPosition + part.OffsetPosition;
            part.OffsetPosition = Vector3.Zero;
            part.RotationOffset = worldRot;

            part.SetParent(this);
            part.ParentID = m_rootPart.LocalId;

            m_parts.Add(part.UUID, part);

            part.LinkNum = linkNum;

            part.OffsetPosition = part.GroupPosition - AbsolutePosition;

            Quaternion rootRotation = m_rootPart.RotationOffset;

            Vector3 pos = part.OffsetPosition;
            pos *= Quaternion.Inverse(rootRotation);
            part.OffsetPosition = pos;

            parentRot = m_rootPart.RotationOffset;
            oldRot = part.RotationOffset;
            Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot;
            part.RotationOffset = newRot;
        }
        // This links an SOP from a previous linkset into my linkset.
        // The trick is that the SOP's position and rotation are relative to the old root SOP's
        //    so we are passed in the position and rotation of the old linkset so this can
        //    unjigger this SOP's position and rotation from the previous linkset and
        //    then make them relative to my linkset root.
        private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum)
        {
            Quaternion parentRot = oldGroupRotation;
            Quaternion oldRot = part.RotationOffset;

            // Move our position in world
            Vector3 axPos = part.OffsetPosition;
            axPos *= parentRot;
            Vector3 newPos = oldGroupPosition + axPos;
            part.setGroupPosition(newPos);
            part.setOffsetPosition(Vector3.Zero);

            // Compution our rotation in world
            Quaternion worldRot = parentRot * oldRot;
            part.RotationOffset = worldRot;

            // Add this SOP to our linkset
            part.SetParent(this);
            part.ParentID = m_rootPart.LocalId;
            m_parts.Add(part.UUID, part);

            part.LinkNum = linkNum;

            m_scene.updateScenePartGroup(part, this);

            // Compute the new position of this SOP relative to the group position
            part.setOffsetPosition(newPos - AbsolutePosition);

            // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times.
            //   It would have the affect of setting the physics engine position multiple 
            //   times. In theory, that is not necessary but I don't have a good linkset
            //   test to know that cleaning up this code wouldn't break things.)

            // Compute the SOP's rotation relative to the rotation of the group.
            parentRot = m_rootPart.RotationOffset;

            oldRot = part.RotationOffset;
            Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot;
            part.setRotationOffset(newRot);

            Vector3 pos = part.OffsetPosition;
            pos *= Quaternion.Conjugate(parentRot);

            part.OffsetPosition = pos; // update position and orientation on physics also

            // Since this SOP's state has changed, push those changes into the physics engine
            //    and the simulator.
            // done on caller
//            part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Set a part to act as the root part for this scene object
        /// </summary>
        /// <param name="part"></param>
        public void SetRootPart(SceneObjectPart part)
        {
            if (part == null)
                throw new ArgumentNullException("Cannot give SceneObjectGroup a null root SceneObjectPart");

            part.SetParent(this);
            m_rootPart = part;
            if (!IsAttachment)
                part.ParentID = 0;
            part.LinkNum = 0;
            
            // No locking required since the SOG should not be in the scene yet - one can't change root parts after
            // the scene object has been attached to the scene
            m_parts.Add(m_rootPart.UUID, m_rootPart);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Add a new part to this scene object.  The part must already be correctly configured.
        /// </summary>
        /// <param name="part"></param>
        public void AddPart(SceneObjectPart part)
        {
            part.SetParent(this);
            UpdatePartList(part);
            if (part != RootPart)
                part.LinkNum = m_parts.Count;

            if (part.LinkNum == 2 && RootPart != null)
                RootPart.LinkNum = 1;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Set a part to act as the root part for this scene object
        /// </summary>
        /// <param name="part"></param>
        public void SetRootPart(SceneObjectPart part)
        {
            m_rootPart = part;
            part.SetParent(this);

            if (!IsAttachment)
                part.ParentID = 0;
            part.LinkNum = 0;

            // No locking required since the SOG should not be in the scene yet - one can't change root parts after
            // the scene object has been attached to the scene
            m_parts.Add(m_rootPart.UUID, m_rootPart);
            this.TrackLocalId(m_rootPart, m_rootPart.LocalId);

            //Rebuild the bounding box
            ClearBoundingBoxCache();
            // Update the ServerWeight/LandImpact and StreamingCost
            if (m_parts.Count == 1) // avoids the recalcs on Copy calls for backup of prims
            {
                m_serverWeight = part.ServerWeight;
                m_streamingCost = part.StreamingCost;
            }
            else
            {
                RecalcPrimWeights();
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Set a part to act as the root part for this scene object
 /// </summary>
 /// <param name="part"></param>
 public void SetRootPart(SceneObjectPart part)
 {            
     part.SetParent(this);
     m_rootPart = part;
     if (!IsAttachment)
         part.ParentID = 0;
     part.LinkNum = 0;           
     
     // No locking required since the SOG should not be in the scene yet - one can't change root parts after
     // the scene object has been attached to the scene
     m_parts.Add(m_rootPart.UUID, m_rootPart);
 }        
Exemplo n.º 11
0
 public bool LinkPartToSOG(SceneObjectGroup grp, SceneObjectPart part, int linkNum)
 {
     part.SetParentLocalId(grp.RootPart.LocalId);
     part.SetParent(grp);
     // Insert in terms of link numbers, the new links
     // before the current ones (with the exception of 
     // the root prim. Shuffle the old ones up
     foreach (ISceneEntity otherPart in grp.ChildrenEntities())
     {
         if (otherPart.LinkNum >= linkNum)
         {
             // Don't update root prim link number
             otherPart.LinkNum += 1;
         }
     }
     part.LinkNum = linkNum;
     return LinkPartToEntity(grp, part);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Set a part to act as the root part for this scene object
        /// </summary>
        /// <param name="part"></param>
        public void SetRootPart(SceneObjectPart part)
        {
            m_rootPart = part;
            part.SetParent(this, false);

            if (!IsAttachment)
                part.ParentID = 0;
            part.LinkNum = 0;

            // SOG should not be in the scene yet - one can't change root parts after
            // the scene object has been attached to the scene
            m_childParts.AddPart(m_rootPart);

            //Rebuild the bounding box
            ClearBoundingBoxCache();
            // Update the ServerWeight/LandImpact and StreamingCost
            if (m_childParts.Count == 1) // avoids the recalcs on Copy calls for backup of prims
            {
                m_serverWeight = part.ServerWeight;
                m_streamingCost = part.StreamingCost;
            }
            else
            {
                RecalcPrimWeights();
            }
            RecalcScriptedStatus();
        }
Exemplo n.º 13
0
 private SceneObjectPart CreatePrim(PrimitiveShapeFunction shapeFunction, string name, Vector3 pos, Vector3 size)
 {
     SceneObjectPart part = new SceneObjectPart(UUID.Zero, shapeFunction(), Transform(pos), Rotate(Quaternion.Identity), Vector3.Zero);
     part.Name = name;
     part.Scale = size;
     part.ObjectFlags &= ~((uint)PrimFlags.Phantom);
     part.ObjectFlags |= (uint)PrimFlags.Temporary;
     SceneObjectGroup sceneObject = new SceneObjectGroup(part);
     part.SetParent(sceneObject);
     sceneObject.SetScene(m_scene);
     return part;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Set a part to act as the root part for this scene object
        /// </summary>
        /// <param name="part"></param>
        public void SetRootPart(SceneObjectPart part)
        {
            if (part == null)
                throw new ArgumentNullException("Cannot give SceneObjectGroup a null root SceneObjectPart");


            part.SetParent(this);
            m_rootPart = part;
            if (!IsAttachment)
                part.ParentID = 0;
            part.LinkNum = 0;

            GRotVersionInc(); // this updates both
            m_parts.Add(m_rootPart.UUID, m_rootPart);
            m_ValidgrpOOB = false;
        }