thanks for help! however i have some problem, so i have made a simple project.
i have used oolong engine example "falling box" (because i'm not able to compile with xcode exaples from bullet)
so the only change i have is box--->d4 dice (more simple than d10!)
the code for a d4 dice:
Code: Select all
struct texCoord
{
GLfloat u;
GLfloat v;
};
typedef struct texCoord texCoord;
typedef texCoord* texCoordPtr;
typedef struct vec2 vec2;
typedef vec2* vec2Ptr;
struct vec3
{
GLfloat x;
GLfloat y;
GLfloat z;
};
typedef struct vec3 vec3;
typedef vec3* vec3Ptr;
struct vec4
{
GLfloat x;
GLfloat y;
GLfloat z;
GLfloat w;
};
typedef struct vec4 vec4;
typedef vec4* vec4Ptr;
struct vertexData
{
vec3 vertex;
vec3 normal;
}
typedef struct vertexData vertexData;
typedef vertexData* vertexDataPtr;
static const vertexData MeshVertexData[] = {
{/*v:*/{0.000000, 1.000000, -0.000000}, /*n:*/{0.000000, 1.000000, 0.000000} },
{/*v:*/{0.942809, -0.333333, 0.000000}, /*n:*/{0.942808, -0.333323, 0.000000} },
{/*v:*/{-0.471405, -0.333333, -0.816497}, /*n:*/{-0.471389, -0.333323, -0.816492} },
{/*v:*/{0.000000, 1.000000, -0.000000}, /*n:*/{0.000000, 1.000000, 0.000000} },
{/*v:*/{-0.471405, -0.333333, -0.816497}, /*n:*/{-0.471389, -0.333323, -0.816492} },
{/*v:*/{-0.471405, -0.333333, 0.816497}, /*n:*/{-0.471389, -0.333323, 0.816492} },
{/*v:*/{0.000000, 1.000000, -0.000000}, /*n:*/{0.000000, 1.000000, 0.000000} },
{/*v:*/{-0.471405, -0.333333, 0.816497}, /*n:*/{-0.471389, -0.333323, 0.816492} },
{/*v:*/{0.942809, -0.333333, 0.000000}, /*n:*/{0.942808, -0.333323, 0.000000} },
{/*v:*/{0.942809, -0.333333, 0.000000}, /*n:*/{0.942808, -0.333323, 0.000000} },
{/*v:*/{-0.471405, -0.333333, 0.816497}, /*n:*/{-0.471389, -0.333323, 0.816492} },
{/*v:*/{-0.471405, -0.333333, -0.816497}, /*n:*/{-0.471389, -0.333323, -0.816492} },
};
// Example OpenGL ES 1.1 Drawing Code:
// glEnableClientState(GL_VERTEX_ARRAY);
// glEnableClientState(GL_NORMAL_ARRAY);
// glVertexPointer(3, GL_FLOAT, sizeof(VertexData3D), &MeshVertexData[0].vertex);
// glNormalPointer(GL_FLOAT, sizeof(VertexData3D), &MeshVertexData[0].normal);
// glDrawArrays(GL_TRIANGLES, 0, kMeshNumberOfVertices);
// glDisableClientState(GL_VERTEX_ARRAY);
// glDisableClientState(GL_NORMAL_ARRAY);
btScalar v[]={
0.000000, 1.000000, -0.000000,
0.942809, -0.333333, 0.000000,
-0.471405, -0.333333, -0.816497,
-0.471405, -0.333333, 0.816497
};
i have changed the box so:
Code: Select all
btCollisionShape *boxShape=new btConvexHullShape(v,4);
instead of:
Code: Select all
btCollisionShape *boxShape=new btBoxShape(btVector3(1,1,1));
and on renderScene the displayed objects:
Code: Select all
glColor4f(0,1,0,1);
glVertexPointer(3, GL_FLOAT, sizeof(vertexData), &MeshVertexData[0].vertex);
glColor4f(1,0,0,1);
glDrawArrays(GL_TRIANGLES, 0, 3);
glVertexPointer(3, GL_FLOAT, sizeof(vertexData), &MeshVertexData[3].vertex);
glDrawArrays(GL_TRIANGLES, 0, 3);
glColor4f(0,0,1,1);
glVertexPointer(3, GL_FLOAT, sizeof(vertexData), &MeshVertexData[6].vertex);
glDrawArrays(GL_TRIANGLES, 0, 3);
glColor4f(1,1,0,1);
glVertexPointer(3, GL_FLOAT, sizeof(vertexData), &MeshVertexData[9].vertex);
glDrawArrays(GL_TRIANGLES, 0, 3);
but seems that the d4 dice not stops on its face, and some dices not stop at all!
any ideas?
thanks