Bend it like Beckham... User controlled model animation in Away3D
Flash Dev

After successfully creating and animating a 3D character in real time in Flash using Away3D, the next logical step was adding some user interaction to a 3D model. As with all of my experiments, when tackling a new subject for the first time I usually start off fairly simply. This time I wanted to allow the user to control the movement of a 3D model using the arrow keys on their keyboards. Here is the flash SWF and a more detailed description after the jump. As always, roll-over with your mouse to activate the SWF and click on the window once to allow user interaction.

 

 

Ok, so it isn't the most exciting bit of user entertainment, but it is proof that this technique could be used for controlling more complex 3D objects. for example we could control a 3D character and depending on which key is pressed, a different action can be performed by the character. Run, jump, punch, fly or whatever, the technique is the same. And this is becase we are not controlling the model itself by pressing keys, but rather we are just telling flash and away3d which animation should be played when.

I am using the MD2 model format in these studies because the model format can also store all of the animation sequences and model information in one file. This means I can import the model into flash and call different animations directly from actionscript. I made this cylinder model with 4 animation sequences that correspond to the keys pressed : "up", "down", "left" and "right". When a key is pressed the animation changes.

If you have played around a bit with the SWF above, you will notice that you do not have to wait for one animation to finish before you can start another one. It actually transitions quite smoothly between them. This is because when animations are changed, the vertices of the 3D model are actually tweened (moved smoothly) to their new position ready for the next animation, very useful for realistic animation!

For my next study I will be trying this technique out on a more complex character, allowing the user to move the character around with the keyboard and maybe jump, sneak and fight as well. I will break the next one down into a few posts so I can describe the process in a little greater depth.

 

Comments 

 
#1 2010-09-15 09:04
I love the website... It is really cool.
Quote
 

Add comment