Add initial prototype.
This commit is contained in:
20
3-mid/physics/implement/bullet/alire.toml
Normal file
20
3-mid/physics/implement/bullet/alire.toml
Normal file
@@ -0,0 +1,20 @@
|
||||
name = "lace_bullet"
|
||||
description = "Provides a thin Ada binding to the 'bullet' C++ project."
|
||||
version = "0.1.1"
|
||||
|
||||
authors = ["Rod Kay"]
|
||||
maintainers = ["Rod Kay <rodakay5@gmail.com>"]
|
||||
maintainers-logins = ["charlie5"]
|
||||
|
||||
licenses = "ISC"
|
||||
website = "https://github.com/charlie5/lace-alire"
|
||||
tags = ["physics", "3d"]
|
||||
|
||||
project-files = ["library/bullet_thin.gpr"]
|
||||
|
||||
[[depends-on]]
|
||||
lace_c_math = "~0.1"
|
||||
libbullet = "*"
|
||||
|
||||
[environment.'case(distribution)'.msys2.C_INCLUDE_PATH]
|
||||
append = "${DISTRIB_ROOT}/mingw64/include/bullet"
|
||||
30
3-mid/physics/implement/bullet/generate/builder
Executable file
30
3-mid/physics/implement/bullet/generate/builder
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
echo
|
||||
echo Removing prior build.
|
||||
echo
|
||||
|
||||
rm *.ads
|
||||
rm *.cxx
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
echo
|
||||
echo Generating the binding.
|
||||
echo
|
||||
|
||||
swig_gnat -gnat -c++ -cpperraswarn bullet_c.i
|
||||
rm portable_new_line_Token.tmp
|
||||
|
||||
|
||||
|
||||
echo
|
||||
echo Pretty printing.
|
||||
echo
|
||||
|
||||
gnatpp -rnb -I/usr/local/include -I../../c_math/source/thin *.ads -cargs -gnat05
|
||||
indent -sob -di16 *.cxx
|
||||
|
||||
40
3-mid/physics/implement/bullet/generate/bullet_c.i
Normal file
40
3-mid/physics/implement/bullet/generate/bullet_c.i
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// SWIG interface defintion for 'Bullet_C' interface library binding.
|
||||
//
|
||||
|
||||
%module bullet_c
|
||||
|
||||
%{
|
||||
extern "C"
|
||||
{
|
||||
#include "../c/bullet-shape.h"
|
||||
#include "../c/bullet-object.h"
|
||||
#include "../c/bullet-joint.h"
|
||||
#include "../c/bullet-space.h"
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
%import "../../c_math/generate/c_math_c.i"
|
||||
|
||||
%include "../source/c/bullet.h"
|
||||
%include "../source/c/bullet-shape.h"
|
||||
%include "../source/c/bullet-object.h"
|
||||
%include "../source/c/bullet-joint.h"
|
||||
%include "../source/c/bullet-space.h"
|
||||
|
||||
|
||||
|
||||
// Tailoring
|
||||
//
|
||||
|
||||
%inline
|
||||
%{
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
10
3-mid/physics/implement/bullet/generate/export_source
Executable file
10
3-mid/physics/implement/bullet/generate/export_source
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
rm ../source/thin/*.ads
|
||||
rm ../source/thin/*.cxx
|
||||
|
||||
mv ./*.ads ../source/thin
|
||||
mv ./*.cxx ../source/thin
|
||||
|
||||
|
||||
23
3-mid/physics/implement/bullet/library/bullet_thin.gpr
Normal file
23
3-mid/physics/implement/bullet/library/bullet_thin.gpr
Normal file
@@ -0,0 +1,23 @@
|
||||
with
|
||||
"bullet_thin_cxx",
|
||||
"c_math_thin",
|
||||
"swig",
|
||||
"math",
|
||||
"lace_shared";
|
||||
|
||||
--library
|
||||
project Bullet_thin
|
||||
is
|
||||
for Languages use ("Ada");
|
||||
for Source_Dirs use ("../source/thin");
|
||||
for Object_Dir use "build";
|
||||
for Library_Dir use "lib";
|
||||
for Library_Ali_Dir use "objects";
|
||||
-- for Library_Name use "Bullet_thin";
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
package Compiler renames Lace_shared.Compiler;
|
||||
package Binder renames Lace_shared.Binder;
|
||||
|
||||
end Bullet_thin;
|
||||
41
3-mid/physics/implement/bullet/library/bullet_thin_c.gpr
Normal file
41
3-mid/physics/implement/bullet/library/bullet_thin_c.gpr
Normal file
@@ -0,0 +1,41 @@
|
||||
with
|
||||
"c_math_thin_c",
|
||||
"lace_shared";
|
||||
|
||||
--library
|
||||
project Bullet_Thin_C
|
||||
is
|
||||
for Languages use ("c++");
|
||||
for Source_Dirs use ("../source/c");
|
||||
for Object_Dir use "build";
|
||||
for Library_Dir use "lib";
|
||||
for Library_Ali_Dir use "objects";
|
||||
-- for Library_Name use "Bullet_Thin_C";
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
|
||||
package Naming is
|
||||
for Spec_Suffix ("c++") use ".h";
|
||||
for Body_Suffix ("c++") use ".cpp";
|
||||
end Naming;
|
||||
|
||||
package Compiler is
|
||||
for Default_Switches ("c++") use ("-g",
|
||||
"-Wno-return-type-c-linkage",
|
||||
"-I../../../c_math/source/c",
|
||||
"-I/usr/include/bullet",
|
||||
"-I" & External ("LIBRARY_PATH", "/usr/include") & "/../include/bullet");
|
||||
--
|
||||
-- TODO: Find out why Alires 'C_INCLUDE_PATH' append is not working on Windows, so that
|
||||
-- the above 'External ("LIBRARY_PATH")' workaround can be removed.
|
||||
end Compiler;
|
||||
|
||||
package Linker is
|
||||
for Linker_Options use ("-lBulletSoftBody",
|
||||
"-lBulletDynamics",
|
||||
"-lBulletCollision",
|
||||
"-lLinearMath");
|
||||
end Linker;
|
||||
|
||||
end Bullet_Thin_C;
|
||||
29
3-mid/physics/implement/bullet/library/bullet_thin_cxx.gpr
Normal file
29
3-mid/physics/implement/bullet/library/bullet_thin_cxx.gpr
Normal file
@@ -0,0 +1,29 @@
|
||||
with
|
||||
"bullet_thin_c",
|
||||
"lace_shared";
|
||||
|
||||
--library
|
||||
project Bullet_Thin_Cxx
|
||||
is
|
||||
for Languages use ("c++");
|
||||
for Source_Dirs use ("../source/thin");
|
||||
for Object_Dir use "build";
|
||||
for Library_Dir use "lib";
|
||||
for Library_Ali_Dir use "objects";
|
||||
-- for Library_Name use "bullet_thin_cxx";
|
||||
|
||||
package Naming is
|
||||
for Spec_Suffix ("c++") use ".h";
|
||||
for Body_Suffix ("c++") use ".cxx";
|
||||
end Naming;
|
||||
|
||||
package Compiler is
|
||||
for Default_Switches ("c++") use ("-g",
|
||||
"-I../../../c_math/source/c",
|
||||
"-Wno-return-type-c-linkage");
|
||||
end Compiler;
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
|
||||
end Bullet_Thin_Cxx;
|
||||
@@ -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
|
||||
382
3-mid/physics/implement/bullet/source/thin/bullet_c-binding.ads
Normal file
382
3-mid/physics/implement/bullet/source/thin/bullet_c-binding.ads
Normal file
@@ -0,0 +1,382 @@
|
||||
-- This file is generated by SWIG. Please do *not* modify by hand.
|
||||
--
|
||||
with bullet_c.Pointers;
|
||||
with bullet_c.ray_Collision;
|
||||
with c_math_c;
|
||||
with c_math_c.Matrix_3x3;
|
||||
with c_math_c.Matrix_4x4;
|
||||
with c_math_c.Pointers;
|
||||
with c_math_c.Triangle;
|
||||
with c_math_c.Vector_2;
|
||||
with c_math_c.Vector_3;
|
||||
with Interfaces.C;
|
||||
with Swig;
|
||||
|
||||
package bullet_c.Binding is
|
||||
|
||||
function b3d_new_Box
|
||||
(half_Extents : in c_math_c.Vector_3.Pointer)
|
||||
return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_Capsule
|
||||
(Radii : in c_math_c.Vector_2.Pointer;
|
||||
Height : in c_math_c.Real) return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_Cone
|
||||
(Radius : in c_math_c.Real;
|
||||
Height : in c_math_c.Real) return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_convex_Hull
|
||||
(Points : in c_math_c.Vector_3.Pointer;
|
||||
point_Count : in Interfaces.C.int)
|
||||
return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_Mesh
|
||||
(Points : in c_math_c.Vector_3.Pointer;
|
||||
point_Count : in Interfaces.C.int;
|
||||
Triangles : in c_math_c.Triangle.Pointer;
|
||||
triangle_Count : in Interfaces.C.int)
|
||||
return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_Cylinder
|
||||
(half_Extents : in c_math_c.Vector_3.Pointer)
|
||||
return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_Heightfield
|
||||
(Width : in Interfaces.C.int;
|
||||
Depth : in Interfaces.C.int;
|
||||
Heights : in c_math_c.Pointers.Real_Pointer;
|
||||
min_Height : in c_math_c.Real;
|
||||
max_Height : in c_math_c.Real;
|
||||
Scale : in c_math_c.Vector_3.Pointer)
|
||||
return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_multiSphere
|
||||
(Positions : in c_math_c.Vector_3.Pointer;
|
||||
Radii : in c_math_c.Pointers.Real_Pointer;
|
||||
sphere_Count : in Interfaces.C.int)
|
||||
return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_Plane
|
||||
(Normal : in c_math_c.Vector_3.Pointer;
|
||||
Offset : in c_math_c.Real) return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_new_Sphere
|
||||
(Radius : in c_math_c.Real) return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_Shape_user_Data
|
||||
(Self : in bullet_c.Pointers.Shape_Pointer) return Swig.void_ptr;
|
||||
|
||||
procedure b3d_Shape_user_Data_is
|
||||
(Self : in bullet_c.Pointers.Shape_Pointer;
|
||||
Now : in Swig.void_ptr);
|
||||
|
||||
function b3d_new_Object
|
||||
(Mass : in c_math_c.Real;
|
||||
the_Shape : in bullet_c.Pointers.Shape_Pointer;
|
||||
is_Kinematic : in Interfaces.C.int)
|
||||
return bullet_c.Pointers.Object_Pointer;
|
||||
|
||||
function b3d_Object_Shape
|
||||
(Self : in bullet_c.Pointers.Object_Pointer)
|
||||
return bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
function b3d_Object_user_Data
|
||||
(Self : in bullet_c.Pointers.Object_Pointer) return Swig.void_ptr;
|
||||
|
||||
procedure b3d_Object_user_Data_is
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Now : in Swig.void_ptr);
|
||||
|
||||
function b3d_Object_Mass
|
||||
(Self : in bullet_c.Pointers.Object_Pointer) return c_math_c.Real;
|
||||
|
||||
procedure b3d_Object_Friction_is
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Now : in c_math_c.Real);
|
||||
|
||||
procedure b3d_Object_Restitution_is
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Now : in c_math_c.Real);
|
||||
|
||||
function b3d_Object_Site
|
||||
(Self : in bullet_c.Pointers.Object_Pointer)
|
||||
return c_math_c.Vector_3.Item;
|
||||
|
||||
procedure b3d_Object_Site_is
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Now : in c_math_c.Vector_3.Pointer);
|
||||
|
||||
function b3d_Object_Spin
|
||||
(Self : in bullet_c.Pointers.Object_Pointer)
|
||||
return c_math_c.Matrix_3x3.Item;
|
||||
|
||||
procedure b3d_Object_Spin_is
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Now : in c_math_c.Matrix_3x3.Pointer);
|
||||
|
||||
function b3d_Object_Transform
|
||||
(Self : in bullet_c.Pointers.Object_Pointer)
|
||||
return c_math_c.Matrix_4x4.Item;
|
||||
|
||||
procedure b3d_Object_Transform_is
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Now : in c_math_c.Matrix_4x4.Pointer);
|
||||
|
||||
function b3d_Object_Speed
|
||||
(Self : in bullet_c.Pointers.Object_Pointer)
|
||||
return c_math_c.Vector_3.Item;
|
||||
|
||||
procedure b3d_Object_Speed_is
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Now : in c_math_c.Vector_3.Pointer);
|
||||
|
||||
function b3d_Object_Gyre
|
||||
(Self : in bullet_c.Pointers.Object_Pointer)
|
||||
return c_math_c.Vector_3.Item;
|
||||
|
||||
procedure b3d_Object_Gyre_is
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Now : in c_math_c.Vector_3.Pointer);
|
||||
|
||||
procedure b3d_Object_apply_Force
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Force : in c_math_c.Vector_3.Pointer);
|
||||
|
||||
procedure b3d_Object_apply_Torque
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Torque : in c_math_c.Vector_3.Pointer);
|
||||
|
||||
procedure b3d_Object_apply_Torque_impulse
|
||||
(Self : in bullet_c.Pointers.Object_Pointer;
|
||||
Torque : in c_math_c.Vector_3.Pointer);
|
||||
|
||||
function b3d_new_hinge_Joint
|
||||
(Object_A : in bullet_c.Pointers.Object_Pointer;
|
||||
Object_B : in bullet_c.Pointers.Object_Pointer;
|
||||
Frame_A : in c_math_c.Matrix_4x4.Pointer;
|
||||
Frame_B : in c_math_c.Matrix_4x4.Pointer)
|
||||
return bullet_c.Pointers.Joint_Pointer;
|
||||
|
||||
function b3d_new_space_hinge_Joint
|
||||
(Object_A : in bullet_c.Pointers.Object_Pointer;
|
||||
Frame_A : in c_math_c.Matrix_4x4.Pointer)
|
||||
return bullet_c.Pointers.Joint_Pointer;
|
||||
|
||||
function b3d_new_DoF6_Joint
|
||||
(Object_A : in bullet_c.Pointers.Object_Pointer;
|
||||
Object_B : in bullet_c.Pointers.Object_Pointer;
|
||||
Frame_A : in c_math_c.Matrix_4x4.Pointer;
|
||||
Frame_B : in c_math_c.Matrix_4x4.Pointer)
|
||||
return bullet_c.Pointers.Joint_Pointer;
|
||||
|
||||
function b3d_new_cone_twist_Joint
|
||||
(Object_A : in bullet_c.Pointers.Object_Pointer;
|
||||
Object_B : in bullet_c.Pointers.Object_Pointer;
|
||||
Frame_A : in c_math_c.Matrix_4x4.Pointer;
|
||||
Frame_B : in c_math_c.Matrix_4x4.Pointer)
|
||||
return bullet_c.Pointers.Joint_Pointer;
|
||||
|
||||
function b3d_new_slider_Joint
|
||||
(Object_A : in bullet_c.Pointers.Object_Pointer;
|
||||
Object_B : in bullet_c.Pointers.Object_Pointer;
|
||||
Frame_A : in c_math_c.Matrix_4x4.Pointer;
|
||||
Frame_B : in c_math_c.Matrix_4x4.Pointer)
|
||||
return bullet_c.Pointers.Joint_Pointer;
|
||||
|
||||
function b3d_new_ball_Joint
|
||||
(Object_A : in bullet_c.Pointers.Object_Pointer;
|
||||
Object_B : in bullet_c.Pointers.Object_Pointer;
|
||||
Pivot_in_A : in c_math_c.Vector_3.Pointer;
|
||||
Pivot_in_B : in c_math_c.Vector_3.Pointer)
|
||||
return bullet_c.Pointers.Joint_Pointer;
|
||||
|
||||
function b3d_Joint_user_Data
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer) return Swig.void_ptr;
|
||||
|
||||
procedure b3d_Joint_user_Data_is
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
Now : in Swig.void_ptr);
|
||||
|
||||
function b3d_Joint_Object_A
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer)
|
||||
return bullet_c.Pointers.Object_Pointer;
|
||||
|
||||
function b3d_Joint_Object_B
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer)
|
||||
return bullet_c.Pointers.Object_Pointer;
|
||||
|
||||
function b3d_Joint_Frame_A
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer)
|
||||
return c_math_c.Matrix_4x4.Item;
|
||||
|
||||
function b3d_Joint_Frame_B
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer)
|
||||
return c_math_c.Matrix_4x4.Item;
|
||||
|
||||
procedure b3d_Joint_Frame_A_is
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
Now : in c_math_c.Matrix_4x4.Pointer);
|
||||
|
||||
procedure b3d_Joint_Frame_B_is
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
Now : in c_math_c.Matrix_4x4.Pointer);
|
||||
|
||||
function b3d_Joint_is_Limited
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
DoF : in Interfaces.C.int) return Swig.bool;
|
||||
|
||||
function b3d_Joint_Extent
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
DoF : in Interfaces.C.int) return Swig.bool;
|
||||
|
||||
procedure b3d_Joint_Velocity_is
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
DoF : in Interfaces.C.int;
|
||||
Now : in c_math_c.Real);
|
||||
|
||||
procedure b3d_Joint_hinge_Limits_are
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
Lower : in c_math_c.Real;
|
||||
Upper : in c_math_c.Real;
|
||||
Softeness : in c_math_c.Real;
|
||||
bias_Factor : in c_math_c.Real;
|
||||
relaxation_Factor : in c_math_c.Real);
|
||||
|
||||
procedure b3d_Joint_6DoF_lower_Limit_is
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
DoF : in Interfaces.C.int;
|
||||
Now : in c_math_c.Real);
|
||||
|
||||
procedure b3d_Joint_6DoF_upper_Limit_is
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
DoF : in Interfaces.C.int;
|
||||
Now : in c_math_c.Real);
|
||||
|
||||
function b3d_Joint_6DoF_lower_Limit
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
DoF : in Interfaces.C.int) return c_math_c.Real;
|
||||
|
||||
function b3d_Joint_6DoF_upper_Limit
|
||||
(Self : in bullet_c.Pointers.Joint_Pointer;
|
||||
DoF : in Interfaces.C.int) return c_math_c.Real;
|
||||
|
||||
function b3d_new_Space return bullet_c.Pointers.Space_Pointer;
|
||||
|
||||
procedure b3d_free_Space (Self : in bullet_c.Pointers.Space_Pointer);
|
||||
|
||||
procedure b3d_Space_add_Object
|
||||
(Self : in bullet_c.Pointers.Space_Pointer;
|
||||
the_Object : in bullet_c.Pointers.Object_Pointer);
|
||||
|
||||
procedure b3d_Space_rid_Object
|
||||
(Self : in bullet_c.Pointers.Space_Pointer;
|
||||
the_Object : in bullet_c.Pointers.Object_Pointer);
|
||||
|
||||
procedure b3d_Space_add_Joint
|
||||
(Self : in bullet_c.Pointers.Space_Pointer;
|
||||
the_Joint : in bullet_c.Pointers.Joint_Pointer);
|
||||
|
||||
procedure b3d_Space_Gravity_is
|
||||
(Self : in bullet_c.Pointers.Space_Pointer;
|
||||
Now : in c_math_c.Vector_3.Pointer);
|
||||
|
||||
procedure b3d_Space_evolve
|
||||
(Self : in bullet_c.Pointers.Space_Pointer;
|
||||
By : in Interfaces.C.C_float);
|
||||
|
||||
function b3d_Space_cast_Ray
|
||||
(Self : in bullet_c.Pointers.Space_Pointer;
|
||||
From : in c_math_c.Vector_3.Pointer;
|
||||
To : in c_math_c.Vector_3.Pointer) return bullet_c.ray_Collision.Item;
|
||||
|
||||
private
|
||||
|
||||
pragma Import (C, b3d_new_Box, "Ada_b3d_new_Box");
|
||||
pragma Import (C, b3d_new_Capsule, "Ada_b3d_new_Capsule");
|
||||
pragma Import (C, b3d_new_Cone, "Ada_b3d_new_Cone");
|
||||
pragma Import (C, b3d_new_convex_Hull, "Ada_b3d_new_convex_Hull");
|
||||
pragma Import (C, b3d_new_Mesh, "Ada_b3d_new_Mesh");
|
||||
pragma Import (C, b3d_new_Cylinder, "Ada_b3d_new_Cylinder");
|
||||
pragma Import (C, b3d_new_Heightfield, "Ada_b3d_new_Heightfield");
|
||||
pragma Import (C, b3d_new_multiSphere, "Ada_b3d_new_multiSphere");
|
||||
pragma Import (C, b3d_new_Plane, "Ada_b3d_new_Plane");
|
||||
pragma Import (C, b3d_new_Sphere, "Ada_b3d_new_Sphere");
|
||||
pragma Import (C, b3d_Shape_user_Data, "Ada_b3d_Shape_user_Data");
|
||||
pragma Import (C, b3d_Shape_user_Data_is, "Ada_b3d_Shape_user_Data_is");
|
||||
pragma Import (C, b3d_new_Object, "Ada_b3d_new_Object");
|
||||
pragma Import (C, b3d_Object_Shape, "Ada_b3d_Object_Shape");
|
||||
pragma Import (C, b3d_Object_user_Data, "Ada_b3d_Object_user_Data");
|
||||
pragma Import (C, b3d_Object_user_Data_is, "Ada_b3d_Object_user_Data_is");
|
||||
pragma Import (C, b3d_Object_Mass, "Ada_b3d_Object_Mass");
|
||||
pragma Import (C, b3d_Object_Friction_is, "Ada_b3d_Object_Friction_is");
|
||||
pragma Import
|
||||
(C,
|
||||
b3d_Object_Restitution_is,
|
||||
"Ada_b3d_Object_Restitution_is");
|
||||
pragma Import (C, b3d_Object_Site, "Ada_b3d_Object_Site");
|
||||
pragma Import (C, b3d_Object_Site_is, "Ada_b3d_Object_Site_is");
|
||||
pragma Import (C, b3d_Object_Spin, "Ada_b3d_Object_Spin");
|
||||
pragma Import (C, b3d_Object_Spin_is, "Ada_b3d_Object_Spin_is");
|
||||
pragma Import (C, b3d_Object_Transform, "Ada_b3d_Object_Transform");
|
||||
pragma Import (C, b3d_Object_Transform_is, "Ada_b3d_Object_Transform_is");
|
||||
pragma Import (C, b3d_Object_Speed, "Ada_b3d_Object_Speed");
|
||||
pragma Import (C, b3d_Object_Speed_is, "Ada_b3d_Object_Speed_is");
|
||||
pragma Import (C, b3d_Object_Gyre, "Ada_b3d_Object_Gyre");
|
||||
pragma Import (C, b3d_Object_Gyre_is, "Ada_b3d_Object_Gyre_is");
|
||||
pragma Import (C, b3d_Object_apply_Force, "Ada_b3d_Object_apply_Force");
|
||||
pragma Import (C, b3d_Object_apply_Torque, "Ada_b3d_Object_apply_Torque");
|
||||
pragma Import
|
||||
(C,
|
||||
b3d_Object_apply_Torque_impulse,
|
||||
"Ada_b3d_Object_apply_Torque_impulse");
|
||||
pragma Import (C, b3d_new_hinge_Joint, "Ada_b3d_new_hinge_Joint");
|
||||
pragma Import
|
||||
(C,
|
||||
b3d_new_space_hinge_Joint,
|
||||
"Ada_b3d_new_space_hinge_Joint");
|
||||
pragma Import (C, b3d_new_DoF6_Joint, "Ada_b3d_new_DoF6_Joint");
|
||||
pragma Import (C, b3d_new_cone_twist_Joint, "Ada_b3d_new_cone_twist_Joint");
|
||||
pragma Import (C, b3d_new_slider_Joint, "Ada_b3d_new_slider_Joint");
|
||||
pragma Import (C, b3d_new_ball_Joint, "Ada_b3d_new_ball_Joint");
|
||||
pragma Import (C, b3d_Joint_user_Data, "Ada_b3d_Joint_user_Data");
|
||||
pragma Import (C, b3d_Joint_user_Data_is, "Ada_b3d_Joint_user_Data_is");
|
||||
pragma Import (C, b3d_Joint_Object_A, "Ada_b3d_Joint_Object_A");
|
||||
pragma Import (C, b3d_Joint_Object_B, "Ada_b3d_Joint_Object_B");
|
||||
pragma Import (C, b3d_Joint_Frame_A, "Ada_b3d_Joint_Frame_A");
|
||||
pragma Import (C, b3d_Joint_Frame_B, "Ada_b3d_Joint_Frame_B");
|
||||
pragma Import (C, b3d_Joint_Frame_A_is, "Ada_b3d_Joint_Frame_A_is");
|
||||
pragma Import (C, b3d_Joint_Frame_B_is, "Ada_b3d_Joint_Frame_B_is");
|
||||
pragma Import (C, b3d_Joint_is_Limited, "Ada_b3d_Joint_is_Limited");
|
||||
pragma Import (C, b3d_Joint_Extent, "Ada_b3d_Joint_Extent");
|
||||
pragma Import (C, b3d_Joint_Velocity_is, "Ada_b3d_Joint_Velocity_is");
|
||||
pragma Import
|
||||
(C,
|
||||
b3d_Joint_hinge_Limits_are,
|
||||
"Ada_b3d_Joint_hinge_Limits_are");
|
||||
pragma Import
|
||||
(C,
|
||||
b3d_Joint_6DoF_lower_Limit_is,
|
||||
"Ada_b3d_Joint_6DoF_lower_Limit_is");
|
||||
pragma Import
|
||||
(C,
|
||||
b3d_Joint_6DoF_upper_Limit_is,
|
||||
"Ada_b3d_Joint_6DoF_upper_Limit_is");
|
||||
pragma Import
|
||||
(C,
|
||||
b3d_Joint_6DoF_lower_Limit,
|
||||
"Ada_b3d_Joint_6DoF_lower_Limit");
|
||||
pragma Import
|
||||
(C,
|
||||
b3d_Joint_6DoF_upper_Limit,
|
||||
"Ada_b3d_Joint_6DoF_upper_Limit");
|
||||
pragma Import (C, b3d_new_Space, "Ada_b3d_new_Space");
|
||||
pragma Import (C, b3d_free_Space, "Ada_b3d_free_Space");
|
||||
pragma Import (C, b3d_Space_add_Object, "Ada_b3d_Space_add_Object");
|
||||
pragma Import (C, b3d_Space_rid_Object, "Ada_b3d_Space_rid_Object");
|
||||
pragma Import (C, b3d_Space_add_Joint, "Ada_b3d_Space_add_Joint");
|
||||
pragma Import (C, b3d_Space_Gravity_is, "Ada_b3d_Space_Gravity_is");
|
||||
pragma Import (C, b3d_Space_evolve, "Ada_b3d_Space_evolve");
|
||||
pragma Import (C, b3d_Space_cast_Ray, "Ada_b3d_Space_cast_Ray");
|
||||
|
||||
end bullet_c.Binding;
|
||||
@@ -0,0 +1,24 @@
|
||||
-- This file is generated by SWIG. Please do *not* modify by hand.
|
||||
--
|
||||
with bullet_c.Pointers;
|
||||
|
||||
package bullet_c.pointer_Pointers
|
||||
is
|
||||
|
||||
-- Shape_Pointer_Pointer
|
||||
--
|
||||
type Shape_Pointer_Pointer is access all bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
-- Object_Pointer_Pointer
|
||||
--
|
||||
type Object_Pointer_Pointer is access all bullet_c.Pointers.Object_Pointer;
|
||||
|
||||
-- Joint_Pointer_Pointer
|
||||
--
|
||||
type Joint_Pointer_Pointer is access all bullet_c.Pointers.Joint_Pointer;
|
||||
|
||||
-- Space_Pointer_Pointer
|
||||
--
|
||||
type Space_Pointer_Pointer is access all bullet_c.Pointers.Space_Pointer;
|
||||
|
||||
end bullet_c.pointer_Pointers;
|
||||
@@ -0,0 +1,51 @@
|
||||
-- This file is generated by SWIG. Please do *not* modify by hand.
|
||||
--
|
||||
with Interfaces.C;
|
||||
|
||||
package bullet_c.Pointers is
|
||||
|
||||
-- Shape_Pointer
|
||||
--
|
||||
type Shape_Pointer is access all bullet_c.Shape;
|
||||
|
||||
-- Shape_Pointers
|
||||
--
|
||||
type Shape_Pointers is
|
||||
array
|
||||
(Interfaces.C
|
||||
.size_t range <>) of aliased bullet_c.Pointers.Shape_Pointer;
|
||||
|
||||
-- Object_Pointer
|
||||
--
|
||||
type Object_Pointer is access all bullet_c.Object;
|
||||
|
||||
-- Object_Pointers
|
||||
--
|
||||
type Object_Pointers is
|
||||
array
|
||||
(Interfaces.C
|
||||
.size_t range <>) of aliased bullet_c.Pointers.Object_Pointer;
|
||||
|
||||
-- Joint_Pointer
|
||||
--
|
||||
type Joint_Pointer is access all bullet_c.Joint;
|
||||
|
||||
-- Joint_Pointers
|
||||
--
|
||||
type Joint_Pointers is
|
||||
array
|
||||
(Interfaces.C
|
||||
.size_t range <>) of aliased bullet_c.Pointers.Joint_Pointer;
|
||||
|
||||
-- Space_Pointer
|
||||
--
|
||||
type Space_Pointer is access all bullet_c.Space;
|
||||
|
||||
-- Space_Pointers
|
||||
--
|
||||
type Space_Pointers is
|
||||
array
|
||||
(Interfaces.C
|
||||
.size_t range <>) of aliased bullet_c.Pointers.Space_Pointer;
|
||||
|
||||
end bullet_c.Pointers;
|
||||
@@ -0,0 +1,46 @@
|
||||
-- This file is generated by SWIG. Please do *not* modify by hand.
|
||||
--
|
||||
with c_math_c;
|
||||
with c_math_c.Vector_3;
|
||||
with Interfaces.C;
|
||||
|
||||
package bullet_c.ray_Collision is
|
||||
|
||||
-- Item
|
||||
--
|
||||
|
||||
type Item is record
|
||||
near_Object : access bullet_c.Object;
|
||||
hit_Fraction : aliased c_math_c.Real;
|
||||
Normal_world : aliased c_math_c.Vector_3.Item;
|
||||
Site_world : aliased c_math_c.Vector_3.Item;
|
||||
end record;
|
||||
|
||||
-- Items
|
||||
--
|
||||
type Items is
|
||||
array
|
||||
(Interfaces.C.size_t range <>) of aliased bullet_c.ray_Collision.Item;
|
||||
|
||||
-- Pointer
|
||||
--
|
||||
type Pointer is access all bullet_c.ray_Collision.Item;
|
||||
|
||||
-- Pointers
|
||||
--
|
||||
type Pointers is
|
||||
array
|
||||
(Interfaces.C
|
||||
.size_t range <>) of aliased bullet_c.ray_Collision.Pointer;
|
||||
|
||||
-- Pointer_Pointer
|
||||
--
|
||||
type Pointer_Pointer is access all bullet_c.ray_Collision.Pointer;
|
||||
|
||||
function construct return bullet_c.ray_Collision.Item;
|
||||
|
||||
private
|
||||
|
||||
pragma Import (C, construct, "Ada_new_ray_Collision");
|
||||
|
||||
end bullet_c.ray_Collision;
|
||||
36
3-mid/physics/implement/bullet/source/thin/bullet_c.ads
Normal file
36
3-mid/physics/implement/bullet/source/thin/bullet_c.ads
Normal file
@@ -0,0 +1,36 @@
|
||||
-- This file is generated by SWIG. Please do *not* modify by hand.
|
||||
--
|
||||
with Swig;
|
||||
with Interfaces.C;
|
||||
|
||||
package bullet_c is
|
||||
|
||||
-- Shape
|
||||
--
|
||||
subtype Shape is Swig.opaque_structure;
|
||||
|
||||
type Shape_array is
|
||||
array (Interfaces.C.size_t range <>) of aliased bullet_c.Shape;
|
||||
|
||||
-- Object
|
||||
--
|
||||
subtype Object is Swig.opaque_structure;
|
||||
|
||||
type Object_array is
|
||||
array (Interfaces.C.size_t range <>) of aliased bullet_c.Object;
|
||||
|
||||
-- Joint
|
||||
--
|
||||
subtype Joint is Swig.opaque_structure;
|
||||
|
||||
type Joint_array is
|
||||
array (Interfaces.C.size_t range <>) of aliased bullet_c.Joint;
|
||||
|
||||
-- Space
|
||||
--
|
||||
subtype Space is Swig.opaque_structure;
|
||||
|
||||
type Space_array is
|
||||
array (Interfaces.C.size_t range <>) of aliased bullet_c.Space;
|
||||
|
||||
end bullet_c;
|
||||
1327
3-mid/physics/implement/bullet/source/thin/bullet_c_wrap.cxx
Normal file
1327
3-mid/physics/implement/bullet/source/thin/bullet_c_wrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user