1 / 93

Yingcai Xiao

Voxel Game Engine Development. Yingcai Xiao. Game Engine Development. What do we need? What tools do we have? How can we design and implement? We will answer those questions in an agile way. What do we need?. Video Game: Interactive animation. Display Device Driver (GDI).

samaniego
Download Presentation

Yingcai Xiao

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. Voxel Game Engine Development • Yingcai Xiao

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

  3. What do we need?

  4. Video Game: Interactive animation Display Device Driver (GDI) Input Device Driver 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. Data: Game Objects Voxelization: to partition a volume into connected voxels. Two types of voxelization: game objects game space

  7. Voxel Based Game Engine

  8. Data: Game Objects Voxel: volume element, the smallest element of a volume. Geometry: hexahedron, tetrahedron, … Attributes: two types: single-valued: one value for each voxel multi-valued: one value for each corner of the voxel

  9. Voxelization of A Game Space To partition a game space into connected voxels. Uniform Grid Rectlinear Grid Structured Grid Unstructured Grid

  10. Uniform Grid • Uniform Grid (uniform in each direction) • Parameters: • Dimension: nx, ny, nz • Origin: x0, y0, z0 • Spacing: dx, dy, dz

  11. Uniform Grid • IJK space • x = i*dx + x0 • y = j*dy + y0 • z = k*dz + z0 • AttributeArray [i, j, k], loops i first, then j, k last. • Simple, compact and speedy retrieval. • Not flexible • 2D equivalent: Elevation Grid

  12. 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,……………}

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

  14. Data Structure for Game Objects

  15. Characteristics of GO Data Structure • DiscreteInterpolation • P1, P2 • Regular/Irregular • Data Dimensions

  16. Data Structure Design Criterion • Compact (save space) • Efficient (fast retrieval) • Map-able (easy to convert) • Minimal Coverage (small foot prints) • Simple (easy to use)

  17. Dataset for a Game Object • Two parts: • Structure • Attributes

  18. Dataset • Structure: topology and geometry • Topology: is the set of properties invariant under certain geometric transformations. • Geometry: is the instantiation of the topology; the specification of positions in a 3D space.

  19. Dataset • Dataset Attribute: • Color • Normal (shading) • Texture coordinates (texture mapping) • Material properties (strength, temperature, …)

  20. Cell Types • A data set consists of one or more cells • A cell is defined by a “type” and an ordered list of point • Type: topology, cell type • Ordered list: geometry, points • Together: organizational structure • Use Set: all the cells using a point: • U(pi) = {Ci: pi Ci}

  21. Cell Types Vertex: zero-dimensional cell, It is defined by a single point. Line: one dimensional cell. It is defined by two points. Polyline: is a composite one-dimensional cell consisting of n connected lines. It is defined by an ordered list of n+1 points. Triangle: is a primary two-dimensional cell. The triangle is defined by a counter-clockwise ordered list of three points. Triangle is a 2D simplex. Polygon: is a primary two-dimensional cell. The polygon is defined by an ordered list of three or more points lying in a plane Tetrahedron: is a primary three-dimensional cell. It is defined by a list of four nonplanar point. Tetrahedron is a 3D simplex.

  22. Data Structure (DS) for Game Objects (GO) indexed structure:

  23. Data Structure (DS) for Game Objects (GO) Convert a uniform grid into an indexed mesh. O(0,0,0) D(1,1,1) 3x3x3

  24. Data Structure (DS) for Game Objects (GO) Convert a surface of two connected triangle into an indexed mesh. P0(0,0,0) P1(1,0,0) P2(1,1,0) P3(0,1,0)

  25. Summary of Volumetric Data Structures

  26. Summary ofData Structures for Game Space andGame Objects

  27. Data Structures forGame SpaceUniform Grid:2D: Elevation Grid of Terrain3D: Voxel Space

  28. Uniform Grid • Uniform Grid (uniform in each direction) • Parameters: • Dimension: nx, ny, nz • Origin: x0, y0, z0 • Spacing: dx, dy, dz

  29. Uniform Grid • IJK space • x = i*dx + x0 • y = j*dy + y0 • z = k*dz + z0 • AttributeArray [i, j, k], loops i first, then j, k last. • Simple, compact and speedy retrieval. • Not flexible • 2D equivalent: Elevation Grid

  30. Data Structures forGame ObjectIndexed Structure:Topology (Cells)Geometry (Points)Attributes (Data)

  31. Data Structure (DS) for Game Objects (GO) indexed dataset:

  32. Algorithms for Voxel Based Game Engine

  33. Algorithms for Construction of Game Space

  34. Construction of Dataset for GS & GO

  35. Constructing a Uniform Grid • Define the bounding box • Specify the dimension: nx, ny, nz • Set the origin: x0, y0, z0 • Compute the spacing: dx, dy, dz

  36. Triangulated Networks • Delaunay Triangulation

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

  38. Visualizing Unstructured Points Triangulation: Connect points to form a triangulated topological structure. (topology generation)

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

  40. 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)

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

  42. Traversing Gaming Space (Image created by Russell Yuncker) (Image created by Jian He)

  43. Follow predefined paths • Follow pre-partitioned spaces • Follow line of sights • Collision detection Traversing Gaming Space

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

  45. AutoDesk provides CAD software for different industries. • AutoCAD and 3DS Max for manufacturing industry. • Maya for entertainment industry. • Develop their own games. • All tools are free for students TGS: Following predefined paths

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

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

  48. Line of sight for eyes: ray-traced image (povray.com)

  49. 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.) } }

  50. Shading Shading: determining light reflection from objects at a pixel. Basic Reflection Model: Phong Reflection Model (most commonly used) I= kaIa + kd Id (l · n) + ksIs(v · r )α I : reflected-light intensity

More Related