University of Southern CaliforniaUSC
USC ICT TwitterUSC ICT FacebookUSC ICT YouTube

How do I restart an animation? | General SmartBody Discussion | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
How do I restart an animation?
December 30, 2015
1:29 am
Avatar
Member
Members
Forum Posts: 28
Member Since:
November 5, 2015
sp_UserOfflineSmall Offline

I want to continue to loop an animation every 10 secs.

How do I go about doing that in SmartBody?

BTW

I do see the character goes upside down when I include

the line

scene->getBmlProcessor()->execBML("mycharacter", "<animation name=\"Operator.dae\"/>");    

But The animation is walking, why I don't see the character walk, it just flips for sometimes and return back to normal

Thanks

Jack

[code]

void TestApp::Update(float dt)
{   
    bool useRealTimeClock = false;
    static double lastPrint = 0;
         
    if (sim->getTime() > 10.0f) {
scene->getBmlProcessor()->execBML("mycharacter", "<animation name=\"Operator.dae\"/>");    
        scene->getBmlProcessor()->execBML("mycharacter", "<sbm:reach sbm:action=\"touch\" target=\"touchPawn\" sbm:reach-finish=\"true\"/>");
        scene->getBmlProcessor()->execBML("mycharacter", "<gaze target=\"touchPawn\" sbm:joint-range=\"EYES NECK\"/>");
        sim->setTime(0.0f);
        sim->reset();
    }        
     
    
    scene->update();
    if (!useRealTimeClock)
        sim->setTime(sim->getTime() + 0.16); // update at 1/60 of a second when running in simulated time
    else
        sim->updateTimer();
        

    
    LOG("Simulation is at time: %5.2f", sim->getTime());
    
    
    const std::vector& characterNames = scene->getCharacterNames();
    for (size_t c = 0; c < characterNames.size(); c++)
    {
        SmartBody::SBCharacter* character = scene->getCharacter(characterNames[c]);
        std::string jointName = "JtRoot";
        SmartBody::SBJoint* joint = character->getSkeleton()->getJointByName(jointName);
        if (joint)
        {
            SrVec position = joint->getPosition();
            LOG("Character %s joint %s is at position (%f, %f, %f)", character->getName().c_str(), jointName.c_str(), position.x, position.y, position.z);
        }
    }     
}

[/code]

December 30, 2015
7:53 am
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

If you want to loop an animation, you can put the animation in to a blend, then call the blend with a loop parameter (this is described in the SmartBody manual around page 135 with the section 'Configuring Motion Blends/Parameterized Animation')

First, create a blend:

 

In C++:

SBAnimationBlendManager* manager = scene->getBlendManager();

myblend = manager->createBlend0D("myblend");

myblend->addMotion("mymotion")

 

Now you can activate that blend with looping (in the Blend BML section in the manual around page 173):

scene->getBmlProcessor()->execBML("mycharacter", "<blend name=\"myblend\" sbm:warp-mode=\"Loop\"/>");

 

As for your character flipping, is your character oriented the proper way (Y-up)?

 

Ari

December 30, 2015
7:09 pm
Avatar
Member
Members
Forum Posts: 28
Member Since:
November 5, 2015
sp_UserOfflineSmall Offline

As I am using 3ds max, the view transformation is y-up, but the world transformation is z-up,

I use the same exporter as yours which is opencollada, but I can't seem to find a way to export the thing

to y-up. But You got the point. How do you export from 3ds max to y-up?

Things are getting strange, As I view the exported mesh in Visual Studio 2013, the mesh is lying on the ground,

, but it is indeed y-up, z pointing upwards, but it is facing forward.

Thanks

Jack

December 30, 2015
7:38 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

After you import the asset into SmartBody,  retrieve the base joint of the skeleton, then apply a rotation to put it in the right direction:

 

sk = scene.getSkeleton("Operator.dae")

j = sk.getJoint(0)

j.setPrerotation(SrQuat(SrVec(1,0,0), -3.14159/2.0))   # -90 degree rotation around the x-axis specified in radians

 

Ari

Forum Timezone: America/Los_Angeles

Top Posters:

jwwalker: 80

jyambao: 52

rbaral: 47

adiaz: 30

WargnierP: 29

lucky7456969: 28

mbarros: 28

avida.matt: 26

JonathanW: 24

laguerre: 23

Member Stats:

Guest Posters: 69

Members: 122211

Moderators: 3

Admins: 4

Forum Stats:

Groups: 1

Forums: 5

Topics: 531

Posts: 2495