3D Model Loading Problems

Started by
25 comments, last by ryan20fun 9 years, 6 months ago

Hello guys

I've written an obj loader that could load the 3dmax obj. I tried to draw a cube but all the things aren't what I've been expecting. There was something displayed but the cube looked awkward and all the vertices are messed up. I don't think it's a cube anyway:(

I know there's something called vertex winding stuff. But I just can't fix this. I tried to load an obj file exported by blender. But it's still very messy.

I wonder if there's any software could export the exact same thing that is compatible with direct3d standard. It's very difficult to work with something wrong.

Advertisement

Why don’t you show a picture of how it looks in your program and how it looks in Blender?

There is no Direct3D 11 standard format; you have to make everything yourself.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

It is typical to see corrupted geometry when programming object importers / exporters. Winding order is the simplest of the problems to solve. Typically invalid output is result of triangles indexing wrong vertices.

Cheers!

Why don’t you show a picture of how it looks in your program and how it looks in Blender?

There is no Direct3D 11 standard format; you have to make everything yourself.

L. Spiro

I use 3dmax for this

iDoUAfs.jpg

Here's how it looks in my program

hTBgoiB.jpg

It is typical to see corrupted geometry when programming object importers / exporters. Winding order is the simplest of the problems to solve. Typically invalid output is result of triangles indexing wrong vertices.

Cheers!

I know that. But how could a professional 3d software give wrong indices or vertices?

By the way, vs2012 model view failed to load the obj exported by max. But it worked well with blender's.

It is typical to see corrupted geometry when programming object importers / exporters. Winding order is the simplest of the problems to solve. Typically invalid output is result of triangles indexing wrong vertices.

Cheers!

I know that. But how could a professional 3d software give wrong indices or vertices?

By the way, vs2012 model view failed to load the obj exported by max. But it worked well with blender's.

The 3D CAD tool 99 times out of 100 produces valid file(albit with there own tweak on some formats like DAE, wavefront object )

The problem most likely exists in your parser code, It is also posible that the CAD tool has produced a edge case with the file.

I would recomend that you use a tool like Assimp to do the heavy lifting for you and you just process the data from it.

It's what i do, And it saves me from the hassle of different 3D formats as it handles a nice variety of them.

Hope that helps smile.png

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.


kauna: "It is typical to see corrupted geometry when programming object importers / exporters.."

how could a professional 3d software give wrong indices or vertices?

Unlikely. I think kauna was referring to your importer. You should be checking the vertex/index array that you generate after you read in the obj file.

My guess at what was intended by kauna's comment is for you to check your data after reading in the obj file (which is the way to go at this point):

1. Do the triangles as indexed form a cube?

2. Assuming your app culls counter-clockwise, are the triangle vertices as indexed in clockwise winding order? I.e., when viewed from outside the cube, does each set of triangle vertices appear in clockwise order, relative to the center of each triangle?

3. If you're using a simple vertex array without indexing, does each set of 3 vertices in series in the vertex buffer form a triangle in clockwise winding order?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

The most likely problem is that you are not handling indices properly.

#1: Have you accounted for the fact that indices are 1-based and not 0-based?

#2: Have you accounted for the fact that there are 2 mapping modes for indices? http://en.wikipedia.org/wiki/Wavefront_.obj_file#Relative_and_absolute_indices

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

It is typical to see corrupted geometry when programming object importers / exporters. Winding order is the simplest of the problems to solve. Typically invalid output is result of triangles indexing wrong vertices.

Cheers!

I know that. But how could a professional 3d software give wrong indices or vertices?
By the way, vs2012 model view failed to load the obj exported by max. But it worked well with blender's.
The 3D CAD tool 99 times out of 100 produces valid file(albit with there own tweak on some formats like DAE, wavefront object )
The problem most likely exists in your parser code, It is also posible that the CAD tool has produced a edge case with the file.

I would recomend that you use a tool like Assimp to do the heavy lifting for you and you just process the data from it.
It's what i do, And it saves me from the hassle of different 3D formats as it handles a nice variety of them.

Hope that helps :)
i don't know much about assimp.but i think i will have to go there some day. Is there any tutorial about assimp with d3d? If not , gl is fine

The most likely problem is that you are not handling indices properly.

#1: Have you accounted for the fact that indices are 1-based and not 0-based?
#2: Have you accounted for the fact that there are 2 mapping modes for indices? http://en.wikipedia.org/wiki/Wavefront_.obj_file#Relative_and_absolute_indices


L. Spiro

what's mapping mode? For th first question i did thought about it

This topic is closed to new replies.

Advertisement