Esempio 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);
        }
Esempio n. 2
0
 public void _applyBaseKeyFrame(VertexPoseKeyFrame arg0)
 {
     OgrePINVOKE.VertexPoseKeyFrame__applyBaseKeyFrame(swigCPtr, VertexPoseKeyFrame.getCPtr(arg0));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
        public VertexPoseKeyFrame getVertexPoseKeyFrame(ushort index)
        {
            global::System.IntPtr cPtr = OgrePINVOKE.VertexAnimationTrack_getVertexPoseKeyFrame(swigCPtr, index);
            VertexPoseKeyFrame    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new VertexPoseKeyFrame(cPtr, false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public virtual VertexPoseKeyFrame createVertexPoseKeyFrame(float timePos)
        {
            global::System.IntPtr cPtr = OgrePINVOKE.VertexAnimationTrack_createVertexPoseKeyFrame(swigCPtr, timePos);
            VertexPoseKeyFrame    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new VertexPoseKeyFrame(cPtr, false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        protected override void CreateScene()
        {
            // Set ambient light
            scene.AmbientLight = new ColorEx(0.5f, 0.5f, 0.5f);

            // Create a light
            Light light = scene.CreateLight("MainLight");

            // Accept default settings: point light, white diffuse, just set position
            // NB I could attach the light to a SceneNode if I wanted it to move automatically with
            //  other objects, but I don't
            light.Position = new Vector3(20f, 80f, 50f);
            light.Diffuse  = new ColorEx(1.0f, 1.0f, 1.0f);

            // Create a light
            light = scene.CreateLight("MainLight2");
            // Accept default settings: point light, white diffuse, just set position
            // NB I could attach the light to a SceneNode if I wanted it to move automatically with
            //  other objects, but I don't
            light.Position = new Vector3(-120f, -80f, -50f);
            light.Diffuse  = new ColorEx(0.7f, 0.7f, 0.6f);

            // Debugging stuff - - load iraq-f.mesh
            //Mesh iraqf_mesh = MeshManager.Instance.Load("iraq-f.mesh");
            //Entity iraqf = scene.CreateEntity("iraqf", "iraq-f.mesh");

            // Pre-load the mesh so that we can tweak it with a manual animation
            Mesh                 mesh  = MeshManager.Instance.Load("facial.mesh");
            Animation            anim  = mesh.CreateAnimation("manual", 0);
            VertexAnimationTrack track = anim.CreateVertexTrack(4, VertexAnimationType.Pose);

            manualKeyFrame = track.CreateVertexPoseKeyFrame(0);
            // create pose references, initially zero
            for (int i = 0; i < (int)ScrollbarIndex.Count; ++i)
            {
                manualKeyFrame.AddPoseReference(poseIndexes[i], 0.0f);
            }

            Entity head = scene.CreateEntity("Head", "facial.mesh");

            speakAnimState            = head.GetAnimationState("Speak");
            speakAnimState.IsEnabled  = true;
            manualAnimState           = head.GetAnimationState("manual");
            manualAnimState.IsEnabled = false;
            manualAnimState.Time      = 0;

            SceneNode headNode = scene.RootSceneNode.CreateChildSceneNode();

            headNode.AttachObject(head);

            camera.Position = new Vector3(-20f, 50f, 150f);
            camera.LookAt(new Vector3(0f, 35f, 0f));
        }
Esempio n. 6
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VertexPoseKeyFrame obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }