Hi to all.
This question relates to creating .egg files that: define the data for an actor, as well as a file the defines its animation. From the manual, I have seen that it is very clearly explained how to store a model as an egg file:
def makeWedge(angleDegrees = 360, numSteps = 16): data = EggData() vp = EggVertexPool('fan') data.addChild(vp) poly = EggPolygon() data.addChild(poly) v = EggVertex() v.setPos(Point3D(0, 0, 0)) poly.addVertex(vp.addVertex(v)) angleRadians = deg2Rad(angleDegrees) for i in range(numSteps + 1): a = angleRadians * i / numSteps y = math.sin(a) x = math.cos(a) v = EggVertex() v.setPos(Point3D(x, 0, y)) poly.addVertex(vp.addVertex(v)) # To write the egg file to disk, use this: data.writeEgg(Filename("wedge.egg"))
That’s clear enough: make vertexlpool, vertex and polygon object; and vertices to vertex object, then to vertexpool, then to polygon object. But that just seems to create the geometry, and not much is said on how to create data like joints, as well as an animation file.
I ask because I have implemented something that sort of creates animations. Basically, there are multiple models within the scene that are all procedurally created. Some models are parented to other models; so when the parent’s attributes change, so does the child’s attributes.
To make it look like it’s animated, I use frames:
- There is a slider, whose position determines the active frame.
- A keyframe can be added where each models hpr, xyz and scale data is captured.
- To play the animation, I add a task which moves from one keyframe to another, updating the hpr, xyz and scale values of all the models in the scene as it moves.
So if I rotate a parent model, it might look like an arm, a foot, a door opening etc, and it would also rotate whatever children it has. To store these models [parent and children] as one model in a file, I know that I would just need to get all their vertex-data and then form the file as described above. But like I said, that just seems to describe how to store the geometry as a model and not an actor; how would I store these models as an actor with joints, and how would I generate the corresponding animation file? If the question appears vague, please specify where and I shall try to elaborate it. I know that there is documentation on the structure of .egg files, but before going into all that, is there a simpler way to do this? As simple as it is to generate an .egg file using the above code, but in this sense, as an actor with a corresponding animation file?
Thanks in advance.