cs 480 680 game engine programming animation
play

CS 480/680: GAME ENGINE PROGRAMMING ANIMATION 2/21/2013 Santiago - PowerPoint PPT Presentation

CS 480/680: GAME ENGINE PROGRAMMING ANIMATION 2/21/2013 Santiago Ontan santi@cs.drexel.edu https://www.cs.drexel.edu/~santi/teaching/2013/CS480-680/intro.html Game AI in Educational Game A CS RA @ 20 hrs/week for two-terms in the Digital


  1. CS 480/680: GAME ENGINE PROGRAMMING ANIMATION 2/21/2013 Santiago Ontañón santi@cs.drexel.edu https://www.cs.drexel.edu/~santi/teaching/2013/CS480-680/intro.html

  2. Game AI in Educational Game A CS RA @ 20 hrs/week for two-terms in the Digital Media program. Experience Management for educational games Skills: * basic knowledge in AI * C# and/or JavaScript * Unity 3D experience is a plus If you are interested, contact me.

  3. Outline • Student Presentations • Cel Animation • Skeletal Animation • Skinning • Project Discussion

  4. Outline • Student Presentations • Cel Animation • Skeletal Animation • Skinning • Project Discussion

  5. Student Presentations • Steven Bauer: • “Real-time Shadows on Complex Objects” • Christopher Miller: • “Real-Time Strategy Network Protocol” • Joseph Muoio: • “Search-based Procedural Content Generation” • James Rodgers • “Terrain Analysis in an RTS – The Hidden Giant” • Justin Weaver: • “Coping with Friction in Dynamic Simulations”

  6. Outline • Student Presentations • Cel Animation • Skeletal Animation • Skinning • Project Discussion

  7. Game Engine Architecture Game Specific Game Engine Functionalities Game Dependencies Resource Management Engine Utility Layer Platform Independence Layer SDKs OS DRIVERS HARDWARE

  8. Game Engine Architecture Online Artificial Scripting Multiplayer Intelligence Gameplay Foundations (Game Loop) Rendering Engine Animation Audio Physics Engine Subsystem Profiling & Collisions Debugging

  9. Game Engine Architecture Online Artificial Scripting Multiplayer Intelligence Gameplay Foundations (Game Loop) Rendering Engine Animation Audio Physics Engine Subsystem Profiling & Collisions Debugging

  10. Animation • Mostly for characters, but used for any animated object in the game • Animation is DIFFERENT from “movement”: • Movement refers to game objects changing location and orientation in the game world • Animation refers to game objects changing shape, or appearance while potentially not changing location nor orientation.

  11. Animation Types • Cel Animation (applicable to bitmap graphics) • Skeletal Animation (applicable to all kind of graphics) • Per-Vertex Animation (applicable to vector-based representations) • Skinned Animation (applicable to vector-based representations)

  12. Cel Animation Examples • Classic pixel-art 2d animations: • Graphic artist draws different frames (“cels”) for each animation, which the game engine displays in sequence • http://www.youtube.com/watch?v=ePJsX2YdqAs

  13. Cell-Animation Engine • Basic concepts: • Sprite: (recall from the “rendering lecture”): • Bitmap • Hotspot • Clip: • A scripted sequence of sprites that represents a specific animation • For example: “walking right”, or “crouching” • The animation engine allows the game engine to assign a “clip” to a game object. The clip determines the sprite to be drawn at each game cycle.

  14. Cell-Animation Engine • Example code These lists define the animation sequence Class Clip { Class Sprite { List<Sprite> sprites; Bitmap bm; List<Integer> times; int hot_x; A clip keeps an internal int hot_y; clock, that is incremented int local_time; Boolean looping; each time the “update” Void draw(int x, int Sprite update(); y); function is called. } } Update advances the clock, checks which is the sprite that should be displayed at the current time, and returns it.

  15. Cell-Animation Engine • Example code Class Clip { Class Sprite { List<Sprite> sprites; Bitmap bm; List<Integer> times; int hot_x; int hot_y; int local_time; Boolean looping; Void draw(int x, int Sprite update(); y); } } bitmaps= [ ] times = [ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 ]

  16. Cell-Animation Engine • Example code This is oversimplistic. More expressive ways to define Class Clip { Class Sprite { List<Sprite> sprites; Bitmap bm; clips (allowing List<Integer> times; int hot_x; randomness, etc.) can be int hot_y; defined. int local_time; Boolean looping; Void draw(int x, int Sprite update(); y); } } bitmaps= [ ] times = [ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 ]

  17. Cell-Animation Engine • As part of your “AI” or “Scripting” code, each game object will have an “update” function. • Such update function is responsible for assigning “clips” to each game object • The rendering module calls the clips to determine which sprite to draw.

  18. Outline • Student Presentations • Cel Animation • Skeletal Animation • Skinning • Project Discussion

  19. Skeletal Animation • Characters made up of rigid parts combined together using a hierarchical “skeleton” • This can be done in either 2D or 3D: • 2D: http://www.youtube.com/watch?v=5_wzNRwyGD0 • 3D: http://www.youtube.com/watch?v=Vb3L7Odrcdo

  20. Skeleton • Hierarchy of “rigid pieces” known as bones . • Example for a human character: Pelvis LowerSpine UpperSpine RightArm RightForearm RightHand LeftArm LeftForearm LeftHand RightThigh RightLeg RightFoot LeftThigh LeftLeg LeftFoot

  21. Skeleton • In code, a skeleton can be represented as: Id: 0, Name: Pelvis, parent: -1, children: [1,9,12] Class Skeleton { Id: 1, Name: LowerSpine, parent: 0, children: [2] List<Bone> bones; Id: 2, Name: UpperSpine, parent: 1, children: [3,6] } Id: 3, Name: RightArm, parent: 2, children: [4] Id: 4, Name: RightForearm, parent: 3, children: [5] Id: 5, Name: RightHand, parent: 4, children: [] Id: 6, Name: LeftArm, parent: 2, children: [7] Class Bone{ Id: 7, Name: LeftForearm, parent: 6, children: [8] Pose defaultPose; Id: 8, Name: LeftHand, parent: 7, children: [] String name; Id: 9, Name: RightThigh, parent: 1, children: [10] int parent; Id: 10, Name: RightLeg, parent: 9, children: [11] List<int> children; } Id: 11, Name: RightFoot, parent: 10, children: [] Id: 12, Name: LeftThigh, parent: 1, children: [13] Id: 13, Name: LeftLeg, parent: 12, children: [14] Id: 14, Name: LeftFoot, parent: 13, children: []

  22. Skeleton • In code, a skeleton can be represented as: Id: 0, Name: Pelvis, parent: -1, children: [1,9,12] Class Skeleton { Id: 1, Name: LowerSpine, parent: 0, children: [2] List<Bone> bones; “defaultPose” sometimes Id: 2, Name: UpperSpine, parent: 1, children: [3,6] } called the “bindPose” Id: 3, Name: RightArm, parent: 2, children: [4] Id: 4, Name: RightForearm, parent: 3, children: [5] Id: 5, Name: RightHand, parent: 4, children: [] Id: 6, Name: LeftArm, parent: 2, children: [7] Class Bone{ Id: 7, Name: LeftForearm, parent: 6, children: [8] Pose defaultPose; Id: 8, Name: LeftHand, parent: 7, children: [] String name; Id: 9, Name: RightThigh, parent: 1, children: [10] int parent; Id: 10, Name: RightLeg, parent: 9, children: [11] List<int> children; } Id: 11, Name: RightFoot, parent: 10, children: [] Id: 12, Name: LeftThigh, parent: 1, children: [13] Id: 13, Name: LeftLeg, parent: 12, children: [14] Id: 14, Name: LeftFoot, parent: 13, children: []

  23. Skeleton Poses • The pose of a bone is defined by (relative to the parent bone): • Location • Orientation • Scale • Typically represented as a SQT structure: S cale (1 number, or a vector), rotation (1 Q uaternion), T ranslation (1 vector) • The SQT structure is preferred to the typical 4x4 matrix used for rendering, since it’s better for “blending” purposes (more on this later)

  24. Skeleton Poses • The pose of a bone is defined by (relative to the parent bone): • Location • Orientation • Scale • Typically represented as a SQT structure: S cale (1 number, or a vector), rotation (1 Q uaternion), T ranslation (1 vector) Class Pose { • The SQT structure is preferred to the typical 4x4 matrix used for Quaternion r; rendering, since it’s better for “blending” purposes (more on this Vector t; later) double s; }

  25. Key Poses • Remember: in “cel animation” the animation was defined by different bitmaps, annotated with the times at which we need to change from one bitmap to another • In Skeletal animation, the idea is the same: • We define “ key poses ” (analogous to the bitmaps in cel animation) • We define the times at which the character should be in each key pose • A key pose: list of poses for each bone (translation, rotation, scale)

  26. Pose Interpolation • Clip : sequence of key poses at times t 1 , t 2 , … , t n • For each time t such that t i < t < t j • The animation engine can interpolate between the poses defined at t i and t j • Interpolation generates intermediate poses • Since we can interpolate poses, we can play animations at any speed, or even in reverse: • Game Time: time as maintained by the game loop • Animation Time: time as maintained internally by the clip

  27. Pose Interpolation • Notice that each pose is basically 10 numbers: • 3 for translation • 4 for rotation • 3 for scaling • A clip can be seen as the definition of 10 functions over time: 5 Tx 4 Ty Tz 3 Qx 2 Qy Qz 1 Qw 0 Sx 0 2 4 6 8 10 12 14 16 18 Sy -1 Sz -2

Recommend


More recommend