Havok Rendering Animation

Havok Rendering Animation

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?

2 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Hi Jose:

Havok_XS is not a skeleton/skin render tools, out graphic lib which can handle some basic model rendering is just for demo purpose. If you use your own render pipeline but still use havok to export model data, you need to extract necessary infos from havok data, prepare your own data and then send them to the render function. Of course, you need to know the correct format of havok model data.

Fortunately there are lots of post discussing about this topic:

http://software.intel.com/en-us/forums/topic/294266 ->this one is helpful
http://software.intel.com/en-us/forums/topic/292298

http://software.intel.com/en-us/forums/topic/277019

I guess you still have some format problem. I suggest you can use preview tool and have a look the vertex/index buffer structure in xml formet.

Let me know if you still have problem.

Joe Developer Support Engineer Havok www.havok.com

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi