Tuesday, May 26, 2015

Cocos2d-x: Extracting animation frames from 3D Model

If the 3D model already has animation frames attached to it. There are 2 ways to extract and use the embedded animation frames depending on what information you have.

If you know the individual frames and how it is spanned you can do this:

auto shootAnim = Animation3D::create("Army.c3b");//Read all animation clips
auto shoot = Animate3D::createWithFrames(shootAnim, 40, 79);//Extract frames 40-79
shoot->setSpeed(2);

army->runAction(RepeatForever::create(shoot));


If you know the name of the animation, or if the frames are layered instead of in sequence, you can do this instead:


auto shootAnim = Animation3D::create("Army.c3b","Shoot");//Read only 'Shoot' frames
auto shoot  = Animate3D::create(shootAnim);
shoot->setSpeed(2);
army->runAction(RepeatForever::create(shoot));



No comments:

Post a Comment