Crystal Space
Welcome, Guest. Please login or register.
September 03, 2014, 06:06:16 am

Login with username, password and session length
Search:     Advanced search
9009 Posts in 2043 Topics by 8379 Members
Latest Member: Hamlock3
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Game Content Creation
| | |-+  genMesh animation tutorial
« previous next »
Pages: [1] Print
Author Topic: genMesh animation tutorial  (Read 5079 times)
Shimon
Newbie
*
Posts: 8


View Profile Email
« on: June 24, 2008, 07:06:25 pm »

hello,

I want to have animated 3D characters in a CS application. I modelled the character and animated it in Blender. I used blender2crystal to export the animation as a genMesh according to the blender2crystal tutorial (http://b2cs.delcorp.org/index.php/Exporting_armature_animation_using_genmesh). Now I want to use that animation in CS.

Is there a tutorial on how to use animations exported as genMesh? I haven't found one yet.

Also, there's a cal3D animation tutorial in the community site (http://community.crystalspace3d.org/tiki-read_article.php?articleId=22).

What are the advantages of using one animation system over the other?

Thank you very much in advance!
Logged
shangobah@users.sourceforge.net
Newbie
*
Posts: 5


View Profile Email
« Reply #1 on: September 03, 2008, 02:05:59 am »

Hello. This is my first post but I have been playing with crystal space and blender for a while now.  I normally try to figure stuff out myself so the solutions I offer may not be the "best" way. 

I have noticed allot of people having issues with genmesh and getting blender armature animations to work.  I had some of the same issues at first and it works beautifully for me now just exporting using the default settings and no changes except one minor tweak.

What I noticed was that when I generated my world folder, either only one animation would play or it would not play at all.  I was debugging and trying to find out what was going on.  What I found is that all of the animations you list will be exported fine in the armature file.  However, they do not seem to be attached to the meshfactory file.  I believe this is either the result of a bug in the version of blender2crystal, or it is an non-intuitive user interface issue.

If you just want to export genmesh armature animtations you can export them directly.  Just select the bone object and be sure you list all of the actions you want to be exported.  Unfortunately only the first action will be linked to the meshfactory.  To solve this what I did was I opened the meshfactory file and you will see something like this:

    <bone>22</bone>
    <bone>1</bone>
  </use_bones>
  <run script="walk"/>
</animcontrol>

It exported the "walk" action fine but the other actions are not listed.  If you try to use the skeleton api to access the other actions then you will get a null object for them and the program will crash.

to resolve this issue (not sure if this is the best way, but it is a quick fix)

add you other actions to the meshfactory file like this

    <bone>22</bone>
    <bone>1</bone>
  </use_bones>
  <run script="walk"/>
  <run script="anotheraction1"/>
  <run script="anotheraction2"/>
  <run script="anotheretc"/>
</animcontrol>

by linking these actions in the meshfactory file they will now be accessible programatically through the skeleton interface functions.

Here is some sample code which loads two animations programattically and changes what animation is playing:

use this at your own risk Smiley

        csRef<iMeshWrapper> lara=Engine->FindMeshObject("larabod"); // create a meshwrapper for the mesh named "larabod"


        //query for the generalmeshstate interface required in order to get the skeleton object
   csRef<iGeneralMeshState> genmesh_state (scfQueryInterface<iGeneralMeshState> (lara->GetMeshObject()));

        //create an animcontrol object also necessary for working with iSkeleton
   csRef<iGenMeshSkeletonControlState> animcontrol ( scfQueryInterface<iGenMeshSkeletonControlState> (       genmesh_state->GetAnimationControl ()));

        //create the actual skeleton object
   iSkeleton* skeleton = animcontrol->GetSkeleton ();
     
        // stop any animtations currently playing
   skeleton->ClearPendingAnimations();

        //get a pointer to the walk animation
   csRef<iSkeletonAnimation> walkanim=skeleton->FindAnimation("walk");
   walkanim->SetLoop(true);  //optional depending on if you want it to loop

   anim2=skeleton->FindAnimation("someotheranimation");

        rinse and repeat. Take a look at the iSkeleton, and iSkeletonAnimation api list for more control. Essentially you should have complete control of your skeleton and animations without using cal3d. I have been impressed with the results. The playback is identical to what I expected.


Feel free to correct anything that should be optimized in my post as I am still learning crystal space myself.

Also feel free to email me if you have a specific problem. I will reply even if it is to tell you that I do not know or don't have time to deal with it.



Logged
shangobah@users.sourceforge.net
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: September 03, 2008, 02:18:31 am »

Also another note.  I noticed some people complaining about their meshes not working in viewmesh.  I could be wrong but I was under the assumption that viewmesh was mainly for cal3d animations and it might not support the current armature genmesh impelementations. 

This information could be wrong but that was what I concluded when I looked into the code a while back. 
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.48 seconds with 16 queries.