1

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)

jpwrunyan
  • 530
  • 5
  • 22
  • btw, this question would fit nicely on [3D Graphics, Modeling & Applications](http://area51.stackexchange.com/proposals/5022/3d-graphics-modeling-applications?referrer=4gdIZ8h3wh8laRLwFFF1-A2) – George Profenza Nov 01 '11 at 17:14

1 Answers1

1

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.

George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • Thanks, I will check with the designer and see if he knows how to do this. I assume this will change the .obj file output. – jpwrunyan Nov 02 '11 at 15:28
  • What I've mentioned above is how to do this. Say you have a primitive(Cube,Platonic,etc.), you need to convert it to a Mesh first (by pressing C), then right before you're ready to export, triangulate the mesh buy using Functions > Triangulate within C4D. If it helps I could whip up a Python script to do the triangulation and export in one go. – George Profenza Nov 02 '11 at 20:39
  • I'm still talking to the designer. He gave me a file that has 3 values per "f" line now, but still the models don't render correctly. A regular tetrahedron only renders two of the four faces. Certainly, if you gave me a script I would pass it on to him. Thanks for the help. BTW I have been looking online for some simple .obj models (like cubes, tetrahedrons) but can't find anything simple like that. Honestly, most free samples break in my parser. I will post the .obj file I am currently having trouble with. – jpwrunyan Nov 03 '11 at 01:36