Animated Meshes - ZackWilde27/Z3dPy GitHub Wiki
z3dpy.Mesh(list_of_lists_of_triangles, vPos)
Animated meshes are just meshes with a non -1 frame number, and a list of 'frames'
# For OBJs, remove the frame number from the name. anim1, anim2, etc. becomes anim.obj
myAniMesh = zp.LoadAniMesh("directory_to_obj_sequence.obj")
print(myAniMesh.frame)
Creating
First, export as an OBJ Sequence.
With Blender, each frame of the timeline is exported as an OBJ, it doesn't matter how it was animated or made, since it's all vertex animation.
OBJ sequences are supported but I heavily recommend storing it in an Animated OBJ file.
Much cleaner
Much smaller
LoadAniMesh() will automatically convert OBJ sequences to AOBJs, with a printed message about it, but I've also included a separate script for converting.
Loading
To load these, call LoadAniMesh() and remove the number from the name
myAnim = z3dpy.LoadAniMesh("mesh/anim.obj")
enemy = z3dpy.Thing([myAnim], [15, 30, 0])
To get the animations to play, the frame counter needs to be incremented during the draw loop.
@myWindow.event
def on_draw:
# Render 3D
triangles = [pyglet.shapes.Triangle(tri[0][0], tri[0][1], tri[1][0], tri[1][1], tri[2][0], tri[2][1], color=zp.VectorFloor(zp.TriGetColour(tri)), batch=myBatch) for tri in zp.Render()]
myWindow.clear()
myBatch.draw()
myAnim.frame += 1
# or
# IncrementFrames() will increment the frame counter for all animeshes in a thing.
enemy.IncrementFrames()