Hi,
Could anyone please give me an example about how to change the position of a node(skeleton) and display(animate) it. I think I am on the right track about using LocalToWorldMatrix but no matter how I mess the matrix ,there is no change happens at all.
It drives me crazy. Could anyone who had similar experience help me.Here are my code:
CrtNode *_SceneRoot = CrtNew(CrtNode);
CrtNode * joint = CrtNew(CrtNode);
CrtNode * children = CrtNew(CrtNode);
_SceneRoot=_CrtRender.GetSceneRoot();
CrtPrint(" Number of Children of scene root is: %d
", _SceneRoot->GetNumChildren());
joint = _SceneRoot;
//CrtPrint(" Next node of scene root is: %s
", joint->GetId());
//joint = joint ->GetNext();
//CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetChild();
CrtPrint(" Getting Children ID is: %s
", joint->GetId());
joint = joint->GetNext();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetNext();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetNext();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetChild();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetNext();
joint = joint->GetNext();
joint = joint->GetNext();
//CrtPrint(" Getting joint ID is: %s
", joint->GetId());
int n = 5;
while(joint && n>0)
{
joint = joint->GetChild();
n--;
}
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
CrtPrint(" Used for skining: %s
", joint->GetIsUsedForSkinning ());
CrtMatrix * m = joint->GetLocalToWorldMatrix();
CrtMatrix4x4RotateAngleAxis((float *)m ,0.0,0.0,1.0,190.0);
CrtMatrixTranspose((float *)m,(float *)m);
//joint->SetLocalToWorldMatrix(m);
CrtMatrix * m2 = joint->GetLocalToWorldMatrix();
CrtVec4f tran((float)2.4,(float)3.6,(float)4.8,(float)10.2);
CrtMatrix4x4Translate((float *)m2,tran);
/*joint->SetUpdateLocalToWorldMatrix(true);
joint->SetUpdateLocalMatrix (true);
joint->Update(0.1);
joint->Render();*/
joint = _SceneRoot;
//CrtPrint(" Next node of scene root is: %s
", joint->GetId());
//joint = joint ->GetNext();
//CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetChild();
CrtPrint(" Getting Children ID is: %s
", joint->GetId());
joint = joint->GetNext();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetNext();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetNext();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetChild();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint = joint->GetNext();
joint = joint->GetNext();
CrtPrint(" Getting joint ID is: %s
", joint->GetId());
joint->SetLocalToWorldMatrix(m2);
joint->SetUpdateLocalToWorldMatrix(true);
joint->SetUpdateLocalMatrix (true);
//joint->Update(0.1);
joint->Render();
//_CrtRender.SetAnimationPaused( CrtTrue );
I know they seems to be crazy and aim less, but I just want to make the scene become different. Is there any method like glutPostRedisplay that I need to use. I think it is not necessary because the animation which is loaded is rendered again and again.
Really appreciate any help from you guys.
Cheers,
Ray