# creating arbitrary geometry

I gather from existings posts that this has been accomplished before, but I can’t find the specific information.

I’m working on a project that requires some static world geometry to be created at runtime, but I’m not sure how to do that in Panda. Could someone please provide example code (a simple CreateTriangle function is enough) that will let me stick an arbitrary triangle into an existing world, with position, normals, and texture coordinates? Are Panda’s triangles one-sided, and do they have a specific winding order? For many triangles, should I be creating some kind of special triangle group, using triangle strips for connected triangles, caching common vertices, etc?

Also, how are Panda’s axes set up? Right or left handed coordinate system? Which way does the default rotation (0,0,0) face? Can I easily change the world axis orientation to suit my needs (+x=east, +y=north, +z=up)?

Some info on geometry here…
panda3d.etc.cmu.edu/phpbb2/viewtopic.php?t=374

You can go really indepth and create all the nodes yourself, which I have attempted to do. But I found it easier to load in a simple model and then mutate the points.

The axes : IIRC, +X is right, +Y is in, +Z is up. So its left-handed with the Y & Z swapped, if that makes sense - Best to list to David on that

See this thread for an example of using the egg library to generate simple geometry:
https://discourse.panda3d.org/viewtopic.php?t=374

By default, triangles are one-sided, but you can change this with:

``````
nodePath.setTwoSided(True)``````

The winding order is counter-clockwise. The egg library will automatically handle making triangle strips out of your triangles and unifying duplicate vertices, so you can just add plain triangles (or higher-order polygons, if you like) to the EggData and let it do the rest. The default coordinate system is right-handed z-up, which is exactly what you describe you need.

David