Presentation is loading. Please wait.

Presentation is loading. Please wait.

Yingcai Xiao Interactive Game Design Final Overview Yingcai Xiao.

Similar presentations


Presentation on theme: "Yingcai Xiao Interactive Game Design Final Overview Yingcai Xiao."— Presentation transcript:

1 Yingcai Xiao Interactive Game Design Final Overview Yingcai Xiao

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

3 Coverage All lecture notes All assignments Thoroughly understand what you did in the assignments.

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

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

6 Game Objects (GO) GO = Geometry + Attribute

7 Surface and Volume Representation of Game Objects Yingcai Xiao

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

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

10 Parametric Form of a Line:  x(t) = x 0 + t * (x 1 – x 0 )  y(t) = y 0 + t * (y 1 – y 0 )  0 <= t <= 1  x(t) = (1-t) * x 0 + t * x 1  y(t) = (1-t) * y 0 + t * y 1  0 <= t <= 1

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

12 Yingcai Xiao Elevation Grid origin: 0,0,0 spacing: 1,1,1 dimension: 5, 5 elevation: 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

13 Game Objects (GO) Conversions to indexed dataset:

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

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

16 Uniform Grid  IJK space  x = i*d x + x 0  y = j*d y + y 0  z = k*d z + z 0  Data array (i, j, k), loop i first, then j, k last.  Simple, compact and speedy retrieval.  Not flexible

17 Rectlinear Grid  Dimension: n x, n y, n z  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,……………}

18 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(n x + n y + n z ) more space)  speedy retrieval  Little more flexible

19 Structured Grid  Dimension: n x, n y, n z  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)

20 Indexed Volume / Surface No dimensions parameters: n x, n y, n z 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

21 Indexed Dataset

22 Summary of Volumetric Data Structures

23 Game Object Appearance

24 The Three Faces of Designing GO Appearance The Artistic Face: laesthetic – beautiful and ugly ldone by artists The Communication Face: lshow and tell (convey a message) ldone by communication experts The Technical Face lthe enabler (can or can’t), game engine design and development. ldone by computer scientists

25 Attributes (Appearance) 1.Color 2.Shades 3.Texture 4.Transparency

26 Color 1.Gamma Correction 2.Dynamic Range 3.Color Models

27 Shading

28 Shading 1.Realism 2.Speed 3.Theory 4.Implementation

29 Shading 1.Realism : Speed 2.HW tools: Frame Buffer, Z Buffer, ID Buffer, GPU 3.SW tools: LOD (Level of Details), 4.Shading Modes: Flat, Smooth, Phong

30 Shading Modes

31 Shading Shading: determining light reflection from objects at each pixel. Basic Reflection Model: Phong Reflection Model (most commonly used) I= k a I a + k d I d (l · n) + k s I s (v · r ) α I : reflected-light intensity

32 Many more things consider: Shadow, Reflection, Transparency, Refraction, … http://www.codeproject.com/KB/graphics/RayTracerNet.aspx Figure 2. Shading effects: a) Ambient, b) Diffuse, c) Highlights, d) Shadows and e) Reflection (notice the reflection on the floor also)

33 Phong Shading: http://www.yourdictionary.com/phong-shading#computer for (each object) for(each triangle of the object) for(each pixel in the triangle) if(closer to the viewer than the current z buffer value) {update z buffer with the new z interpolate the pixel normal from the vertex normals compute the pixel color/relection using Phong reflection model using pixel normals and the properties of the object. }

34 Morphing and Procedural Animation

35 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.

36 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.

37 Demo in Unity3D (Wave) #pragma strict function Start () { var mesh: Mesh = this.GetComponent(MeshFilter).m esh; 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 () { }

38 Time-dependent Carpet Plots y(r,t) = A e -r-at cos(2π (r-Vt) /λ); r = sqrt ((x-x 0 )*(x-x 0 )+ (z-z 0 )*(z-z 0 )) P 0 (x 0, y 0, z 0 ) : 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 (t 0 )

39 Yingcai Xiao EDP Scripting Yingcai Xiao

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

41 Events 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 Event Handler

42 Key Components of EDP 1.Events 2.Event loop 3.Event mapping 4.Event dispatching 5.Event handlers All, but the handlers, are taken care of by the game engine and its underplaying graphics and OS platform.

43 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.

44 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 */} }

45 C# Code Example: IGD5.cs 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 () { }

46 C# Code Example: IGD5.cs //colision detection void OnCollisionEnter (Collision collision) { if (collision.gameObject.tag == "terrain") { collisionCount++; score.GetComponent ().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); }

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

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

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

50 Game Controller: Kinect NUI

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

52 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) 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)

53 OpenNI

54 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. 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.

55 Yingcai Xiao Artificial Intelligence in Game Development Yingcai Xiao

56 PA4 Coding / Flocking http://www.cs.uakron.edu/~xiao/game/igd4.htm The Theory / Rules: cohesion - to move toward the center of the mass of the flockmates separation - to avoid flockmates alignment – to steer towards the flock direction

57 PA4 Coding / Flocking The Example: Holistic Game Development with Unity By: Penny de Byl http://proquest.safaribooksonline.com/book/programming/ga me-programming/9780240819334 Section 5.6: a flock of seagulls flying against wind in small groups. http://proquest.safaribooksonline.com/book/programming/ga me-programming/9780240819334/chapter-5-character- mechanics/ch5_6_006_9780240819341_web_ch05_html

58 Flocking Code Example C# code at http://wiki.unity3d.com/index.php?title=Flocking (1)Create the flock at the BiodController::Start() (2)Update animation parameters in BiodController::Update () (3)Control the animation in BoidFlocking::BoidSteering ()

59 Professional Game Development

60 Pre-productionDesign phase: concept development ProductionMain stage of development. MilestonesMajor events of alpha, beta releases Post-productionSales and support Game Development Principles: The Process

61 High conceptMain idea, pitch document Concept documentation Game proposal, game plan Proof of conceptPrototyping, design document The Process: Pre-production: Three stages

62 designpresentation and rules of the game collaborative assetssprites, 3D models, audioartists codein graphical, scripting, or major programming languages, programmers level creationdesign and add features at different levels artists and designer testingquality assurancetesters The Process: Production: Assets and Code

63 First playableWith limited features AlphaWith full features, internal test Code freezeNo more programming BetaCompleted, external test. Gold masterFinal build for the distribution production The Process: Milestone: Major Events

64 MarketingTrade shows, app stores, communities Maintenance1:1000 rule Indie Development Independent games (indie games): Internet distribution (app stores) The Process: Post-production: Sales & Support

65 What do we need? What tools do we have? How can we design and implement? We will answer those questions in an agile way. Game Engine Development

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

67 Graphics Engine / Display Engine / Shading Engine

68 Animation

69 Animation Keyframe: Most commonly used. Need to provide GUI for entering the keyframes. Procedural: For advanced physical simulation. Tracking live actor: Can be modified and saved.

70 Animation Animation: any change that has a visual effect. Motion Dynamics: movements (geometry change) Update Dynamics: attribute change (color, texture, …) Others: camera position, lighting, rendering techniques, … Animation: any change that has a visual effect. Motion Dynamics: movements (geometry change) Update Dynamics: attribute change (color, texture, …) Others: camera position, lighting, rendering techniques, …

71 Key-frame Animation Defining key-frames Inbetweening with interpolations: Lerping (linear interpolation) parabola interpolation Defining key-frames Inbetweening with interpolations: Lerping (linear interpolation) parabola interpolation

72 Key-frame Animation

73 Study All PPTs Including the Following EDP in Game Development Procedural Animation and Physics Engine Game Engine Development.ppt AI.ppt Appearance.pptx Voxel-Engine.ppt Data Analytics & Decision Making


Download ppt "Yingcai Xiao Interactive Game Design Final Overview Yingcai Xiao."

Similar presentations


Ads by Google