Matthew Christian - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Matthew Christian

Description:

Beaten over 140 games (Yes I have a list) Independent Game Developer (spare time) for 5 years. XNA developer for around a year and a half. Definition ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 18
Provided by: inside9
Category:

less

Transcript and Presenter's Notes

Title: Matthew Christian


1
Basics of 3D Math in Games
  • Matthew Christian

2
Overview
  • About Me
  • Introduction to Linear Algebra
  • Vectors
  • Matrices
  • Quaternions
  • Links

3
About Me
  • Student
  • Applied Mathematics and Computer Science
    Software Development at UW-Stout
  • Degree
  • Associates Degree in Computer Programming from
    Northcentral Technical College
  • Gamer
  • Beaten over 140 games (Yes I have a list)
  • Independent Game Developer (spare time) for 5
    years
  • XNA developer for around a year and a half

4
Intro to Linear Algebra
  • Definition
  • The part of algebra that deals with the theory of
    linear equations and linear transformations
  • In which the specific properties of vector spaces
    are studied (including matrices)
  • This is NOT about Linear Algebra, its about
    the gaming version of Linear Algebra

5
Vectors
  • Definitions
  • A variable quantity that can be resolved into
    components
  • A straight line segment whose length is magnitude
    and whose orientation in space is direction
  • Vectors are simple row-based data structures
  • In XNA
  • Microsoft.XNA.Framework
  • Vector2, Vector3, Vector4
  • public Vector2 ( float x, float y )

6
Cartesian Example
Let P be a point at (2,2) Then the vector p can
be described as p 2, 2 Ex 2,1 , 1,3
7
Vector Operations
  • Vector Addition
  • Add terms in similar positions
  • Vector Subtraction
  • Remember, vectors represent directions
  • How to subtract direction? Add negative
    direction
  • Scalar-Vector Multiplication
  • Scaling a Vector up or down is easy, multiply
    each element by the scalar
  • Similar for Division (multiply by scalar
    fraction)
  • Vector Matrix Multiplication
  • See later

8
More Advanced Operations
  • Dot Product
  • Helps determine the angle between 2 vectors
  • Cross Product
  • Creates another vector perpendicular to the
    other two vectors (normal) (3D)
  • Normalizing
  • Magnitude (length)

9
Basic Uses for Vectors
  • Storing values (positions)
  • Directions (move direction, collision direction)
  • Demo(s)
  • Simple Vectors
  • Vector Collision

10
Matrices
  • Definition
  • A rectangular array of quantities set out by
    rows and columns, treated as a single element and
    manipulated accordingly
  • For us programmers,
  • Multi-dimensional arrays
  • A column is a 3x3 matrix if it has 3 rows and 3
    columns
  • Nxm matrix is a matrix with n rows and m columns

11
Anatomy of a Matrix
  • Square Matrix
  • N-rows, N-columns
  • Main Diagonal
  • Runs from upper left corner down (includes
    non-square matrices)
  • Diagonal Matrix
  • Matrix where all entries outside of the main
    diagonal are zero (main diagonal entries can be
    zero)
  • Identity Matrix
  • The matrix equivalent of multiplying by 1 1s
    across the main diagonal with zeros elsewhere
    (nxn sized)

12
3D Rendering
  • 3D Rendering is possible BECAUSE of matrices
  • ModelViewProjection Matrix
  • Model Matrix Matrix describing the
    position/rotation/scale of your object
  • Order is important (multiply in order of
    operations)
  • View Matrix Camera position, target, up
    direction (orientation)
  • Projection Matrix View frustum squished (your
    monitor doesnt display 3D)

13
Uses for Matrices
  • Math Demos
  • Transformations!
  • In XNA
  • Microsoft.XNA.Framework
  • Matrix
  • 4x4 matrix (M11 M44)
  • Demos
  • MatrixTransformations
  • Camera Demo (from Tutorials)

14
Quaternions
  • Quaternions are compact descriptions of
    rotations
  • Quaternions DONT Prevent Gimbal Lock
  • Matrices use Euler numbers to calculate rotations
    which cancels a direction
  • After calculating, you can only rotate on the
    Z-Axis
  • In all honesty, Im still researching it!

15
Quaternions (cont'd)
  • (X, Y, Z, W)
  • (X, Y, Z) is the axis to do rotations about
  • (W) is the amount to rotate about that axis
  • Arbitrary Axis
  • Not global axis

16
Uses for Quaternions
  • Demo
  • Quaternion Camera

17
Questions? Links
  • http//www.insidegamer.org/XnaTutorials.aspx
  • My tutorials (specifically Tutorial 4)
  • http//www.ziggyware.com/readarticle.php?article_i
    d54
  • Specifically about Vectors in XNA
  • http//hyperphysics.phy-astr.gsu.edu/hbase/vect.ht
    ml
  • Some Vector operations
  • http//geekswithblogs.net/CodeBlog
  • My (seldom updated) Blog
Write a Comment
User Comments (0)
About PowerShow.com