Jump to content
  • Advertisement
Sign in to follow this  
Mercenarey

Problem with Directx, Milkshape and Normals

This topic is 5212 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been going over Brett Porter's Skeletal Animation demo. I am using DirectX. And this OpenGL snippet puzzled me: glBegin( GL_TRIANGLES ); {   for ( int j = 0; j < m_pMeshes.m_numTriangles; j++ )   {     int triangleIndex = m_pMeshes.m_pTriangleIndices[j];     const Triangle* pTri = &m_pTriangles[triangleIndex];     for ( int k = 0; k < 3; k++ )     {       int index = pTri->m_vertexIndices[k];       glNormal3fv( pTri->m_vertexNormals[k] );       glTexCoord2f( pTri->m_s[k], pTri->m_t[k] );       glVertex3fv( m_pVertices[index].m_location );     }   } } glEnd(); It seems, that for an indexed vertex you can pick a normal. This is a loose coupling compared to DirectX, where a vertex' normal is locked inside the vertex structure - and then it is cemented down in a locked vertexbuffer. The problem with this is, that shared Milkshape vertices can have different normals in different contexts/indices (for instance a sharp corner would have triangles sharing the same vertex, while having different normals), and this is well supported by OpenGL, while in DirectX, you can't simply unlock the vertexbuffer and alter the stuff constantly. The traffic over the bus would kill performance. So how the heck do I get around this? And how does directx' own .x format get around it? Should I duplicate those vertices that don't share normals? Thanx.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Mercenarey
It seems, that for an indexed vertex you can pick a normal. This is a loose coupling compared to DirectX, where a vertex' normal is locked inside the vertex structure - and then it is cemented down in a locked vertexbuffer...

You can do the same thing in D3D by filling a vertex buffer every frame (which is pretty much what "immediate mode" OpenGL code does).

Quote:
Original post by Mercenarey
...The problem with this is, that shared Milkshape vertices can have different normals ... So how the heck do I get around this?


In both OpenGL and D3D, you have to duplicate the vertex if anything is different.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!