[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.10.4 Moving On

Written by Michael Voase, mvoase@midcoast.com.au.

Please note this document is not complete as yet. The examples given are not 100% checked and verified.

In this section we will be exploring the second method of sprite animation, skeletal animation. The Crystal Space sprite contains a number of interfaces and data structures that allow you to control your sprite on a limb by limb basis. Additionally, the `skel3d' module also transparently updates and applies the animation transforms on the skeleton of the sprite for you. To accomplish this feat of wizardry, the skeleton employs a number of embedded interfaces that permit the rapid updating of skeletal intformation. However, before we can beging, first we must define a skeleton for our sprite.

Sprite Skeleton

The sprite skeleton is a farily simple structure. The most notable difference from a frame is the addition of connections with embedded transforms that permit the attached bones to be translated and transformed about the connection point. Each limb of the skeleton has a number of attached vertices which are transformed under the influence of the connection transform. The declaration for an articulated sprite is very simmilar to a frame animated sprite, with the notable exception that an articulated sprite usually conatins one frame. You can use multiple frames if you want, I dont belive there is a restriction at all, however, generally, a single frame is sufficient. We will start with an identical sprite to our previous example, then add an appendage to it. The appendage will be the same in shape, but intverted and touching the lower appendage by a single point. We will then add an animation to make the top pyramid wobble backward and forward.

 
MESHFACT(
  PLUGIN(crystalspace.mesh.loader.factory.sprite.3d)
  PARAMS(
    MATERIAL(white)
    FRAME 'the_frame' (
      V(0,0,0:0,0) ; 0
      V(0,1,0:0,0) ; 1
      V(1,0,0:0,0) ; 2
      V(0,0,1:0,0) ; 3
      V(0,2,0:0,0) ; 4
      V(0,2,1:0,0) ; 5
      V(1,2,0:0,0) ; 6
    )

    TRIANGLE(0,2,3)
    TRIANGLE(0,3,1)
    TRIANGLE(0,1,2)
    TRIANGLE(2,1,3)
    TRIANGLE(4,6,1)
    TRIANGLE(4,5,6)
    TRIANGLE(5,4,1)
    TRIANGLE(6,5,1)

    ACTION( F('the_frame',1000))

    SKELETON 'skel' (
      LIMB 'top' (
        VERTICES(1,4,5,6)
      )
    )
  )
)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html