Manually Controlling Bones in MOGRE

chrisg

09-02-2011 10:28:56

I'm trying to manually control a bone in the robot example and have code from C++ but can't seem to get it working in C#.

The code in the create scene function is:

var robot = mSceneMgr.CreateEntity("Robot", "robot.mesh");
mSceneMgr.RootSceneNode.CreateChildSceneNode("Robot").AttachObject(robot);

SkeletonPtr skel = robot.GetMesh().GetSkeleton();
Animation anim = skel.GetAnimation("Walk");
manualBone = skel.GetBone("Joint10");
manualBone.SetManuallyControlled(true);
anim.DestroyNodeTrack(manualBone.Handle);

mAnimationState = robot.GetAnimationState("Walk");
mAnimationState.Loop = false;
mAnimationState.Enabled = true;
Debug.Print(mAnimationState.ToString());


The code in the update function is:

mAnimationState.AddTime(evt.timeSinceLastFrame);
manualBone.Yaw(evt.timeSinceLastFrame * 100);


I'm really in need of some help with this, been trying to solve it for ages!

smiley80

09-02-2011 11:12:47

use
SkeletonInstance skel = robot.Skeleton;
instead of
SkeletonPtr skel = robot.GetMesh().GetSkeleton();

chrisg

09-02-2011 11:15:29

Works perfectly, Thanks!