Esempio n. 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);
            }
        }
Esempio n. 2
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");
            }
        }
Esempio n. 3
0
        protected override void constructed()
        {
            base.constructed();

            mainNode = Owner.getElement(mainNodeName) as SceneNodeElement;
            if (mainNode == null)
            {
                blacklist("Cannot find main scene node {0}", mainNodeName);
            }

            rigidBody = Owner.getElement(reshapeableRigidBodyName) as ReshapeableRigidBody;
            if (rigidBody == null)
            {
                blacklist("Cannot find reshapeable rigid body {0}", reshapeableRigidBodyName);
            }

            ogreSceneManager = Owner.SubScene.getSimElementManager <OgreSceneManager>();

            if (sections.Count > 0)
            {
                beginUpdates();

                foreach (var section in sections.Values)
                {
                    section.create(this);
                }

                finishUpdates();
            }
        }
Esempio n. 4
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);
     }
 }
Esempio n. 5
0
        public static String FindMeshName(SimObject simObject)
        {
            String name = null;

            foreach (var element in simObject.getElementIter())
            {
                SceneNodeElement sceneElement = element as SceneNodeElement;
                if (sceneElement != null)
                {
                    foreach (var movable in sceneElement.MovableObjects)
                    {
                        Entity entity = movable as Entity;
                        if (entity != null)
                        {
                            using (MeshPtr mesh = entity.getMesh())
                            {
                                String meshName = mesh.Value.getName();
                                if (meshName != null)
                                {
                                    name = Path.GetFileNameWithoutExtension(meshName);
                                    break;
                                }
                            }
                        }
                    }
                    break;
                }
            }
            return(name);
        }
Esempio n. 6
0
        protected override void constructed()
        {
            base.constructed();

            SceneNodeElement sceneNode = Owner.getElement(PropFactory.NodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Could not find SceneNode {0} in pen.", PropFactory.NodeName);
            }

            penEntity = sceneNode.getNodeObject(PropFactory.EntityName) as Entity;
            if (penEntity == null)
            {
                blacklist("Could not find Entity {0} in pen.", PropFactory.NodeName);
            }

            clickOnAnim = penEntity.getAnimationState("ClickOn");
            if (clickOnAnim == null)
            {
                blacklist("Could not find Animation ClickOn in pen.");
            }
            clickOnAnim.setLoop(false);

            clickOffAnim = penEntity.getAnimationState("ClickOff");
            if (clickOffAnim == null)
            {
                blacklist("Could not find Animation ClickOff in pen.");
            }
            clickOffAnim.setLoop(false);
        }
        protected override void link()
        {
            SceneNodeElement sceneNode = Owner.getElement(nodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Could not find node {0}.", nodeName);
            }
            entity = sceneNode.getNodeObject(entityName) as ManualObject;
            if (entity == null)
            {
                blacklist("No entity specified or entity is not found.");
            }
            if (subEntityIndex >= entity.getNumSections())
            {
                blacklist("Entity {0} only has {1} SubEntities. Index {2} is invalid.", entity.getName(), entity.getNumSections(), subEntityIndex);
            }
            subEntity        = entity.getSection(subEntityIndex);
            baseMaterialName = subEntity.getMaterialName();
            MaterialManager materialManager   = MaterialManager.getInstance();
            String          alphaMaterialName = baseMaterialName + alphaSuffix;

            if (materialManager.resourceExists(alphaMaterialName))
            {
                finalAlphaMaterialName = alphaMaterialName;
            }
            else
            {
                blacklist("Cannot find automatic alpha material {0}.  Please ensure one exists or define a custom alpha behavior.", alphaMaterialName);
            }
        }
Esempio n. 8
0
        protected override void constructed()
        {
            SimObject targetObject = Owner.getOtherSimObject(targetSimObject);

            if (targetObject == null)
            {
                blacklist("Could not find Target SimObject {0}.", targetSimObject);
            }
            SceneNodeElement node = targetObject.getElement(targetNode) as SceneNodeElement;

            if (node == null)
            {
                blacklist("Could not find target SceneNodeElement {0}.", targetNode);
            }
            Entity entity = node.getNodeObject(targetEntity) as Entity;

            if (entity == null)
            {
                blacklist("Could not find Entity {0}.", targetEntity);
            }
            mesh = entity.getMesh();
            OgrePlugin.Animation anim;
            VertexAnimationTrack track;

            if (mesh.Value.hasAnimation(manualAnimationName))
            {
                anim           = mesh.Value.getAnimation(manualAnimationName);
                track          = anim.getVertexTrack(1);
                manualKeyFrame = track.getKeyFrame(0) as VertexPoseKeyFrame;
            }
            else
            {
                blacklist("Could not find animation {0}.", manualAnimationName);
            }
            //Must look this up this way to get the correct pose index.
            int poseCount = mesh.Value.getPoseCount();

            OgrePlugin.Pose pose = null;
            for (ushort i = 0; i < poseCount; ++i)
            {
                OgrePlugin.Pose innerPose = mesh.Value.getPose(i);
                if (innerPose.getName() == poseName)
                {
                    pose      = innerPose;
                    poseIndex = i;
                    break;
                }
            }
            if (pose == null)
            {
                blacklist("Cannot find pose {0}.", poseName);
            }
            manualKeyFrame.addPoseReference(poseIndex, 0.0f);
            manualAnimationState = entity.getAnimationState(manualAnimationName);
            manualAnimationState.setLength(0.0f);
            manualAnimationState.setTimePosition(0.0f);
            manualAnimationState.setEnabled(true);
            AnimationManipulatorController.addAnimationManipulator(this);
        }
Esempio n. 9
0
        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);
            }
        }
Esempio n. 10
0
        protected override void constructed()
        {
            base.constructed();

            SceneNodeElement sceneNode = Owner.getElement(PropFactory.NodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Could not find SceneNode {0} in Caliper SimObject", PropFactory.NodeName);
            }

            entity = sceneNode.getNodeObject(PropFactory.EntityName) as Entity;
            if (entity == null)
            {
                blacklist("Could not find Entity {0} in Caliper SimObject", PropFactory.EntityName);
            }

            subEntity = entity.getSubEntity(0);
            if (subEntity == null)
            {
                blacklist("Could not find sub entity with index 0 in Caliper SimObject");
            }

            Skeleton skeleton = entity.getSkeleton();

            if (skeleton == null)
            {
                blacklist("Could not find skeleton for Caliper SimObject");
            }

            sliderBone = skeleton.getBone("BCalSlider");
            if (sliderBone == null)
            {
                blacklist("Could not find 'BCalSlider' for Caliper SimObject");
            }
            sliderBone.setManuallyControlled(true);
            caliperBoneStart = sliderBone.getPosition();

            lockAnim = entity.getAnimationState("Lock");
            if (lockAnim == null)
            {
                blacklist("Could not find animation 'Lock' in caliper entity");
            }
            lockAnim.setLoop(false);
            lockAnimLength = lockAnim.getLength();
            lockAnim.setEnabled(true);
            lockAnim.setTimePosition(lockAnimLength); //The caliper starts unlocked, so set this animation active and at the end to keep it locked.

            unlockAnim = entity.getAnimationState("Unlock");
            if (unlockAnim == null)
            {
                blacklist("Could not find animation 'Unlock' in caliper entity");
            }
            unlockAnim.setLoop(false);
            unlockAnimLength = unlockAnim.getLength();
        }
Esempio n. 11
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);
     }
 }
Esempio n. 14
0
 protected override void constructed()
 {
     base.constructed();
     node = Owner.getElement(sceneNodeName) as SceneNodeElement;
     if (node == null)
     {
         blacklist("Could not find scene node named {0}.", sceneNodeName);
     }
     manualObject = node.getNodeObject(manualObjectName) as ManualObject;
     if (manualObject == null)
     {
         blacklist("Could not find manual object named {0}.", manualObjectName);
     }
 }
        protected override void constructed()
        {
            SceneNodeElement sceneNode = Owner.getElement(nodeName) as SceneNodeElement;

            if (sceneNode != null)
            {
                entity = sceneNode.getNodeObject(entityName) as Entity;
            }

            if (entity == null)
            {
                blacklist("No entity specified or entity is not found.");
            }

            originalRenderGroup = entity.getRenderQueueGroup();

            if (subEntityIndex >= entity.getNumSubEntities())
            {
                blacklist("Entity {0} only has {1} SubEntities. Index {2} is invalid.", entity.getName(), entity.getNumSubEntities(), subEntityIndex);
            }
            subEntity        = entity.getSubEntity(subEntityIndex);
            baseMaterialName = subEntity.getMaterialName();
            MaterialManager materialManager    = MaterialManager.getInstance();
            bool            useDefinedMaterial = !(alphaMaterialName == null || alphaMaterialName.Equals(String.Empty));

            if (useDefinedMaterial)
            {
                if (materialManager.resourceExists(alphaMaterialName))
                {
                    finalAlphaMaterialName = alphaMaterialName;
                }
                else
                {
                    blacklist("A custom material {0} is defined that cannot be found.  This object will not be able to be alpha controlled.", this.alphaMaterialName);
                }
            }
            else
            {
                if (materialManager.resourceExists(baseMaterialName + alphaSuffix))
                {
                    finalAlphaMaterialName = baseMaterialName + alphaSuffix;
                }
                else
                {
                    blacklist("Cannot find automatic alpha material {0}.  Please ensure one exists or define a custom alpha behavior.", baseMaterialName + alphaSuffix);
                }
            }
            setAlpha(currentAlpha);
        }
Esempio n. 16
0
        protected override void constructed()
        {
            SimObject 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);
            }

            protrude = entity.getAnimationState(protrudeAnimationName);
            if (protrude == null)
            {
                blacklist("Tongue Entity {0} does not have an animation for protrusion named {1}.", tongueEntityName, protrudeAnimationName);
            }

            back = entity.getAnimationState(backAnimationName);
            if (back == null)
            {
                blacklist("Tongue Entity {0} does not have an animation for back named {1}.", tongueEntityName, backAnimationName);
            }

            rest = entity.getAnimationState(restAnimationName);
            if (rest == null)
            {
                blacklist("Tongue Entity {0} does not have an animation for rest named {1}.", tongueEntityName, restAnimationName);
            }

            protrude.setLoop(false);
            back.setLoop(false);
            rest.setLoop(false);

            TongueMode = tongueMode;
        }
Esempio n. 17
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);
            }
        }
Esempio n. 18
0
        protected override void constructed()
        {
            base.constructed();
            SceneNodeElement sceneNode = Owner.getElement(PropFactory.NodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Cannot find scene node {0} in LineProp.", PropFactory.NodeName);
            }
            manualObject = sceneNode.getNodeObject("ManualObject") as ManualObject;
            if (manualObject == null)
            {
                blacklist("Cannot find 'ManualObject' in node {0}.", PropFactory.NodeName);
            }
            manualObject.RedrawRequired += manualObject_RedrawRequired;
            createLine();
        }
Esempio n. 19
0
        protected override void constructed()
        {
            base.constructed();

            SceneNodeElement sceneNode = Owner.getElement(PropFactory.NodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Could not find SceneNode {0} in PoseableHand SimObject", PropFactory.NodeName);
            }
            entity = sceneNode.getNodeObject(PropFactory.EntityName) as Entity;
            if (entity == null)
            {
                blacklist("Could not find Entity {0} in PoseableHand SimObject", PropFactory.EntityName);
            }
            subEntity = entity.getSubEntity(0);
            if (subEntity == null)
            {
                blacklist("Could not find sub entity with index 0 in PoseableHand SimObject");
            }
            Skeleton skeleton = entity.getSkeleton();

            if (skeleton == null)
            {
                blacklist("Could not find skeleton for PoseableHand SimObject");
            }
            wrist = skeleton.getBone("BWrist" + BoneSuffix);
            if (wrist == null)
            {
                blacklist("Could not find bwrist in PoseableHand");
            }
            wrist.setManuallyControlled(true);
            palm = skeleton.getBone("BPalm" + BoneSuffix);
            if (palm == null)
            {
                blacklist("Could not find bpalm in PoseableHand");
            }
            palm.setManuallyControlled(true);
            thumb  = new PoseableThumb(skeleton, "BThumbBase" + BoneSuffix, "BThumb02" + BoneSuffix, "BThumb01" + BoneSuffix);
            index  = new PoseableFinger(skeleton, "BIndexKnuckle" + BoneSuffix, "BIndex03" + BoneSuffix, "BIndex02" + BoneSuffix, "BIndex01" + BoneSuffix);
            middle = new PoseableFinger(skeleton, "BMiddleKnuckle" + BoneSuffix, "BMiddle03" + BoneSuffix, "BMiddle02" + BoneSuffix, "BMiddle01" + BoneSuffix);
            ring   = new PoseableFinger(skeleton, "BRingKnuckle" + BoneSuffix, "BRing03" + BoneSuffix, "BRing02" + BoneSuffix, "BRing01" + BoneSuffix);
            pinky  = new PoseableFinger(skeleton, "BPinkyKnuckle" + BoneSuffix, "BPinky03" + BoneSuffix, "BPinky02" + BoneSuffix, "BPinky01" + BoneSuffix);
        }
Esempio n. 20
0
 protected override void constructed()
 {
     targetObject = Owner.getOtherSimObject(targetSimObject);
     if (targetObject != null)
     {
         nodeElement = targetObject.getElement(targetNode) as SceneNodeElement;
         if (nodeElement != null)
         {
             offset = this.Owner.Translation - nodeElement.getDerivedPosition();
         }
         else
         {
             blacklist("Could not find target SceneNodeElement {0}.", targetNode);
         }
     }
     else
     {
         blacklist("Could not find Target SimObject {0}.", targetSimObject);
     }
 }
        protected override void constructed()
        {
            base.constructed();
            SceneNodeElement sceneNode = Owner.getElement(nodeName) as SceneNodeElement;

            if (sceneNode != null)
            {
                entity = sceneNode.getNodeObject(entityName) as Entity;
            }

            if (entity == null)
            {
                blacklist("No entity specified or entity is not found.");
            }
            if (subEntityIndex >= entity.getNumSubEntities())
            {
                blacklist("Entity {0} only has {1} SubEntities. Index {2} is invalid.", entity.getName(), entity.getNumSubEntities(), subEntityIndex);
            }
            subEntity = entity.getSubEntity(subEntityIndex);
        }
Esempio n. 22
0
        protected override void constructed()
        {
            base.constructed();

            SceneNodeElement sceneNode = Owner.getElement(PropFactory.NodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Could not find SceneNode {0} in Arrow SimObject", PropFactory.NodeName);
            }
            entity = sceneNode.getNodeObject(PropFactory.EntityName) as Entity;
            if (entity == null)
            {
                blacklist("Could not find Entity {0} in Arrow SimObject", PropFactory.EntityName);
            }
            subEntity = entity.getSubEntity(0);
            if (subEntity == null)
            {
                blacklist("Could not find sub entity with index 0 in Arrow SimObject");
            }
            Skeleton skeleton = entity.getSkeleton();

            if (skeleton == null)
            {
                blacklist("Could not find skeleton for Arrow SimObject");
            }
            topBone = skeleton.getBone("ArrowTopBone");
            if (topBone == null)
            {
                blacklist("Could not find 'ArrowTopBone' for Arrow SimObject");
            }
            topBone.setManuallyControlled(true);
            bottomBone = skeleton.getBone("ArrowBottomBone");
            if (bottomBone == null)
            {
                blacklist("Could not find 'ArrowBottomBone' for Arrow SimObject");
            }
            bottomBone.setManuallyControlled(true);
            Color      = color;
            tailLength = bottomBone.getPosition().y;
        }
 protected override void constructed()
 {
     sceneNode = Owner.getElement(nodeName) as SceneNodeElement;
     if (sceneNode == null)
     {
         blacklist("Cannot find scene node named {0}.", nodeName);
     }
     manualObject = sceneNode.getNodeObject(manualObjectName) as ManualObject;
     if (manualObject == null)
     {
         blacklist("Cannot find manual object named {0}.", manualObjectName);
     }
     manualObject.setVisible(drawLines);
     manualObject.begin("Grid", OperationType.OT_LINE_LIST);
     manualObject.position(ref Vector3.Zero);
     manualObject.color(0, 0, 0, 0);
     manualObject.position(ref Vector3.Zero);
     manualObject.color(0, 0, 0, 0);
     manualObject.end();
     MeasurementController.setMeasurementDrawer(this);
 }
Esempio n. 24
0
        protected override void constructed()
        {
            SceneNodeElement sceneNode = Owner.getElement(nodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Cannot find Node '{0}'", nodeName);
            }

            entity = sceneNode.getNodeObject(entityName) as Entity;

            if (entity == null)
            {
                if (entityName == null)
                {
                    blacklist("entityName is Null");
                }
                else
                {
                    blacklist("Cannot find entity named '{0}' in node '{1}'.", entityName, nodeName);
                }
            }

            if (String.IsNullOrEmpty(name))
            {
                blacklist("Name is empty");
            }

            VolumeController.addVolume(this);

            base.constructed();

            //VERY hacky and bad, figure out another way to do this
            ThreadManager.invoke(() =>
            {
                initialVolume = CurrentVolume;
            });
        }
        protected override void link()
        {
            String errorMessage = null;

            foreach (AnatomyCommand command in commands)
            {
                if (!command.link(Owner, this, ref errorMessage))
                {
                    blacklist("SimObject {0} AnatomyIdentifier {1} failed to link command {2}. Reason: {3}", Owner.Name, AnatomicalName, command.UIText, errorMessage);
                }
            }
            SceneNodeElement nodeElement = Owner.getElement(nodeName) as SceneNodeElement;

            if (nodeElement == null)
            {
                blacklist("SimObject {0} AnatomyIdentifier {1} cannot find node named {2}", Owner.Name, AnatomicalName, nodeName);
            }
            entity = nodeElement.getNodeObject(entityName) as Entity;
            if (entity == null)
            {
                blacklist("SimObject {0} AnatomyIdentifier {1} Node {2} cannot find entity named {3}", Owner.Name, AnatomicalName, nodeName, entityName);
            }
            AnatomyManager.addAnatomy(this);
        }
Esempio n. 26
0
        protected override void constructed()
        {
            sceneNodeElement = Owner.getElement(sceneNodeName) as SceneNodeElement;
            if (sceneNodeElement == null)
            {
                blacklist("Could not find SceneNodeElement {0}.", sceneNodeName);
            }
            entity = sceneNodeElement.getNodeObject(entityName) as Entity;
            if (entity == null)
            {
                blacklist("Could not find Entity {0}.", entityName);
            }

            actorElement = Owner.getElement(actorName) as RigidBody;
            if (actorElement == null)
            {
                blacklist("Could not find Actor {0}.", actorName);
            }
            SleepyActorRepository.addSleeper(actorElement);

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

            transparency = Owner.getElement(transparencyInterface) as TransparencyInterface;
            if (transparency == null)
            {
                blacklist("Could not find TransparencyInterface {0}", transparencyInterface);
            }
            TeethController.addTooth(Owner.Name, this);
            HighlightColor = Color.White;
        }
Esempio n. 27
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);
            }
        }
        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);
        }
        protected override void constructed()
        {
            transparencyStates = new List <TransparencyState>();
            transparencyStates.Add(new TransparencyState(startingTransparency));

            SceneNodeElement sceneNode = Owner.getElement(nodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Cannot find Node '{0}'", nodeName);
            }

            if (childNodeName != null && childNodeName != String.Empty)
            {
                sceneNode = sceneNode.findChildNode(childNodeName);
                if (sceneNode == null)
                {
                    blacklist("Could not find child node '{0}' in node '{1}'.", childNodeName, nodeName);
                }
            }
            entity = sceneNode.getNodeObject(entityName) as Entity;

            if (entity == null)
            {
                if (entityName == null)
                {
                    blacklist("entityName is Null");
                }
                else
                {
                    blacklist("Cannot find entity named '{0}' in node '{1}'.", entityName, nodeName);
                }
            }

            originalRenderGroup = entity.getRenderQueueGroup();

            if (subEntityIndex >= entity.getNumSubEntities())
            {
                blacklist("Entity '{0}' only has '{1}' SubEntities. Index '{2}' is invalid.", entity.getName(), entity.getNumSubEntities(), subEntityIndex);
            }

            subEntity        = entity.getSubEntity(subEntityIndex);
            baseMaterialName = subEntity.getMaterialName();
            MaterialManager materialManager    = MaterialManager.getInstance();
            bool            useDefinedMaterial = !(alphaMaterialName == null || alphaMaterialName.Equals(String.Empty));

            if (useDefinedMaterial)
            {
                if (materialManager.resourceExists(alphaMaterialName))
                {
                    finalAlphaMaterialName = alphaMaterialName;
                }
                else
                {
                    blacklist("A custom material '{0}' is defined that cannot be found.  This object will not be able to be alpha controlled.", this.alphaMaterialName);
                }
            }
            else
            {
                if (materialManager.resourceExists(baseMaterialName + alphaSuffix))
                {
                    finalAlphaMaterialName = baseMaterialName + alphaSuffix;
                }
                else
                {
                    blacklist("Cannot find automatic alpha material '{0}'.  Please ensure one exists or define a custom alpha behavior.", baseMaterialName + alphaSuffix);
                }
            }

            using (var mat = subEntity.getMaterial())
            {
                usesVirtualTexture = TransparencyController.isVirtualTextureMaterial(mat.Value);
                if (!usesVirtualTexture)
                {
                    entity.setVisibilityFlags(TransparencyController.HiddenVisibilityMask);
                }
            }

            TransparencyController.addTransparencyObject(this);

            applyAlphaToMaterial(getCurrentTransparency(activeTransparencyState));
        }
Esempio n. 30
0
        protected override void link()
        {
            base.link();

            var controlsType = this.PlayerId.GetPlayerKeyedType(typeof(PlayerControls <>));

            playerControls = Scope.ServiceProvider.GetService(controlsType) as PlayerControls;

            rigidBody = Owner.getElement(RigidBodyName) as RigidBody;
            if (rigidBody == null)
            {
                blacklist("Cannot find player rigid body '{0}'", RigidBodyName);
            }

            node = Owner.getElement(NodeName) as SceneNodeElement;
            if (node == null)
            {
                blacklist("Cannot find player node '{0}'");
            }
            entity = node.getNodeObject(EntityName) as Entity;
            if (entity == null)
            {
                blacklist("Cannot find entity '{0}' on node '{1}'", EntityName, NodeName);
            }

            runBase = entity.getAnimationState(RunBaseAnimationName);
            if (runBase == null)
            {
                blacklist("Cannot find animation for run base '{0}' on entity '{1}'", RunBaseAnimationName, EntityName);
            }

            runTop = entity.getAnimationState(RunTopAnimationName);
            if (runTop == null)
            {
                blacklist("Cannot find animation for run top '{0}' on entity '{1}'", RunTopAnimationName, EntityName);
            }

            idleBase = entity.getAnimationState(IdleBaseAnimationName);
            if (idleBase == null)
            {
                blacklist("Cannot find animation for idle base '{0}' on entity '{1}'", IdleBaseAnimationName, EntityName);
            }

            idleTop = entity.getAnimationState(IdleTopAnimationName);
            if (idleTop == null)
            {
                blacklist("Cannot find animation for idle top '{0}' on entity '{1}'", IdleTopAnimationName, EntityName);
            }

            jumpStart = entity.getAnimationState(JumpStartAnimationName);
            if (jumpStart == null)
            {
                blacklist("Cannot find animation for jump start '{0}' on entity '{1}'", JumpStartAnimationName, EntityName);
            }

            jumpLoop = entity.getAnimationState(JumpLoopAnimationName);
            if (jumpLoop == null)
            {
                blacklist("Cannot find animation for jump loop '{0}' on entity '{1}'", JumpLoopAnimationName, EntityName);
            }

            jumpEnd = entity.getAnimationState(JumpLoopAnimationName);
            if (jumpEnd == null)
            {
                blacklist("Cannot find animation for jump end '{0}' on entity '{1}'", JumpEndAnimationName, EntityName);
            }

            groundRayCenter = new ClosestRayResultCallback(Owner.Translation, Owner.Translation + Vector3.Down);
            groundRayCenter.CollisionFilterMask = ~2;

            groundRayFront = new ClosestRayResultCallback(Owner.Translation + frontRearRayOffset, Owner.Translation + Vector3.Down);
            groundRayFront.CollisionFilterMask = ~2;

            groundRayRear = new ClosestRayResultCallback(Owner.Translation - frontRearRayOffset, Owner.Translation + Vector3.Down);
            groundRayRear.CollisionFilterMask = ~2;

            rigidBody.Scene.Tick += Scene_Tick;

            runningState = new RunningPlayerState();
            runningState.link(this);

            idleState = new IdlePlayerState();
            idleState.link(this);

            jumpUpState = new JumpUpPlayerState();
            jumpUpState.link(this);

            fallingState = new FallingPlayerState();
            fallingState.link(this);

            CurrentState = idleState;

            addToDebugDrawing();
        }