parsingobjectwavefrontmolehillcinema-4d

Cinema 4D .obj files do not import correctly


I have a parser written in ActionScript for importing .obj files. I then render them in Molehill, which is awesome. So far, I can import what I think are standard .obj files with vertices in the x, y, z order or the z, x, y order. However, any .obj file exported from Cinema 4D just fails.
A tetrahedron, for example, doesn't even render a z component (the .obj file has indices with proper z-depth!). A simple cube is missing half of the triangle faces. I heard that Cinema 4D exports in the x, z, y order and so I tried to account for that as well, but no luck. And really, the vertex order shouldn't result in missing polygons anyway.

Has anyone imported Cinema 4D meshes from .obj files? Is there some special trick? Does Cinema 4D just ingnore the Wavefront .obj standards? Thanks in advance for any help.

Update: I believe the culprit is that the index data for the polygons is in a set of 4 instead of 3. For example, I want this: 1/1 2/2 3/3 but not this: 1/1 2/2 3/3 4/4. The Cinema 4D exports .obj files as the latter. Anyway to address this problem on either the parsing end or the Cinema 4D exporting end?

Update2: Now the index data is the way I want it, but still I cannot render properly. The following is for a regular tetrahedron. When I attempt to render it, only two of the four faces appear:

# WaveFront *.obj file (generated by CINEMA 4D)
g __
v -70.571068 -100 122.232675
v 141.142136 -100 0
v 0 100 0
v -70.571068 -100 -122.232675
vt 0.666667 0 0
vt 0.5 0.5 0
vt 0 0 0
vt 1 0 0
vt 0 0.5 0
vt 0.333333 1 0
vt 1 1 0
vt 0.666667 1 0
vt 0.333333 0 0
vt 0.75 0.933013 0
f 4/10 2/5 1/2 
f 1/1 3/8 4/9 
f 2/4 3/7 1/1 
f 4/9 3/6 2/3 

Is there anything odd about the above conent? (It would help if I had an .obj file exported from another standard 3D software of the same tetrahedron)


Solution

  • I'm not sure how you're drawing the mesh using Molehill, but it's fairly easy to triangulate the mesh before exporting to .obj by using Functions > Triangulate.