1 / 79

Interactive Animation Display in Game Design

Explore system design, algorithms, and pseudo code in interactive game design. Understand game objects, animations, and input/output. Learn about geometric transformations and procedural animation.

carinas
Download Presentation

Interactive Animation Display in Game Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Yingcai Xiao • Yingcai Xiao Interactive Game Design Final Overview

  2. Monday, May 7th, 5:15 pm – 7:15 pmIn ClassroomClose Book When/Where

  3. What • System/Algorithm Design • No aesthetic design • Concepts • Systems • Algorithms • Pseudo code (logic not syntax)

  4. Coverage • All lecture notes • All assignments • Everything else covered in the class. • Thoroughly understand what you did in the assignments.

  5. Video Game: Interactive animation Display Device Driver (GDI) Input Device Driver Game (Software)

  6. Video Game: Interactive animation Similar to all other programs: data, algorithms, input, output. Data: Game Objects Algorithms: Animation Input: Interactive Events Output: Display

  7. Game Objects (GO) GO = Geometry + Attribute

  8. Yingcai Xiao Surface and Volume Representation of Game Objects

  9. Game Objects (GO) Geometry: primitives: points, lines, triangles, polygons, spheres tetrahedrons, hexahedrons, … meshes: grids: elevation, uniform, rectlinear, structured, tin: triangular integrated network

  10. Game Objects (GO) Geometry: meshes: indexed Analytical: planes, curves, surfaces, parametrical lines, curves, …

  11. Parametric Form of a Line: • x(t) = x0 + t * (x1 – x0) • y(t) = y0 + t * (y1 – y0) • 0 <= t <= 1 • x(t) = (1-t) * x0 + t * x1 • y(t) = (1-t) * y0 + t * y1 • 0 <= t <= 1

  12. Game Objects (GO) Geometry: Stroked: stroked primitives stroked free curves and surfaces composite: avatars, prefabs, packages, …

  13. Elevation Gridorigin: 0,0,0spacing: 1,1,1dimension: 5, 5elevation:1,2,3,4,5,11, 12, 13, 14, 15,21, 22, 23, 24, 25,31, 32, 33, 34, 35,41, 42, 43, 44, 45 • Yingcai Xiao

  14. Game Objects (GO) Conversions to indexed meshes:

  15. Voxel-based Game Objects Voxelization: to partition a volume into connected voxels. Two types of voxelization: game objects game space

  16. Voxelization of Game Space and GOs To partition a game space and GOs into connected voxels. Uniform Grid Rectlinear Grid Structured Grid Unstructured Grid

  17. Uniform Grid • IJK space • x = i*dx + x0 • y = j*dy + y0 • z = k*dz + z0 • Data array (i, j, k), loop i first, then j, k last. • Simple, compact and speedy retrieval. • Not flexible

  18. Rectlinear Grid • Dimension: nx, ny, nz • Nonuniform spacing, but straight grid lines. float x[44]={0.0,1.2,2.8,3.9…….} float y[33]={1.0,……………} float z[22]={0.8,……………}

  19. Rectlinear Grid • IJK space. x = x[I]; y = y[J]; z = z[K]; • Data array (i, j, k), i changes first, then j, k last. • Simple • compact (takes O(nx +ny + nz) more space) • speedy retrieval • Little more flexible

  20. Structured Grid • Dimension: nx, ny, nz • Nonuniform spacing • IJK space (no formula) • Coordinates of each grid node need to be given. x(I,J,K), y(I,J,K), z(I,J,K)

  21. Indexed Volume / Surface • No dimensions parameters: nx, ny, nz • No IJK space • Coordinates of each node need to be given • Most flexible, can represent any structures • Easy to modify geometry, only need to change the point list. • Not compact (need space to save xyz values and cell information) • Slow retrieval

  22. IndexedData Structure

  23. Summary of Volumetric Data Structures

  24. Game Object Appearance

  25. The Three Faces of Designing GO Appearance • The Artistic Face: • aesthetic – beautiful and ugly • done by artists • The Communication Face: • show and tell (convey a message) • done by communication experts • The Technical Face • the enabler (can or can’t), game engine design and development. • done by computer scientists

  26. Attributes (Appearance) • Color • Shades • Texture • Transparency

  27. Color • Gamma Correction • Dynamic Range • Color Models

  28. Types of Gemtetric Transformations Rigid-body Transformation: T and R. change: location, orientation; not change: size, angle between elements. Affine Transformation: S, SH change: size, location, angle; not change: line (parallelism). Note: uniform scaling is between the two. It changes size but not angle. So far, our S, R, SH are all around the origin.

  29. Morphing and Procedural Animation

  30. Procedural Morphing • Use scripts to change the geometry of game objects at run-time. • A demo in Unity3D to change the geometry of a plane to a wave form.

  31. Demo in Unity3D • To change the geometry of a plane to a wave form. • Create a new project with Character Controller package. • Add a plane (GameObject->CreateOhters->Plane) • Scale it in the Inspector to 10X10 (in x and z). • Uncheck the Mesh Collider (in the Inspector) • Add a light (GameObject->CreateOhters->DirectionalLight) • Add a FPC (Project->Assets->StandardAssets->CharacterControllers->FirstPersonController, drag-and-drop it to Hierarchy.) • Move it up. (Change its y position in the Inspector to 11). • Add script to morph the plane (Plane->Inspector->AddComponent->NewScript->JavaScript) name it Wave. • Add the code on the next page to the Wave.js in Mono. • Build->Build All in Mono to make sure there is no compilation errors.

  32. Demo in Unity3D (Wave) • #pragma strictfunction Start () { var mesh: Mesh = this.GetComponent(MeshFilter).mesh; var verts: Vector3[] = mesh.vertices; for (var v = 0; v < verts.Length; v++) {     verts[v].y = Random.Range(0,10); } mesh.vertices = verts; mesh.RecalculateBounds(); mesh.RecalculateNormals(); this.gameObject.AddComponent(MeshCollider); }function Update () {}

  33. Time-dependentCarpet Plots y(r,t) = A e-r-at cos(2π (r-Vt) /λ); r = sqrt ((x-x0)*(x-x0)+ (z-z0)*(z-z0)) P0(x0, y0, z0) : center of the wave A: amplitude of the wave V: velocity of the wave λ: wave length of the wave a: speed of decaying t = current time – time of impact (t0)

  34. Yingcai Xiao • Yingcai Xiao EDP Scripting

  35. EDP: Event-driven programmingApplication awaits in an idle state and responds to user requests by calling the corresponding even handlers. EDP • Yingcai Xiao

  36. A menu in C++: char c; bool done = false; while(!done) { cout << “Please make your selection, q to end:” cin >> c; switch(c) { case “+”: add( ); break; case “-”: sub( ); break; case “q”: done = true; break; } } Event Loop Event Mapping & Event Dispatching Event Events Event Handler

  37. Key Components of EDP • Events • Event loop • Event mapping • Event dispatching • Event handlers • All, but the handlers, are taken care of by the game engine and its underplaying graphics and OS platform.

  38. EDP in Unity3D • Unity game engine supports EDP. • Download the EDP-Scripting project. • Open it with Unity3D and select scene1. • Object Cylinder and Terrain. • Note: animation1 was created using Unity GUI. • IGD5 script was created to do simulation. • Simulation is animation obeying certain rules, e.g., trajectory of a projectile.

  39. EDP-Scripting Demo Coding • To create scripts: • Assets->Create->C# Script • Name it in the Assets Pane. public class Test:MonoBehaviour{ void Start () { /* initialization at the start of the application */} void Update ( ) { /* invoked at every frame of drawing */} }

  40. using UnityEngine;using UnityEngine.UI;using System.Collections;public class IGD5 : MonoBehaviour {    float time = 0;    float threshold = 0.5f;    bool isReady = true;    bool isSimulate = false;    int collisionCount = 0;    public Vector3 speed = new Vector3(5,5,0);    public GameObject score; // the text object for displaying score     // Use this for initialization    void Start () {  } C# Code Example: IGD5.cs

  41.     //colision detection    void OnCollisionEnter (Collision collision) {        if (collision.gameObject.tag == "terrain") {            collisionCount++;            score.GetComponent<Text>().text = "Score : " + collisionCount;        }    }    void simulationControl () {        transform.position = new Vector3 (    //colision detection    void OnCollisionEnter (Collision collision) {        if (collision.gameObject.tag == "terrain") {            collisionCount++;            score.GetComponent<Text>().text = "Score : " + collisionCount;        }    }    void simulationControl () {        transform.position = new Vector3 ( transform.position.x + speed.x*Time.deltaTime,  transform.position.y + speed.y*Time.deltaTime,  transform.position.z);    } C# Code Example: IGD5.cs

  42.         void Update () {        if (!isReady) {            if (time >= threshold) {                isReady = true;                time = 0;            }            else {                time += Time.deltaTime;            }        } else               void Update () {        if (!isReady) {            if (time >= threshold) {                isReady = true;                time = 0;            }            else {                time += Time.deltaTime;            }        } else        C# Code Example: IGD5.cs

  43.          { if (Input.GetKey (KeyCode.G)) {                if (gameObject.GetComponent<Rigidbody> ()) {                    gameObject.rigidbody.useGravity = !gameObject.rigidbody.useGravity;                } else {                    gameObject.AddComponent<Rigidbody> ();                }         isReady = false;             }             else if (Input.GetKey (KeyCode.A)) {                if (animation.isPlaying)   gameObject.animation.Stop();                else gameObject.animation.Play ();                isReady = false;  }  C# Code Example: IGD5.cs

  44.                 else if (Input.GetKey (KeyCode.S)) {  ///simulation                isSimulate = !isSimulate; //on-off         isReady = false;            }        }         //Animation control        if (isSimulate)  simulationControl();     }} C# Code Example: IGD5.cs

  45. Game Controller: Kinect NUI

  46. Kinect for Windows Release date : November 2010 Kinect : natural user interface that provides real-time gesture recognition. Sensors: RGB camera and 3D depth sensor.

  47. The Gang of Four OpenNI: a general-purpose framework for obtaining data from 3D sensors NITE: a skeleton-tracking and gesture-recognition library SensorKinect: the driver for interfacing with the Microsoft Kinect ZigFu: Unity Package (Assets and Scripts)

  48. OpenNI

  49. OpenNI • Production Nodes: • a set of components that have a productive role in the data creation process required for Natural Interaction based applications. • the API of the production nodes only defines the language. • The logic of data generation must be implemented by the modules that plug into OpenNI. • E.g. for a production node that represents the functionality of generating hand-point data, the logic of hand-point data generation must come from an external middleware component that is both plugged into OpenNI, and also has the knowledge of how to produce such data.

  50. Yingcai Xiao • Yingcai Xiao Artificial Intelligence in Game Development

More Related