Hmm, I prefer trying ASE before going into something that is maybe more complicated, just because I can't find a good ASE to DAE or a BSP converter.
I tried my ASE map into a simple ASE viewer, it's really OK, the mesh doesn't have any degenerated faces, it has 6 faces, just a simple room, like a cube.
If I have to define a box for it's size, it would be
-512
-512
8
512
512
368
(Yeah, again, Quake 3 inverts the Y and Z axis,... sorry.)
There are 4 vertices by mesh, I can use that code successfully :
- Code: Select all
col = NewtonCreateTreeCollision(g_NewtonWorld);
NewtonTreeCollisionBeginBuild(col);
for (int i = 0 ; i < m->objectCount; i++) {
ASE_GeomObject * tmpObj = &m->objs[i];
int nbVertices = tmpObj->mesh.vertexCount;
float vArray[12];
vArray[0] = tmpObj->mesh.vertices[0].x;
vArray[1] = tmpObj->mesh.vertices[0].y;
vArray[2] = tmpObj->mesh.vertices[0].z;
vArray[3] = tmpObj->mesh.vertices[1].x;
vArray[4] = tmpObj->mesh.vertices[1].y;
vArray[5] = tmpObj->mesh.vertices[1].z;
vArray[6] = tmpObj->mesh.vertices[2].x;
vArray[7] = tmpObj->mesh.vertices[2].y;
vArray[8] = tmpObj->mesh.vertices[2].z;
vArray[9] = tmpObj->mesh.vertices[3].x;
vArray[10] = tmpObj->mesh.vertices[3].y;
vArray[11] = tmpObj->mesh.vertices[3].z;
G_Printf("-- Mesh %i Start --\n", i);
G_Printf("[0] = %f, [1] = %f, [2] = %f\n", vArray[0], vArray[1], vArray[2]);
G_Printf("[3] = %f, [4] = %f, [5] = %f\n", vArray[3], vArray[4], vArray[5]);
G_Printf("[6] = %f, [7] = %f, [8] = %f\n", vArray[6], vArray[7], vArray[8]);
G_Printf("[9] = %f, [10] = %f, [11] = %f\n", vArray[9], vArray[10], vArray[11]);
G_Printf("--- Mesh %i End ---\n",i);
NewtonTreeCollisionAddFace(col, 4, (float*)vArray, sizeof(float) * 4, 0);
}
NewtonTreeCollisionEndBuild(col, 0);
Log output :
- Code: Select all
-- Mesh 0 Start --
[0] = 512.000000, [1] = -512.000000, [2] = 8.000000
[3] = -512.000000, [4] = -512.000000, [5] = 8.000000
[6] = 512.000000, [7] = 512.000000, [8] = 8.000000
[9] = -512.000000, [10] = 512.000000, [11] = 8.000000
--- Mesh 0 End ---
-- Mesh 1 Start --
[0] = 512.000000, [1] = -512.000000, [2] = 368.000000
[3] = 512.000000, [4] = -512.000000, [5] = 8.000000
[6] = 512.000000, [7] = 512.000000, [8] = 368.000000
[9] = 512.000000, [10] = 512.000000, [11] = 8.000000
--- Mesh 1 End ---
-- Mesh 2 Start --
[0] = 512.000000, [1] = 512.000000, [2] = 368.000000
[3] = -512.000000, [4] = 512.000000, [5] = 8.000000
[6] = -512.000000, [7] = 512.000000, [8] = 368.000000
[9] = 512.000000, [10] = 512.000000, [11] = 8.000000
--- Mesh 2 End ---
-- Mesh 3 Start --
[0] = -512.000000, [1] = 512.000000, [2] = 368.000000
[3] = -512.000000, [4] = -512.000000, [5] = 368.000000
[6] = 512.000000, [7] = 512.000000, [8] = 368.000000
[9] = 512.000000, [10] = -512.000000, [11] = 368.000000
--- Mesh 3 End ---
-- Mesh 4 Start --
[0] = -512.000000, [1] = -512.000000, [2] = 368.000000
[3] = -512.000000, [4] = -512.000000, [5] = 8.000000
[6] = 512.000000, [7] = -512.000000, [8] = 368.000000
[9] = 512.000000, [10] = -512.000000, [11] = 8.000000
--- Mesh 4 End ---
-- Mesh 5 Start --
[0] = -512.000000, [1] = 512.000000, [2] = 368.000000
[3] = -512.000000, [4] = -512.000000, [5] = 8.000000
[6] = -512.000000, [7] = -512.000000, [8] = 368.000000
[9] = -512.000000, [10] = 512.000000, [11] = 8.000000
--- Mesh 5 End ---
But it doesn't seem that it's loaded perfectly, because when I do
- Code: Select all
float boxP0[3];
float boxP1[3];
float matrix[4][4];
NewtonBodyGetMatrix (g_NewtonRigidBody, &matrix[0][0]);
NewtonCollisionCalculateAABB (g_NewtonCollision, &matrix[0][0], &boxP0[0], &boxP1[0]);
NewtonSetWorldSize (g_NewtonWorld, (float*)boxP0, (float*)boxP1);
G_Printf("World Min Size : [0] = %f, [1] = %f, [2] = %f\n", boxP0[0], boxP0[1], boxP0[2]);
G_Printf("World Max Size : [0] = %f, [1] = %f, [2] = %f\n", boxP1[0], boxP1[1], boxP1[2]);
The log prints :
- Code: Select all
World Min Size : [0] = -512.224976, [1] = -512.224976, [2] = -512.224976
World Max Size : [0] = 512.224976, [1] = 512.224976, [2] = 512.224976
It should be something like...
- Code: Select all
World Min Size : [0] = -512.224976, [1] = -512.224976, [2] = 8.000000
World Max Size : [0] = 512.224976, [1] = 512.224976, [2] = 368.000000
Then I try to simulate a simple cube, with a small size, NewtonCreateBox... The cube falls, pass through the floor and it stops at -538.000000 in the Z (normally Y) axis.
Is there a problem ? I already tried to invert some axis in the Tree Collision building stuff...
If you wanna look at my ASE file, just have to look at something like that :
- Code: Select all
*MESH_VERTEX_LIST {
*MESH_VERTEX 0 512.000000 -512.000000 8.000000
*MESH_VERTEX 1 -512.000000 -512.000000 8.000000
*MESH_VERTEX 2 512.000000 512.000000 8.000000
*MESH_VERTEX 3 -512.000000 512.000000 8.000000
}
Thanks so much for your help, I think again there's something stupid I missed...