Complete rewrite of actor animation system
This commit is contained in:
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -3348,7 +3348,8 @@ bool rc_update()
|
|||||||
|
|
||||||
irr::core::vector2d<irr::f32> screenSize( (irr::f32) rc_canvas[0].dimension.Width, (irr::f32) rc_canvas[0].dimension.Height );
|
irr::core::vector2d<irr::f32> screenSize( (irr::f32) rc_canvas[0].dimension.Width, (irr::f32) rc_canvas[0].dimension.Height );
|
||||||
|
|
||||||
double frame_current_time = ((double)SDL_GetTicks())/1000.0;
|
Uint32 current_time_ms = SDL_GetTicks();
|
||||||
|
double frame_current_time = ((double)current_time_ms)/1000.0;
|
||||||
|
|
||||||
for(int i = 0; i < rc_transition_actor.size();)
|
for(int i = 0; i < rc_transition_actor.size();)
|
||||||
{
|
{
|
||||||
@@ -3361,6 +3362,13 @@ bool rc_update()
|
|||||||
rc_actor[i].transition_time = 0;
|
rc_actor[i].transition_time = 0;
|
||||||
rc_actor[i].transition_start_time = 0;
|
rc_actor[i].transition_start_time = 0;
|
||||||
rc_transition_actor.erase(i);
|
rc_transition_actor.erase(i);
|
||||||
|
|
||||||
|
rc_actor[i].animation[0].start_frame = (int)rc_actor[i].transition_frame;
|
||||||
|
rc_actor[i].animation[0].end_frame = (int)rc_actor[i].transition_frame;
|
||||||
|
rc_actor[i].animation[0].fps = 0;
|
||||||
|
rc_actor[i].current_animation_loop = 0;
|
||||||
|
rc_actor[i].isPlaying = true;
|
||||||
|
rc_actor[i].current_animation = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -604,6 +604,22 @@ int rc_createMeshActor(int mesh_id)
|
|||||||
rc_actor[actor_id] = actor;
|
rc_actor[actor_id] = actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//animation
|
||||||
|
rc_actor_animation_obj animation;
|
||||||
|
animation.start_frame = 0;
|
||||||
|
animation.end_frame = 0;
|
||||||
|
animation.fps = 60.0;
|
||||||
|
animation.frame_start_time = SDL_GetTicks();
|
||||||
|
animation.frame_swap_time = 1000/60;
|
||||||
|
rc_actor[actor_id].animation.push_back(animation);
|
||||||
|
rc_animEndCallBack* anim_callback = new rc_animEndCallBack();
|
||||||
|
anim_callback->ref_actor = &rc_actor[actor_id];
|
||||||
|
anim_callback->OnAnimationEnd(node);
|
||||||
|
node->setAnimationEndCallback(anim_callback);
|
||||||
|
node->setLoopMode(false);
|
||||||
|
anim_callback->drop();
|
||||||
|
|
||||||
|
|
||||||
//Actor RigidBody
|
//Actor RigidBody
|
||||||
rc_actor[actor_id].physics.shape_type = RC_NODE_SHAPE_TYPE_BOX;
|
rc_actor[actor_id].physics.shape_type = RC_NODE_SHAPE_TYPE_BOX;
|
||||||
rc_actor[actor_id].physics.rigid_body = NULL;
|
rc_actor[actor_id].physics.rigid_body = NULL;
|
||||||
@@ -4952,21 +4968,97 @@ void rc_setWorld3DTimeStep(double ts)
|
|||||||
|
|
||||||
|
|
||||||
//set actor animation [TODO]
|
//set actor animation [TODO]
|
||||||
void rc_setActorAnimation(int actor, int start_frame, int end_frame)
|
int rc_createActorAnimation(int actor, int start_frame, int end_frame, double speed)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
rc_actor_animation_obj animation;
|
||||||
|
animation.active = true;
|
||||||
|
animation.start_frame = start_frame;
|
||||||
|
animation.end_frame = end_frame;
|
||||||
|
animation.fps = speed;
|
||||||
|
animation.frame_swap_time = 1000/speed;
|
||||||
|
|
||||||
|
int animation_id = rc_actor[actor].animation.size();
|
||||||
|
|
||||||
|
if(rc_actor[actor].deleted_animation.size() > 0)
|
||||||
|
{
|
||||||
|
animation_id = rc_actor[actor].deleted_animation[0];
|
||||||
|
rc_actor[actor].deleted_animation.erase(0);
|
||||||
|
rc_actor[actor].animation[animation_id] = animation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rc_actor[actor].animation.push_back(animation);
|
||||||
|
|
||||||
|
return animation_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rc_deleteActorAnimation(int actor, int animation)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!rc_actor[actor].animation[animation].active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rc_actor[actor].animation[animation].active = false;
|
||||||
|
rc_actor[actor].deleted_animation.push_back(animation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rc_setActorAnimation(int actor, int animation, int num_loops)
|
||||||
{
|
{
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||||
|
return;
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
switch(rc_actor[actor].node_type)
|
||||||
{
|
{
|
||||||
case RC_NODE_TYPE_MESH:
|
case RC_NODE_TYPE_MESH:
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
|
int start_frame = rc_actor[actor].animation[animation].start_frame;
|
||||||
|
int end_frame = rc_actor[actor].animation[animation].end_frame;
|
||||||
|
rc_actor[actor].current_animation = animation;
|
||||||
|
rc_actor[actor].current_animation_loop = 0;
|
||||||
|
rc_actor[actor].num_animation_loops = num_loops;
|
||||||
|
rc_actor[actor].isPlaying = true;
|
||||||
|
node->setCurrentFrame(start_frame);
|
||||||
node->setFrameLoop((irr::s32)start_frame, (irr::s32)end_frame );
|
node->setFrameLoop((irr::s32)start_frame, (irr::s32)end_frame );
|
||||||
|
node->setAnimationSpeed(rc_actor[actor].animation[animation].fps);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rc_setActorMD2Animation(int actor, int md2_animation)
|
int rc_getActorCurrentAnimation(int actor)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return rc_actor[actor].current_animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rc_numActorAnimationLoops(int actor)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return rc_actor[actor].num_animation_loops;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rc_actorAnimationIsPlaying(int actor)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return rc_actor[actor].isPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rc_setActorMD2Animation(int actor, int md2_animation, int num_loops)
|
||||||
{
|
{
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
return;
|
return;
|
||||||
@@ -4976,11 +5068,21 @@ void rc_setActorMD2Animation(int actor, int md2_animation)
|
|||||||
case RC_NODE_TYPE_MESH:
|
case RC_NODE_TYPE_MESH:
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
node->setMD2Animation( (irr::scene::EMD2_ANIMATION_TYPE) md2_animation );
|
node->setMD2Animation( (irr::scene::EMD2_ANIMATION_TYPE) md2_animation );
|
||||||
|
|
||||||
|
//int start_frame = node->getStartFrame();
|
||||||
|
//int end_frame = node->getEndFrame();
|
||||||
|
rc_actor[actor].current_animation = RC_ANIMATION_MD2;
|
||||||
|
rc_actor[actor].current_animation_loop = 0;
|
||||||
|
rc_actor[actor].num_animation_loops = num_loops;
|
||||||
|
rc_actor[actor].isPlaying = true;
|
||||||
|
//node->setCurrentFrame(start_frame);
|
||||||
|
//node->setFrameLoop((irr::s32)start_frame, (irr::s32)end_frame ); //setMD2Animation() does this for me
|
||||||
|
node->setAnimationSpeed(node->getMesh()->getAnimationSpeed());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rc_setActorMD2AnimationByName(int actor, std::string animation_name)
|
void rc_setActorMD2AnimationByName(int actor, std::string animation_name, int num_loops)
|
||||||
{
|
{
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
return;
|
return;
|
||||||
@@ -4990,35 +5092,65 @@ void rc_setActorMD2AnimationByName(int actor, std::string animation_name)
|
|||||||
case RC_NODE_TYPE_MESH:
|
case RC_NODE_TYPE_MESH:
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
node->setMD2Animation( animation_name.c_str() );
|
node->setMD2Animation( animation_name.c_str() );
|
||||||
|
|
||||||
|
//int start_frame = node->getStartFrame();
|
||||||
|
//int end_frame = node->getEndFrame();
|
||||||
|
rc_actor[actor].current_animation = RC_ANIMATION_MD2;
|
||||||
|
rc_actor[actor].current_animation_loop = 0;
|
||||||
|
rc_actor[actor].num_animation_loops = num_loops;
|
||||||
|
rc_actor[actor].isPlaying = true;
|
||||||
|
//node->setCurrentFrame(start_frame);
|
||||||
|
//node->setFrameLoop((irr::s32)start_frame, (irr::s32)end_frame ); //setMD2Animation() does this for me
|
||||||
|
node->setAnimationSpeed(node->getMesh()->getAnimationSpeed());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int rc_getActorStartFrame(int actor)
|
int rc_getActorAnimationStartFrame(int actor, int animation)
|
||||||
{
|
{
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
switch(rc_actor[actor].node_type)
|
||||||
{
|
{
|
||||||
case RC_NODE_TYPE_MESH:
|
case RC_NODE_TYPE_MESH:
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
if(rc_actor[actor].current_animation == animation)
|
||||||
return node->getStartFrame();
|
{
|
||||||
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
|
return node->getStartFrame();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return rc_actor[actor].animation[animation].start_frame;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rc_getActorEndFrame(int actor)
|
int rc_getActorAnimationEndFrame(int actor, int animation)
|
||||||
{
|
{
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
switch(rc_actor[actor].node_type)
|
||||||
{
|
{
|
||||||
case RC_NODE_TYPE_MESH:
|
case RC_NODE_TYPE_MESH:
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
if(rc_actor[actor].current_animation == animation)
|
||||||
return node->getEndFrame();
|
{
|
||||||
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
|
return node->getEndFrame();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return rc_actor[actor].animation[animation].end_frame;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -5040,33 +5172,37 @@ int rc_getActorCurrentFrame(int actor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set actor animation speed
|
//set actor animation speed
|
||||||
void rc_setActorAnimationSpeed(int actor, double speed)
|
void rc_setActorAnimationSpeed(int actor, int animation, double speed)
|
||||||
{
|
{
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||||
|
return;
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
switch(rc_actor[actor].node_type)
|
||||||
{
|
{
|
||||||
case RC_NODE_TYPE_MESH:
|
case RC_NODE_TYPE_MESH:
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
rc_actor[actor].animation[animation].fps = speed;
|
||||||
node->setAnimationSpeed( (irr::f32)speed );
|
|
||||||
|
if(animation == rc_actor[actor].current_animation)
|
||||||
|
{
|
||||||
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
|
node->setAnimationSpeed( (irr::f32)speed );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double rc_getActorAnimationSpeed(int actor)
|
double rc_getActorAnimationSpeed(int actor, int animation)
|
||||||
{
|
{
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||||
{
|
return 0;
|
||||||
case RC_NODE_TYPE_MESH:
|
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
|
||||||
return node->getAnimationSpeed();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return rc_actor[actor].animation[animation].fps;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rc_setActorFrame(int actor, int frame)
|
void rc_setActorFrame(int actor, int frame)
|
||||||
@@ -5078,11 +5214,117 @@ void rc_setActorFrame(int actor, int frame)
|
|||||||
{
|
{
|
||||||
case RC_NODE_TYPE_MESH:
|
case RC_NODE_TYPE_MESH:
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
|
rc_actor[actor].animation[0].start_frame = frame;
|
||||||
|
rc_actor[actor].animation[0].end_frame = frame;
|
||||||
|
rc_actor[actor].animation[0].fps = 0;
|
||||||
|
rc_actor[actor].current_animation_loop = 0;
|
||||||
|
rc_actor[actor].isPlaying = true;
|
||||||
|
rc_actor[actor].current_animation = 0;
|
||||||
node->setCurrentFrame(frame);
|
node->setCurrentFrame(frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rc_setActorAnimationFrames(int actor, int animation, int start_frame, int end_frame)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(rc_actor[actor].node_type)
|
||||||
|
{
|
||||||
|
case RC_NODE_TYPE_MESH:
|
||||||
|
rc_actor[actor].animation[animation].start_frame = start_frame;
|
||||||
|
rc_actor[actor].animation[animation].end_frame = end_frame;
|
||||||
|
|
||||||
|
if(animation == rc_actor[actor].current_animation)
|
||||||
|
{
|
||||||
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
|
node->setFrameLoop(start_frame, end_frame);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rc_startActorTransition(int actor, double frame, double transition_time)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(rc_actor[actor].transition)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(rc_actor[actor].node_type)
|
||||||
|
{
|
||||||
|
case RC_NODE_TYPE_MESH:
|
||||||
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
|
node->setTransitionTime(transition_time);
|
||||||
|
node->setJointMode(irr::scene::EJUOR_CONTROL);
|
||||||
|
node->setCurrentFrame(frame);
|
||||||
|
rc_actor[actor].transition_frame = frame;
|
||||||
|
rc_actor[actor].transition = true;
|
||||||
|
rc_actor[actor].transition_time = transition_time;
|
||||||
|
rc_actor[actor].transition_start_time = ((double)SDL_GetTicks())/1000.0;
|
||||||
|
rc_actor[actor].current_animation = RC_ANIMATION_TRANSITION;
|
||||||
|
rc_transition_actor.push_back(actor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double rc_getActorTransitionTime(int actor)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(rc_actor[actor].transition)
|
||||||
|
return rc_actor[actor].transition_time;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rc_stopActorTransition(int actor)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
switch(rc_actor[actor].node_type)
|
||||||
|
{
|
||||||
|
case RC_NODE_TYPE_MESH:
|
||||||
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
||||||
|
node->setTransitionTime(0);
|
||||||
|
node->setJointMode(irr::scene::EJUOR_NONE);
|
||||||
|
rc_actor[actor].transition = false;
|
||||||
|
rc_actor[actor].transition_time = 0;
|
||||||
|
|
||||||
|
rc_setActorFrame(actor, rc_actor[actor].transition_frame);
|
||||||
|
|
||||||
|
for(int i = 0; i < rc_transition_actor.size();)
|
||||||
|
{
|
||||||
|
if(rc_transition_actor[i] == actor)
|
||||||
|
{
|
||||||
|
rc_transition_actor.erase(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rc_actorIsInTransition(int actor)
|
||||||
|
{
|
||||||
|
if(actor < 0 || actor >= rc_actor.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return rc_actor[actor].transition;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//set actor animation speed
|
//set actor animation speed
|
||||||
void rc_setActorAutoCulling(int actor, int cull_type)
|
void rc_setActorAutoCulling(int actor, int cull_type)
|
||||||
{
|
{
|
||||||
@@ -5458,34 +5700,7 @@ Uint32 rc_getLightSpecularColor(int actor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void rc_loopActorAnimation(int actor, bool flag)
|
|
||||||
{
|
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
|
||||||
{
|
|
||||||
case RC_NODE_TYPE_MESH:
|
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
|
||||||
node->setLoopMode(flag);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rc_actorAnimationIsLooped(int actor)
|
|
||||||
{
|
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
|
||||||
{
|
|
||||||
case RC_NODE_TYPE_MESH:
|
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
|
||||||
return node->getLoopMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//set actor animation speed
|
//set actor animation speed
|
||||||
void rc_setActorVisible(int actor, bool flag)
|
void rc_setActorVisible(int actor, bool flag)
|
||||||
@@ -5505,75 +5720,6 @@ bool rc_actorIsVisible(int actor)
|
|||||||
return rc_actor[actor].mesh_node->isVisible();
|
return rc_actor[actor].mesh_node->isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void rc_startActorTransition(int actor, double frame, double transition_time)
|
|
||||||
{
|
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(rc_actor[actor].transition)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
|
||||||
{
|
|
||||||
case RC_NODE_TYPE_MESH:
|
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
|
||||||
node->setTransitionTime(transition_time);
|
|
||||||
node->setJointMode(irr::scene::EJUOR_CONTROL);
|
|
||||||
node->setCurrentFrame(frame);
|
|
||||||
rc_actor[actor].transition = true;
|
|
||||||
rc_actor[actor].transition_time = transition_time;
|
|
||||||
rc_actor[actor].transition_start_time = ((double)SDL_GetTicks())/1000.0;
|
|
||||||
rc_transition_actor.push_back(actor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double rc_getActorTransitionTime(int actor)
|
|
||||||
{
|
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if(rc_actor[actor].transition)
|
|
||||||
return rc_actor[actor].transition_time;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void rc_stopActorTransition(int actor)
|
|
||||||
{
|
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
switch(rc_actor[actor].node_type)
|
|
||||||
{
|
|
||||||
case RC_NODE_TYPE_MESH:
|
|
||||||
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*)rc_actor[actor].mesh_node;
|
|
||||||
node->setTransitionTime(0);
|
|
||||||
node->setJointMode(irr::scene::EJUOR_NONE);
|
|
||||||
rc_actor[actor].transition = false;
|
|
||||||
rc_actor[actor].transition_time = 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < rc_transition_actor.size();)
|
|
||||||
{
|
|
||||||
if(rc_transition_actor[i] == actor)
|
|
||||||
{
|
|
||||||
rc_transition_actor.erase(i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rc_actorIsInTransition(int actor)
|
|
||||||
{
|
|
||||||
if(actor < 0 || actor >= rc_actor.size())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return rc_actor[actor].transition;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void rc_getTerrainPatchAABB(int actor, double patch_x, double patch_z, double* min_x, double* min_y, double* min_z, double* max_x, double* max_y, double* max_z)
|
void rc_getTerrainPatchAABB(int actor, double patch_x, double patch_z, double* min_x, double* min_y, double* min_z, double* max_x, double* max_y, double* max_z)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ struct rc_physicsWorld2D_obj
|
|||||||
b2World* world;
|
b2World* world;
|
||||||
|
|
||||||
rc_contactListener_obj* contact_listener;
|
rc_contactListener_obj* contact_listener;
|
||||||
float timeStep = 1/20.0; //the length of time passed to simulate (seconds)
|
float timeStep = 1/60.0; //the length of time passed to simulate (seconds)
|
||||||
int velocityIterations = 8; //how strongly to correct velocity
|
int velocityIterations = 8; //how strongly to correct velocity
|
||||||
int positionIterations = 3; //how strongly to correct position
|
int positionIterations = 3; //how strongly to correct position
|
||||||
};
|
};
|
||||||
@@ -516,6 +516,19 @@ struct rc_particle_properties_obj
|
|||||||
bool outlineOnly;
|
bool outlineOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define RC_ANIMATION_MD2 -2
|
||||||
|
#define RC_ANIMATION_TRANSITION -3
|
||||||
|
|
||||||
|
struct rc_actor_animation_obj
|
||||||
|
{
|
||||||
|
bool active;
|
||||||
|
int start_frame;
|
||||||
|
int end_frame;
|
||||||
|
double fps;
|
||||||
|
irr::u32 frame_start_time;
|
||||||
|
irr::u32 frame_swap_time;
|
||||||
|
};
|
||||||
|
|
||||||
struct rc_scene_node
|
struct rc_scene_node
|
||||||
{
|
{
|
||||||
int node_type = 0;
|
int node_type = 0;
|
||||||
@@ -525,12 +538,20 @@ struct rc_scene_node
|
|||||||
rc_node_physics physics;
|
rc_node_physics physics;
|
||||||
|
|
||||||
bool transition;
|
bool transition;
|
||||||
|
double transition_frame;
|
||||||
double transition_time;
|
double transition_time;
|
||||||
double transition_start_time;
|
double transition_start_time;
|
||||||
|
|
||||||
rc_particle_properties_obj particle_properties;
|
rc_particle_properties_obj particle_properties;
|
||||||
|
|
||||||
int material_ref_index = -1;
|
int material_ref_index = -1;
|
||||||
|
|
||||||
|
int current_animation;
|
||||||
|
int num_animation_loops;
|
||||||
|
int current_animation_loop;
|
||||||
|
bool isPlaying;
|
||||||
|
irr::core::array<int> deleted_animation;
|
||||||
|
irr::core::array<rc_actor_animation_obj> animation;
|
||||||
};
|
};
|
||||||
|
|
||||||
irr::core::array<rc_scene_node> rc_actor;
|
irr::core::array<rc_scene_node> rc_actor;
|
||||||
@@ -538,6 +559,34 @@ irr::core::array<rc_scene_node> rc_actor;
|
|||||||
irr::core::array<int> rc_transition_actor;
|
irr::core::array<int> rc_transition_actor;
|
||||||
|
|
||||||
|
|
||||||
|
class rc_animEndCallBack : public IAnimationEndCallBack
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
rc_scene_node* ref_actor;
|
||||||
|
|
||||||
|
void OnAnimationEnd( IAnimatedMeshSceneNode *node)
|
||||||
|
{
|
||||||
|
if(ref_actor->current_animation_loop < ref_actor->num_animation_loops || ref_actor->num_animation_loops < 0)
|
||||||
|
{
|
||||||
|
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*) ref_actor->mesh_node;
|
||||||
|
int animation = ref_actor->current_animation;
|
||||||
|
if(animation < 0 || animation >= ref_actor->animation.size())
|
||||||
|
return;
|
||||||
|
int start_frame = ref_actor->animation[animation].start_frame;
|
||||||
|
int end_frame = ref_actor->animation[animation].end_frame;
|
||||||
|
node->setFrameLoop(start_frame, end_frame);
|
||||||
|
ref_actor->current_animation_loop++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ref_actor->isPlaying = false;
|
||||||
|
}
|
||||||
|
//std::cout << "The animation has ended!" << std::endl;
|
||||||
|
// Your callback code goes there.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void myTickCallback2(btSoftRigidDynamicsWorld* dynamicsWorld, btScalar timeStep)
|
void myTickCallback2(btSoftRigidDynamicsWorld* dynamicsWorld, btScalar timeStep)
|
||||||
{
|
{
|
||||||
rc_collisions.clear();
|
rc_collisions.clear();
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ double rc_getSpriteAnimationSpeed(int spr_id, int animation)
|
|||||||
return rc_sprite[spr_id].animation[animation].fps;
|
return rc_sprite[spr_id].animation[animation].fps;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rc_setSpriteAnimation(int spr_id, int animation)
|
void rc_setSpriteAnimation(int spr_id, int animation, int num_loops)
|
||||||
{
|
{
|
||||||
if(spr_id < 0 || spr_id >= rc_sprite.size())
|
if(spr_id < 0 || spr_id >= rc_sprite.size())
|
||||||
return;
|
return;
|
||||||
@@ -191,6 +191,7 @@ void rc_setSpriteAnimation(int spr_id, int animation)
|
|||||||
rc_sprite[spr_id].animation[animation].current_frame = 0;
|
rc_sprite[spr_id].animation[animation].current_frame = 0;
|
||||||
rc_sprite[spr_id].isPlaying = true;
|
rc_sprite[spr_id].isPlaying = true;
|
||||||
rc_sprite[spr_id].animation[animation].frame_start_time = SDL_GetTicks();
|
rc_sprite[spr_id].animation[animation].frame_start_time = SDL_GetTicks();
|
||||||
|
rc_sprite[spr_id].num_animation_loops = num_loops;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rc_getSpriteAnimation(int spr_id)
|
int rc_getSpriteAnimation(int spr_id)
|
||||||
@@ -238,6 +239,17 @@ int rc_numSpriteAnimationLoops(int spr_id)
|
|||||||
return rc_sprite[spr_id].num_animation_loops;
|
return rc_sprite[spr_id].num_animation_loops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rc_spriteAnimationIsPlaying(int spr_id)
|
||||||
|
{
|
||||||
|
if(spr_id < 0 || spr_id >= rc_sprite.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!rc_sprite[spr_id].active)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return rc_sprite[spr_id].isPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------SPRITES-------------------------------------------------------
|
//------------------------------SPRITES-------------------------------------------------------
|
||||||
//Larger z gets drawn first
|
//Larger z gets drawn first
|
||||||
void sortSpriteZ(int canvas_id)
|
void sortSpriteZ(int canvas_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user