CSCE 590E Spring 2007 Game Architecture and Math By Jijun Tang.

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Advertisements

Trigonometry A brief review. 1.4 Trigonometry.
Debugging Mohammad Zikky, M.T. 2 Debugging Introduction (1 of 2)  Debugging is methodical process for removing mistakes in a program  So important,
Chapter 3.5 Debugging Games
CSCE 590E Spring 2007 Game Programming By Jijun Tang.
2008/03/25 Unified Modeling Lanauage 1 Introduction to Unified Modeling Language (UML) – Part One Ku-Yaw Chang Assistant Professor.
Maths for Computer Graphics
How do games work? Game Workshop July 4, Parts Sprites/pictures Map/background Music/sounds Player character Enemies Objects.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Now Playing: My Mathematical Mind Spoon From Gimme Fiction Released May 10, 2005.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
CSci 6971: Image Registration Lecture 2: Vectors and Matrices January 16, 2004 Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware Prof. Chuck Stewart, RPI.
Introduction What is this ? What is this ? This project is a part of a scientific research in machine learning, whose objective is to develop a system,
Chapter 3.7 Memory and I/O Systems. 2 Memory Management Only applies to languages with explicit memory management (C or C++) Memory problems are one of.
Chapter 3.6 Game Architecture. 2 Overall Architecture The code for modern games is highly complex With code bases exceeding a million lines of code, a.
Chapter 3.4 Programming Fundamentals. 2 Data Structures Arrays – Elements are adjacent in memory (great cache consistency) – They never grow or get reallocated.
Chapter 3.4 Game Architecture. Overall Architecture The code for modern games is highly complex With code bases exceeding a million lines of code, a well-defined.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Matrices and Determinants
Intro to Matrices Don’t be scared….
2IV60 Computer Graphics Basic Math for CG
Basics of Linear Algebra A review?. Matrix  Mathematical term essentially corresponding to an array  An arrangement of numbers into rows and columns.
Graphical Analytical Component Method
Chapter Languages, Programming and Architecture.
CSE 381 – Advanced Game Programming 3D Game Architecture.
Mathematical Fundamentals
Mathematical Concepts: Polynomials, Trigonometry and Vectors AP Physics C 20 Aug 2009.
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
Chapter 4.1 Mathematical Concepts
Tuesday, June 16, 2015PHYS , Summer 2015 Dr. Jaehoon Yu 1 PHYS 1441 – Section 001 Lecture #5 Tuesday, June 16, 2015 Dr. Jaehoon Yu Trigonometry.
SOFTWARE ENGINEERING BIT-8 APRIL, 16,2008 Introduction to UML.
CSCE 552 Spring 2011 Math By Jijun Tang. Layered.
Physics and Physical Measurement Topic 1.3 Scalars and Vectors.
Unit 3 Vectors and Motion in Two Dimensions. What is a vector A vector is a graphical representation of a mathematical concept Every vector has 2 specific.
Vector Quantities We will concern ourselves with two measurable quantities: Scalar quantities: physical quantities expressed in terms of a magnitude only.
CSCE 552 Spring 2009 Programming Fundamentals By Jijun Tang.
1 CO Games Concepts Week 20 Matrices continued Gareth Bellaby.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Math / Physics 101 GAM 376 Robin Burke Fall 2006.
CHAPTER 5 FORCES IN TWO DIMENSIONS
Vector Addition and Subtraction
Object Oriented Design David Talby. Welcome! n Introduction n UML u Use Case Diagrams u Interaction Diagrams u Class Diagrams n Design Patterns u Composite.
Tuesday, June 10, 2014PHYS , Summer 2014 Dr. Jaehoon Yu 1 PHYS 1441 – Section 001 Lecture #5 Tuesday, June 10, 2014 Dr. Jaehoon Yu Trigonometry.
Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22.
Chapter 3.6 Game Architecture. 2 Overall Architecture The code for modern games is highly complex (can easily exceed 1M LOC) The larger your program,
Vector components and motion. There are many different variables that are important in physics. These variables are either vectors or scalars. What makes.
CSCE 552 Fall 2012 Language and Programming By Jijun Tang.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
Games Development 1 Review / Revision CO2301 Games Development 1 Semester 2.
CSCE 552 Fall 2012 Language and Programming By Jijun Tang.
CSCE 552 Spring 2011 Math By Jijun Tang. Languages C/C++ Java Script: Flash, Python, LISP, etc. C# XNA for PC and Xbox.
Chapter 3: Introducing the UML
Computer Graphics Matrices
UML - Development Process 1 Software Development Process Using UML.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
CSCE 552 Spring 2009 Game Architecture and Math By Jijun Tang.
CSCE 552 Spring 2011 Language and Programming By Jijun Tang.
Language and Programming
Game Architecture Rabin is a good overview of everything to do with Games A lot of these slides come from the 1st edition CS 4455.
Chapter 3.
Games Development Game Architecture: Entities
Math review - scalars, vectors, and matrices
Game Programming Algorithms and Techniques
Games Development 1 Review / Revision
Or What’s Our Vector Victor?
Presentation transcript:

CSCE 590E Spring 2007 Game Architecture and Math By Jijun Tang

Announcements We will meet in 2A21 on Wednesday Please bring laptops (with mouse) on Wednesday Small game due Friday, March 9 th, 5:00pm Presentations start on Monday, March 5 th.

Game Design Presentation Two presentations, on March 5 th and March 7 th. March 5 th : Project Gnosis, Cheeze Puffs!, Team Swampus March 7 th : Space Banditos, Group E, Psychosoft Each has 20 minutes to present, 5 minutes to answer questions

Contents for the Presentation Description, specification, goals, game play System requirement, audience, rating Interface, input/output, interactions, cameras Premise/limitations/choices/resources Content designs, audio Level designs, flexibility Use case/UML (rough) Engines to use Version control/testing strategy Brief timeline (demo date is May 2 nd -9 th )

Logos-so-far

Data Structures: Array Elements are adjacent in memory (great cache consistency)  Requires continuous memory space They never grow or get reallocated  Use dynamic incremental array concept  GCC has a remalloc function In C++ there's no check for going out of bounds  Use vector if possible  Keep in mind of checking boundaries Inserting and deleting elements in the middle is expensive

Lists

Hash Table

Stack/Queue/Priority Queue

Bits

Inheritance Models “is-a” relationship Extends behavior of existing classes by making minor changes Do not overuse, if possible, use component systerm UML diagram representing inheritance

Polymorphism The ability to refer to an object through a reference (or pointer) of the type of a parent class Key concept of object oriented design C++ implements it using virtual functions

Multiple Inheritance Allows a class to have more than one base class Derived class adopts characteristics of all parent classes Huge potential for problems (clashes, casting, dreaded diamond, etc) Multiple inheritance of abstract interfaces is much less error prone (virtual inheritance) Java has no multiple inheritance

Component Systems Component system organization

Object Factory Creates objects by name Pluggable factory allows for new object types to be registered at runtime Extremely useful in game development for passing messages, creating new objects, loading games, or instantiating new content after game ships

Singleton Implements a single instance of a class with global point of creation and access For example, GUI Don't overuse it!!!

Observer Allows objects to be notified of specific events with minimal coupling to the source of the event Two parts  subject and observer

Composite Allow a group of objects to be treated as a single object Very useful for GUI elements, hierarchical objects, inventory systems, etc

The Five Step Debugging Process 1. Reproduce the problem consistently 2. Collect clues 3. Pinpoint the error 4. Repair the problem 5. Test the solution

Expert Debugging Tips Question assumptions Minimize interactions and interference Minimize randomness Break complex calculations into steps Check boundary conditions, use assertions Disrupt parallel computations Exploit tools in the debugger (VC is good) Check code that has recently changed Explain the bug to someone else Debug with a partner (A second pair of eyes) Take a break from the problem Get outside help (call people)

Game Architecture

Overall Architecture The code for modern games is highly complex  The Sims: 3 million lines of code  Xbox HD DVD player: 4.7 million lines  MS Train Simulator has 1GB installed, with only 10MB executable With code bases exceeding a million lines of code, a well-defined architecture is essential

Overall Architecture Main structure  Game-specific code  Game-engine code Both types of code are often split into modules, which can be static libraries, DLLs, or just subdirectories

Overall Architecture Architecture types  Ad-hoc (everything accesses everything)  Modular  DAG (directed acyclic graph)  Layered Options for integrating tools into the architecture  Separate code bases (if there's no need to share functionality)  Partial use of game-engine functionality  Full integration

Ad-hoc

Modular

DAG

Layered

Overview: Initialization/Shutdown The initialization step prepares everything that is necessary to start a part of the game The shutdown step undoes everything the initialization step did, but in reverse order

Initialization/Shutdown Resource Acquisition Is Initialization  A useful rule to minimalize mismatch errors in the initialization and shutdown steps  Means that creating an object acquires and initializes all the necessary resources, and destroying it destroys and shuts down all those resources Optimizations  Fast shutdown  Warm reboot

Overview: Main Game Loop Games are driven by a game loop that performs a series of tasks every frame Some games have separate loops for the front and and the game itself Other games have a unified main loop

Tasks of Main Game Loop Handling time Gathering player input Networking Simulation Collision detection and response Object updates Rendering Other miscellaneous tasks

Main Game Loop Structure  Hard-coded loops  Multiple game loops For each major game state  Consider steps as tasks to be iterated through Coupling  Can decouple the rendering step from simulation and update steps  Results in higher frame rate, smoother animation, and greater responsiveness  Implementation is tricky and can be error-prone

Execution Order of Main Loop Most of the time it doesn't matter In some situations, execution order is important Can help keep player interaction seamless Can maximize parallelism Exact ordering depends on hardware

Sample Game Loop

Game Entities What are game entities?  Basically anything in a game world that can be interacted with  More precisely, a self-contained piece of logical interactive content  Only things we will interact with should become game entities Organization  Simple list  Multiple databases  Logical tree  Spatial database

Creation and Updating Object creation  Basic object factories  Extensible object factories  Using automatic registration  Using explicit registration Updating  Updating each entity once per frame can be too expensive  Can use a tree structure to impose a hierarchy for updating  Can use a priority queue to decide which entities to update every frame

Level Instantiation Loading a level involves loading both assets and the game state It is necessary to create the game entities and set the correct state for them Using instance data vs. template data

Identification and Communication Identification  Strings  Pointers  Unique IDs or handles Communication  Simplest method is function calls  Many games use a full messaging system  Need to be careful about passing and allocating messages

Math

Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h

Applied Trigonometry Angles measured in radians Full circle contains 2  radians

Applied Trigonometry Sine and cosine used to decompose a point into horizontal and vertical components  r cos  r sin  r x y

Trigonometry

Trigonometric identities

Inverse trigonometric functions Return angle for which sin, cos, or tan function produces a particular value If sin  = z, then  = sin -1 z If cos  = z, then  = cos -1 z If tan  = z, then  = tan -1 z

arcs

Applied Trigonometry Law of sines Law of cosines  Reduces to Pythagorean theorem when  = 90 degrees   b a c

Vectors and Matrices Scalars represent quantities that can be described fully using one value  Mass  Time  Distance Vectors describe a magnitude and direction together using multiple values

Vectors and Matrices Examples of vectors  Difference between two points Magnitude is the distance between the points Direction points from one point to the other  Velocity of a projectile Magnitude is the speed of the projectile Direction is the direction in which it ’ s traveling  A force is applied along a direction

Vectors and Matrices Vectors can be visualized by an arrow  The length represents the magnitude  The arrowhead indicates the direction  Multiplying a vector by a scalar changes the arrow ’ s length V 2V2V –V–V

Vectors and Matrices Two vectors V and W are added by placing the beginning of W at the end of V Subtraction reverses the second vector V W V + W V W V V – WV – W –W–W

Vectors and Matrices An n-dimensional vector V is represented by n components In three dimensions, the components are named x, y, and z Individual components are expressed using the name as a subscript:

Vectors and Matrices Vectors add and subtract componentwise

Vectors and Matrices The magnitude of an n-dimensional vector V is given by In three dimensions, this is

Vectors and Matrices A vector having a magnitude of 1 is called a unit vector Any vector V can be resized to unit length by dividing it by its magnitude: This process is called normalization

Vectors and Matrices A matrix is a rectangular array of numbers arranged as rows and columns  A matrix having n rows and m columns is an n  m matrix  At the right, M is a 2  3 matrix  If n = m, the matrix is a square matrix

Vectors and Matrices The entry of a matrix M in the i-th row and j-th column is denoted M ij For example,

Vectors and Matrices The transpose of a matrix M is denoted M T and has its rows and columns exchanged:

Vectors and Matrices An n-dimensional vector V can be thought of as an n  1 column matrix: Or a 1  n row matrix:

Vectors and Matrices Product of two matrices A and B  Number of columns of A must equal number of rows of B  Entries of the product are given by  If A is a n  m matrix, and B is an m  p matrix, then AB is an n  p matrix

Vectors and Matrices Example matrix product

Vectors and Matrices Matrices are used to transform vectors from one coordinate system to another In three dimensions, the product of a matrix and a column vector looks like:

Identity Matrix I n For any n  n matrix M, the product with the identity matrix is M itself  I n M = M  MI n = M

Invertible An n  n matrix M is invertible if there exists another matrix G such that The inverse of M is denoted M -1

Properties of Inverse Not every matrix has an inverse A noninvertible matrix is called singular Whether a matrix is invertible can be determined by calculating a scalar quantity called the determinant

Determinant The determinant of a square matrix M is denoted det M or |M| A matrix is invertible if its determinant is not zero For a 2  2 matrix,

Determinant The determinant of a 3  3 matrix is

Inverse Explicit formulas exist for matrix inverses  These are good for small matrices, but other methods are generally used for larger matrices  In computer graphics, we are usually dealing with 2  2, 3  3, and a special form of 4  4 matrices

Vectors and Matrices The inverse of a 2  2 matrix M is The inverse of a 3  3 matrix M is

Vectors and Matrices A special type of 4  4 matrix used in computer graphics looks like  R is a 3  3 rotation matrix, and T is a translation vector

Vectors and Matrices The inverse of this 4  4 matrix is