Jump to content
  • Advertisement
Sign in to follow this  

Indexed Primitives with Maya exporter

This topic is 5458 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'm trying to write a maya exporter that will export textured geometry that will in turn be read-in by a DirectX program that I'm currently writing. I want to utilize an index buffer to load the geometry with in my DirectX program, but I'm getting confused on how to handle shared vertices between different faces (the vertex position is the same, but the U/Vs might be different, since each face might have a different texture). In Maya, an index buffer of sorts is used per-face to index a giant vertex list. However, each face also has its own list of UV coordinates. So Maya gets away with using an index buffer of its own by de-coupling vertex UV info with vertex position info. Since UV info is part of the vertex format in DirectX, I can't really do that. My question is: how should I export the mesh so that I can utilize an indexed buffer in my program? At worst I'll just create a giant vertex buffer with lots of duplicated vertices. But I know that's very inefficient and I'd really prefer using an index buffer. Any help would be appreciated! Thanks!

Share this post

Link to post
Share on other sites
The same with 3D Studio max.
Take a box for example:
8 vertices, 12 faces, 24 normals, 24 uvs

What do ?
You can assume that when it gets to the maximum, you will require:
#numvertices = #numfaces * 3(vertices per face)

for ( every face ) do
for ( every wedge in face ) do
if ( buffer.vertex = face.wedge.vertex && buffer.uv = face.wedge.uv && buffer.normal = face.wedge.normal )
Allready buffered
buffer[numbuffered].vertex = face.wedge.vertex;
buffer[numbuffered].uv = face.wedge.uv;
buffer[numbuffered].normal = face.wedge.normal;

You have to remap to the new face indexes.

No other way arround.

Share this post

Link to post
Share on other sites
What you need to do is keep a vector of vertices.

As your iterating through the mesh try this

if VERTEX != exist in vertexList
pushBack VERTEX
indexBuffer.pushBack( indexBuffer.size() - 1 )
else if exists
int index = find index that it exists in
indexBuffer.pushBack( index );
end if

Hope this algo helps

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!