I am new to Newton and trying to build a collision tree with 6 vertices and 4 triangles. Here is the code which I have added to Entity class of the tutorial commons.
- Code: Select all
void Entity::LoadSimple ()
{
m_vertexCount = 6;
m_vertex = (dFloat*) malloc (3 * m_vertexCount * sizeof (dFloat));
m_normal = (dFloat*) malloc (3 * m_vertexCount * sizeof (dFloat));
m_uv = (dFloat*) malloc (2 * m_vertexCount * sizeof (dFloat));
m_vertex[0] = -100;
m_vertex[1] = 0;
m_vertex[2] = -100;
m_vertex[3] = -100;
m_vertex[4] = 0;
m_vertex[5] = 100;
m_vertex[6] = 100;
m_vertex[7] = 0;
m_vertex[8] = 100;
m_vertex[9] = 100;
m_vertex[10] = 0;
m_vertex[11] = -100;
m_vertex[12] = 0;
m_vertex[13] = 0;
m_vertex[14] = -200;
m_vertex[15] = 200;
m_vertex[16] = 0;
m_vertex[17] = -200;
for (int i = 0; i < m_vertexCount; i ++)
{
m_normal[i * 3 + 0] = 0;
m_normal[i * 3 + 1] = 0;
m_normal[i * 3 + 2] = 1;
m_uv[i * 2 + 0] = -4.250000;
m_uv[i * 2 + 1] = 1.000000;
}
//read all of the mesh segments,
int subMeshCount = 1;
m_subMeshCount = subMeshCount;
m_subMeshes = (SubMesh*) malloc (subMeshCount * sizeof (SubMesh));
for (int i = 0; i < subMeshCount; i ++)
{
int indexCount = 4;
const char* texName = "smilly.tga";
//load the texture for this submesh
m_subMeshes[i].m_textureHandle = LoadTexture (texName);
m_subMeshes[i].m_indexCount = indexCount;
m_subMeshes[i].m_indexArray = (unsigned short*) malloc (3 * indexCount * sizeof (unsigned short));
m_subMeshes[i].m_indexArray[0] = 1;
m_subMeshes[i].m_indexArray[1] = 2;
m_subMeshes[i].m_indexArray[2] = 0;
m_subMeshes[i].m_indexArray[3] = 2;
m_subMeshes[i].m_indexArray[4] = 3;
m_subMeshes[i].m_indexArray[5] = 0;
m_subMeshes[i].m_indexArray[6] = 0;
m_subMeshes[i].m_indexArray[7] = 3;
m_subMeshes[i].m_indexArray[8] = 4;
m_subMeshes[i].m_indexArray[9] = 3;
m_subMeshes[i].m_indexArray[10] = 5;
m_subMeshes[i].m_indexArray[11] = 4;
}
//create a complied DislpalyList
OptimizeMesh();
}
Please see attached image below which is what I expect to see as a result of the code above. But I see only a single triangle rendered on the application screen (see attached snapshot) when I run application.
Can anyone please let me know if I am doing something wrong when building triangle mesh above.
Thanks.