Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
            }
        }