Troubles with exporter

Hi everyone,

I’m new here, so I’d like to introduce myself with a (hopefully) minor problem. :slight_smile:

I’m trying to create a Python script that exports geometry data from Houdini into the egg format. I’m doing this partly as an exercise, partly as a convenient part of my pipeline, and partly because I would like the flexibility that doing it myself offers.

I’ve got it exporting vertices and polygons just fine, as well as normals and uvs. However, when I load and render the resultant model, it appears that the normals have been reversed (the model is inside-out). I reverse both vertex and primitive normals in Houdini, but it doesn’t help. I turn on two-sided in Panda, and it “fixes” the issue–now I want to fix it for real.

My code is below. If you aren’t familiar with Houdini (totally wouldn’t blame you), the hou module is what you use to interface your Python scripts with data in Houdini. I’m familiar enough with Houdini that I’m relatively certain there are no errors in these parts of my script.

Can anyone spot something I’m doing wrong with the Panda parts of my code?

from pandac.PandaModules import *
def writeEgg():
    geo = hou.pwd().geometry()
    filepath ='/')
    filepath = filepath[:-1]
    fileBase = ''
    for f in filepath:
        fileBase = fileBase + f + '/'
    file = fileBase + 'test.egg'
    egg = EggData()
    points = geo.points()
    group = EggGroup('group1')
    verts = EggVertexPool('group1')
    for face in geo.prims():
        poly = EggPolygon()
        for vert in face.vertices():
            ev = EggVertex()
            ev.setPos(Point3D(vert.point().position()[0], vert.point().position()[1], vert.point().position()[2]))
    egg.triangulatePolygons(EggData.TConvex & EggData.TPolygon)
    print file

Yes, it’s basically copied from Treeform’s code here in the forums. :blush:

Thanks so much!

Panda (as most 3-D engines) uses vertex ordering, not the normal, to determine which is the “front” of a polygon. Panda’s convention is that the vertices should be ordered counter-clockwise when seen from the front. Thus, your converter will have to ensure that it outputs the vertices in the correct order.


That worked great. Thanks!