Пример #1
0
        public void UnlinkChildren(EntityGroup group)
        {
            Vector3 ParentPos        = group.pos;
            Rot     ParentRot        = group.rot;
            Rot     InverseParentRot = ParentRot.Inverse();

            for (int i = 0; i < group.iNumSubEntities; i++)
            {
                Test.Debug("unlinking child " + group.SubEntities[i].ToString() +
                           " group pos " + group.pos.ToString()); // Test.Debug

                // Entity childentity = GetEntityByReference( group.SubEntityReferences[i] );
                Entity childentity = (Entity)group.SubEntities[i];

                Rot OldChildRot = childentity.rot;
                Rot NewChildRot = ParentRot * OldChildRot;

                Vector3 OldChildPos = childentity.pos;
                Vector3 GroupAxesVectorFromParentToChild  = OldChildPos;
                Vector3 GlobalAxesVectorFromParentToChild = GroupAxesVectorFromParentToChild * InverseParentRot;
                //MultiplyVectorByRot( GlobalAxesVectorFromParentToChild, InverseParentRot, GroupAxesVectorFromParentToChild );
                Vector3 NewChildPos = GlobalAxesVectorFromParentToChild + ParentPos;

                childentity.iParentReference = 0;
                childentity.pos = NewChildPos;
                childentity.rot = NewChildRot;
                Test.Debug("child after unlinking: " + childentity.pos.ToString() + " " + childentity.rot.ToString());    // Test.Debug

                group.SubEntities[i] = null;
            }
            group.iNumSubEntities = 0;
        }
Пример #2
0
        public void UnlinkChildren( EntityGroup group )
        {
            Vector3 ParentPos = group.pos;
            Rot ParentRot = group.rot;
            Rot InverseParentRot= ParentRot.Inverse();

            for( int i = 0; i < group.iNumSubEntities; i++ )
            {
                Test.Debug(  "unlinking child " + group.SubEntities[i].ToString() +
                        " group pos " + group.pos.ToString() ); // Test.Debug

                // Entity childentity = GetEntityByReference( group.SubEntityReferences[i] );
                Entity childentity = (Entity)group.SubEntities[i];

                Rot OldChildRot = childentity.rot;
                Rot NewChildRot = ParentRot * OldChildRot;

                Vector3 OldChildPos = childentity.pos;
                Vector3 GroupAxesVectorFromParentToChild = OldChildPos;
                Vector3 GlobalAxesVectorFromParentToChild = GroupAxesVectorFromParentToChild * InverseParentRot;
                //MultiplyVectorByRot( GlobalAxesVectorFromParentToChild, InverseParentRot, GroupAxesVectorFromParentToChild );
                Vector3 NewChildPos = GlobalAxesVectorFromParentToChild + ParentPos;

                childentity.iParentReference = 0;
                childentity.pos = NewChildPos;
                childentity.rot = NewChildRot;
                Test.Debug(  "child after unlinking: " + childentity.pos.ToString() + " " + childentity.rot.ToString() ); // Test.Debug

                group.SubEntities[i] = null;
            }
            group.iNumSubEntities = 0;
        }
Пример #3
0
        public void ApplyTransforms()
        {
            IGraphicsHelper graphics = GraphicsHelperFactory.GetInstance();

            if (Parent != null)
            {
                EntityGroup parententity = Parent as EntityGroup;
                parententity.ApplyTransforms();
            }
            graphics.Translate(pos);
            graphics.Rotate(rot);
        }
Пример #4
0
 public void CrossReferenceChildrenIfNecessary( EntityGroup group )
 {
     int iArrayPos = 0;
     for( iArrayPos = 0; iArrayPos < iNumEntities; iArrayPos++ )
     {
         Entity childentity = entities[ iArrayPos ];
         if( childentity.iParentReference == group.iReference )
         {
             Test.Debug(  "Child of iReference " + childentity.iParentReference.ToString() + " is " + childentity.iReference.ToString() ); // Test.Debug
             group.AddSubEntity( childentity );
         }
     }
 }
Пример #5
0
        public void CrossReferenceChildrenIfNecessary(EntityGroup group)
        {
            int iArrayPos = 0;

            for (iArrayPos = 0; iArrayPos < iNumEntities; iArrayPos++)
            {
                Entity childentity = entities[iArrayPos];
                if (childentity.iParentReference == group.iReference)
                {
                    Test.Debug("Child of iReference " + childentity.iParentReference.ToString() + " is " + childentity.iReference.ToString());    // Test.Debug
                    group.AddSubEntity(childentity);
                }
            }
        }