Merge pull request #13 from n00b87/use_degrees
Converted radian parameters and return values to degrees
This commit is contained in:
359
rcbasic_runtime/rc_actor_animation.h
Normal file
359
rcbasic_runtime/rc_actor_animation.h
Normal file
@@ -0,0 +1,359 @@
|
||||
#ifndef RC_ACTOR_ANIMATION_H_INCLUDED
|
||||
#define RC_ACTOR_ANIMATION_H_INCLUDED
|
||||
|
||||
//set actor animation [TODO]
|
||||
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())
|
||||
return;
|
||||
|
||||
if(animation < 0 || animation >= rc_actor[actor].animation.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;
|
||||
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->setAnimationSpeed(rc_actor[actor].animation[animation].fps);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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())
|
||||
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->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;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorMD2AnimationByName(int actor, std::string animation_name, int num_loops)
|
||||
{
|
||||
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->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;
|
||||
}
|
||||
}
|
||||
|
||||
int rc_getActorAnimationStartFrame(int actor, int animation)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||
return 0;
|
||||
|
||||
switch(rc_actor[actor].node_type)
|
||||
{
|
||||
case RC_NODE_TYPE_MESH:
|
||||
if(rc_actor[actor].current_animation == animation)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
int rc_getActorAnimationEndFrame(int actor, int animation)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||
return 0;
|
||||
|
||||
switch(rc_actor[actor].node_type)
|
||||
{
|
||||
case RC_NODE_TYPE_MESH:
|
||||
if(rc_actor[actor].current_animation == animation)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
int rc_getActorFrame(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
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->getFrameNr();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//set actor animation speed
|
||||
void rc_setActorAnimationSpeed(int actor, int animation, double speed)
|
||||
{
|
||||
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].fps = 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;
|
||||
}
|
||||
}
|
||||
|
||||
double rc_getActorAnimationSpeed(int actor, int animation)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(animation < 0 || animation >= rc_actor[actor].animation.size())
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].animation[animation].fps;
|
||||
}
|
||||
|
||||
void rc_setActorFrame(int actor, int frame)
|
||||
{
|
||||
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;
|
||||
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);
|
||||
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); //This is actually called in setTransitionTime()
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
#endif // RC_ACTOR_ANIMATION_H_INCLUDED
|
||||
1012
rcbasic_runtime/rc_actor_material.h
Normal file
1012
rcbasic_runtime/rc_actor_material.h
Normal file
File diff suppressed because it is too large
Load Diff
713
rcbasic_runtime/rc_actor_physics.h
Normal file
713
rcbasic_runtime/rc_actor_physics.h
Normal file
@@ -0,0 +1,713 @@
|
||||
#ifndef RC_ACTOR_PHYSICS_H_INCLUDED
|
||||
#define RC_ACTOR_PHYSICS_H_INCLUDED
|
||||
|
||||
void rc_setActorGravity(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->setGravity(irr::core::vector3df(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorGravity(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df gvec = rc_actor[actor].physics.rigid_body->getGravity();
|
||||
*x = gvec.X;
|
||||
*y = gvec.Y;
|
||||
*z = gvec.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorDamping(int actor, double lin_damping, double ang_damping)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->setDamping(lin_damping, ang_damping);
|
||||
}
|
||||
}
|
||||
|
||||
double rc_getActorLinearDamping(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
return rc_actor[actor].physics.rigid_body->getLinearDamping();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double rc_getActorAngularDamping(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
return rc_actor[actor].physics.rigid_body->getAngularDamping();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double rc_getActorLinearSleepThreshold(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
return rc_actor[actor].physics.rigid_body->getLinearSleepingThreshold();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double rc_getActorAngularSleepThreshold(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
return rc_util_degrees(rc_actor[actor].physics.rigid_body->getAngularSleepingThreshold()); //convert to degrees per second
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rc_applyActorDamping(int actor, double timeStep)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyDamping(timeStep);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorMassProperties(int actor, double mass, double inertia_x, double inertia_y, double inertia_z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_physics3D.world->removeCollisionObject(rc_actor[actor].physics.rigid_body, false);
|
||||
rc_actor[actor].physics.rigid_body->setMassProps(mass, irr::core::vector3df(inertia_x, inertia_y, inertia_z));
|
||||
rc_physics3D.world->addRigidBody(rc_actor[actor].physics.rigid_body);
|
||||
}
|
||||
rc_actor[actor].physics.mass = mass;
|
||||
}
|
||||
|
||||
void rc_getActorLinearFactor(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df lf = rc_actor[actor].physics.rigid_body->getLinearFactor();
|
||||
*x = lf.X;
|
||||
*y = lf.Y;
|
||||
*z = lf.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorLinearFactor(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->setLinearFactor(irr::core::vector3df(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
double rc_getActorInverseMass(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
return rc_actor[actor].physics.rigid_body->getInvMass();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rc_integrateActorVelocities(int actor, double step)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->integrateVelocities(step);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorCentralForceLocal(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyCentralForce(irr::core::vector3df(x,y,z), ERBTransformSpace::ERBTS_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorCentralForceWorld(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyCentralForce(irr::core::vector3df(x,y,z), ERBTransformSpace::ERBTS_WORLD);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorTotalForce(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df f = rc_actor[actor].physics.rigid_body->getTotalForce();
|
||||
*x = f.X;
|
||||
*y = f.Y;
|
||||
*z = f.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorTotalTorque(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df f = rc_actor[actor].physics.rigid_body->getTotalTorque();
|
||||
*x = f.X;
|
||||
*y = f.Y;
|
||||
*z = f.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorInverseInertiaDiagLocal(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df f = rc_actor[actor].physics.rigid_body->getInvInertiaDiagLocal();
|
||||
*x = f.X;
|
||||
*y = f.Y;
|
||||
*z = f.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorInverseInertiaDiagLocal(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->setInvInertiaDiagLocal(irr::core::vector3df(x,y,z));
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorSleepThresholds(int actor, double linear, double angular)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->setSleepingThresholds(linear, rc_util_radians(angular));
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorTorqueLocal(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyTorque(irr::core::vector3df(x,y,z), ERBTransformSpace::ERBTS_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorTorqueWorld(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyTorque(irr::core::vector3df(x,y,z), ERBTransformSpace::ERBTS_WORLD);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorForceLocal(int actor, double x, double y, double z, double rel_x, double rel_y, double rel_z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyForce(irr::core::vector3df(x,y,z), irr::core::vector3df(rel_x, rel_y, rel_z), ERBTransformSpace::ERBTS_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorForceWorld(int actor, double x, double y, double z, double rel_x, double rel_y, double rel_z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyForce(irr::core::vector3df(x,y,z), irr::core::vector3df(rel_x, rel_y, rel_z), ERBTransformSpace::ERBTS_WORLD);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorCentralImpulseLocal(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyCentralImpulse(irr::core::vector3df(x,y,z), ERBTransformSpace::ERBTS_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorCentralImpulseWorld(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyCentralImpulse(irr::core::vector3df(x,y,z), ERBTransformSpace::ERBTS_WORLD);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorTorqueImpulseLocal(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyTorqueImpulse(irr::core::vector3df(x,y,z), ERBTransformSpace::ERBTS_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorTorqueImpulseWorld(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyTorqueImpulse(irr::core::vector3df(x,y,z), ERBTransformSpace::ERBTS_WORLD);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorImpulseLocal(int actor, double x, double y, double z, double rel_x, double rel_y, double rel_z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyImpulse(irr::core::vector3df(x,y,z), irr::core::vector3df(rel_x, rel_y, rel_z), ERBTransformSpace::ERBTS_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_applyActorImpulseWorld(int actor, double x, double y, double z, double rel_x, double rel_y, double rel_z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->applyImpulse(irr::core::vector3df(x,y,z), irr::core::vector3df(rel_x, rel_y, rel_z), ERBTransformSpace::ERBTS_WORLD);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_clearActorForces(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->clearForces();
|
||||
}
|
||||
}
|
||||
|
||||
void rc_updateActorInertiaTensor(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->updateInertiaTensor();
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorCenter(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df pos = rc_actor[actor].physics.rigid_body->getCenterOfMassPosition();
|
||||
*x = pos.X;
|
||||
*y = pos.Y;
|
||||
*z = pos.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorRotationQ(int actor, double* x, double* y, double* z, double* w)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
*w = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::quaternion q = rc_actor[actor].physics.rigid_body->getOrientation();
|
||||
*x = q.X;
|
||||
*y = q.Y;
|
||||
*z = q.Z;
|
||||
*w = q.W;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorLinearVelocityWorld(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df pos = rc_actor[actor].physics.rigid_body->getLinearVelocity();
|
||||
*x = pos.X;
|
||||
*y = pos.Y;
|
||||
*z = pos.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorAngularVelocityWorld(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df pos = rc_actor[actor].physics.rigid_body->getAngularVelocity();
|
||||
*x = rc_util_degrees(pos.X);
|
||||
*y = rc_util_degrees(pos.Y);
|
||||
*z = rc_util_degrees(pos.Z);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorLinearVelocityLocal(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->setLinearVelocity(irr::core::vector3df(x, y, z), ERBTransformSpace::ERBTS_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorLinearVelocityWorld(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->setLinearVelocity(irr::core::vector3df(x, y, z), ERBTransformSpace::ERBTS_WORLD);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorAngularVelocityLocal(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
x = rc_util_radians(x);
|
||||
y = rc_util_radians(y);
|
||||
z = rc_util_radians(z);
|
||||
rc_actor[actor].physics.rigid_body->setAngularVelocity(irr::core::vector3df(x, y, z), ERBTransformSpace::ERBTS_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setActorAngularVelocityWorld(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
x = rc_util_radians(x);
|
||||
y = rc_util_radians(y);
|
||||
z = rc_util_radians(z);
|
||||
rc_actor[actor].physics.rigid_body->setAngularVelocity(irr::core::vector3df(x, y, z), ERBTransformSpace::ERBTS_WORLD);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorVelocityInLocalPoint(int actor, double rel_x, double rel_y, double rel_z, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df pos = rc_actor[actor].physics.rigid_body->getVelocityInLocalPoint(irr::core::vector3df(rel_x, rel_y, rel_z));
|
||||
*x = pos.X;
|
||||
*y = pos.Y;
|
||||
*z = pos.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorLinearVelocityLocal(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
btVector3 v = rc_actor[actor].physics.rigid_body->getPointer()->getWorldTransform().getBasis().transpose() * rc_actor[actor].physics.rigid_body->getPointer()->getLinearVelocity();
|
||||
*x = v.getX();
|
||||
*y = v.getY();
|
||||
*z = v.getZ();
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorAngularVelocityLocal(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
btVector3 v = rc_actor[actor].physics.rigid_body->getPointer()->getWorldTransform().getBasis().transpose() * rc_actor[actor].physics.rigid_body->getPointer()->getAngularVelocity();
|
||||
*x = rc_util_degrees(v.getX());
|
||||
*y = rc_util_degrees(v.getY());
|
||||
*z = rc_util_degrees(v.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorAABB(int actor, double* min_x, double* min_y, double* min_z, double* max_x, double* max_y, double* max_z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*min_x = 0;
|
||||
*min_y = 0;
|
||||
*min_z = 0;
|
||||
*max_x = 0;
|
||||
*max_y = 0;
|
||||
*max_z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df min_aabb;
|
||||
irr::core::vector3df max_aabb;
|
||||
rc_actor[actor].physics.rigid_body->getAabb(min_aabb, max_aabb);
|
||||
*min_x = min_aabb.X;
|
||||
*min_y = min_aabb.Y;
|
||||
*min_z = min_aabb.Z;
|
||||
*max_x = max_aabb.X;
|
||||
*max_y = max_aabb.Y;
|
||||
*max_z = max_aabb.Z;
|
||||
}
|
||||
}
|
||||
|
||||
double rc_computeActorImpulseDenominator(int actor, double pos_x, double pos_y, double pos_z, double normal_x, double normal_y, double normal_z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
return rc_actor[actor].physics.rigid_body->computeImpulseDenominator(irr::core::vector3df(pos_x, pos_y, pos_z), irr::core::vector3df(normal_x, normal_y, normal_z));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
double rc_computeActorAngularImpulseDenominator(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
return rc_actor[actor].physics.rigid_body->computeAngularImpulseDenominator(irr::core::vector3df(x, y, z));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rc_setActorAngularFactor(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
rc_actor[actor].physics.rigid_body->setAngularFactor(irr::core::vector3df(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorAngularFactor(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
irr::core::vector3df af = rc_actor[actor].physics.rigid_body->getAngularFactor();
|
||||
*x = af.X;
|
||||
*y = af.Y;
|
||||
*z = af.Z;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_computeActorGyroImpulseLocal(int actor, double step, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
btVector3 v = rc_actor[actor].physics.rigid_body->getPointer()->computeGyroscopicImpulseImplicit_Body(step);
|
||||
*x = v.getX();
|
||||
*y = v.getY();
|
||||
*z = v.getZ();
|
||||
}
|
||||
}
|
||||
|
||||
void rc_computeActorGyroImpulseWorld(int actor, double dt, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
btVector3 v = rc_actor[actor].physics.rigid_body->getPointer()->computeGyroscopicImpulseImplicit_World(dt);
|
||||
*x = v.getX();
|
||||
*y = v.getY();
|
||||
*z = v.getZ();
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getActorLocalInertia(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(rc_actor[actor].physics.rigid_body)
|
||||
{
|
||||
btVector3 v = rc_actor[actor].physics.rigid_body->getPointer()->getLocalInertia();
|
||||
*x = v.getX();
|
||||
*y = v.getY();
|
||||
*z = v.getZ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // RC_ACTOR_PHYSICS_H_INCLUDED
|
||||
1509
rcbasic_runtime/rc_base_actor.h
Normal file
1509
rcbasic_runtime/rc_base_actor.h
Normal file
File diff suppressed because it is too large
Load Diff
166
rcbasic_runtime/rc_camera.h
Normal file
166
rcbasic_runtime/rc_camera.h
Normal file
@@ -0,0 +1,166 @@
|
||||
#ifndef RC_CAMERA_H_INCLUDED
|
||||
#define RC_CAMERA_H_INCLUDED
|
||||
|
||||
void rc_setCameraPosition(double x, double y, double z)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
void rc_getCameraPosition(double* x, double* y, double* z)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
irr::f32 fx, fy, fz;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.getPosition(fx, fy, fz);
|
||||
|
||||
*x = fx;
|
||||
*y = fy;
|
||||
*z = fz;
|
||||
}
|
||||
|
||||
void rc_translateCamera(double x, double y, double z)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.translate(x, y, z);
|
||||
}
|
||||
|
||||
void rc_translateCameraW(double x, double y, double z)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.translateW(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
void rc_setCameraRotation(double x, double y, double z)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.setRotation(x, y, z);
|
||||
}
|
||||
|
||||
void rc_getCameraRotation(double* x, double* y, double* z)
|
||||
{
|
||||
if(rc_active_canvas <= 0 || rc_active_canvas >= rc_canvas.size())
|
||||
return;
|
||||
|
||||
*x = rc_canvas[rc_active_canvas].camera.rx;
|
||||
*y = rc_canvas[rc_active_canvas].camera.ry;
|
||||
*z = rc_canvas[rc_active_canvas].camera.rz;
|
||||
|
||||
//std::cout << "Get Rotation: " << x[0] << ", " << y[0] << ", " << z[0] << std::endl;
|
||||
}
|
||||
|
||||
void rc_rotateCamera(double x, double y, double z)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.rotate(x, y, z);
|
||||
}
|
||||
|
||||
void rc_setCameraFOV(double fov)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.camera->setFOV(fov);
|
||||
}
|
||||
|
||||
double rc_getCameraFOV()
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return 0;
|
||||
|
||||
return rc_canvas[rc_active_canvas].camera.camera->getFOV();
|
||||
}
|
||||
|
||||
void rc_setCameraAspectRatio(double aspect)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.camera->setAspectRatio(aspect);
|
||||
}
|
||||
|
||||
double rc_getCameraAspectRatio()
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return 0;
|
||||
|
||||
return rc_canvas[rc_active_canvas].camera.camera->getAspectRatio();
|
||||
}
|
||||
|
||||
void rc_setCameraFarValue(double zf)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.camera->setFarValue(zf);
|
||||
}
|
||||
|
||||
double rc_getCameraFarValue()
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return 0;
|
||||
|
||||
return rc_canvas[rc_active_canvas].camera.camera->getFarValue();
|
||||
}
|
||||
|
||||
void rc_setCameraNearValue(double zn)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
rc_canvas[rc_active_canvas].camera.camera->setNearValue(zn);
|
||||
}
|
||||
|
||||
double rc_getCameraNearValue()
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return 0;
|
||||
|
||||
return rc_canvas[rc_active_canvas].camera.camera->getNearValue();
|
||||
}
|
||||
|
||||
void rc_setProjectionMatrix(int proj_matrix, int proj_type)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
if(proj_matrix < 0 || proj_matrix >= rc_matrix.size())
|
||||
return;
|
||||
|
||||
if(!rc_matrix[proj_matrix].active)
|
||||
return;
|
||||
|
||||
irr::core::matrix4 irr_mat = rc_convertToIrrMatrix(proj_matrix);
|
||||
bool isOrtho = (proj_type == RC_PROJECTION_TYPE_ORTHOGRAPHIC);
|
||||
rc_canvas[rc_active_canvas].camera.camera->setProjectionMatrix(irr_mat, isOrtho);
|
||||
}
|
||||
|
||||
void rc_getProjectionMatrix(int proj_matrix)
|
||||
{
|
||||
if(!(rc_active_canvas > 0 && rc_active_canvas < rc_canvas.size()))
|
||||
return;
|
||||
|
||||
if(proj_matrix < 0 || proj_matrix >= rc_matrix.size())
|
||||
return;
|
||||
|
||||
if(!rc_matrix[proj_matrix].active)
|
||||
return;
|
||||
|
||||
irr::core::matrix4 pmat = rc_canvas[rc_active_canvas].camera.camera->getProjectionMatrix();
|
||||
rc_convertFromIrrMatrix(pmat, proj_matrix);
|
||||
}
|
||||
|
||||
#endif // RC_CAMERA_H_INCLUDED
|
||||
1976
rcbasic_runtime/rc_constraint.h
Normal file
1976
rcbasic_runtime/rc_constraint.h
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -420,6 +420,17 @@ bool mobile_active_window_flag = true;
|
||||
|
||||
|
||||
//------------ 3D Graphics ----------------//
|
||||
struct rc_material_obj
|
||||
{
|
||||
irr::video::SMaterial mat;
|
||||
bool isUsed = false;
|
||||
bool isReference = false;
|
||||
int refActor = -1;
|
||||
int refMatNum = 0;
|
||||
};
|
||||
|
||||
irr::core::array<rc_material_obj> rc_material;
|
||||
|
||||
#define RC_MESH_TYPE_NONE 0
|
||||
#define RC_MESH_TYPE_ANIMATED 1
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ int rc_createDistanceJoint(int spriteA, int spriteB, double aX, double aY, doubl
|
||||
|
||||
b2DistanceJointDef joint_def;
|
||||
joint_def.Initialize(rc_sprite[spriteA].physics.body, rc_sprite[spriteB].physics.body, b2Vec2(aX, aY), b2Vec2(bX, bY));
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_DISTANCE;
|
||||
@@ -98,6 +99,7 @@ int rc_createFrictionJoint(int spriteA, int spriteB, double x, double y, bool co
|
||||
|
||||
b2FrictionJointDef joint_def;
|
||||
joint_def.Initialize(rc_sprite[spriteA].physics.body, rc_sprite[spriteB].physics.body, b2Vec2(x, y));
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_FRICTION;
|
||||
@@ -149,6 +151,7 @@ int rc_createGearJoint(int jointA, int jointB, double g_ratio, bool collide_conn
|
||||
b2GearJointDef joint_def;
|
||||
joint_def.joint1 = rc_joint[jointA].joint;
|
||||
joint_def.joint2 = rc_joint[jointB].joint;
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_GEAR;
|
||||
@@ -196,6 +199,7 @@ int rc_createMotorJoint(int spriteA, int spriteB, bool collide_connected)
|
||||
|
||||
b2MotorJointDef joint_def;
|
||||
joint_def.Initialize(rc_sprite[spriteA].physics.body, rc_sprite[spriteB].physics.body);
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_MOTOR;
|
||||
@@ -243,6 +247,7 @@ int rc_createPrismaticJoint(int spriteA, int spriteB, double aX, double aY, doub
|
||||
|
||||
b2PrismaticJointDef joint_def;
|
||||
joint_def.Initialize(rc_sprite[spriteA].physics.body, rc_sprite[spriteB].physics.body, b2Vec2(aX, aY), b2Vec2(axisX, axisY));
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_PRISMATIC;
|
||||
@@ -290,6 +295,7 @@ int rc_createPulleyJoint(int spriteA, int spriteB, double gaX, double gaY, doubl
|
||||
|
||||
b2PulleyJointDef joint_def;
|
||||
joint_def.Initialize(rc_sprite[spriteA].physics.body, rc_sprite[spriteB].physics.body, b2Vec2(gaX, gaY), b2Vec2(gbX, gbY), b2Vec2(aX, aY), b2Vec2(bX, bY), j_ratio);
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_PULLEY;
|
||||
@@ -337,6 +343,7 @@ int rc_createRevoluteJoint(int spriteA, int spriteB, double x, double y, bool co
|
||||
|
||||
b2RevoluteJointDef joint_def;
|
||||
joint_def.Initialize(rc_sprite[spriteA].physics.body, rc_sprite[spriteB].physics.body, b2Vec2(x, y));
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_REVOLUTE;
|
||||
@@ -384,6 +391,7 @@ int rc_createWeldJoint(int spriteA, int spriteB, double x, double y, bool collid
|
||||
|
||||
b2WeldJointDef joint_def;
|
||||
joint_def.Initialize(rc_sprite[spriteA].physics.body, rc_sprite[spriteB].physics.body, b2Vec2(x, y));
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_WELD;
|
||||
@@ -431,6 +439,7 @@ int rc_createWheelJoint(int spriteA, int spriteB, double aX, double aY, double a
|
||||
|
||||
b2WheelJointDef joint_def;
|
||||
joint_def.Initialize(rc_sprite[spriteA].physics.body, rc_sprite[spriteB].physics.body, b2Vec2(aX, aY), b2Vec2(axisX, axisY));
|
||||
joint_def.collideConnected = collide_connected;
|
||||
|
||||
rc_joint[joint_id].joint = rc_canvas[rc_active_canvas].physics2D.world->CreateJoint(&joint_def);
|
||||
rc_joint[joint_id].type = RC_JOINT_TYPE_WHEEL;
|
||||
@@ -1143,6 +1152,8 @@ void rc_setJointAngularOffset(int joint_id, double angleOffset)
|
||||
if(!rc_joint[joint_id].active)
|
||||
return;
|
||||
|
||||
angleOffset = rc_util_radians(angleOffset);
|
||||
|
||||
switch(rc_joint[joint_id].type)
|
||||
{
|
||||
case RC_JOINT_TYPE_MOTOR:
|
||||
@@ -1167,7 +1178,7 @@ double rc_getJointAngularOffset(int joint_id)
|
||||
case RC_JOINT_TYPE_MOTOR:
|
||||
{
|
||||
b2MotorJoint* j = (b2MotorJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetAngularOffset();
|
||||
return rc_util_degrees(j->GetAngularOffset());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1220,14 +1231,14 @@ double rc_getJointReferenceAngle(int joint_id)
|
||||
case RC_JOINT_TYPE_PRISMATIC:
|
||||
{
|
||||
b2PrismaticJoint* j = (b2PrismaticJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetReferenceAngle();
|
||||
return rc_util_degrees(j->GetReferenceAngle());
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_JOINT_TYPE_REVOLUTE:
|
||||
{
|
||||
b2RevoluteJoint* j = (b2RevoluteJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetReferenceAngle();
|
||||
return rc_util_degrees(j->GetReferenceAngle());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1285,7 +1296,7 @@ double rc_getJointSpeed(int joint_id)
|
||||
case RC_JOINT_TYPE_REVOLUTE:
|
||||
{
|
||||
b2RevoluteJoint* j = (b2RevoluteJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetJointSpeed();
|
||||
return rc_util_degrees(j->GetJointSpeed());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1385,7 +1396,7 @@ double rc_getJointLowerLimit(int joint_id)
|
||||
case RC_JOINT_TYPE_REVOLUTE:
|
||||
{
|
||||
b2RevoluteJoint* j = (b2RevoluteJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetLowerLimit();
|
||||
return rc_util_degrees(j->GetLowerLimit());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1421,7 +1432,7 @@ double rc_getJointUpperLimit(int joint_id)
|
||||
case RC_JOINT_TYPE_REVOLUTE:
|
||||
{
|
||||
b2RevoluteJoint* j = (b2RevoluteJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetUpperLimit();
|
||||
return rc_util_degrees(j->GetUpperLimit());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1457,7 +1468,7 @@ void rc_setJointLimits(int joint_id, double lower_limit, double upper_limit)
|
||||
case RC_JOINT_TYPE_REVOLUTE:
|
||||
{
|
||||
b2RevoluteJoint* j = (b2RevoluteJoint*)rc_joint[joint_id].joint;
|
||||
j->SetLimits(lower_limit, upper_limit);
|
||||
j->SetLimits(rc_util_radians(lower_limit), rc_util_radians(upper_limit));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1561,14 +1572,14 @@ void rc_setJointMotorSpeed(int joint_id, double speed)
|
||||
case RC_JOINT_TYPE_REVOLUTE:
|
||||
{
|
||||
b2RevoluteJoint* j = (b2RevoluteJoint*)rc_joint[joint_id].joint;
|
||||
j->SetMotorSpeed(speed);
|
||||
j->SetMotorSpeed(rc_util_radians(speed));
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_JOINT_TYPE_WHEEL:
|
||||
{
|
||||
b2WheelJoint* j = (b2WheelJoint*)rc_joint[joint_id].joint;
|
||||
j->SetMotorSpeed(speed);
|
||||
j->SetMotorSpeed(rc_util_radians(speed));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1595,14 +1606,14 @@ double rc_getJointMotorSpeed(int joint_id)
|
||||
case RC_JOINT_TYPE_REVOLUTE:
|
||||
{
|
||||
b2RevoluteJoint* j = (b2RevoluteJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetMotorSpeed();
|
||||
return rc_util_degrees(j->GetMotorSpeed());
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_JOINT_TYPE_WHEEL:
|
||||
{
|
||||
b2WheelJoint* j = (b2WheelJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetMotorSpeed();
|
||||
return rc_util_degrees(j->GetMotorSpeed());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1929,14 +1940,14 @@ double rc_getJointAngle(int joint_id)
|
||||
case RC_JOINT_TYPE_REVOLUTE:
|
||||
{
|
||||
b2RevoluteJoint* j = (b2RevoluteJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetJointAngle();
|
||||
return rc_util_degrees(j->GetJointAngle());
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_JOINT_TYPE_WHEEL:
|
||||
{
|
||||
b2WheelJoint* j = (b2WheelJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetJointAngle();
|
||||
return rc_util_degrees(j->GetJointAngle());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1980,7 +1991,7 @@ double rc_getJointAngularSpeed(int joint_id)
|
||||
case RC_JOINT_TYPE_WHEEL:
|
||||
{
|
||||
b2WheelJoint* j = (b2WheelJoint*)rc_joint[joint_id].joint;
|
||||
return j->GetJointAngularSpeed();
|
||||
return rc_util_degrees(j->GetJointAngularSpeed());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
270
rcbasic_runtime/rc_mesh.h
Normal file
270
rcbasic_runtime/rc_mesh.h
Normal file
@@ -0,0 +1,270 @@
|
||||
#ifndef RC_MESH_H_INCLUDED
|
||||
#define RC_MESH_H_INCLUDED
|
||||
|
||||
//load a mesh from a file
|
||||
int rc_loadMesh(std::string mesh_file)
|
||||
{
|
||||
int mesh_id = -1;
|
||||
|
||||
rc_mesh_obj mesh_obj;
|
||||
mesh_obj.mesh_type = RC_MESH_TYPE_ANIMATED;
|
||||
|
||||
irr::scene::IAnimatedMesh* mesh = SceneManager->getMesh(mesh_file.c_str());
|
||||
mesh_obj.mesh = mesh;
|
||||
|
||||
if(!mesh)
|
||||
return -1;
|
||||
|
||||
for(int i = 0; i < rc_mesh.size(); i++)
|
||||
{
|
||||
if(!rc_mesh[i].mesh)
|
||||
{
|
||||
mesh_id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(mesh_id < 0)
|
||||
{
|
||||
mesh_id = rc_mesh.size();
|
||||
rc_mesh.push_back(mesh_obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_mesh[mesh_id] = mesh_obj;
|
||||
}
|
||||
|
||||
return mesh_id;
|
||||
}
|
||||
|
||||
//load a mesh from an archive
|
||||
int rc_loadMeshFromArchive(std::string archive, std::string mesh_file)
|
||||
{
|
||||
int mesh_id = -1;
|
||||
|
||||
device->getFileSystem()->addFileArchive(archive.c_str());
|
||||
irr::scene::IAnimatedMesh *mesh = SceneManager->getMesh(mesh_file.c_str());
|
||||
device->getFileSystem()->removeFileArchive((irr::u32) 0);
|
||||
|
||||
rc_mesh_obj mesh_obj;
|
||||
mesh_obj.mesh_type = RC_MESH_TYPE_ANIMATED;
|
||||
mesh_obj.mesh = mesh;
|
||||
|
||||
if(!mesh)
|
||||
return -1;
|
||||
|
||||
for(int i = 0; i < rc_mesh.size(); i++)
|
||||
{
|
||||
if(!rc_mesh[i].mesh)
|
||||
{
|
||||
mesh_id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(mesh_id < 0)
|
||||
{
|
||||
mesh_id = rc_mesh.size();
|
||||
rc_mesh.push_back(mesh_obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_mesh[mesh_id] = mesh_obj;
|
||||
}
|
||||
|
||||
return mesh_id;
|
||||
}
|
||||
|
||||
int rc_loadAN8(std::string an8_file)
|
||||
{
|
||||
int id = -1;
|
||||
|
||||
for(int i = 0; i < rc_an8.size(); i++)
|
||||
{
|
||||
if(!rc_an8[i].active)
|
||||
{
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(id < 0)
|
||||
{
|
||||
id = rc_an8.size();
|
||||
rc_an8_obj obj;
|
||||
rc_an8.push_back(obj);
|
||||
}
|
||||
|
||||
rc_an8[id].project = an8::loadAN8(an8_file);
|
||||
if(rc_an8[id].project.exists)
|
||||
{
|
||||
rc_an8[id].active = true;
|
||||
return id;
|
||||
}
|
||||
|
||||
rc_an8[id].active = false;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//load a mesh from an archive
|
||||
int rc_loadMeshFromAN8(int an8_id, std::string scene_name)
|
||||
{
|
||||
int mesh_id = -1;
|
||||
|
||||
if(an8_id < 0 || an8_id >= rc_an8.size())
|
||||
return -1;
|
||||
|
||||
if(!rc_an8[an8_id].active)
|
||||
return -1;
|
||||
|
||||
rc_mesh_obj mesh_obj;
|
||||
mesh_obj.mesh_type = RC_MESH_TYPE_ANIMATED;
|
||||
mesh_obj.mesh = an8::loadAN8Scene(device, rc_an8[an8_id].project, scene_name);
|
||||
|
||||
if(!mesh_obj.mesh)
|
||||
return -1;
|
||||
|
||||
for(int i = 0; i < rc_mesh.size(); i++)
|
||||
{
|
||||
if(!rc_mesh[i].mesh)
|
||||
{
|
||||
mesh_id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(mesh_id < 0)
|
||||
{
|
||||
mesh_id = rc_mesh.size();
|
||||
rc_mesh.push_back(mesh_obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_mesh[mesh_id] = mesh_obj;
|
||||
}
|
||||
|
||||
return mesh_id;
|
||||
}
|
||||
|
||||
int rc_getNumAN8Scenes(int an8_id)
|
||||
{
|
||||
if(an8_id < 0 || an8_id >= rc_an8.size())
|
||||
return 0;
|
||||
|
||||
if(!rc_an8[an8_id].active)
|
||||
return 0;
|
||||
|
||||
return rc_an8[an8_id].project.scenes.size();
|
||||
}
|
||||
|
||||
std::string rc_getAN8SceneName(int an8_id, int scene_num)
|
||||
{
|
||||
if(an8_id < 0 || an8_id >= rc_an8.size())
|
||||
return "";
|
||||
|
||||
if(!rc_an8[an8_id].active)
|
||||
return "";
|
||||
|
||||
if(scene_num < 0 || scene_num >= rc_an8[an8_id].project.scenes.size())
|
||||
return "";
|
||||
|
||||
return rc_an8[an8_id].project.scenes[scene_num].name;
|
||||
}
|
||||
|
||||
//delete mesh
|
||||
void rc_deleteMesh(int mesh_id)
|
||||
{
|
||||
if(mesh_id < 0 || mesh_id >= rc_mesh.size())
|
||||
return;
|
||||
|
||||
if(rc_mesh[mesh_id].mesh)
|
||||
rc_mesh[mesh_id].mesh->drop();
|
||||
|
||||
rc_mesh[mesh_id].mesh = NULL;
|
||||
rc_mesh[mesh_id].mesh_type = 0;
|
||||
|
||||
}
|
||||
|
||||
//create mesh from geometry data [TODO]
|
||||
int rc_createMesh()
|
||||
{
|
||||
irr::scene::ISkinnedMesh * mesh = SceneManager->createSkinnedMesh();
|
||||
|
||||
if(!mesh)
|
||||
return -1;
|
||||
|
||||
int mesh_id = rc_mesh.size();
|
||||
rc_mesh_obj mesh_obj;
|
||||
mesh_obj.mesh = mesh;
|
||||
mesh_obj.mesh_type = RC_MESH_TYPE_ANIMATED;
|
||||
|
||||
rc_mesh.push_back(mesh_obj);
|
||||
|
||||
return mesh_id;
|
||||
}
|
||||
|
||||
int rc_createPlaneMesh(double w, double h, double tileCount_w, double tileCount_h)
|
||||
{
|
||||
irr::scene::IAnimatedMesh* mesh = SceneManager->addHillPlaneMesh( "plane",
|
||||
irr::core::dimension2d<irr::f32>(w/tileCount_w, h/tileCount_h),
|
||||
irr::core::dimension2d<irr::u32>(tileCount_w, tileCount_h));
|
||||
|
||||
if(!mesh)
|
||||
return -1;
|
||||
|
||||
int mesh_id = rc_mesh.size();
|
||||
rc_mesh_obj mesh_obj;
|
||||
mesh_obj.mesh = mesh;
|
||||
mesh_obj.mesh_type = RC_MESH_TYPE_ANIMATED;
|
||||
|
||||
rc_mesh.push_back(mesh_obj);
|
||||
|
||||
return mesh_id;
|
||||
}
|
||||
|
||||
|
||||
//create mesh from geometry data [TODO]
|
||||
bool rc_addMeshBuffer(int mesh_id, int vertex_count, double* vertex_data, double* normal_data, double* uv_data, int index_count, double* index_data)
|
||||
{
|
||||
irr::scene::ISkinnedMesh * mesh = (irr::scene::ISkinnedMesh*) rc_mesh[mesh_id].mesh;
|
||||
|
||||
irr::scene::SSkinMeshBuffer* mbuf = mesh->addMeshBuffer();
|
||||
|
||||
if(!mbuf)
|
||||
{
|
||||
mesh->drop();
|
||||
return false;
|
||||
}
|
||||
|
||||
irr::core::array<irr::video::S3DVertex> vertices;
|
||||
irr::core::array<irr::u16> indices;
|
||||
|
||||
for(int i = 0; i < vertex_count; i++)
|
||||
{
|
||||
irr::video::S3DVertex v;
|
||||
v.Pos = irr::core::vector3df( (irr::f32) vertex_data[i*3], (irr::f32) vertex_data[i*3+1], (irr::f32) vertex_data[i*3+2] );
|
||||
v.Normal = irr::core::vector3df( (irr::f32) normal_data[i*3], (irr::f32) normal_data[i*3+1], (irr::f32) normal_data[i*3+2] );
|
||||
v.TCoords = irr::core::vector2df( (irr::f32) uv_data[i*2], (irr::f32) uv_data[i*2+1] );
|
||||
vertices.push_back(v);
|
||||
}
|
||||
|
||||
for(int i = 0; i < index_count; i++)
|
||||
{
|
||||
indices.push_back( (irr::u16) index_data[i] );
|
||||
}
|
||||
|
||||
if(indices.size() > 0)
|
||||
{
|
||||
for(int i = 0; i < vertices.size(); i++)
|
||||
mbuf->Vertices_Standard.push_back(vertices[i]);
|
||||
|
||||
for(int i = 0; i < indices.size(); i++)
|
||||
mbuf->Indices.push_back(indices[i]);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // RC_MESH_H_INCLUDED
|
||||
@@ -20,4 +20,16 @@
|
||||
#define RC_MOBILE
|
||||
#endif
|
||||
|
||||
#define RC_PI 3.14159265359
|
||||
|
||||
inline double rc_util_radians(double degrees)
|
||||
{
|
||||
return degrees * (RC_PI/180);
|
||||
}
|
||||
|
||||
inline double rc_util_degrees(double radians)
|
||||
{
|
||||
return radians * (180/RC_PI);
|
||||
}
|
||||
|
||||
#endif // RC_OS_DEFINES_H_INCLUDED
|
||||
|
||||
863
rcbasic_runtime/rc_particles.h
Normal file
863
rcbasic_runtime/rc_particles.h
Normal file
@@ -0,0 +1,863 @@
|
||||
#ifndef RC_PARTICLES_H_INCLUDED
|
||||
#define RC_PARTICLES_H_INCLUDED
|
||||
|
||||
int rc_getParticleType(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.particle_type;
|
||||
}
|
||||
|
||||
void rc_startParticleEmitter(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
|
||||
bool everyMeshVertex = rc_actor[actor].particle_properties.everyMeshVertex;
|
||||
irr::s32 mbNumber = rc_actor[actor].particle_properties.mbNumber;
|
||||
irr::f32 normalDirectionModifier = rc_actor[actor].particle_properties.normalDirectionModifier;
|
||||
bool useNormalDirection = rc_actor[actor].particle_properties.useNormalDirection;
|
||||
irr::s32 mesh_id = rc_actor[actor].particle_properties.mesh_id;
|
||||
irr::core::vector3df direction = rc_actor[actor].particle_properties.direction;
|
||||
irr::u32 minParticlesPerSecond = rc_actor[actor].particle_properties.minParticlesPerSecond;
|
||||
irr::u32 maxParticlesPerSecond = rc_actor[actor].particle_properties.maxParticlesPerSecond;
|
||||
irr::video::SColor minStartColor = rc_actor[actor].particle_properties.minStartColor;
|
||||
irr::video::SColor maxStartColor = rc_actor[actor].particle_properties.maxStartColor;
|
||||
irr::u32 lifeTimeMin = rc_actor[actor].particle_properties.lifeTimeMin;
|
||||
irr::u32 lifeTimeMax = rc_actor[actor].particle_properties.lifeTimeMax;
|
||||
irr::s32 maxAngleDegrees = rc_actor[actor].particle_properties.maxAngleDegrees;
|
||||
irr::core::dimension2df minStartSize = rc_actor[actor].particle_properties.minStartSize;
|
||||
irr::core::dimension2df maxStartSize = rc_actor[actor].particle_properties.maxStartSize;
|
||||
irr::core::vector3df center = rc_actor[actor].particle_properties.center;
|
||||
irr::f32 radius = rc_actor[actor].particle_properties.radius;
|
||||
irr::f32 ringThickness = rc_actor[actor].particle_properties.ringThickness;
|
||||
irr::core::aabbox3df box = rc_actor[actor].particle_properties.box;
|
||||
irr::core::vector3df normal = rc_actor[actor].particle_properties.normal;
|
||||
irr::f32 length = rc_actor[actor].particle_properties.length;
|
||||
bool outlineOnly = rc_actor[actor].particle_properties.outlineOnly;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*) rc_actor[actor].mesh_node;
|
||||
|
||||
irr::scene::IParticleEmitter* em = NULL;
|
||||
|
||||
switch(rc_actor[actor].particle_properties.particle_type)
|
||||
{
|
||||
case RC_PARTICLE_TYPE_POINT:
|
||||
em = node->createPointEmitter(direction, minParticlesPerSecond, maxParticlesPerSecond,
|
||||
minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
|
||||
maxAngleDegrees, minStartSize, maxStartSize);
|
||||
node->setEmitter(em);
|
||||
em->drop();
|
||||
break;
|
||||
|
||||
case RC_PARTICLE_TYPE_BOX:
|
||||
em = node->createBoxEmitter(box, direction, minParticlesPerSecond, maxParticlesPerSecond,
|
||||
minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
|
||||
maxAngleDegrees, minStartSize, maxStartSize);
|
||||
node->setEmitter(em);
|
||||
em->drop();
|
||||
break;
|
||||
|
||||
case RC_PARTICLE_TYPE_SPHERE:
|
||||
em = node->createSphereEmitter(center, radius, direction,
|
||||
minParticlesPerSecond, maxParticlesPerSecond,
|
||||
minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
|
||||
maxAngleDegrees, minStartSize, maxStartSize);
|
||||
node->setEmitter(em);
|
||||
em->drop();
|
||||
break;
|
||||
|
||||
case RC_PARTICLE_TYPE_CYLINDER:
|
||||
em = node->createCylinderEmitter(center, radius, normal, length, outlineOnly,
|
||||
direction, minParticlesPerSecond, maxParticlesPerSecond,
|
||||
minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
|
||||
maxAngleDegrees, minStartSize, maxStartSize);
|
||||
node->setEmitter(em);
|
||||
em->drop();
|
||||
break;
|
||||
|
||||
case RC_PARTICLE_TYPE_MESH:
|
||||
if(mesh_id < 0 || mesh_id >= rc_mesh.size())
|
||||
return;
|
||||
|
||||
if(!rc_mesh[mesh_id].mesh)
|
||||
return;
|
||||
|
||||
em = node->createMeshEmitter(rc_mesh[mesh_id].mesh, useNormalDirection,
|
||||
direction, normalDirectionModifier, mbNumber, everyMeshVertex,
|
||||
minParticlesPerSecond, maxParticlesPerSecond,
|
||||
minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
|
||||
maxAngleDegrees, minStartSize, maxStartSize);
|
||||
node->setEmitter(em);
|
||||
em->drop();
|
||||
break;
|
||||
|
||||
case RC_PARTICLE_TYPE_RING:
|
||||
em = node->createRingEmitter(center, radius, ringThickness,
|
||||
direction, minParticlesPerSecond, maxParticlesPerSecond,
|
||||
minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
|
||||
maxAngleDegrees, minStartSize, maxStartSize);
|
||||
node->setEmitter(em);
|
||||
em->drop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_stopParticleEmitter(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*) rc_actor[actor].mesh_node;
|
||||
node->setEmitter(0);
|
||||
}
|
||||
|
||||
void rc_setParticleDirection(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.direction.set(x, y, z);
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setDirection( rc_actor[actor].particle_properties.direction );
|
||||
}
|
||||
|
||||
void rc_getParticleDirection(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
*x = rc_actor[actor].particle_properties.direction.X;
|
||||
*y = rc_actor[actor].particle_properties.direction.Y;
|
||||
*z = rc_actor[actor].particle_properties.direction.Z;
|
||||
}
|
||||
|
||||
void rc_useParticleEveryMeshVertex(int actor, bool flag)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].particle_properties.particle_type != RC_PARTICLE_TYPE_MESH)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.everyMeshVertex = flag;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
{
|
||||
irr::scene::IParticleMeshEmitter* em = (irr::scene::IParticleMeshEmitter*)node->getEmitter();
|
||||
em->setEveryMeshVertex(rc_actor[actor].particle_properties.everyMeshVertex);
|
||||
}
|
||||
}
|
||||
|
||||
bool rc_particleIsUsingEveryMeshVertex(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return false;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return false;
|
||||
|
||||
if(rc_actor[actor].particle_properties.particle_type != RC_PARTICLE_TYPE_MESH)
|
||||
return false;
|
||||
|
||||
return rc_actor[actor].particle_properties.everyMeshVertex;
|
||||
|
||||
}
|
||||
|
||||
void rc_setParticleNormalDirectionMod(int actor, double mod)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].particle_properties.particle_type != RC_PARTICLE_TYPE_MESH)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.normalDirectionModifier = mod;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
{
|
||||
irr::scene::IParticleMeshEmitter* em = (irr::scene::IParticleMeshEmitter*)node->getEmitter();
|
||||
em->setNormalDirectionModifier(rc_actor[actor].particle_properties.normalDirectionModifier);
|
||||
}
|
||||
}
|
||||
|
||||
double rc_getParticleNormalDirectionMod(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].particle_properties.particle_type != RC_PARTICLE_TYPE_MESH)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.normalDirectionModifier;
|
||||
}
|
||||
|
||||
void rc_useParticleNormalDirection(int actor, bool flag)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].particle_properties.particle_type != RC_PARTICLE_TYPE_MESH)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.useNormalDirection = flag;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
{
|
||||
irr::scene::IParticleMeshEmitter* em = (irr::scene::IParticleMeshEmitter*)node->getEmitter();
|
||||
em->setUseNormalDirection(rc_actor[actor].particle_properties.useNormalDirection);
|
||||
}
|
||||
}
|
||||
|
||||
bool rc_particleIsUsingNormalDirection(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return false;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return false;
|
||||
|
||||
if(rc_actor[actor].particle_properties.particle_type != RC_PARTICLE_TYPE_MESH)
|
||||
return false;
|
||||
|
||||
return rc_actor[actor].particle_properties.useNormalDirection;
|
||||
}
|
||||
|
||||
void rc_setParticleMesh(int actor, int mesh)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].particle_properties.particle_type != RC_PARTICLE_TYPE_MESH)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.mesh_id = mesh;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
{
|
||||
if(mesh < 0 || mesh >= rc_mesh.size())
|
||||
return;
|
||||
|
||||
if(!rc_mesh[mesh].mesh)
|
||||
return;
|
||||
|
||||
irr::scene::IParticleMeshEmitter* em = (irr::scene::IParticleMeshEmitter*)node->getEmitter();
|
||||
em->setMesh(rc_mesh[mesh].mesh);
|
||||
}
|
||||
}
|
||||
|
||||
void rc_setMinParticlesPerSecond(int actor, Uint32 minParticlesPerSecond)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.minParticlesPerSecond = minParticlesPerSecond;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMinParticlesPerSecond(minParticlesPerSecond);
|
||||
}
|
||||
|
||||
Uint32 rc_getMinParticlesPerSecond(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.minParticlesPerSecond;
|
||||
}
|
||||
|
||||
void rc_setMaxParticlesPerSecond(int actor, Uint32 maxParticlesPerSecond)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.maxParticlesPerSecond = maxParticlesPerSecond;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMaxParticlesPerSecond(maxParticlesPerSecond);
|
||||
}
|
||||
|
||||
Uint32 rc_getMaxParticlesPerSecond(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.maxParticlesPerSecond;
|
||||
}
|
||||
|
||||
void rc_setParticleMinStartColor(int actor, Uint32 color)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.minStartColor = irr::video::SColor(color);
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMinStartColor(rc_actor[actor].particle_properties.minStartColor);
|
||||
}
|
||||
|
||||
Uint32 rc_getParticleMinStartColor(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.minStartColor.color;
|
||||
}
|
||||
|
||||
void rc_setParticleMaxStartColor(int actor, Uint32 color)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.maxStartColor = irr::video::SColor(color);
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMaxStartColor(rc_actor[actor].particle_properties.maxStartColor);
|
||||
}
|
||||
|
||||
Uint32 rc_getParticleMaxStartColor(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.maxStartColor.color;
|
||||
}
|
||||
|
||||
void rc_setParticleMinLife(int actor, Uint32 minLife)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.lifeTimeMin = minLife;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMinLifeTime(rc_actor[actor].particle_properties.lifeTimeMin);
|
||||
}
|
||||
|
||||
Uint32 rc_getParticleMinLife(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.lifeTimeMin;
|
||||
}
|
||||
|
||||
void rc_setParticleMaxLife(int actor, Uint32 maxLife)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.lifeTimeMax = maxLife;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMaxLifeTime(rc_actor[actor].particle_properties.lifeTimeMax);
|
||||
}
|
||||
|
||||
Uint32 rc_getParticleMaxLife(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.lifeTimeMax;
|
||||
}
|
||||
|
||||
void rc_setParticleMaxAngle(int actor, int maxAngle)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.maxAngleDegrees = maxAngle;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMaxAngleDegrees(rc_actor[actor].particle_properties.maxAngleDegrees);
|
||||
}
|
||||
|
||||
int rc_getParticleMaxAngle(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.maxAngleDegrees;
|
||||
}
|
||||
|
||||
void rc_setParticleMinStartSize(int actor, double w, double h)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.minStartSize = irr::core::dimension2df(w, h);
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMinStartSize(rc_actor[actor].particle_properties.minStartSize);
|
||||
}
|
||||
|
||||
void rc_getParticleMinStartSize(int actor, double* w, double* h)
|
||||
{
|
||||
*w = 0;
|
||||
*h = 0;
|
||||
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
*w = rc_actor[actor].particle_properties.minStartSize.Width;
|
||||
*h = rc_actor[actor].particle_properties.minStartSize.Height;
|
||||
}
|
||||
|
||||
void rc_setParticleMaxStartSize(int actor, double w, double h)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.maxStartSize = irr::core::dimension2df(w, h);
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(node->getEmitter())
|
||||
node->getEmitter()->setMaxStartSize(rc_actor[actor].particle_properties.maxStartSize);
|
||||
}
|
||||
|
||||
void rc_getParticleMaxStartSize(int actor, double* w, double* h)
|
||||
{
|
||||
*w = 0;
|
||||
*h = 0;
|
||||
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
*w = rc_actor[actor].particle_properties.maxStartSize.Width;
|
||||
*h = rc_actor[actor].particle_properties.maxStartSize.Height;
|
||||
}
|
||||
|
||||
void rc_setParticleCenter(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.center = irr::core::vector3df(x, y, z);
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(!node->getEmitter())
|
||||
return;
|
||||
|
||||
|
||||
switch(rc_actor[actor].particle_properties.particle_type)
|
||||
{
|
||||
case RC_PARTICLE_TYPE_SPHERE:
|
||||
{
|
||||
irr::scene::IParticleSphereEmitter* em = (irr::scene::IParticleSphereEmitter*)node->getEmitter();
|
||||
em->setCenter(rc_actor[actor].particle_properties.center);
|
||||
}
|
||||
break;
|
||||
case RC_PARTICLE_TYPE_CYLINDER:
|
||||
{
|
||||
irr::scene::IParticleCylinderEmitter* em = (irr::scene::IParticleCylinderEmitter*)node->getEmitter();
|
||||
em->setCenter(rc_actor[actor].particle_properties.center);
|
||||
}
|
||||
break;
|
||||
case RC_PARTICLE_TYPE_RING:
|
||||
{
|
||||
irr::scene::IParticleRingEmitter* em = (irr::scene::IParticleRingEmitter*)node->getEmitter();
|
||||
em->setCenter(rc_actor[actor].particle_properties.center);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getParticleCenter(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
*x = rc_actor[actor].particle_properties.center.X;
|
||||
*y = rc_actor[actor].particle_properties.center.Y;
|
||||
*z = rc_actor[actor].particle_properties.center.Z;
|
||||
}
|
||||
|
||||
void rc_setParticleRadius(int actor, double radius)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.radius = radius;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(!node->getEmitter())
|
||||
return;
|
||||
|
||||
|
||||
switch(rc_actor[actor].particle_properties.particle_type)
|
||||
{
|
||||
case RC_PARTICLE_TYPE_SPHERE:
|
||||
{
|
||||
irr::scene::IParticleSphereEmitter* em = (irr::scene::IParticleSphereEmitter*)node->getEmitter();
|
||||
em->setRadius(rc_actor[actor].particle_properties.radius);
|
||||
}
|
||||
break;
|
||||
case RC_PARTICLE_TYPE_CYLINDER:
|
||||
{
|
||||
irr::scene::IParticleCylinderEmitter* em = (irr::scene::IParticleCylinderEmitter*)node->getEmitter();
|
||||
em->setRadius(rc_actor[actor].particle_properties.radius);
|
||||
}
|
||||
break;
|
||||
case RC_PARTICLE_TYPE_RING:
|
||||
{
|
||||
irr::scene::IParticleRingEmitter* em = (irr::scene::IParticleRingEmitter*)node->getEmitter();
|
||||
em->setRadius(rc_actor[actor].particle_properties.radius);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double rc_getParticleRadius(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.radius;
|
||||
}
|
||||
|
||||
void rc_setParticleRingThickness(int actor, double ringThickness)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.ringThickness = ringThickness;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(!node->getEmitter())
|
||||
return;
|
||||
|
||||
|
||||
switch(rc_actor[actor].particle_properties.particle_type)
|
||||
{
|
||||
case RC_PARTICLE_TYPE_RING:
|
||||
{
|
||||
irr::scene::IParticleRingEmitter* em = (irr::scene::IParticleRingEmitter*)node->getEmitter();
|
||||
em->setRingThickness(rc_actor[actor].particle_properties.ringThickness);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double rc_getParticleRingThickness(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.ringThickness;
|
||||
}
|
||||
|
||||
void rc_setParticleBox(int actor, double min_x, double min_y, double min_z, double max_x, double max_y, double max_z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.box = irr::core::aabbox3df(min_x, min_y, min_z, max_x, max_y, max_z);
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(!node->getEmitter())
|
||||
return;
|
||||
|
||||
|
||||
switch(rc_actor[actor].particle_properties.particle_type)
|
||||
{
|
||||
case RC_PARTICLE_TYPE_BOX:
|
||||
{
|
||||
irr::scene::IParticleBoxEmitter* em = (irr::scene::IParticleBoxEmitter*)node->getEmitter();
|
||||
em->setBox(rc_actor[actor].particle_properties.box);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getParticleBox(int actor, double* min_x, double* min_y, double* min_z, double* max_x, double* max_y, double* max_z)
|
||||
{
|
||||
*min_x = 0;
|
||||
*min_y = 0;
|
||||
*min_z = 0;
|
||||
|
||||
*max_x = 0;
|
||||
*max_y = 0;
|
||||
*max_z = 0;
|
||||
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
*min_x = rc_actor[actor].particle_properties.box.MinEdge.X;
|
||||
*min_y = rc_actor[actor].particle_properties.box.MinEdge.Y;
|
||||
*min_z = rc_actor[actor].particle_properties.box.MinEdge.Z;
|
||||
|
||||
*max_x = rc_actor[actor].particle_properties.box.MaxEdge.X;
|
||||
*max_y = rc_actor[actor].particle_properties.box.MaxEdge.Y;
|
||||
*max_z = rc_actor[actor].particle_properties.box.MaxEdge.Z;
|
||||
}
|
||||
|
||||
void rc_setParticleNormal(int actor, double x, double y, double z)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.normal.set(x, y, z);
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(!node->getEmitter())
|
||||
return;
|
||||
|
||||
|
||||
switch(rc_actor[actor].particle_properties.particle_type)
|
||||
{
|
||||
case RC_PARTICLE_TYPE_CYLINDER:
|
||||
{
|
||||
irr::scene::IParticleCylinderEmitter* em = (irr::scene::IParticleCylinderEmitter*)node->getEmitter();
|
||||
em->setNormal(rc_actor[actor].particle_properties.normal);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_getParticleNormal(int actor, double* x, double* y, double* z)
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*z = 0;
|
||||
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
*x = rc_actor[actor].particle_properties.normal.X;
|
||||
*y = rc_actor[actor].particle_properties.normal.Y;
|
||||
*z = rc_actor[actor].particle_properties.normal.Z;
|
||||
}
|
||||
|
||||
void rc_setParticleLength(int actor, double length)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.length = length;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(!node->getEmitter())
|
||||
return;
|
||||
|
||||
|
||||
switch(rc_actor[actor].particle_properties.particle_type)
|
||||
{
|
||||
case RC_PARTICLE_TYPE_CYLINDER:
|
||||
{
|
||||
irr::scene::IParticleCylinderEmitter* em = (irr::scene::IParticleCylinderEmitter*)node->getEmitter();
|
||||
em->setLength(rc_actor[actor].particle_properties.length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double rc_getParticleLength(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return 0;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return 0;
|
||||
|
||||
return rc_actor[actor].particle_properties.length;
|
||||
}
|
||||
|
||||
void rc_useParticleOutlineOnly(int actor, bool flag)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return;
|
||||
|
||||
rc_actor[actor].particle_properties.outlineOnly = flag;
|
||||
|
||||
irr::scene::IParticleSystemSceneNode* node = (irr::scene::IParticleSystemSceneNode*)rc_actor[actor].mesh_node;
|
||||
|
||||
if(!node->getEmitter())
|
||||
return;
|
||||
|
||||
|
||||
switch(rc_actor[actor].particle_properties.particle_type)
|
||||
{
|
||||
case RC_PARTICLE_TYPE_CYLINDER:
|
||||
{
|
||||
irr::scene::IParticleCylinderEmitter* em = (irr::scene::IParticleCylinderEmitter*)node->getEmitter();
|
||||
em->setOutlineOnly(flag);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool rc_particleIsUsingOutlineOnly(int actor)
|
||||
{
|
||||
if(actor < 0 || actor >= rc_actor.size())
|
||||
return false;
|
||||
|
||||
if(rc_actor[actor].node_type != RC_NODE_TYPE_PARTICLE)
|
||||
return false;
|
||||
|
||||
return rc_actor[actor].particle_properties.outlineOnly;
|
||||
}
|
||||
|
||||
#endif // RC_PARTICLES_H_INCLUDED
|
||||
35
rcbasic_runtime/rc_physics3D_base.h
Normal file
35
rcbasic_runtime/rc_physics3D_base.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef RC_PHYSICS3D_BASE_H_INCLUDED
|
||||
#define RC_PHYSICS3D_BASE_H_INCLUDED
|
||||
|
||||
#include "rc_gfx_core.h"
|
||||
|
||||
//Set Gravity
|
||||
void rc_setGravity3D(double x, double y, double z)
|
||||
{
|
||||
rc_physics3D.world->setGravity(irr::core::vector3d<f32>(x, y, z));
|
||||
}
|
||||
|
||||
void rc_getGravity3D(double* x, double* y, double* z)
|
||||
{
|
||||
btVector3 v = rc_physics3D.world->getPointer()->getGravity();
|
||||
*x = v.getX();
|
||||
*y = v.getY();
|
||||
*z = v.getZ();
|
||||
}
|
||||
|
||||
void rc_setWorld3DDeltaTime(double dt)
|
||||
{
|
||||
rc_physics3D.DeltaTime = dt;
|
||||
}
|
||||
|
||||
void rc_setWorld3DMaxSubSteps(double steps)
|
||||
{
|
||||
rc_physics3D.maxSubSteps = steps;
|
||||
}
|
||||
|
||||
void rc_setWorld3DTimeStep(double ts)
|
||||
{
|
||||
rc_physics3D.fixedTimeStep = ts;
|
||||
}
|
||||
|
||||
#endif // RC_PHYSICS3D_BASE_H_INCLUDED
|
||||
53
rcbasic_runtime/rc_scene.h
Normal file
53
rcbasic_runtime/rc_scene.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef RC_SCENE_H_INCLUDED
|
||||
#define RC_SCENE_H_INCLUDED
|
||||
|
||||
void rc_addSceneSkyBox(int img_top, int img_bottom, int img_left, int img_right, int img_front, int img_back)
|
||||
{
|
||||
if(!SceneManager)
|
||||
return;
|
||||
|
||||
if(rc_scene_properties.sky)
|
||||
return;
|
||||
|
||||
irr::video::ITexture* tp = rc_image[img_top].image;
|
||||
irr::video::ITexture* bt = rc_image[img_bottom].image;
|
||||
irr::video::ITexture* lf = rc_image[img_left].image;
|
||||
irr::video::ITexture* rt = rc_image[img_right].image;
|
||||
irr::video::ITexture* ft = rc_image[img_front].image;
|
||||
irr::video::ITexture* bk = rc_image[img_back].image;
|
||||
rc_scene_properties.sky = SceneManager->addSkyBoxSceneNode(tp, bt, lf, rt, ft, bk);
|
||||
}
|
||||
|
||||
void rc_addSceneSkyDome(int img)
|
||||
{
|
||||
if(!SceneManager)
|
||||
return;
|
||||
|
||||
if(rc_scene_properties.sky)
|
||||
return;
|
||||
|
||||
irr::video::ITexture* texture = rc_image[img].image;
|
||||
rc_scene_properties.sky = SceneManager->addSkyDomeSceneNode(texture);
|
||||
}
|
||||
|
||||
void rc_addSceneSkyDomeEx(int img, Uint32 horiRes, Uint32 vertRes, double txPercentage, double spherePercentage, double radius)
|
||||
{
|
||||
if(!SceneManager)
|
||||
return;
|
||||
|
||||
if(rc_scene_properties.sky)
|
||||
return;
|
||||
|
||||
irr::video::ITexture* texture = rc_image[img].image;
|
||||
rc_scene_properties.sky = SceneManager->addSkyDomeSceneNode(texture, horiRes, vertRes, txPercentage, spherePercentage, radius);
|
||||
}
|
||||
|
||||
void rc_removeSceneSky()
|
||||
{
|
||||
if(rc_scene_properties.sky)
|
||||
rc_scene_properties.sky->remove();
|
||||
|
||||
rc_scene_properties.sky = NULL;
|
||||
}
|
||||
|
||||
#endif // RC_SCENE_H_INCLUDED
|
||||
@@ -572,6 +572,9 @@ void rc_setSpriteRotation(int spr_id, double angle)
|
||||
if(!rc_sprite[spr_id].active)
|
||||
return;
|
||||
|
||||
//convert angle to radians
|
||||
angle = rc_util_radians(angle);
|
||||
|
||||
rc_sprite[spr_id].physics.body->SetTransform(rc_sprite[spr_id].physics.body->GetPosition(), angle);
|
||||
}
|
||||
|
||||
@@ -583,6 +586,9 @@ void rc_rotateSprite(int spr_id, double angle)
|
||||
if(!rc_sprite[spr_id].active)
|
||||
return;
|
||||
|
||||
//convert angle to radians
|
||||
angle = rc_util_radians(angle);
|
||||
|
||||
float new_angle = rc_sprite[spr_id].physics.body->GetAngle() + angle;
|
||||
rc_sprite[spr_id].physics.body->SetTransform(rc_sprite[spr_id].physics.body->GetPosition(), new_angle);
|
||||
}
|
||||
@@ -595,7 +601,7 @@ double rc_getSpriteRotation(int spr_id)
|
||||
if(!rc_sprite[spr_id].active)
|
||||
return 0;
|
||||
|
||||
return rc_sprite[spr_id].physics.body->GetAngle();
|
||||
return rc_util_degrees(rc_sprite[spr_id].physics.body->GetAngle());
|
||||
}
|
||||
|
||||
void rc_setSpriteScale(int spr_id, double x, double y)
|
||||
@@ -923,15 +929,6 @@ void drawSprites(int canvas_id)
|
||||
VideoDriver->setRenderTarget(rc_canvas[0].texture, false, false);
|
||||
}
|
||||
|
||||
//NOTE TO TBIRD
|
||||
// 1. Each sprite has a Box2D body. You can look in "rc_sprite2D.h" to see how a sprite is structured.
|
||||
// 2. A box2D world is setup for each canvas. So a sprite will be attached to the canvas thats active when its created. When that canvas is destroyed, so is the sprite.
|
||||
// 3. By default, I have the sprite.physics_enabled attribute set to false. I feel like it makes sense to have a user intentionally enable physics since a user may not want physics for every sprite.
|
||||
// 4. The sprite.visible attribute only determines whether to draw the sprite. The physics simulation will still happen each frame unless physics are disabled.
|
||||
// 5. Don't change the value of sprite.active. Its used to check whether a sprite exists or not. I have an array of sprites in rc_sprite2D.h and if the active attribute is set to false, I reuse that slot to create a new sprite. If there is no inactive sprites in the array then I add a new sprite index to the array.
|
||||
// 6. The time step, velocity Iterations, and position iterations are part of the canvas.physics2D attribute. You will need to make functions to allow the user to change those.
|
||||
// 7. If you want to modify how sprites are rendered then you can just change the drawSprites() function above these notes.
|
||||
|
||||
//-----------------------------END OF SPRITE STUFF------------------------------------------------------------------------------
|
||||
|
||||
#endif // RC_SPRITELIB_H_INCLUDED
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "rc_os_defines.h"
|
||||
|
||||
#define RC_PI 3.14159265359
|
||||
//#define RC_PI 3.14159265359 //Moved to rc_os_defines.h
|
||||
|
||||
#ifdef RC_MAC
|
||||
#define RC_GETCWD
|
||||
|
||||
Reference in New Issue
Block a user