Code: Select all
#include <iostream>
#include <btBulletDynamicsCommon.h>
#include <btBulletCollisionCommon.h>
float pyramidVertices[] = {
0.000000f,1.000000f,0.000000f,
0.500000f,0.000000f,-0.500000f,
0.500000f,0.000000f,0.500000f,
0.000000f,1.000000f,0.000000f,
0.500000f,0.000000f,0.500000f,
-0.500000f,0.000000f,0.500000f,
0.000000f,1.000000f,0.000000f,
-0.500000f,0.000000f,0.500000f,
-0.500000f,0.000000f,-0.500000f,
0.000000f,1.000000f,0.000000f,
-0.500000f,0.000000f,-0.500000f,
0.500000f,0.000000f,-0.500000f,
0.500000f,0.000000f,-0.500000f,
0.000000f,0.000000f,0.000000f,
0.500000f,0.000000f,0.500000f,
0.500000f,0.000000f,0.500000f,
-0.500000f,0.000000f,0.500000f,
-0.500000f,0.000000f,-0.500000f,
-0.500000f,0.000000f,-0.500000f,
0.500000f,0.000000f,-0.500000f};
unsigned short pyramidIndices[] = {
0,1,2,
3,4,5,
6,7,8,
9,10,11,
12,13,14,
15,13,16,
16,13,17,
18,13,19};
int main (int argc, const char* argv[])
{
int i = 0;
btTransform t;
btVector3 aabbMin, aabbMax;
btTriangleMesh* mesh = new btTriangleMesh(false);
//issue here with findOrAddVertex()
while(i < sizeof(pyramidVertices) / sizeof(float))
mesh->findOrAddVertex(btVector3(pyramidVertices[i++], pyramidVertices[i++], pyramidVertices[i++]), true);
i = 0;
while(i < sizeof(pyramidIndices) / sizeof(unsigned short))
mesh->addIndex(pyramidIndices[i++]);
btSphereShape* sphereCDShape = new btSphereShape(.5f);
sphereCDShape->getAabb(t, aabbMin, aabbMax);
std::cout << aabbMin.getX() << ","
<< aabbMin.getY() << ","
<< aabbMin.getZ() << ","
<< aabbMax.getX() << ","
<< aabbMax.getY() << ","
<< aabbMax.getZ() << std::endl << std::endl;
mesh->calculateAabbBruteForce(aabbMin, aabbMax);
std::cout << aabbMin.getX() << ","
<< aabbMin.getY() << ","
<< aabbMin.getZ() << ","
<< aabbMax.getX() << ","
<< aabbMax.getY() << ","
<< aabbMax.getZ() << std::endl;
delete mesh;
delete sphereCDShape;
return 0;
}
http://www.gamedev.net/community/forums ... _id=541145