Hi,
I have .3ds ball mesh,did u know how to calculate
dFloat radiusX,radiusY, radiusZ - sphere radius along x axis from my ball scenode
regards
anandh
Need help NewtonCreateSphere
for any objects to create collision i use NewtonCreateConvexHull(). Its very hard to calculate exact values of models. I gues only possible way is to set random values, turn on debug geometry and then adjust values till you got it perfect. Anyway for NewtonCreateConvexHull() use this:
if you are not using IrrToNewton - delete it or declare const float IrrToNewton = 1;
Code: Select all
NewtonCollision *PIN::getConvexCollision(IMesh *MyMesh)
{
// Init stuff
int BufferCount = MyMesh->getMeshBufferCount();
IMeshBuffer *mb = 0;
float *varray = 0;
// Loop through all vertices and add them to an array of float that newton wants.
for (int bi = 0 ; bi < BufferCount ; bi++)
{
mb = MyMesh->getMeshBuffer(bi);
int VerticeCount = mb->getVertexCount();
varray = new float[VerticeCount*3];
switch(mb->getVertexType())
{
case EVT_STANDARD:
{
S3DVertex* Vertices = (S3DVertex*)mb->getVertices();
for (int ii = 0 ; ii < VerticeCount ; ii++)
{
varray[(ii*3)] = Vertices[ii].Pos.X * IrrToNewton;
varray[(ii*3)+1] = Vertices[ii].Pos.Y * IrrToNewton;
varray[(ii*3)+2] = Vertices[ii].Pos.Z * IrrToNewton;
}
break;
}
case EVT_2TCOORDS:
{
S3DVertex2TCoords* Vertices = (S3DVertex2TCoords*)mb->getVertices();
for (int ii = 0 ; ii < VerticeCount ; ii++)
{
varray[(ii*3)] = Vertices[ii].Pos.X * IrrToNewton;
varray[(ii*3)+1] = Vertices[ii].Pos.Y * IrrToNewton;
varray[(ii*3)+2] = Vertices[ii].Pos.Z * IrrToNewton;
}
break;
}
}
}
NewtonCollision *collision = NewtonCreateConvexHull(pWorld, mb->getVertexCount(), varray, sizeof(float)*3, 0);
return collision;
}
-
- Posts: 269
- Joined: Tue Oct 31, 2006 3:24 pm
- Contact: