How to play animations with Scythe API ?

Help
Ogre Mage
2008-05-04
2013-04-17
  • Ogre Mage
    Ogre Mage
    2008-05-04

    I have been using Scythe and Ogre for a while now.  It is an awesome application and it has been a great help.  I am getting some fantastic results.

    However, I am having the most confusing problem with it.  I am unable to play animations on my Scythe API ragdolls!

    Well, actually I have done it, but only if I call updateRagdoll.  But I really only want to go into ragdoll when a character is killed, otherwise just play normal skeletal animations, of course.  I want the performance boost of only turning ragdoll ON when I need it, especially because in my case I have many characters on screen simultaneously.

    So here is the technical info.  This is all about the Sycthe PhysX example in API 1.14

    First off, there is this comment in main.cpp:

        //ragdoll character has now been created, before update we want to set the ragdoll
        //to match up the the character's current pose (the character may be in mid-stride,
        //and so we want the ragdoll to start from that position.  We use a non API function here,
        //but it uses the API's setBonePosition() to position the ragdoll.
        player->skeleton.setRagdollToSkeleton();        //player variable was initialised in the ragdoll callback, but it doesnt have to

    "we want to set the ragdoll to match up the the character's current pose (the character may be in mid-stride" means to me that Scythe API was designed to perform what I need as described above, the ability to enable ragdoll after playing animations!  ?

    BUT in the example you cannot play any animations!

    If after:
        //run the ragdoll calculations
        player->skeleton.updateRagdoll();

    I add:
        player->skeleton.entity->getAnimationState("Default")->setEnabled(true);
        player->skeleton.entity->getAnimationState("Default")->setLoop(true);
        player->skeleton.entity->getAnimationState("Default")->addTime( 0.01 );

    ("Default" is the name of the animation for the zombie2.mesh/zombie.phs used in the Scythe PhysX example.  I played it in LexiView)

    And whether I comment out:

        //run the ragdoll calculations
        ////player->skeleton.updateRagdoll();

    and/or and/or not:

        //ragdoll character has now been created, before update we want to set the ragdoll
        //to match up the the character's current pose (the character may be in mid-stride,
        //and so we want the ragdoll to start from that position.  We use a non API function here,
        //but it uses the API's setBonePosition() to position the ragdoll.
        ////player->skeleton.setRagdollToSkeleton();        //player variable was initialised in the ragdoll callback, but it doesnt have to

    The character freaks out!

    This is so confusing to me, because no Scythe function is being called, yet the character will not animate correctly and instead spazzes out!

    Now I bring this problem up to you after many, and I mean very many, days and hours of working on this problem.  I have tried everything I can think of and basically I cannot wrap my head around the problem.  I have of course tried setting the Scythe Physics Bodies to KINEMATIC so they don't move nor influence anything.

    Again, I have tried limitless combinations.  I am assuming there is a missing bit of key information that I do not understand about the entire connection and process.

    So my question is, how do I play a normal Ogre animation and then stop it (and the entire time NOT recursively setting the Scythe skeleton Quaternions etc etc, i.e. no Scythe) and THEN enable Scythe API ragdoll!

    HALP!!!  I really could use a very informative, educational, constructive, and wildly helpful answer!  And hopefully this thread will help someone else.

    Thank you dearly,
    OM

     
    • King of Scythe
      King of Scythe
      2008-05-05

      Why do you need to load the ragdoll before you use it?  The best way is to just load the ragdoll file when the character dies, then you dont have to worry about it.  It shouldn't cause a noticeable performance spike.

      setRagdollToSkeleton(); is used only once at ragdoll creation, so that the ragdoll starts in a position that matches the character (so he doesn't go into a T-bone pose before he collapses)

       
      • Ogre Mage
        Ogre Mage
        2008-05-05

        Hellp SpaceJim, thank you very much for responding.

        In my project's case, I have a lot of characters going into ragdoll simultaneously.  I also have a need to maintain a smooth application with no spikes.

        I think what I am asking is *why* does playing an animation not work?  I mean it loads the .mesh file, correct?  So if I do not tick ScytheAPI (updateRagdoll etc), why is the animation paying so bizarre?  Again, what am I not understanding about the load process that appears to be actually modifying the actual incoming mesh?  Can I simply have it make these modifications later?

        Respectfully,
        OM

         
    • King of Scythe
      King of Scythe
      2008-05-06

      It would result in poorer overall performance, since you would essentially have all those ragdolls invisibly running at once, even when not needed, it may even cause unpredicted collisions. 
      What are the ragdolls doing? you say the model spazzes out, but in the debug wireframe what are the collision shapes doing?

      What do you have in your loadSkeletonCallback?  in the skeleton.setup(..) function there is a line 30 in ogreSkeletonSetup.cpp

      b->setManuallyControlled(true);

      that would stop any animations playing.

      if that does not help try a process of elimination, commenting out all the ragdoll setup code and see if animations work then.

       
      • Ogre Mage
        Ogre Mage
        2008-05-06

        Solved!

        Thank you, yes, the animations not playing correctly from "b->setManuallyControlled(true);".  I feel foolish not catching that!  I've used it much before.

        Just fyi, in my case it's great to have the physics skeleton playing with just the animations and not in a ragdoll for precise collisions if needed.  And if I do not need it, for performance I can disable the collisions, put them to "sleep", etc, etc.

        Also just fyi I have made adjustments to the API.  In the example, ragdoll did not crash to the floor if you lift the player above the ground, etc.

        THANK YOU AGAIN!  I LOVE SCYTHE!
        -OM