Hey guys,
I know this is mostly a physics engine based but since in the demos, its rendering the animation models, so how can I render my own models. I tried looking deep in the demos and couldnt come up with anything. I am using OpenGL for my rendering and I kind of came up with this code by grabbing the vertices, normals and texture coordinates but it not working too well. My animation loading works great and I even tried to load my own model in the demos and it rendered and animated completely fine so I know there isnt anything wrong with it. This is the way I am getting it:
for(int sections = 0; sections < m_skinBinding[1]->m_mesh->m_sections.getSize(); ++sections)
{
hkxMeshSection* sec = m_skinBinding[1]->m_mesh->m_sections[sections];
//grab the vertex, normals, and textures coodinates
const hkxVertexDescription& vdesc = sec->m_vertexBuffer->getVertexDesc();
const hkxVertexDescription::ElementDecl* pdecl = vdesc.getElementDecl(hkxVertexDescription::HKX_DU_POSITION, 0);
const hkxVertexDescription::ElementDecl* inormDecl = vdesc.getElementDecl(hkxVertexDescription::HKX_DU_NORMAL, 0);
const hkxVertexDescription::ElementDecl* texDecl = vdesc.getElementDecl(hkxVertexDescription::HKX_DU_TEXCOORD, 0);
verts = (float*)sec->m_vertexBuffer->getVertexDataPtr(*pdecl);
norms = (float*)sec->m_vertexBuffer->getVertexDataPtr(*inormDecl);
texs = (float*)sec->m_vertexBuffer->getVertexDataPtr(*texDecl);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(float) * 3, &verts[0]);
if (texs)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(float), &texs[0]);
}
if (norms)
{
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(float) * 3, &norms[0]);
}
//grab the indicies
for(int indx = 0; indx < sec->m_indexBuffers.getSize(); ++indx)
{
hkxIndexBuffer* indexBuf = sec->m_indexBuffers[indx];
indiciesCount = indexBuf->m_indices16.getSize();
glDrawElements(GL_TRIANGLES, indiciesCount, GL_UNSIGNED_SHORT, &indexBuf->m_indices16[0]);
}
glDisableClientState(GL_VERTEX_ARRAY);
if (texs)
{
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (norms)
{
glDisableClientState(GL_NORMAL_ARRAY);
}
}
This doesnt work for me. The model is completely stretch out everywhere in the scene. What is the best way to do this? Or is there a something in the demos that I completely missed?



