990 likes | 993 Views
Yingcai Xiao. Yingcai Xiao. Interactive Game Design Final Overview. What. System/Algorithm Design No aesthetic design Concepts Systems Algorithms Pseudo code (logic not syntax). Coverage. All lecture notes All assignments Thoroughly understand what you did in the assignments.
E N D
Yingcai Xiao • Yingcai Xiao Interactive Game Design Final Overview
What • System/Algorithm Design • No aesthetic design • Concepts • Systems • Algorithms • Pseudo code (logic not syntax)
Coverage • All lecture notes • All assignments • Thoroughly understand what you did in the assignments.
Video Game: Interactive animation Display Device Driver (GDI) Input Device Driver Game (Software)
Video Game: Interactive animation Similar to all other programs: data, algorithms, input, output. Data: Game Objects Algorithms: Animation Input: Interactive Events Output: Display
Game Objects (GO) GO = Geometry + Attribute
Yingcai Xiao Surface and Volume Representation of Game Objects
Game Objects (GO) Geometry: primitives: points, lines, triangles, polygons, spheres tetrahedrons, hexahedrons, … meshes: grids: elevation, uniform, rectlinear, structured, tin: triangular integrated network
Game Objects (GO) Geometry: meshes: indexed Analytical: planes, curves, surfaces, parametrical lines, curves, …
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
Game Objects (GO) Geometry: Stroked: stroked primitives stroked free curves and surfaces composite: avatars, prefabs, packages, …
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
Game Objects (GO) Conversions to indexed dataset:
Voxel-based Game Objects Voxelization: to partition a volume into connected voxels. Two types of voxelization: game objects game space
Voxelization of Game Space and GOs To partition a game space and GOs into connected voxels. Uniform Grid Rectlinear Grid Structured Grid Unstructured Grid
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
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,……………}
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
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)
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
Triangulated Networks • Delaunay Triangulation
Data collected in the real world • Can we use local interpolation with the closest points? • Need to find and connect the closest points. • Demo in 2D.
Visualizing Unstructured Points Triangulation: Connect points to form a triangulated topological structure. (topology generation)
Triangulation • Use Edge Swapping to make a Delaunay Triangulation. • Find the minimum bounding triangle. (may need to add a fake point) • Add one point at a time, do triangulation. • After each point is added, check if the joined triangles are optimal or not; if not swap the joining edge (edge swapping). Check all other triangles and make sure they are still optimal after adding the current point. • Repeat step 3 to add each point and we when all points are added and all triangles are optimal. • Clean up: remove all fake points and related triangles.
Triangulation • Properties of Delaunay Triangulation: • Circumsphic property: no other points in the circumspheres. • Optimal property: The minimum interior angle of a triangle is greater than or equal to the minimum interior angle of any other triangulation • It is the dual of the Diritchlet tessellation • Voronoi cell, Centroid • A collection of connected Voronoi cells tessellete the area (partition, coverage)
Triangulation Formal definition of Triangulation: N dimensional triangulation of a point set P=(P1, P2, ……,Pn) is a collection of N-dimensional simplexes (triangles) whose defining points lie in P. Optimal Triangulation: a triangulation that generates maximized minimum angles. Delaunay Trianglation: an optimal triangulation, which satisfies the circumshpere condition. Circumsphere Condition: the circumshpere of any N-dementional simplex contains no other points of P except the n+1 points defining the simplex.
Shading Shading: determining light reflection from objects at each pixel. Basic reflection model for a given point P: Phong Reflection Model (most commonly used) I= kaIa + kd Id (l · n) + ksIs(v · r )α I : reflected-light intensity
Ambient Reflection: Direction independent ka Ia Ia : incident ambient-light intensity ka : object ambient-reflection coefficient part of the object material properties
Lambertian / Diffusive Reflection: Lighting-direction dependent Id kd(ln) = Id kdcos() Id : incident diffusive-light intensity kd : object diffusive-reflection coefficient : angle between light direction (l) and surface normal (n). Both l and n are unit vectors.
Specular Reflection: Viewing-direction dependent Is ks(vr)α = Is ks cos α (Ф). Is : incident specular-light intensity ks : object specular-reflection coefficient Ф : angle between reflection direction (r) and viewing direction (v). : specular-reflection exponent, shininess coefficient. 1/: roughness.
Implementation of Reflections Ambient Reflection: Uniform distribution, Lighting-direction independent, viewer independent Implemented in OpenGL, 3D graphics cards, and GPU Lambertian / Diffusive Reflection: Lighting-direction dependent, viewer independent Implemented in OpenGL, 3D graphics cards, and GPU GPU is designed to compute diffusive reflection of every pixel within a triangle using linear interpolation of computed diffusive reflection at each vertex of the triangle.
Implementation of Reflections Specular Reflection: Viewing-direction dependent (viewer dependent) Not implemented in OpenGL, 3D graphics cards Implemented through raytracing (e.g. povray) and recently through GPU Shadow: Light-direction dependent Not directly implemented in OpenGL and 3D graphics cards Can be implemented using logical buffers
Implementation of Reflections Surface Reflection: Viewing-direction dependent (viewer dependent) Not implemented in OpenGL, 3D graphics cards Implemented through recursive raytracing (e.g. povray) and recently through GPU
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) Many more things consider: Shadow, Reflection, Transparency, Refraction, …
Simple Ray Tracing for Image Generation for (each scan line in image ) { for (each pixel in the scan line ) { determine ray from eye through pixel; for(each object in scene) { if(object is intersected and is the closest considered thus far) record intersection point and object id. } set pixel’s color to that at closest object intersection point (using the REGULAR I formula.) } }
RECURSIVE Ray Tracing for Imaging for (each scan line in image ) { for (each pixel in the scan line ) { determine ray from eye through pixel; for(each object in scene) { if(object is intersected and is the closest considered thus far) record intersection point and object id. } set pixel’s color to that at closest object intersection point (using the RECURSIVEI formula.) } }
Recursive Ray Tracing for Image Generation Set pixel’s color to that at closest object intersection point using the I formular given below. I= (1- kr - kt )Iregular+ kr Ir+ kt It Iregular: regular reflection of lights from light source. Computed by the formula above. kr : reflection coefficient. Ir: illumination from other objects (to be reflected). kt : transmission coefficient. It: illumination from other objects (to be transmitted).
Simple Ray Tracing for Shadowing • for (each scan line in image ) { • for (each pixel in the scan line ) { • determine ray from the light through pixel; • for(each object in scene) • if(object is intersected) • flag the pixel as in a shadow • } • } • Usually use a separate buffer (shadow buffer) of the same size as the frame buffer to store the shadow flag. • Darkened a pixel in image generation if its shadow flag is on.
Simple Ray Tracing for Collision // a ray has been defined. for(each object in scene) { if(object is intersected and is the closest considered thus far) record intersection point and object id. } The recorded object is the closest and is the one being hit.
Simple Ray Tracing for Collision (Voxelized) // a ray has been defined. Follow the ray’s path for each voxel in the path { if (a GO is in) { record it’s ID break; } The recorded object is the closest and is the one being hit.
Follow predefined paths • Follow pre-partitioned spaces • Follow line of sights • Collision detection Traversing Gaming Space
Used in maze games. • 3D Maze 2: an Android app. • The predefined paths are usually bounded by predefined structures. • Simple bounding structures can be designed in game engines. • Complicated bounding structures can be designed in a Computer Aided Design software. TGS: Following predefined paths
For voxelized game space, use IJK space to traverse. • x = i*dx + x0 • y = j*dy + y0 • z = k*dz + z0 • i = (x - x0) / dx • j = (y - y0) / dy • k = (z - z0) / dz TGS: Follow pre-partitioned spaces
Line of sight for eyes: image generation • Line of sight for lights: shadow • Line of sight for objects: collision • Commonly use the ray tracing technique. • TGS: Follow line of sights