Results 1 to 4 of 4

Thread: Is it possible to move the skeletons using Collada DOM.

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    10

    Is it possible to move the skeletons using Collada DOM.

    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:
    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 \n", _SceneRoot->GetNumChildren()); 
    		joint = _SceneRoot;
    		//CrtPrint(" Next node of scene root is:  %s \n", joint->GetId()); 
     
    			//joint = joint ->GetNext();
    			//CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetChild();		
    			CrtPrint(" Getting Children ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetNext();
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetNext();
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetNext();
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
     
    			joint = joint->GetChild();		
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetNext();	
    			joint = joint->GetNext();
    			joint = joint->GetNext();
    			//CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    			int n = 5;
    			while(joint && n>0)
    			{
    					joint = joint->GetChild();
    					n--;
    			}
     
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    				CrtPrint(" Used for skining:  %s \n", 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 \n", joint->GetId()); 
     
    			//joint = joint ->GetNext();
    			//CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetChild();		
    			CrtPrint(" Getting Children ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetNext();
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetNext();
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
    			joint = joint->GetNext();
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 
     
    			joint = joint->GetChild();		
    			CrtPrint(" Getting joint ID is:  %s \n", joint->GetId()); 	
    			joint = joint->GetNext();
    			joint = joint->GetNext();
    			CrtPrint(" Getting joint ID is:  %s \n", 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

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: Is it possible to move the skeletons using Collada DOM.

    I suspect that the sample viewer's animation calculations are stomping on your manual changes of the joint transforms. You'll want to do apply your transforms after the animations (check what Update() is doing and before the Render().

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    10

    Re: Is it possible to move the skeletons using Collada DOM.

    Thanks a lot for the reply.
    That is really something. I found that _CrtRender.Render(); contains the update for the whole scene. So it seems to be designed to render the animation from the collada file rather than getting any information outside. Do you think it is possible to use it the way I am trying. Would you please give me some examples about how to change the way in which it render the scenes.Otherwise, I think I have to go to the animation part and try to add some animation which I think would be very complicated.

    Anyway, thanks again for you help , I am kinda desperate.

  4. #4
    Junior Member
    Join Date
    Jan 2010
    Posts
    10

    Re: Is it possible to move the skeletons using Collada DOM.

    I MADE IT!!!THANKS!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •