Defining animations in a "procedural" manner.

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.

I could have added an EDIT, but that would make the question too long.

After some little reading, I came across some relevant material. To define joints:

The structure for an animated model should resemble the following:

<Group> CHARACTER_NAME {
  <Dart> { 1 }
  <Joint> JOINT_A {
    <Transform> { ... }
    <VertexRef> { ... }
    <Group> { <Polygon> ... }
    <Joint> JOINT_B {
      <Transform> { ... }
      <VertexRef> { ... }
      <Group> { <Polygon> ... }
    }
    <Joint> JOINT_C {
      <Transform> { ... }
      <VertexRef> { ... }
      <Group> { <Polygon> ... }
    }
    ...
  }
}

So after creating the relevant vertexpools with vertices and polygons that reference vertices, I would append the relevant joint-data to the file that I am writing. That’s how joints are defined. Next, to create an animation table:

<Table> {
  <Bundle> CHARACTER_NAME {
    <Table> "<skeleton>" {
      <Table> JOINT_A {
        <Xfm$Anim_S$> xform {
          <Char*> order { sphrt }
          <Scalar> fps { 24 }
          <S$Anim> x { 0 0 10 10 20 ... }
          <S$Anim> y { 0 0 0 0 0 ... }
          <S$Anim> z { 20 20 20 20 20 ... }
        }
        <Table> JOINT_B {
          <Xfm$Anim_S$> xform {
            <Char*> order { sphrt }
            <Scalar> fps { 24 }
            <S$Anim> x { ... }
            <S$Anim> y { ... }
            <S$Anim> z { ... }
          }
        }
        <Table> JOINT_C {
          <Xfm$Anim_S$> xform {
            <Char*> order { sphrt }
            <Scalar> fps { 24 }
            <S$Anim> x { ... }
            <S$Anim> y { ... }
            <S$Anim> z { ... }
          }
        }
      }
    }

Here is where something is not clear to me. What exactly are the values in “<S$Anim> x { … }”? Like for instance here:

<S$Anim> x { 0 0 10 10 20 ... }

What do “0,0,10,10,20” represent? Are they the values of x at frame: “0,1,2,3 and 4”? If so, where is the distance between frame 0 and 1 indicated? I mean, let’s say frame 0 was at time 10 and frame 1 was at time 30; where is this indicated? I know it also says this:

What does the part in bold mean? Like if before creating the animation table, my joint at time 10 has an x-value of 3 and at time 30 has an x value of 8, how would that be represented? I know I’ve misunderstood something, hopefully someone can clarify it for me.

(This is information is all from the “eggSyntax.txt” file).

Is it that when it is said that:

It means each of the digits here:

<S$Anim> x { 0 0 10 10 20 ... }

Represent the value of x at frame:1,2,3,4 and 5? And the fact that “all frames represent the same length of time”, the time per frame would be gotten from the fps? So if the fps is 24, does that mean that frame 0 is at 1/24 seconds, frame 1 at 2/24 seconds, etc? So that this:

<S$Anim> x { 0 0 10 10 20 ... }

Would mean 0->is at time 1/24s, 0->is at time 2/24s, 10->is at time 3/24s, 10->is at time 4/24s, 20->is at time 5/24s? So that each value entered in the list would be at time n/fps in seconds? Am I way off base with that, or is it correct?