Exemple #1
0
        protected override void constructed()
        {
            DiscController.addDisc(this);
            SimObject controlPointObj = Owner.getOtherSimObject(controlPointObject);

            if (controlPointObj != null)
            {
                controlPoint = controlPointObj.getElement(controlPointBehavior) as ControlPointBehavior;
                if (controlPoint == null)
                {
                    blacklist("Could not find controlPointBehavior {0}.", controlPointBehavior);
                }
            }
            else
            {
                blacklist("Could not find controlPointObject {0}.", controlPointObject);
            }

            SimObject fossaSimObject = Owner.getOtherSimObject(fossaObject);

            if (fossaSimObject != null)
            {
                fossa = fossaSimObject.getElement(fossaName) as Fossa;
                if (fossa == null)
                {
                    blacklist("Could not find Fossa {0} in SimObject {1}.", fossaName, fossaObject);
                }
            }
            else
            {
                blacklist("Could not find Fossa SimObject {0}.", fossaObject);
            }

            SceneNodeElement node = Owner.getElement(sceneNodeName) as SceneNodeElement;

            if (node != null)
            {
                Entity entity = node.getNodeObject(entityName) as Entity;
                if (entity != null)
                {
                    if (entity.hasSkeleton())
                    {
                        SkeletonInstance skeleton = entity.getSkeleton();
                        medialPole.findBone(skeleton);
                        lateralPole.findBone(skeleton);
                        ventralPole.findBone(skeleton);
                        posteriorPole.initialize(skeleton, Owner, controlPoint, this);
                        topSurface.initialize(skeleton, fossa, Owner);
                    }
                }
                else
                {
                    blacklist("Could not find entity {0} in node {1}.", entityName, sceneNodeName);
                }
            }
            else
            {
                blacklist("Could not find SceneNode {0}.", sceneNodeName);
            }
        }
Exemple #2
0
 private void processDebug(EventManager eventManager)
 {
     if (eventManager[DiscEvents.PrintBoneLocations].FirstFrameDown)
     {
         Log.Default.debug("\nCP position -- {0} {1}", Owner.Name, controlPoint.Owner.Translation);
         Log.Default.debug("\nBone position -- {0}", Owner.Name);
         SceneNodeElement node = Owner.getElement(sceneNodeName) as SceneNodeElement;
         if (node != null)
         {
             Entity entity = node.getNodeObject(entityName) as Entity;
             if (entity != null)
             {
                 if (entity.hasSkeleton())
                 {
                     SkeletonInstance skeleton = entity.getSkeleton();
                     for (ushort i = 0; i < skeleton.getNumBones(); ++i)
                     {
                         Bone    bone = skeleton.getBone(i);
                         Vector3 loc  = Quaternion.quatRotate(Owner.Rotation, bone.getDerivedPosition()) + Owner.Translation;
                         Vector3 rot  = bone.getOrientation().getEuler() * 57.2957795f;
                         Log.Default.debug("Bone \"{0}\"{1},{2},{3},{4},{5},{6}", bone.getName(), loc.x, loc.y, loc.z, rot.x, rot.y, rot.z);
                         //Log.Default.debug("Bone \"{0}\"{1},{2},{3},{4},{5},{6}", bone.getName(), loc.x, -loc.z, loc.y, rot.x * -1.0f, rot.y, rot.z * -1.0f);
                     }
                 }
             }
         }
         Log.Default.debug("End Bone position -- {0}\n", Owner.Name);
     }
 }
Exemple #3
0
        protected override void constructed()
        {
            base.constructed();
            SceneNodeElement sceneNode = Owner.getElement(nodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Could not find SceneNode {0} in Syringe SimObject", nodeName);
            }
            Entity entity = sceneNode.getNodeObject(entityName) as Entity;

            if (entity == null)
            {
                blacklist("Could not find Entity {0} in Syringe SimObject", entityName);
            }
            if (entity.hasSkeleton())
            {
                SkeletonInstance skeleton = entity.getSkeleton();
                if (skeleton.hasBone(plungerBoneName))
                {
                    plungerBone = skeleton.getBone(plungerBoneName);
                    plungerBone.setManuallyControlled(true);
                    plungerBoneStart = plungerBone.getPosition();
                }
                else
                {
                    blacklist("Could not find plunger bone {0} for syringe", plungerBoneName);
                }
            }
            else
            {
                blacklist("Entity has no skeleton in Syringe SimObject");
            }
        }
        protected override void constructed()
        {
            joint = Owner.getElement(jointName) as Generic6DofConstraintElement;
            if (joint == null)
            {
                blacklist("Could not find Joint {0}.", jointName);
            }

            originalPosition = joint.getFrameOffsetOriginA();

            rigidBody = Owner.getElement(rigidBodyName) as RigidBody;
            if (rigidBody == null)
            {
                blacklist("Could not find RigidBody {0}", rigidBodyName);
            }
            rigidBody.ContactStarted += new CollisionCallback(rigidBody_ContactStarted);
            rigidBody.ContactEnded   += new CollisionCallback(rigidBody_ContactEnded);

            skinObject = Owner.getOtherSimObject(skinSimObjectName);
            if (skinObject == null)
            {
                blacklist("Could not find Target skin SimObject {0}.", skinSimObjectName);
            }

            SceneNodeElement node = skinObject.getElement(skinNodeName) as SceneNodeElement;

            if (node == null)
            {
                blacklist("Could not find target skin SceneNodeElement {0}.", skinSimObjectName);
            }

            Entity entity = node.getNodeObject(skinEntityName) as Entity;

            if (entity == null)
            {
                blacklist("Could not find skin Entity {0}.", skinNodeName);
            }

            if (!entity.hasSkeleton())
            {
                blacklist("Skin Entity {0} does not have a skeleton.", skinEntityName);
            }

            SkeletonInstance skeleton = entity.getSkeleton();

            if (skeleton.hasBone(lipBoneName))
            {
                lipBone = skeleton.getBone(lipBoneName);
                lipBone.setManuallyControlled(true);
                offset       = lipBone.getPosition() + skinObject.Translation - this.Owner.Translation;
                lastPosition = this.Owner.Translation;
            }
            else
            {
                blacklist("Cannot find bone {0} in Skin Entity {1} in SimObject {2}", lipBoneName, skinEntityName, skinSimObjectName);
            }
        }
        public SkeletonInstance getSkeleton()
        {
            global::System.IntPtr cPtr = OgrePINVOKE.InstancedEntity_getSkeleton(swigCPtr);
            SkeletonInstance      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SkeletonInstance(cPtr, false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemple #6
0
        protected override void constructed()
        {
            targetObject = Owner.getOtherSimObject(targetSimObject);
            if (targetObject != null)
            {
                SceneNodeElement node = targetObject.getElement(targetNode) as SceneNodeElement;
                if (node != null)
                {
                    Entity entity = node.getNodeObject(targetEntity) as Entity;
                    if (entity != null)
                    {
                        if (entity.hasSkeleton())
                        {
                            skeleton = entity.getSkeleton();
                            if (skeleton.hasBone(targetBone))
                            {
                                bone   = skeleton.getBone(targetBone);
                                offset = Owner.Translation - targetObject.Translation - bone.getDerivedPosition();
                                //calculate the scale at 100%
                                Vector3 adjust = (Vector3.ScaleIdentity - Owner.Scale) * offset;
                                offset += adjust;
                            }
                            else
                            {
                                blacklist("Entity {0} does not have a bone named {1}.", targetEntity, targetBone);
                            }
                        }
                        else
                        {
                            blacklist("Entity {0} does not have a skeleton.", targetEntity);
                        }
                    }
                    else
                    {
                        blacklist("Could not find Entity {0}.", targetEntity);
                    }
                }
                else
                {
                    blacklist("Could not find target SceneNodeElement {0}.", targetNode);
                }
            }
            else
            {
                blacklist("Could not find Target SimObject {0}.", targetSimObject);
            }

            joint = Owner.getElement(jointName) as Generic6DofConstraintElement;
            if (joint == null)
            {
                blacklist("Could not find joint {0}.", jointName);
            }
        }
        protected override void constructed()
        {
            tongueObject = Owner.getOtherSimObject(tongueSimObjectName);
            if (tongueObject == null)
            {
                blacklist("Could not find Target tongue SimObject {0}.", tongueSimObjectName);
            }

            SceneNodeElement node = tongueObject.getElement(tongueNodeName) as SceneNodeElement;

            if (node == null)
            {
                blacklist("Could not find target tongue SceneNodeElement {0}.", tongueSimObjectName);
            }

            Entity entity = node.getNodeObject(tongueEntityName) as Entity;

            if (entity == null)
            {
                blacklist("Could not find tongue Entity {0}.", tongueNodeName);
            }
            if (!entity.hasSkeleton())
            {
                blacklist("Tongue Entity {0} does not have a skeleton.", tongueEntityName);
            }

            SkeletonInstance skeleton = entity.getSkeleton();

            bone = skeleton.getBone(boneName);
            if (bone == null)
            {
                blacklist("Tongue Entity {0} does not have a bone named {1}.", tongueEntityName, boneName);
            }

            offset = Owner.Translation - tongueObject.Translation - bone.getDerivedPosition();
            //calculate the scale at 100%
            Vector3 adjust = (Vector3.ScaleIdentity - Owner.Scale) * offset;

            offset += adjust;

            joint = Owner.getElement(jointName) as Generic6DofConstraintElement;
            if (joint == null)
            {
                blacklist("Could not find Joint {0}.", jointName);
            }

            rigidBody = Owner.getElement(rigidBodyName) as RigidBody;
            if (rigidBody == null)
            {
                blacklist("Could not find RigidBody {0}", rigidBodyName);
            }
        }
 protected override void constructed()
 {
     targetObject = Owner.getOtherSimObject(targetSimObject);
     if (targetObject != null)
     {
         SceneNodeElement node = targetObject.getElement(targetNode) as SceneNodeElement;
         if (node != null)
         {
             Entity entity = node.getNodeObject(targetEntity) as Entity;
             if (entity != null)
             {
                 if (entity.hasSkeleton())
                 {
                     skeleton = entity.getSkeleton();
                     if (skeleton.hasBone(targetBone))
                     {
                         bone = skeleton.getBone(targetBone);
                         //Calculate the offset from this object to the bone
                         offset = Owner.Translation - (targetObject.Translation + bone.getDerivedPosition());
                         //calculate the scale at 100%
                         Vector3 adjust = (Vector3.ScaleIdentity - Owner.Scale) * offset;
                         offset += adjust;
                         //Rotate the offset into the space for the object
                         offset = Quaternion.quatRotate(targetObject.Rotation.inverse(), offset);
                     }
                     else
                     {
                         blacklist("Entity {0} does not have a bone named {1}.", targetEntity, targetBone);
                     }
                 }
                 else
                 {
                     blacklist("Entity {0} does not have a skeleton.", targetEntity);
                 }
             }
             else
             {
                 blacklist("Could not find Entity {0}.", targetEntity);
             }
         }
         else
         {
             blacklist("Could not find target SceneNodeElement {0}.", targetNode);
         }
     }
     else
     {
         blacklist("Could not find Target SimObject {0}.", targetSimObject);
     }
 }
        public void SetSkeleton(SkeletonInstance skel)
        {
            Bone     bone = skel.RootBone;
            TreeNode node = new TreeNode();

            node.Name = bone.Name;
            node.Text = bone.Name;
            boneTreeView.Nodes.Add(node);
            AddChildBones(node, bone);

            skeleton = skel;
            string skeletonName = skel.MasterSkeleton.Name;

            helperSkeleton = SkeletonManager.Instance.Load(skeletonName);
        }
Exemple #10
0
        protected override void constructed()
        {
            SimObject targetObject = Owner.getOtherSimObject(targetSimObject);

            if (targetObject != null)
            {
                SceneNodeElement node = targetObject.getElement(targetNode) as SceneNodeElement;
                if (node != null)
                {
                    Entity entity = node.getNodeObject(targetEntity) as Entity;
                    if (entity != null)
                    {
                        if (entity.hasSkeleton())
                        {
                            skeleton = entity.getSkeleton();
                            if (skeleton.hasBone(targetBone))
                            {
                                bone = skeleton.getBone(targetBone);
                                bone.setManuallyControlled(true);
                                AnimationManipulatorController.addAnimationManipulator(this);
                            }
                            else
                            {
                                blacklist("Entity {0} does not have a bone named {1}.", targetEntity, targetBone);
                            }
                        }
                        else
                        {
                            blacklist("Entity {0} does not have a skeleton.", targetEntity);
                        }
                    }
                    else
                    {
                        blacklist("Could not find Entity {0}.", targetEntity);
                    }
                }
                else
                {
                    blacklist("Could not find target SceneNodeElement {0}.", targetNode);
                }
            }
            else
            {
                blacklist("Could not find Target SimObject {0}.", targetSimObject);
            }
        }
Exemple #11
0
        ///<summary>
        ///  Adds an Entity to the static geometry.
        ///  <remarks>
        ///    This method takes an existing Entity and adds its details to the list of elements to include when building. Note that the Entity itself is not copied or referenced in this method; an Entity is passed simply so that you can change the materials of attached SubEntity objects if you want. You can add the same Entity instance multiple times with different material settings completely safely, and destroy the Entity before destroying this InstancedGeometry if you like. The Entity passed in is simply Must be called before 'Build'.
        ///  </remarks>
        ///</summary>
        ///<param name="ent"> The Entity to use as a definition (the Mesh and Materials referenced will be recorded for the build call). </param>
        ///<param name="position"> The world position at which to add this Entity </param>
        ///<param name="orientation"> The world orientation at which to add this Entity </param>
        ///<param name="scale"> </param>
        public virtual void AddEntity(Entity ent, Vector3 position, Quaternion orientation, Vector3 scale)
        {
            Mesh msh = ent.Mesh;

            // Validate
            if (msh.IsLodManual)
            {
                LogManager.Instance.Write(
                    "(InstancedGeometry): Manual LOD is not supported. Using only highest LOD level for mesh " + msh.Name);
            }

            //get the skeleton of the entity, if that's not already done
            if (ent.Mesh.Skeleton != null && mBaseSkeleton == null)
            {
                mBaseSkeleton     = ent.Mesh.Skeleton;
                mSkeletonInstance = new SkeletonInstance(mBaseSkeleton);
                mSkeletonInstance.Load();
                mAnimationState = ent.GetAllAnimationStates();
            }

            BoundingBox sharedWorldBounds;

            // queue this entities submeshes and choice of material
            // also build the lists of geometry to be used for the source of lods


            for (int i = 0; i < ent.SubEntityCount; ++i)
            {
                SubEntity se = ent.GetSubEntity(i);
                var       q  = new QueuedSubMesh();

                // Get the geometry for this SubMesh
                q.submesh         = se.SubMesh;
                q.geometryLodList = DetermineGeometry(q.submesh);
                q.materialName    = se.MaterialName;
                q.orientation     = orientation;
                q.position        = position;
                q.scale           = scale;
                q.ID = mObjectCount;
            }

            mObjectCount++;
        }
Exemple #12
0
 public InstancedGeometry(SceneManager owner, String name)
 {
     mOwner                       = owner;
     mName                        = name;
     mBuilt                       = false;
     mUpperDistance               = 0.0f;
     mSquaredUpperDistance        = 0.0f;
     mCastShadows                 = false;
     mBatchInstanceDimensions     = new Vector3(1000, 1000, 1000);
     mHalfBatchInstanceDimensions = new Vector3(500, 500, 500);
     mOrigin                      = new Vector3(0, 0, 0);
     mVisible                     = true;
     mRenderQueueID               = (byte)RenderQueueGroupID.Main;
     mRenderQueueIDSet            = false;
     mObjectCount                 = 0;
     mInstancedGeometryInstance   = null;
     mSkeletonInstance            = null;
     mBaseSkeleton                = null;
 }
        public void setSkeleton(Entity entity)
        {
            SkeletonInstance skeleton = entity.getSkeleton();

            skeletonTree.Nodes.clear();
            for (ushort i = 0; i < skeleton.getNumBones(); i++)
            {
                Bone     bone         = skeleton.getBone(i);
                TreeNode skeletonNode = new TreeNode(bone.getName());
                skeletonNode.UserData = bone;
                TreeNode positionNode = new TreeNode("Position " + bone.getPosition());
                skeletonNode.Children.add(positionNode);
                TreeNode rotationNode = new TreeNode("Rotation" + bone.getOrientation());
                skeletonNode.Children.add(rotationNode);
                skeletonTree.Nodes.add(skeletonNode);
            }
            using (MeshPtr mesh = entity.getMesh())
            {
                mesh.Value._updateCompiledBoneAssignments();
                if (mesh.Value.SharedVertexData != null)
                {
                    //Logging.Log.Debug("Shared Bone Assignments {0}", mesh.Value.SharedBoneAssignmentCount);
                }
                else
                {
                    ushort numSubMeshes = mesh.Value.getNumSubMeshes();
                    for (ushort i = 0; i < numSubMeshes; ++i)
                    {
                        SubMesh           subMesh           = mesh.Value.getSubMesh(i);
                        VertexData        vertexData        = subMesh.vertexData;
                        VertexDeclaration vertexDeclaration = vertexData.vertexDeclaration;
                        VertexElement     elem = vertexDeclaration.findElementBySemantic(VertexElementSemantic.VES_BLEND_WEIGHTS);
                        if (elem != null)
                        {
                            Logging.Log.Debug("Sub Mesh {0} Bone Assignments {1}", i, VertexElement.getTypeCount(elem.getType()));
                        }
                    }
                }
            }
            skeletonTree.layout();
        }
Exemple #14
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SkeletonInstance obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
        protected override void constructed()
        {
            boneObject = Owner.getOtherSimObject(boneSimObject);
            if (boneObject != null)
            {
                SceneNodeElement node = boneObject.getElement(boneNode) as SceneNodeElement;
                if (node != null)
                {
                    Entity entity = node.getNodeObject(boneEntity) as Entity;
                    if (entity != null)
                    {
                        if (entity.hasSkeleton())
                        {
                            SkeletonInstance skeleton = entity.getSkeleton();
                            if (skeleton.hasBone(targetBone))
                            {
                                bone = skeleton.getBone(targetBone);
                            }
                            else
                            {
                                blacklist("Entity {0} does not have a bone named {1}.", boneEntity, targetBone);
                            }
                        }
                        else
                        {
                            blacklist("Entity {0} does not have a skeleton.", boneEntity);
                        }
                    }
                    else
                    {
                        blacklist("Could not find Entity {0}.", boneEntity);
                    }
                }
                else
                {
                    blacklist("Could not find target SceneNodeElement {0}.", boneNode);
                }
            }
            else
            {
                blacklist("Could not find Target SimObject {0}.", boneSimObject);
            }
            SimObject discSimObject = Owner.getOtherSimObject(discObject);

            if (discSimObject != null)
            {
                disc = discSimObject.getElement(discName) as Disc;
                if (disc == null)
                {
                    blacklist("Could not find Disc {0} in SimObject {1}.", discName, discObject);
                }
            }
            else
            {
                blacklist("Could not find Disc SimObject {0}.", discObject);
            }
            joint = Owner.getElement(jointName) as Generic6DofConstraintElement;
            if (joint == null)
            {
                blacklist("Could not find joint {0}.", jointName);
            }

            ControlPointController.addControlPoint(this);
        }
Exemple #16
0
        protected override void constructed()
        {
            curve = new CatmullRomSpline3d();

            FossaController.add(this);
            SimObject eminanceSimObject = Owner.getOtherSimObject(eminanceName);

            if (eminanceSimObject == null)
            {
                blacklist("Cannot find the eminance SimObject {0}", eminanceName);
            }

            eminanceOffset = eminanceSimObject.Translation;
            SceneNodeElement eminanceSceneNode = eminanceSimObject.getElement(eminanceNodeName) as SceneNodeElement;

            if (eminanceSceneNode == null)
            {
                blacklist("Cannot find the eminance scene node {0}", eminanceNodeName);
            }

            Entity eminanceEntity = eminanceSceneNode.getNodeObject(eminanceEntityName) as Entity;

            if (eminanceEntity == null)
            {
                blacklist("Cannot find the eminance entity {0}", eminanceEntityName);
            }

            if (!eminanceEntity.hasSkeleton())
            {
                blacklist("Eminance entity {0} does not have a skeleton.", eminanceEntityName);
            }

            SkeletonInstance skeleton = eminanceEntity.getSkeleton();

            for (int i = 1; skeleton.hasBone(fossaBoneBaseName + i); ++i)
            {
                Bone bone = skeleton.getBone(fossaBoneBaseName + i);
                eminanceBones.Add(bone);
                bone.setManuallyControlled(true);
            }

            SimObject skullSimObject = Owner.getOtherSimObject(skullName);

            if (skullSimObject == null)
            {
                blacklist("Could not find a skull SimObject named {0}.", skullName);
            }

            skullOffset = skullSimObject.Translation;
            SceneNodeElement skullNode = skullSimObject.getElement(skullNodeName) as SceneNodeElement;

            if (skullNode == null)
            {
                blacklist("Could not find skull node {0}.", skullNodeName);
            }

            Entity skullEntity = skullNode.getNodeObject(skullEntityName) as Entity;

            if (skullEntity == null)
            {
                blacklist("Could not find skull entity {0}.", skullEntityName);
            }

            if (!skullEntity.hasSkeleton())
            {
                blacklist("Skull entity {0} does not have a skeleton.", skullEntityName);
            }

            skeleton = skullEntity.getSkeleton();
            Vector3 eminanceTrans = Vector3.Zero;

            for (int i = 1; skeleton.hasBone(fossaBoneBaseName + i); ++i)
            {
                Bone bone = skeleton.getBone(fossaBoneBaseName + i);
                skullBones.Add(bone);
                bone.setManuallyControlled(true);
                Vector3 trans = bone.getDerivedPosition() + skullSimObject.Translation - this.Owner.Translation;
                trans.x = 0;
                basePoints.Add(trans);
                if (i < eminanceStart)
                {
                    eminanceDistort.Add(trans);
                    eminanceTrans = trans;
                }
                else
                {
                    trans.y = eminanceTrans.y;
                    eminanceDistort.Add(trans);
                }
            }

            foreach (Vector3 point in basePoints)
            {
                curve.addControlPoint(point);
            }

            //Find the control point
            SimObject controlPointObj = Owner.getOtherSimObject(controlPointObject);

            if (controlPointObj == null)
            {
                blacklist("Could not find controlPointObject {0}.", controlPointObject);
            }

            controlPoint = controlPointObj.getElement(controlPointBehavior) as ControlPointBehavior;
            if (controlPoint == null)
            {
                blacklist("Could not find controlPointBehavior {0}.", controlPointBehavior);
            }
        }