box
rp3d :: CollisionWorld world ;
rp3d :: Vector3 initPosition (0.0 , 0.0 , 0.0) ;
rp3d :: Quaternion initOrientation = rp3d :: Quaternion ::identity () ;
rp3d :: Transform transform ( initPosition , initOrientation ) ;
rp3d :: CollisionBody * body ;
body = world.createCollisionBody(transform) ;
rp3d ::BoxShape *box = new rp3d ::BoxShape(rp3d ::Vector3(2.f,3.f, 5.f));
rp3d::Transform transform2 = rp3d:: Transform :: identity () ;
rp3d :: ProxyShape * proxyShape ;
proxyShape = body->addCollisionShape (box , transform2);
rp3d::Vector3 startPoint (2 , 3 , 5);
rp3d:: Vector3 endPoint (-4 , -6 , 10) ;
rp3d::Ray ray (startPoint , endPoint) ;
rp3d::RaycastInfo raycastInfo ;
bool isHit = body->raycast(ray,raycastInfo ) ;
std::cout << isHit << std::endl;
body->removeCollisionShape ( proxyShape ) ;
concaveMesh
reactphysics3d :: CollisionWorld world ;
reactphysics3d :: Vector3 initPosition (0.0 , 0.0 , 0.0) ;
reactphysics3d :: Quaternion initOrientation = rp3d :: Quaternion ::identity () ;
reactphysics3d :: Transform transform ( initPosition , initOrientation ) ;
reactphysics3d :: CollisionBody * body ;
body = world.createCollisionBody(transform) ;
float vertices [9];
vertices [0] = -3; vertices [1] = -3; vertices [2] = 3;
vertices [3] = 3; vertices [4] = -3; vertices [5] = 3;
vertices [6] = 0; vertices [7] = 3; vertices [8] = 3;
int indices [3];
indices [0]=0; indices [1]=3; indices [2]=2;
const int nbVertices = 3;
const int nbTriangles = 1;
// float vertices [3 * nbVertices ] = ...;
// int indices [3 * nbTriangles ] = ...;
reactphysics3d :: TriangleVertexArray * triangleArray =
new reactphysics3d :: TriangleVertexArray ( nbVertices , vertices , 3 * sizeof ( float ) , nbTriangles ,
indices , 3 * sizeof ( int ) ,
reactphysics3d::TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE ,
reactphysics3d::TriangleVertexArray::IndexDataType ::INDEX_INTEGER_TYPE ) ;
reactphysics3d :: TriangleMesh triangleMesh ;
triangleMesh.addSubpart(triangleArray);
reactphysics3d::ConcaveMeshShape * concaveMesh = new reactphysics3d :: ConcaveMeshShape (&
triangleMesh ) ;
rp3d :: ProxyShape * proxyShape ;
proxyShape = body->addCollisionShape (concaveMesh , rp3d::Transform::identity());
reactphysics3d::Vector3 startPoint (0 , 0 , 0);
reactphysics3d:: Vector3 endPoint (0 , 0 , 10) ;
reactphysics3d::Ray ray ( startPoint , endPoint ) ;
reactphysics3d::RaycastInfo raycastInfo ;
bool isHit = body->raycast(ray,raycastInfo ) ;
std::cout << isHit << std::endl;
body->removeCollisionShape ( proxyShape ) ;