Meshes 0.4 - ZackWilde27/Z3dPy GitHub Wiki
myMesh = z3dpy.Mesh((thisTri, thatTri), [1.0, 2.0, 3.0])-
tris
-
position
-
rotation
measured in degrees. -
scale
-
id
copied to the triangles, so you can test where a given triangle came from. -
colour
the current colour, set during SetColour(). -
cull
wether or not back-facing triangles are culled. -
visible
-
material
the material that determines the final colour of it's triangles. -
frame
if -1, it's a static mesh, if 0 or above, the current frame of an animated mesh.
- SetColour(vColour)
Sets the colour of the triangles in a mesh, which are given to the shaders.
To load a mesh from an OBJ, DAE, or X3D file, use LoadMesh()
# LoadMesh(filename, *vPos, *VScale)
myMesh = z3dpy.LoadMesh("directory-to-mesh.obj", [0.0, 0.0, 0.0], [1.0, 1.0, 1.0])- N-gons are triangulated automatically
- UVs are supported, kinda.
If an OBJ file is exported with materials, LoadMesh() will automatically separate it and return a list of meshes, with their colours determined by the mtl file.
Animated meshes are supported through OBJ sequences or animated obj files.
To load an OBJ sequence or AOBJ file, use LoadAniMesh()
# LoadAniMesh(filename, *vPos, *VScale)
# When loading an OBJ sequence, remove the frame number from the name.
# If my objs were called anim1.obj, anim2.obj, etc. Put in anim.obj
myMesh = z3dpy.LoadAniMesh("anim.obj")OBJ sequences will automatically be converted to an AOBJ on import, and I've also included a separate script for converting.
Each mesh has a material that determines the final colour of each triangle.
myMesh.material = z3dpy.MATERIAL_SIMPLE
myOtherMesh.material = z3dpy.MATERIAL_DYNAMIC
# Then, during the draw loop...
for tri in z3dpy.RenderMeshList([myMesh, myOtherMesh]):
# The colour will be pre-set based on the material
colour = z3dpy.TriGetColour(tri)Materials page
Meshes also have their own id, which is copied to the triangles for testing where it came from
myMesh.id = 2
# Then...
for tri in z3dpy.RenderMeshList([myMesh]):
print(z3dpy.TriGetId(tri))