Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Animation CMT3317. Do you need to do animation? We consider ways of animating composite objects – that have a number of different parts e.g. a.

Similar presentations


Presentation on theme: "Object Animation CMT3317. Do you need to do animation? We consider ways of animating composite objects – that have a number of different parts e.g. a."— Presentation transcript:

1 Object Animation CMT3317

2 Do you need to do animation? We consider ways of animating composite objects – that have a number of different parts e.g. a person, a tank You may want to do this for the second cswk or not – depends entirely on you and your game design

3 We consider Model cycling –Easiest to do, very simple, most likely to be used Articulated model animation –A bit harder, a bit better, more work, might use it Animating a skinned boned model –A lot harder, needs good animation skills, the best, but no simple demonstration, unlikely to use it

4 Model cycling Just like 2D image cycling (e.g. using sprite sheets) but uses 3D models instead Create a number of models and render the appropriate one at the appropriate time

5 Class ModelCycleObject This class is similar to the AnimatedSprite class It has a list of 3d models that it uses for animation It is used to build a green guy, who can perform a number of behaviours depending on his current state

6 Finite state machine of a GreenGuy

7 ModelCycleObject In the walk state he walks a distance down the z axis cycling between left walk, standing and right walk models In the jump state he does two continuous jumps In the look state he merely billboards to look at the camera In the sleep state he rotates increasingly position while flipping between two sitting models In the dead state the dead model is drawn

8 ModelCycleObject – class variables

9

10 ModelCycleObject – Update

11 ModelCycleObject – look

12 ModelCycleObject – jump

13 ModelCycleObject – sleep

14 ModelCycleObject – walk

15 Look at GreenGuys1.zip

16 Green Guys In this step a manager class that holds an array of green guys is created A bounding sphere variable is added to the ModelCycleClass to enable collision detection You can then drive over the green guys in the car

17 Green Guys Collision detection is done in the Game1.cs Update() function after reading input and possibly having moved the car, and updating the guys Look at GreenGuys2.zip

18 Synchronised guys

19 Unsynchronised

20 Articulated Object Animation Objects made of rigid segments which can rotate at their joints, like people Segments lower down the chain inherit the rotation and translation of segments higher up E.g. if you move your thigh your shin and foot will also move Such objects are hierarchies, the top of the hierarchy is the root, other segments are children

21 One legged teapot

22 Forward kinematics In forward kinematics animation is achieved by starting at the root and descending the hierarchy applying transformations on joints as you go This is tedious from a programming point of view you may well be happier just using model cycling if you need animation Tedious because nearly all transformation sequences are non-linear and hard to model in a program

23 Create a model Use Max to create a model, e.g. a leg Shown in left view, with a blue thigh, green shin, and orange foot

24 Procedure You need to set the pivot points for each component correctly You need to save components individually Save your model in MAX format first

25 Thigh pivot point Thigh pivot point needs to be at top of thigh Therefore position it with the top over the origin in MAX Delete the shin and foot to save the thigh individually, export to.x format

26 Shin Reload the leg, delete the thigh and foot Move the shin up over the origin in the top view to set the correct pivot point Process foot in a similar manner

27 Body Articulated object hierarchy needs a root object Create a torso for your leg to attach to In this case we used a teapot for convenience We create a class TorsoTwoLegs (which will be a torso – the teapot- which will have two legs for walking But first we need a class to represent a node in an articulated heirarchy

28 Class ArticulatedObjectNode A node in an articulated model can either be a root node or a child node This class is subclassed from SimpleObject and has a variable ‘parent’ to store its parent node The parent for the root node is set to null, the parent node for a child will be set to that child’s parent This class also has a matrix for its own rotation and another matrix to store the rotation of its parent

29 Class ArticulatedObjectNode

30 The class has a function to set the parent node In the classes’ Draw() function if the node is the root node ( its ‘parent’ variable is set to null) it draws as usual Otherwise it multiplies on the parent matrix before the child transformations

31 Class ArticulatedObjectNode

32 The class has a function to make it translate along the path of a circle The teapot will be simply translated whilst the legs will be animated to simulate walking The class has a function to rotate around the x axis as this is how the thighs and knees will be animated – around the local x axis

33 Class ArticulatedObjectNode

34 Class TorsoTwoLegs Having defined the class needed for an articulated structure, and 3D models needed We need a class to represent the walking teapot and to implement it’s animation It will have a torso, and a thigh, shin, and foot for each leg (are defined as class variables are counters needed for animation)

35 Class TorsoTwoLegs

36 Initialise Recall that the leg components were moved to the origin in MAX to set the pivot points Therefore we need to translate them to their correct positions in the program We can work out where the objects end by checking in MAX

37 Object size in MAX Put cursor a point where new object will join in top window At the bottom of the screen the 3 numbers to the left of grid show the cursor position E.g the bottom of the thigh is at ~-23 in the y from the origin

38 Initialize()

39 Update() A function is defined to make each component walk, called from the update function The feet aren’t animated so there are no functions for them

40 Animate the torso Only the torso is allowed to translate, it ‘drags’ the legs along with it The torso makes the object walk in a circle by rotating and translating

41 Animate leg components Each of the leg components had to perform local rotation around it’s axis A local static variable is defined and used as a counter, –e.g. the thigh rotates -4 degs for first 15 cycles 4 degs for next 15 cycles 2 degs for next 15 cycles -2 degs for next 15 cycles

42 Animate leg components Other leg components are dealt with in a similar way The result is reminiscent of walking or skating Hard to get right by programming Transformation sequence should be non- linear rather than linear

43 Continuous Animation Results

44 See Articulated.zip

45 Skinned Mesh A skinned mesh is a mesh which has been animated with a bone system A bone system is an articulated hierarchy (as described earlier) However the bones are not rendered, the mesh is linked to the bone system Allows the mesh to be stretched and deformed naturally Look at the skinned mesh example D3D8 program

46 Bones, bones and mesh, skinned mesh

47 Skinned Mesh The D3D example was created with the Character Studio plugin Which allows you to easily animate bipeds Support for keyframe animation is provided in D3D via Animations and AnimationSets You are unlikely to be able to get on top of this material in time for the cswk.


Download ppt "Object Animation CMT3317. Do you need to do animation? We consider ways of animating composite objects – that have a number of different parts e.g. a."

Similar presentations


Ads by Google