Ignore:
Timestamp:
Sep 9, 2013, 12:30:11 AM (6 years ago)
Author:
touky
Message:

btPhysTest : Added a new test mode called "CAT_MODE". Try it out at your own risks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/physics/easyphysics.cpp

    r2816 r2879  
    3939    m_motion_state(NULL),
    4040    m_mass(.0f),
     41    m_hit_restitution(.0f),
    4142    m_collision_group(1),
    4243    m_collision_mask(1),
     
    175176//Mass related functions
    176177//--
    177 //Set Shape functions
     178//Set Mass functions
    178179void EasyPhysic::SetMass(float mass)
    179180{
     
    183184    {
    184185        SetLocalInertia(m_mass);
    185         m_rigid_body->setMassProps(mass, m_local_inertia);
    186     }
    187 }
    188 
    189 //-------------------------------------------------------------------------
    190 //Final conversion pass functons : Body related
     186        m_rigid_body->setMassProps(m_mass, m_local_inertia);
     187    }
     188}
     189
     190//-------------------------------------------------------------------------
     191//Hit restitution functions
     192//--
     193//Set Hit Restitution functions
     194void EasyPhysic::SetHitRestitution(float hit_restitution)
     195{
     196    m_hit_restitution = hit_restitution;
     197
     198    if (m_rigid_body)
     199    {
     200        m_rigid_body->setRestitution(m_hit_restitution);
     201    }
     202}
     203
     204//-------------------------------------------------------------------------
     205//Final conversion pass functions : Body related
    191206//--
    192207
     
    201216
    202217    btRigidBody::btRigidBodyConstructionInfo NewInfos(m_mass, m_motion_state, m_collision_shape, m_local_inertia);
     218    NewInfos.m_restitution = m_hit_restitution;
    203219    m_rigid_body = new btRigidBody(NewInfos);
    204220    m_collision_object = m_rigid_body;
     
    330346}
    331347
     348//-------------------------------------------------------------------------
     349//Force/Impulse functions
     350//--
     351void EasyPhysic::AddImpulse(const lol::vec3& impulse)
     352{
     353    if (m_rigid_body)
     354        m_rigid_body->applyCentralImpulse(LOL2BT_VEC3(impulse));
     355}
     356
     357void EasyPhysic::AddImpulse(const lol::vec3& impulse, const lol::vec3& rel_pos)
     358{
     359    if (m_rigid_body)
     360        m_rigid_body->applyImpulse(LOL2BT_VEC3(impulse), LOL2BTU_VEC3(rel_pos));
     361}
     362
     363void EasyPhysic::AddImpulseTorque(const lol::vec3& torque)
     364{
     365    if (m_rigid_body)
     366        m_rigid_body->applyTorqueImpulse(LOL2BT_VEC3(torque));
     367}
     368
     369//--
     370void EasyPhysic::AddForce(const lol::vec3& force)
     371{
     372    if (m_rigid_body)
     373        m_rigid_body->applyCentralForce(LOL2BT_VEC3(force));
     374}
     375
     376void EasyPhysic::AddForce(const lol::vec3& force, const lol::vec3& rel_pos)
     377{
     378    if (m_rigid_body)
     379        m_rigid_body->applyForce(LOL2BT_VEC3(force), LOL2BTU_VEC3(rel_pos));
     380}
     381
     382void EasyPhysic::AddForceTorque(const lol::vec3& torque)
     383{
     384    if (m_rigid_body)
     385        m_rigid_body->applyTorque(LOL2BT_VEC3(torque));
     386}
     387
     388//-------------------------------------------------------------------------
     389//Movements getter
     390//--
     391lol::vec3 EasyPhysic::GetLinearVelocity() const
     392{
     393    if (m_rigid_body)
     394        return BT2LOL_VEC3(m_rigid_body->getLinearVelocity());
     395    return lol::vec3(.0f);
     396}
     397
     398lol::vec3 EasyPhysic::GetLinearForce() const
     399{
     400    if (m_rigid_body)
     401        return BT2LOL_VEC3(m_rigid_body->getTotalForce());
     402    return lol::vec3(.0f);
     403}
     404
     405lol::vec3 EasyPhysic::GetAngularVelocity() const
     406{
     407    if (m_rigid_body)
     408        return BT2LOL_VEC3(m_rigid_body->getAngularVelocity());
     409    return lol::vec3(.0f);
     410}
     411
     412lol::vec3 EasyPhysic::GetAngularForce() const
     413{
     414    if (m_rigid_body)
     415        return BT2LOL_VEC3(m_rigid_body->getTotalTorque());
     416    return lol::vec3(.0f);
     417}
     418
    332419//Set Local Inertia
    333420void EasyPhysic::SetLocalInertia(float mass)
Note: See TracChangeset for help on using the changeset viewer.