Add initial prototype.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#include "bullet-conversions.h"
|
||||
|
||||
|
||||
btVector3
|
||||
to_btVector3 (Vector_3* From)
|
||||
{
|
||||
return btVector3 (From->x,
|
||||
From->y,
|
||||
From->z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vector_3
|
||||
to_Vector_3 (btVector3& From)
|
||||
{
|
||||
Vector_3 Result;
|
||||
|
||||
Result.x = From [0];
|
||||
Result.y = From [1];
|
||||
Result.z = From [2];
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
btTypedConstraint*
|
||||
to_bullet_Joint (Joint* From)
|
||||
{
|
||||
return (btTypedConstraint*) From;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Joint*
|
||||
to_bt3_Joint (btTypedConstraint* From)
|
||||
{
|
||||
return (Joint*) From;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
btRigidBody*
|
||||
to_bullet_Object (Object* From)
|
||||
{
|
||||
return (btRigidBody*) From;
|
||||
}
|
||||
|
||||
|
||||
Object*
|
||||
to_bt3_Object (btRigidBody* From)
|
||||
{
|
||||
return (Object*) From;
|
||||
}
|
||||
|
||||
|
||||
23
3-mid/physics/implement/bullet/source/c/bullet-conversions.h
Normal file
23
3-mid/physics/implement/bullet/source/c/bullet-conversions.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_BULLET_CONVERSIONS_H
|
||||
#define C_BULLET_CONVERSIONS_H
|
||||
|
||||
#include "bullet-joint.h"
|
||||
#include <BulletDynamics/ConstraintSolver/btHingeConstraint.h>
|
||||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
||||
|
||||
|
||||
|
||||
btVector3 to_btVector3 (Vector_3* From);
|
||||
Vector_3 to_Vector_3 (btVector3& From);
|
||||
|
||||
|
||||
btTypedConstraint* to_bullet_Joint (Joint* From);
|
||||
Joint* to_bt3_Joint (btTypedConstraint* From);
|
||||
|
||||
|
||||
btRigidBody* to_bullet_Object (Object* From);
|
||||
Object* to_bt3_Object (btRigidBody* From);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
326
3-mid/physics/implement/bullet/source/c/bullet-joint.cpp
Normal file
326
3-mid/physics/implement/bullet/source/c/bullet-joint.cpp
Normal file
@@ -0,0 +1,326 @@
|
||||
#include "bullet-joint.h"
|
||||
#include "bullet-space.h"
|
||||
#include "bullet-conversions.h"
|
||||
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
#include <BulletDynamics/ConstraintSolver/btHingeConstraint.h>
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/////////
|
||||
/// Forge
|
||||
//
|
||||
|
||||
|
||||
Joint*
|
||||
b3d_new_hinge_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Matrix_4x4* Frame_A,
|
||||
Matrix_4x4* Frame_B)
|
||||
{
|
||||
btTransform Trans_A;
|
||||
btTransform Trans_B;
|
||||
|
||||
Trans_A.setFromOpenGLMatrix (&Frame_A->m00);
|
||||
Trans_B.setFromOpenGLMatrix (&Frame_B->m00);
|
||||
|
||||
btTypedConstraint* Self = (btTypedConstraint*) (new btHingeConstraint (*to_bullet_Object (Object_A),
|
||||
*to_bullet_Object (Object_B),
|
||||
Trans_A,
|
||||
Trans_B));
|
||||
return (Joint*) Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Joint*
|
||||
b3d_new_space_hinge_Joint (Object* Object_A,
|
||||
Matrix_4x4* Frame_A)
|
||||
{
|
||||
btTransform Trans_A;
|
||||
|
||||
Trans_A.setFromOpenGLMatrix (&Frame_A->m00);
|
||||
|
||||
btTypedConstraint* Self = (btTypedConstraint*) (new btHingeConstraint (*to_bullet_Object (Object_A),
|
||||
Trans_A));
|
||||
return (Joint*) Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Joint*
|
||||
b3d_new_DoF6_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Matrix_4x4* Frame_A,
|
||||
Matrix_4x4* Frame_B)
|
||||
{
|
||||
btTransform Trans_A;
|
||||
btTransform Trans_B;
|
||||
|
||||
Trans_A.setFromOpenGLMatrix (&Frame_A->m00);
|
||||
Trans_B.setFromOpenGLMatrix (&Frame_B->m00);
|
||||
|
||||
btTypedConstraint* Self = (btTypedConstraint*) (new btGeneric6DofConstraint (*to_bullet_Object (Object_A),
|
||||
*to_bullet_Object (Object_B),
|
||||
Trans_A,
|
||||
Trans_B,
|
||||
0));
|
||||
return (Joint*) Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Joint*
|
||||
b3d_new_cone_twist_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Matrix_4x4* Frame_A,
|
||||
Matrix_4x4* Frame_B)
|
||||
{
|
||||
btTransform Trans_A;
|
||||
btTransform Trans_B;
|
||||
|
||||
Trans_A.setFromOpenGLMatrix (&Frame_A->m00);
|
||||
Trans_B.setFromOpenGLMatrix (&Frame_B->m00);
|
||||
|
||||
btTypedConstraint* Self = (btTypedConstraint*) (new btHingeConstraint (*to_bullet_Object (Object_A),
|
||||
*to_bullet_Object (Object_B),
|
||||
Trans_A,
|
||||
Trans_B));
|
||||
return (Joint*) Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Joint*
|
||||
b3d_new_slider_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Matrix_4x4* Frame_A,
|
||||
Matrix_4x4* Frame_B)
|
||||
{
|
||||
btTransform Trans_A;
|
||||
btTransform Trans_B;
|
||||
|
||||
Trans_A.setFromOpenGLMatrix (&Frame_A->m00);
|
||||
Trans_B.setFromOpenGLMatrix (&Frame_B->m00);
|
||||
|
||||
btTypedConstraint* Self = (btTypedConstraint*) (new btSliderConstraint (*to_bullet_Object (Object_A),
|
||||
*to_bullet_Object (Object_B),
|
||||
Trans_A,
|
||||
Trans_B,
|
||||
0));
|
||||
return (Joint*) Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Joint*
|
||||
b3d_new_ball_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Vector_3* Pivot_in_A,
|
||||
Vector_3* Pivot_in_B)
|
||||
{
|
||||
btVector3 pivot_A = btVector3 (Pivot_in_A->x, Pivot_in_A->y, Pivot_in_A->z);
|
||||
btVector3 pivot_B = btVector3 (Pivot_in_B->x, Pivot_in_B->y, Pivot_in_B->z);
|
||||
|
||||
btTypedConstraint* Self = (btTypedConstraint*) (new btPoint2PointConstraint (*to_bullet_Object (Object_A),
|
||||
*to_bullet_Object (Object_B),
|
||||
pivot_A,
|
||||
pivot_B));
|
||||
return (Joint*) Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////
|
||||
/// Attributes
|
||||
//
|
||||
|
||||
void*
|
||||
b3d_Joint_user_Data (Joint* Self)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void b3d_Joint_user_Data_is(Joint* Self,
|
||||
void* Now)
|
||||
{
|
||||
// btTypedConstraint* the_Joint = to_bullet_Joint (Self);
|
||||
|
||||
// TODO: the_Joint->setUserPointer (Now);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Object*
|
||||
b3d_Joint_Object_A (Joint* Self)
|
||||
{
|
||||
btTypedConstraint* c_Self = to_bullet_Joint (Self);
|
||||
|
||||
return to_bt3_Object (&c_Self->getRigidBodyA());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Object*
|
||||
b3d_Joint_Object_B (Joint* Self)
|
||||
{
|
||||
btTypedConstraint* c_Self = to_bullet_Joint (Self);
|
||||
|
||||
return to_bt3_Object (&c_Self->getRigidBodyB());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool b3d_Joint_Extent (Joint* Self,
|
||||
int DoF)
|
||||
{
|
||||
// btTypedConstraint* c_Self = to_bullet_Joint (Self);
|
||||
// return c_Self->Extent;
|
||||
|
||||
printf ("TODO: b3d_Joint_Extent");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Below are for hinges, it seems.
|
||||
//
|
||||
|
||||
Matrix_4x4
|
||||
b3d_Joint_Frame_A (Joint* Self)
|
||||
{
|
||||
// TODO: This does not apply to all types ... have to check type and then use switch to convert to correct bullet joint pointer.
|
||||
|
||||
btHingeConstraint* c_Self = (btHingeConstraint*) to_bullet_Joint (Self);
|
||||
btTransform& trans = c_Self->getAFrame();
|
||||
btScalar gl_Matrix [16];
|
||||
|
||||
trans.getOpenGLMatrix (gl_Matrix);
|
||||
|
||||
return Matrix_4x4 (gl_Matrix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Matrix_4x4
|
||||
b3d_Joint_Frame_B (Joint* Self)
|
||||
{
|
||||
btHingeConstraint* c_Self = (btHingeConstraint*) to_bullet_Joint (Self);
|
||||
btTransform& trans = c_Self->getBFrame();
|
||||
btScalar gl_Matrix [16];
|
||||
|
||||
trans.getOpenGLMatrix (gl_Matrix);
|
||||
|
||||
return Matrix_4x4 (gl_Matrix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void b3d_Joint_Frame_A_is (Joint* Self,
|
||||
Matrix_4x4* Now)
|
||||
{
|
||||
printf ("TODO: b3d_Joint_Frame_A_is");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void b3d_Joint_Frame_B_is (Joint* Self,
|
||||
Matrix_4x4* Now)
|
||||
{
|
||||
printf ("TODO: b3d_Joint_Frame_B_is");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool b3d_Joint_is_Limited(Joint* Self,
|
||||
int DoF)
|
||||
{
|
||||
printf ("TODO: b3d_Joint_is_Limited");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void b3d_Joint_Velocity_is (Joint* Self,
|
||||
int DoF,
|
||||
Real Velocity)
|
||||
{
|
||||
printf ("TODO: b3d_Joint_Velocity_is");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Hinge Joint
|
||||
//
|
||||
|
||||
void b3d_Joint_hinge_Limits_are (Joint* Self,
|
||||
Real Lower,
|
||||
Real Upper,
|
||||
Real Softeness,
|
||||
Real bias_Factor,
|
||||
Real relaxation_Factor)
|
||||
{
|
||||
btHingeConstraint* c_Self = (btHingeConstraint*) to_bullet_Joint (Self);
|
||||
|
||||
c_Self->setLimit (Lower,
|
||||
Upper,
|
||||
Softeness,
|
||||
bias_Factor,
|
||||
relaxation_Factor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 6 Degrees of Freedom Joint (6DoF)
|
||||
//
|
||||
|
||||
void b3d_Joint_6DoF_lower_Limit_is (Joint* Self,
|
||||
int DoF,
|
||||
Real Now)
|
||||
{
|
||||
btGeneric6DofConstraint* c_Self = (btGeneric6DofConstraint*) to_bullet_Joint (Self);
|
||||
btRotationalLimitMotor* the_Motor = c_Self->getRotationalLimitMotor (DoF - 4);
|
||||
|
||||
the_Motor->m_loLimit = Now;
|
||||
|
||||
c_Self->setOverrideNumSolverIterations (2000); // Improves joint limit stiffness.
|
||||
}
|
||||
|
||||
|
||||
|
||||
void b3d_Joint_6DoF_upper_Limit_is (Joint* Self,
|
||||
int DoF,
|
||||
Real Now)
|
||||
{
|
||||
btGeneric6DofConstraint* c_Self = (btGeneric6DofConstraint*) to_bullet_Joint (Self);
|
||||
btRotationalLimitMotor * the_Motor = c_Self->getRotationalLimitMotor (DoF - 4);
|
||||
|
||||
the_Motor->m_hiLimit = Now;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Real b3d_Joint_6DoF_lower_Limit (Joint* Self,
|
||||
int DoF)
|
||||
{
|
||||
btGeneric6DofConstraint* c_Self = (btGeneric6DofConstraint*) to_bullet_Joint (Self);
|
||||
|
||||
return c_Self->getRotationalLimitMotor (DoF - 4)->m_loLimit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Real b3d_Joint_6DoF_upper_Limit(Joint* Self,
|
||||
int DoF)
|
||||
{
|
||||
btGeneric6DofConstraint* c_Self = (btGeneric6DofConstraint*) to_bullet_Joint (Self);
|
||||
|
||||
return c_Self->getRotationalLimitMotor (DoF - 4)->m_hiLimit;
|
||||
}
|
||||
|
||||
|
||||
} // extern "C"
|
||||
87
3-mid/physics/implement/bullet/source/c/bullet-joint.h
Normal file
87
3-mid/physics/implement/bullet/source/c/bullet-joint.h
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef C_BULLET_JOINT_H
|
||||
#define C_BULLET_JOINT_H
|
||||
|
||||
#include "bullet.h"
|
||||
#include "bullet-object.h"
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
struct Joint;
|
||||
|
||||
Joint* b3d_new_hinge_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Matrix_4x4* Frame_A,
|
||||
Matrix_4x4* Frame_B);
|
||||
|
||||
Joint* b3d_new_space_hinge_Joint (Object* Object_A,
|
||||
Matrix_4x4* Frame_A);
|
||||
|
||||
|
||||
Joint* b3d_new_DoF6_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Matrix_4x4* Frame_A,
|
||||
Matrix_4x4* Frame_B);
|
||||
|
||||
Joint* b3d_new_cone_twist_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Matrix_4x4* Frame_A,
|
||||
Matrix_4x4* Frame_B);
|
||||
|
||||
Joint* b3d_new_slider_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Matrix_4x4* Frame_A,
|
||||
Matrix_4x4* Frame_B);
|
||||
|
||||
Joint* b3d_new_ball_Joint (Object* Object_A,
|
||||
Object* Object_B,
|
||||
Vector_3* Pivot_in_A,
|
||||
Vector_3* Pivot_in_B);
|
||||
|
||||
|
||||
/////////////
|
||||
// Attributes
|
||||
//
|
||||
|
||||
void* b3d_Joint_user_Data (Joint* Self);
|
||||
void b3d_Joint_user_Data_is (Joint* Self, void* Now);
|
||||
|
||||
Object* b3d_Joint_Object_A (Joint* Self);
|
||||
Object* b3d_Joint_Object_B (Joint* Self);
|
||||
|
||||
Matrix_4x4 b3d_Joint_Frame_A (Joint* Self);
|
||||
Matrix_4x4 b3d_Joint_Frame_B (Joint* Self);
|
||||
|
||||
void b3d_Joint_Frame_A_is (Joint* Self, Matrix_4x4* Now);
|
||||
void b3d_Joint_Frame_B_is (Joint* Self, Matrix_4x4* Now);
|
||||
|
||||
bool b3d_Joint_is_Limited (Joint* Self, int DoF);
|
||||
bool b3d_Joint_Extent (Joint* Self, int DoF);
|
||||
|
||||
void b3d_Joint_Velocity_is (Joint* Self, int DoF,
|
||||
Real Now);
|
||||
|
||||
// Hinge Joint
|
||||
//
|
||||
|
||||
void b3d_Joint_hinge_Limits_are (Joint* Self, Real Lower,
|
||||
Real Upper,
|
||||
Real Softeness,
|
||||
Real bias_Factor,
|
||||
Real relaxation_Factor);
|
||||
|
||||
// 6 Degrees of Freedom Joint (6DoF)
|
||||
//
|
||||
|
||||
void b3d_Joint_6DoF_lower_Limit_is (Joint* Self, int DoF,
|
||||
Real Now);
|
||||
void b3d_Joint_6DoF_upper_Limit_is (Joint* Self, int DoF,
|
||||
Real Now);
|
||||
|
||||
Real b3d_Joint_6DoF_lower_Limit (Joint* Self, int DoF);
|
||||
Real b3d_Joint_6DoF_upper_Limit (Joint* Self, int DoF);
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
||||
#endif
|
||||
373
3-mid/physics/implement/bullet/source/c/bullet-object.cpp
Normal file
373
3-mid/physics/implement/bullet/source/c/bullet-object.cpp
Normal file
@@ -0,0 +1,373 @@
|
||||
#include "bullet-object.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
|
||||
|
||||
///////////////
|
||||
/// C++ Support
|
||||
//
|
||||
|
||||
class KinematicMotionState : public btMotionState
|
||||
{
|
||||
public:
|
||||
KinematicMotionState (const btTransform &initialpos) { mPos1 = initialpos; }
|
||||
virtual ~ KinematicMotionState () { }
|
||||
|
||||
virtual void getWorldTransform ( btTransform &worldTrans) const { worldTrans = mPos1; }
|
||||
void setKinematicPos ( btTransform ¤tPos) { mPos1 = currentPos; }
|
||||
virtual void setWorldTransform (const btTransform &worldTrans) { }
|
||||
|
||||
protected:
|
||||
btTransform mPos1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
///////////
|
||||
/// Utility
|
||||
//
|
||||
|
||||
btRigidBody*
|
||||
to_bullet (Object* From)
|
||||
{
|
||||
return (btRigidBody*) From;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Object*
|
||||
to_bt3 (btRigidBody* From)
|
||||
{
|
||||
return (Object*) From;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////
|
||||
/// C Interface
|
||||
//
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
|
||||
int
|
||||
is_Kinematic (btRigidBody* Self)
|
||||
{
|
||||
return Self->getCollisionFlags()
|
||||
& btCollisionObject::CF_KINEMATIC_OBJECT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct Object*
|
||||
b3d_new_Object (Real Mass,
|
||||
Shape* the_Shape,
|
||||
int is_Kinematic)
|
||||
{
|
||||
btCollisionShape* bt_Shape = (btCollisionShape*) (the_Shape);
|
||||
btScalar mass = Mass;
|
||||
bool isDynamic = (mass != 0.f);
|
||||
btVector3 localInertia (0,0,0);
|
||||
btTransform groundTransform;
|
||||
|
||||
groundTransform.setIdentity();
|
||||
|
||||
if (isDynamic)
|
||||
bt_Shape->calculateLocalInertia (mass, localInertia);
|
||||
|
||||
|
||||
KinematicMotionState* myMotionState = new KinematicMotionState (groundTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo (mass, myMotionState, bt_Shape, localInertia);
|
||||
btRigidBody* body = new btRigidBody (rbInfo);
|
||||
|
||||
|
||||
if (is_Kinematic)
|
||||
{
|
||||
body->setCollisionFlags ( body->getCollisionFlags()
|
||||
| btCollisionObject::CF_KINEMATIC_OBJECT);
|
||||
|
||||
body->setActivationState (DISABLE_DEACTIVATION);
|
||||
}
|
||||
|
||||
if (isDynamic)
|
||||
body->setActivationState (DISABLE_DEACTIVATION);
|
||||
|
||||
return (Object*) body;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_Object_Shape (Object* Self)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
return (Shape*) the_Body->getCollisionShape ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void*
|
||||
b3d_Object_user_Data (Object* Self)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
return the_Body->getUserPointer ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_user_Data_is (Object* Self, void* Now)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
the_Body->setUserPointer (Now);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Real
|
||||
b3d_Object_Mass (Object* Self)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
Real inv_Mass = the_Body->getInvMass();
|
||||
|
||||
if (inv_Mass == 0.0)
|
||||
return 0.0;
|
||||
else
|
||||
return 1.0 / inv_Mass;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_Friction_is (Object* Self, Real Now)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
the_Body->setFriction (Now);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_Restitution_is (Object* Self, Real Now)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
the_Body->setRestitution (Now);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Vector_3
|
||||
b3d_Object_Site (Object* Self)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
Vector_3 the_Site;
|
||||
|
||||
btTransform& trans = the_Body->getWorldTransform ();
|
||||
btVector3 bt_Site = trans.getOrigin();
|
||||
|
||||
the_Site.x = bt_Site.x();
|
||||
the_Site.y = bt_Site.y();
|
||||
the_Site.z = bt_Site.z();
|
||||
|
||||
return the_Site;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_Site_is (Object* Self, Vector_3* Now)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
btTransform& trans = the_Body->getWorldTransform ();
|
||||
|
||||
trans.setOrigin (btVector3 (Now->x, Now->y, Now->z));
|
||||
the_Body->activate();
|
||||
|
||||
if (is_Kinematic (the_Body))
|
||||
{
|
||||
KinematicMotionState* the_Motion_State = (KinematicMotionState*) the_Body->getMotionState();
|
||||
|
||||
the_Motion_State->setKinematicPos (trans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Matrix_3x3
|
||||
b3d_Object_Spin (Object* Self)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
Vector_3 the_Site;
|
||||
|
||||
btTransform& trans = the_Body->getWorldTransform ();
|
||||
btMatrix3x3 the_Spin = trans.getBasis();
|
||||
|
||||
btVector3& R1 = the_Spin [0];
|
||||
btVector3& R2 = the_Spin [1];
|
||||
btVector3& R3 = the_Spin [2];
|
||||
|
||||
return Matrix_3x3 (R1 [0], R1 [1], R1 [2],
|
||||
R2 [0], R2 [1], R2 [2],
|
||||
R3 [0], R3 [1], R3 [2]);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_Spin_is (Object* Self, Matrix_3x3* Now)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
btTransform& trans = the_Body->getWorldTransform();
|
||||
|
||||
trans.setBasis (btMatrix3x3 (Now->m00, Now->m01, Now->m02,
|
||||
Now->m10, Now->m11, Now->m12,
|
||||
Now->m20, Now->m21, Now->m22));
|
||||
|
||||
if (is_Kinematic (the_Body))
|
||||
{
|
||||
KinematicMotionState* the_Motion_State = (KinematicMotionState*) the_Body->getMotionState();
|
||||
|
||||
the_Motion_State->setKinematicPos (trans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Matrix_4x4
|
||||
b3d_Object_Transform (Object* Self)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
btTransform& trans = the_Body->getWorldTransform ();
|
||||
btScalar gl_Matrix [16];
|
||||
|
||||
trans.getOpenGLMatrix (gl_Matrix);
|
||||
|
||||
return Matrix_4x4 (gl_Matrix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_Transform_is (Object* Self, Matrix_4x4* Now)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
|
||||
if (is_Kinematic (the_Body))
|
||||
{
|
||||
btTransform trans;
|
||||
KinematicMotionState* the_Motion_State = (KinematicMotionState*) the_Body->getMotionState();
|
||||
|
||||
trans.setFromOpenGLMatrix (&Now->m00);
|
||||
the_Motion_State->setKinematicPos (trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
btTransform& trans = the_Body->getWorldTransform ();
|
||||
|
||||
trans.setFromOpenGLMatrix (&Now->m00);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Vector_3
|
||||
b3d_Object_Speed (Object* Self)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
Vector_3 the_Speed;
|
||||
btVector3 bt_Speed = the_Body->getLinearVelocity ();
|
||||
|
||||
the_Speed.x = bt_Speed.x();
|
||||
the_Speed.y = bt_Speed.y();
|
||||
the_Speed.z = bt_Speed.z();
|
||||
|
||||
return the_Speed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_Speed_is (Object* Self, Vector_3* Now)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
the_Body->setLinearVelocity (btVector3 (Now->x, Now->y, Now->z));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Vector_3
|
||||
b3d_Object_Gyre (Object* Self)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
Vector_3 the_Gyre;
|
||||
btVector3 bt_Gyre = the_Body->getAngularVelocity ();
|
||||
|
||||
the_Gyre.x = bt_Gyre.x();
|
||||
the_Gyre.y = bt_Gyre.y();
|
||||
the_Gyre.z = bt_Gyre.z();
|
||||
|
||||
return the_Gyre;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_Gyre_is (Object* Self, Vector_3* Now)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
the_Body->setAngularVelocity (btVector3 (Now->x, Now->y, Now->z));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_apply_Torque (Object* Self, Vector_3* Torque)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
the_Body->applyTorque (btVector3 (Torque->x, Torque->y, Torque->z));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_apply_Torque_impulse (Object* Self, Vector_3* Torque)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
the_Body->applyTorqueImpulse (btVector3 (Torque->x, Torque->y, Torque->z));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Object_apply_Force (Object* Self, Vector_3* Force)
|
||||
{
|
||||
btRigidBody* the_Body = to_bullet (Self);
|
||||
|
||||
the_Body->applyCentralImpulse (btVector3 (Force->x, Force->y, Force->z));
|
||||
}
|
||||
|
||||
|
||||
} // extern "C"
|
||||
53
3-mid/physics/implement/bullet/source/c/bullet-object.h
Normal file
53
3-mid/physics/implement/bullet/source/c/bullet-object.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef C_BULLET_OBJECT_H
|
||||
#define C_BULLET_OBJECT_H
|
||||
|
||||
|
||||
#include "bullet.h"
|
||||
#include "bullet-shape.h"
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
struct Object;
|
||||
|
||||
struct Object* b3d_new_Object (Real Mass,
|
||||
Shape* the_Shape,
|
||||
int is_Kinematic);
|
||||
|
||||
Shape* b3d_Object_Shape (Object* Self);
|
||||
|
||||
void* b3d_Object_user_Data (Object* Self);
|
||||
void b3d_Object_user_Data_is (Object* Self, void* Now);
|
||||
|
||||
|
||||
Real b3d_Object_Mass (Object* Self);
|
||||
void b3d_Object_Friction_is (Object* Self, Real Now);
|
||||
void b3d_Object_Restitution_is (Object* Self, Real Now);
|
||||
|
||||
|
||||
Vector_3 b3d_Object_Site (Object* Self);
|
||||
void b3d_Object_Site_is (Object* Self, Vector_3* Now);
|
||||
|
||||
Matrix_3x3 b3d_Object_Spin (Object* Self);
|
||||
void b3d_Object_Spin_is (Object* Self, Matrix_3x3* Now);
|
||||
|
||||
Matrix_4x4 b3d_Object_Transform (Object* Self);
|
||||
void b3d_Object_Transform_is (Object* Self, Matrix_4x4* Now);
|
||||
|
||||
|
||||
Vector_3 b3d_Object_Speed (Object* Self);
|
||||
void b3d_Object_Speed_is (Object* Self, Vector_3* Now);
|
||||
|
||||
Vector_3 b3d_Object_Gyre (Object* Self);
|
||||
void b3d_Object_Gyre_is (Object* Self, Vector_3* Now);
|
||||
|
||||
|
||||
void b3d_Object_apply_Force (Object* Self, Vector_3* Force);
|
||||
void b3d_Object_apply_Torque (Object* Self, Vector_3* Torque);
|
||||
void b3d_Object_apply_Torque_impulse (Object* Self, Vector_3* Torque);
|
||||
|
||||
}; // extern "C"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
234
3-mid/physics/implement/bullet/source/c/bullet-shape.cpp
Normal file
234
3-mid/physics/implement/bullet/source/c/bullet-shape.cpp
Normal file
@@ -0,0 +1,234 @@
|
||||
#include "bullet-shape.h"
|
||||
#include "bullet-space.h"
|
||||
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
|
||||
|
||||
|
||||
|
||||
///////////
|
||||
// Utility
|
||||
//
|
||||
|
||||
btCollisionShape*
|
||||
to_bullet (Shape* From)
|
||||
{
|
||||
return (btCollisionShape*) From;
|
||||
}
|
||||
|
||||
|
||||
Shape*
|
||||
to_bt3 (btCollisionShape* From)
|
||||
{
|
||||
return (Shape*) From;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/////////
|
||||
// Forge
|
||||
//
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_Box (Vector_3* half_Extents)
|
||||
{
|
||||
Shape* Self = (Shape*)(btCollisionShape*) (new btBoxShape (btVector3 (half_Extents->x,
|
||||
half_Extents->y,
|
||||
half_Extents->z)));
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_Capsule (Vector_2* Radii,
|
||||
Real Height)
|
||||
{
|
||||
Shape* Self = (Shape*)(btCollisionShape*) (new btCapsuleShapeZ (Radii->x,
|
||||
Height));
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_Cone (Real Radius,
|
||||
Real Height)
|
||||
{
|
||||
Shape* Self = (Shape*)(btCollisionShape*) (new btConeShape (Radius, Height));
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_convex_Hull (Vector_3 Points[],
|
||||
int point_Count)
|
||||
{
|
||||
btConvexHullShape* bt_Hull = new btConvexHullShape ();
|
||||
|
||||
for (int i = 0; i < point_Count; i++)
|
||||
{
|
||||
bt_Hull->addPoint (btVector3 (Points [i].x,
|
||||
Points [i].y,
|
||||
Points [i].z));
|
||||
}
|
||||
|
||||
|
||||
Shape* Self = (Shape*)(btCollisionShape*) bt_Hull;
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_Mesh (Vector_3 Points[],
|
||||
int point_Count,
|
||||
Triangle Triangles[],
|
||||
int triangle_Count)
|
||||
{
|
||||
btTriangleMesh* mesh = new btTriangleMesh();
|
||||
|
||||
for (int i = 0; i < triangle_Count; i++)
|
||||
{
|
||||
btVector3 bV1, bV2, bV3;
|
||||
|
||||
bV1 [0] = Points [Triangles [i].a - 1].x;
|
||||
bV1 [1] = Points [Triangles [i].a - 1].y;
|
||||
bV1 [2] = Points [Triangles [i].a - 1].z;
|
||||
|
||||
bV2 [0] = Points [Triangles [i].b - 1].x;
|
||||
bV2 [1] = Points [Triangles [i].b - 1].y;
|
||||
bV2 [2] = Points [Triangles [i].b - 1].z;
|
||||
|
||||
bV3 [0] = Points [Triangles [i].c - 1].x;
|
||||
bV3 [1] = Points [Triangles [i].c - 1].y;
|
||||
bV3 [2] = Points [Triangles [i].c - 1].z;
|
||||
|
||||
|
||||
mesh->addTriangle (bV1, bV2, bV3);
|
||||
}
|
||||
|
||||
|
||||
btBvhTriangleMeshShape* bt_Mesh = new btBvhTriangleMeshShape (mesh, true, true);
|
||||
|
||||
Shape* Self = (Shape*)(btCollisionShape*) bt_Mesh;
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_Cylinder (Vector_3* half_Extents)
|
||||
{
|
||||
Shape* Self = (Shape*)(btCollisionShape*) (new btCylinderShape (btVector3 (half_Extents->x,
|
||||
half_Extents->y,
|
||||
half_Extents->z)));
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_Heightfield (int Width,
|
||||
int Depth,
|
||||
Real Heights[],
|
||||
Real min_Height,
|
||||
Real max_Height,
|
||||
Vector_3* Scale)
|
||||
{
|
||||
btCollisionShape* Self = (btCollisionShape*) (new btHeightfieldTerrainShape (Width, Depth,
|
||||
Heights,
|
||||
1.0,
|
||||
min_Height, max_Height,
|
||||
1, PHY_FLOAT, 0));
|
||||
Self->setLocalScaling (btVector3 (Scale->x,
|
||||
Scale->y,
|
||||
Scale->z));
|
||||
return (Shape*) Self;;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_multiSphere (Vector_3* Positions,
|
||||
Real* Radii,
|
||||
int sphere_Count)
|
||||
{
|
||||
btVector3 bt_Positions [sphere_Count];
|
||||
|
||||
for (int i=0; i < sphere_Count; i++)
|
||||
{
|
||||
bt_Positions [i][0] = Positions [i].x;
|
||||
bt_Positions [i][1] = Positions [i].y;
|
||||
bt_Positions [i][2] = Positions [i].z;
|
||||
}
|
||||
|
||||
Shape* Self = (Shape*)(btCollisionShape*) (new btMultiSphereShape (bt_Positions,
|
||||
Radii,
|
||||
sphere_Count));
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_Plane (Vector_3* Normal,
|
||||
Real Offset)
|
||||
{
|
||||
Shape* Self = (Shape*)(btCollisionShape*) (new btStaticPlaneShape (btVector3 (Normal->x,
|
||||
Normal->y,
|
||||
Normal->z),
|
||||
Offset));
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Shape*
|
||||
b3d_new_Sphere (Real Radius)
|
||||
{
|
||||
Shape* Self = (Shape*)(btCollisionShape*) (new btSphereShape (Radius));
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////
|
||||
// Attributes
|
||||
//
|
||||
|
||||
void*
|
||||
b3d_Shape_user_Data (Shape* Self)
|
||||
{
|
||||
btCollisionShape* the_Shape = to_bullet (Self);
|
||||
|
||||
return the_Shape->getUserPointer();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
b3d_Shape_user_Data_is (Shape* Self, void* Now)
|
||||
{
|
||||
btCollisionShape* the_Shape = to_bullet (Self);
|
||||
|
||||
the_Shape->setUserPointer (Now);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
54
3-mid/physics/implement/bullet/source/c/bullet-shape.h
Normal file
54
3-mid/physics/implement/bullet/source/c/bullet-shape.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef C_BULLET_SHAPE_H
|
||||
#define C_BULLET_SHAPE_H
|
||||
|
||||
#include "bullet.h"
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
struct Shape;
|
||||
|
||||
Shape* b3d_new_Box (Vector_3* half_Extents);
|
||||
|
||||
Shape* b3d_new_Capsule (Vector_2* Radii,
|
||||
Real Height);
|
||||
|
||||
Shape* b3d_new_Cone (Real Radius,
|
||||
Real Height);
|
||||
|
||||
Shape* b3d_new_convex_Hull (Vector_3 Points[],
|
||||
int point_Count);
|
||||
|
||||
Shape* b3d_new_Mesh (Vector_3 Points[],
|
||||
int point_Count,
|
||||
Triangle Triangles[],
|
||||
int triangle_Count);
|
||||
|
||||
Shape* b3d_new_Cylinder (Vector_3* half_Extents);
|
||||
|
||||
Shape* b3d_new_Heightfield (int Width,
|
||||
int Depth,
|
||||
Real* Heights,
|
||||
Real min_Height,
|
||||
Real max_Height,
|
||||
Vector_3* Scale);
|
||||
|
||||
Shape* b3d_new_multiSphere (Vector_3 Positions[],
|
||||
Real* Radii,
|
||||
int sphere_Count);
|
||||
|
||||
Shape* b3d_new_Plane (Vector_3* Normal,
|
||||
Real Offset);
|
||||
|
||||
Shape* b3d_new_Sphere (Real Radius);
|
||||
|
||||
|
||||
void* b3d_Shape_user_Data (Shape* Self);
|
||||
void b3d_Shape_user_Data_is (Shape* Self, void* Now);
|
||||
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
||||
#endif
|
||||
146
3-mid/physics/implement/bullet/source/c/bullet-space.cpp
Normal file
146
3-mid/physics/implement/bullet/source/c/bullet-space.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
#include "bullet-space.h"
|
||||
#include "bullet-conversions.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
struct Space
|
||||
{
|
||||
btDefaultCollisionConfiguration* collisionConfiguration;
|
||||
btCollisionDispatcher* dispatcher;
|
||||
btBroadphaseInterface* overlappingPairCache;
|
||||
btSequentialImpulseConstraintSolver* solver;
|
||||
btDiscreteDynamicsWorld* dynamicsWorld;
|
||||
|
||||
unsigned moved_Count;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct Space*
|
||||
b3d_new_Space ()
|
||||
{
|
||||
Space* Self = new Space();
|
||||
|
||||
// collision configuration contains default setup for memory, collision setup. Advanced users can create their own configuration.
|
||||
//
|
||||
Self->collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
|
||||
|
||||
// use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||
//
|
||||
Self->dispatcher = new btCollisionDispatcher (Self->collisionConfiguration);
|
||||
|
||||
|
||||
// btDbvtBroadphase is a good general purpose broadphase. You can also try out btAxis3Sweep.
|
||||
//
|
||||
Self->overlappingPairCache = new btDbvtBroadphase();
|
||||
|
||||
|
||||
// the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
||||
//
|
||||
Self->solver = new btSequentialImpulseConstraintSolver;
|
||||
|
||||
|
||||
Self->dynamicsWorld = new btDiscreteDynamicsWorld (Self->dispatcher,
|
||||
Self->overlappingPairCache,
|
||||
Self->solver,
|
||||
Self->collisionConfiguration);
|
||||
return Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_free_Space (Space* Self)
|
||||
{
|
||||
//delete dynamics world
|
||||
delete Self->dynamicsWorld;
|
||||
|
||||
//delete solver
|
||||
delete Self->solver;
|
||||
|
||||
//delete broadphase
|
||||
delete Self->overlappingPairCache;
|
||||
|
||||
//delete dispatcher
|
||||
delete Self->dispatcher;
|
||||
|
||||
delete Self->collisionConfiguration;
|
||||
|
||||
delete Self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Space_Gravity_is (Space* Self, Vector_3* Now)
|
||||
{
|
||||
Self->dynamicsWorld->setGravity (btVector3 (Now->x, Now->y, Now->z));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Space_evolve (Space* Self, float By)
|
||||
{
|
||||
Self->dynamicsWorld->stepSimulation (By, 10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Space_add_Object (Space* Self, Object* the_Object)
|
||||
{
|
||||
Self->dynamicsWorld->addRigidBody ((btRigidBody*) (the_Object));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Space_rid_Object (Space* Self, Object* the_Object)
|
||||
{
|
||||
Self->dynamicsWorld->removeRigidBody ((btRigidBody*) (the_Object));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
b3d_Space_add_Joint (Space* Self, Joint* the_Joint)
|
||||
{
|
||||
bool disable_Collisions = true;
|
||||
|
||||
Self->dynamicsWorld->addConstraint ((btTypedConstraint*) (the_Joint),
|
||||
disable_Collisions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ray_Collision
|
||||
b3d_Space_cast_Ray (Space* Self, Vector_3* From,
|
||||
Vector_3* To)
|
||||
{
|
||||
btVector3 rayFrom = to_btVector3 (From);
|
||||
btVector3 rayTo = to_btVector3 (To);
|
||||
btCollisionWorld::ClosestRayResultCallback rayCallback (rayFrom, rayTo);
|
||||
|
||||
Self->dynamicsWorld->rayTest (rayFrom, rayTo,
|
||||
rayCallback);
|
||||
|
||||
ray_Collision the_Collision;
|
||||
|
||||
the_Collision.near_Object = (Object*) (rayCallback.m_collisionObject);
|
||||
the_Collision.hit_Fraction = rayCallback.m_closestHitFraction;
|
||||
the_Collision.Normal_world = to_Vector_3 (rayCallback.m_hitNormalWorld);
|
||||
the_Collision.Site_world = to_Vector_3 (rayCallback.m_hitPointWorld);
|
||||
|
||||
return the_Collision;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // extern "C"
|
||||
|
||||
46
3-mid/physics/implement/bullet/source/c/bullet-space.h
Normal file
46
3-mid/physics/implement/bullet/source/c/bullet-space.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef C_BULLET_SPACE_H
|
||||
#define C_BULLET_SPACE_H
|
||||
|
||||
|
||||
#include "bullet.h"
|
||||
#include "bullet-object.h"
|
||||
#include "bullet-joint.h"
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
struct Space;
|
||||
|
||||
|
||||
struct Space* b3d_new_Space ();
|
||||
void b3d_free_Space (Space* Self);
|
||||
|
||||
void b3d_Space_add_Object (Space* Self, Object* the_Object);
|
||||
void b3d_Space_rid_Object (Space* Self, Object* the_Object);
|
||||
|
||||
void b3d_Space_add_Joint (Space* Self, Joint* the_Joint);
|
||||
|
||||
void b3d_Space_Gravity_is (Space* Self, Vector_3* Now);
|
||||
|
||||
void b3d_Space_evolve (Space* Self, float By);
|
||||
|
||||
|
||||
// Ray Casting
|
||||
//
|
||||
struct ray_Collision
|
||||
{
|
||||
const Object* near_Object;
|
||||
Real hit_Fraction;
|
||||
Vector_3 Normal_world;
|
||||
Vector_3 Site_world;
|
||||
};
|
||||
|
||||
ray_Collision b3d_Space_cast_Ray (Space* Self, Vector_3* From,
|
||||
Vector_3* To);
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
8
3-mid/physics/implement/bullet/source/c/bullet.h
Normal file
8
3-mid/physics/implement/bullet/source/c/bullet.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef C_BULLET_H
|
||||
#define C_BULLET_H
|
||||
|
||||
#include "c_math.h"
|
||||
|
||||
// Provides a simple C interface to the Bullet3D C++ library.
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user