1 / 16

Introduction

Introduction. General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures Why care? Binary Space Partitioning (BSP) trees. Arrays & Linked Lists.

heidi
Download Presentation

Introduction

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. Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures Why care? Binary Space Partitioning (BSP) trees

  2. Arrays & Linked Lists 2D arrays and linked lists are used as: - Single and multi- layered Tile maps in 2D scenes in which each tile acts like a pixel. - Terrain maps in 3D world where 2D array represents the height of each tile in a level. Utility: - Abstracts the idea of pixels to a higher level significantly simplifying a drawing engine: - Linked Lists can be used for inventory

  3. Stacks & Queues Stacks: used to construct Menu, Submenus Queues: used for command queuing e.g. Real Time Strategy (RTS) games such as Command & Conquer, War craft, Star craft: Demo-5 Trade Off: When expandability is more important than speed, use linked stacks and queues; otherwise use arrayed stacks and queues.

  4. Others.. Hash Tables & Binary Search Trees: - searching; Trees: - Map editor (hierarchy of maps); - Skill system like RPGs such as Diablo 2 do. option to choose the skills e.g. healing skills or fighting skills. Graphs: - Portal Engine; games like Descent, Quake 2. more efficient method for rendering things:Demo-7

  5. Spatial Partitioning • What do we mean by spatial partitioning? Spatial partitioning mean dividing up the game world into regions that can be used to find spatial relationships between objects. • Why do we need spatial partitioning? Scenegraphs are great for recording the dynamic relationships between dynamic objects, e.g. parts of a body. They are not so good for storing information about static elements in a game world, e.g. walls in a building.

  6. Using Spatial Partitioning Spatial partitioning data structures are used to: • Determine which parts of large static objects are visible, e.g. buildings, terrains. • Determine neighborhood relationships between dynamic objects, e.g. for collision detection. • Determine how much data needs to be sent across a network, e.g. based on what is currently visible to the client.

  7. Spatial data Structures Spatial data structures store data indexed in some way by their spatial location • For instance, store points according to their location, or polygons, … • Before graphics, used for queries like “Where is the nearest hotel?” or “Which stars are strong enough to influence the sun?”

  8. Applications • Multitude of uses in computer games • Visibility - What can I see? • Ray intersections - What did the player just shoot? • Collision detection - Did the player just hit a wall? • Proximity queries - Where is the nearest power-up?

  9. Spatial Partitioning Schemes Two common spatial partitioning schemes are: - Binary Space Partitioning (BSP) - Quadtree/Octree Partitioning The partitioning schemes are similar in some ways, both: - Recursively subdivide a space into smaller spaces - Construct tree data-structure that can be searched quickly - Are expensive to modify, hence they are best used for static features of a world when they can be pre-computed once

  10. Binary Space Partitioning • Binary space partitioning works by dividing a space into two subspaces at each recursion with a plane • Choosing the best plane to divide a given space into two equally complex subspaces is the most difficult part. • Most game engines analyze the geometry of a world and choose an existing polygon to define a plane. • The analysis should determine which polygon will result in the most balanced tree.

  11. Binary Space Partitioning Example • Suppose that this figure - 1 represents the walls of a building in a game • We want to pre-process this complex shape into a BSP tree consisting of simpler regions to assist real-time rendering

  12. Walls of a building as space

  13. First subdivision: Split occurs at polygon 16

  14. Second subdivision: Split at polygon 4, 21

  15. Final BSP tree

  16. Choosing Splitting Planes • Goals: • Trees with few cells • Planes that are mostly opaque (best for visibility calculations) • Objects not split across cells • Some heuristics: • Choose planes that are also polygon planes • Choose large polygons first • Choose planes that don’t split many polygons • Try to choose planes that evenly divide the data • Let the user select or otherwise guide the splitting process • Random choice of splitting planes doesn’t do too badly

More Related