Home > Documents > Geometric Objects and Basic Transformations

# Geometric Objects and Basic Transformations

Date post: 23-Feb-2016
Category:
Upload: bern
View: 50 times
Download: 1 times
Share this document with a friend
Description:
Geometric Objects and Basic Transformations. Paul Taylor 2010. 3D Coordinate systems. DirectXOpenGL. http://alt.pluralsight.com/wiki/default.aspx/Craig.DirectX/CoordinateSystemsTutorial.html. xMax , 0. 2D Coordinates in Windows. 0,0. 0, yMax. xMax , yMax. - PowerPoint PPT Presentation
Popular Tags:
of 25 /25
Geometric Objects and Basic Transformations Paul Taylor 2010
Transcript

Geometric Objects and Basic Transformations

Paul Taylor 2010

3D Coordinate systems

http://alt.pluralsight.com/wiki/default.aspx/Craig.DirectX/CoordinateSystemsTutorial.html

DirectX OpenGL

2D Coordinates in Windows0,0

xMax, yMax

0, yMax

xMax, 0

• In both OpenGL and Direct3D Z is the depth of the viewport!!!!hence the Z-buffer (Depth Buffer)

• Z Buffer Depth– Due to the scalar nature of the Pyramid Viewport– Depth precision drops as the distance between

the Near and Far planes are moved apart– This will result in more artefacts and visual errors

Using the Z Buffer

glEnable(GL_DEPTH_TEST);This enables the Z buffer, but is entirely useless

without: glDepthFunc(GL_LEQUAL);You’ll find that the default for the Depth buffer

usually doesn’t work.

Viewport types

• Orthogonal– No depth perception (scaling)

• Projected– This is the typical 3D viewport

• Objects \ Vertices are scaled and rotated based on the ‘virtual’ distance from the screen

Viewport Creation

• glOrtho(left, right, bottom, top, near, far)• gluOrtho2D

– Sets the Near and Far values to 1.0• (Only renders objects with z=1.0)• Same as glOrtho with near & far = 1.0

• GluPerspective(…)– Creates the Viewport Frame based on a FOV

• GlFrustrum(…) – Create the Viewport in a more numerical way

• Create your viewport matrix manually if you like!

Matriceis

• GL_PROJECTION• GL_MODEL_VIEW• GL_TEXTURE_MATRIX

Matrix Math (Joy!)

• Matrix Addition• Matrix Multiplication• Translation and Rotation Matrices

Matrix Addition1 2 3

4 5 6

7 8 9

A B C

D E F

G H I+ =1+A 2+B 3+C

4+D 5+E 6+F

7+G 8+H 9+I

4 0 0

0 6 0

0 0 9

3 0 0

0 1 0

0 0 0+ =7 0 0

0 7 0

0 0 9

Matrix Multiplication Row,Colum1 2 3

4 5 6

7 8 9

A B C

D E F

G H Ix =1A + 2D + 3G

1B + 2E + 3H

1C + 2F + 3I

4A + 5D + 6G

4B + 5E + 6H

4C + 5F + 6I

7A + 8D + 9G

7B + 8E + 9H

7C + 8F + 9I

4 0 0

0 6 0

0 0 9

3 0 0

0 1 0

0 0 0x =12 0 0

0 6 0

0 0 0

That’s great, what do I need them for?

Translation Matrices• Coordinates from Object Coordinates to world

CoordinatesObject Translation World

Typically we use a Matrix Multiplication

100 0 0

0 20 0

0 0 -100+ =110 0 0

0 30 0

0 0 -100

10 0 0

0 10 0

0 0 0

Scalar MatricesObject Scalar (1/10) World

This can be done by glScalef(x,y,z);

100 0 0

0 100 0

0 0 100

0.1 0.1 0.1

0.1 0.1 0.1

0.1 0.1 0.1x =10 0 0

0 10 0

0 0 10

Translation by Multiplication

• This is a computationally longer way to do a simple translation

• glTranslatef(x,y,z);1 0 0 x

0 1 0 y

0 0 1 z

0 0 0 1

x =1 0 0 x

0 1 0 y

0 0 1 z

0 0 0 1

1 0 0 10

0 1 0 5

0 0 1 10

0 0 0 1

Rotational Matrices

http://en.wikipedia.org/wiki/Rotation_matrix#Dimension_threeA Rotation around the unit vector u = (ux,uy,uz)

glRotatef(Theta,x,y,z);

Putting it all together

Typically you will want to:TranslateRotateScale

Matrix Multiplication is the inverse to the logical order!

So:Scale then Rotate, then Translate

Retrieving Matrices

• This is slow!• The Video Matricies are 4x4 hence:GLfloat matrix[16];glGetFloatv(GL_PROJECTION_MATRIX, &matrix[0]);matrix =

Simillarly you can do this for GL_MODEL_VIEW and GL_TEXTURE_MATRIX

Setting your own Matrixvoid glLoadMatrixf( &matrix[0]);

0 4 8 C1 5 9 D2 6 A E3 7 B F

0 1 2 3 4 5 6 7 8 9 A B C D E F

BG115 has

XNA

Silent Hill 5 (Homecoming)

From Jason Allen (Lead Designer)

…” We made a decision during development to support invert aim and not invert camera. Unfortunately none of the team nor any of our test group actually had a preference for playing with an inverted camera, so the issue of its omission never came up.”…

http://72.14.235.132/search?q=cache:ylhQ9HOmPg4J:gamesblog.ugo.com/index.php/gamesblog/more/silent_hill_homecomings_jason_allen_on_inverted_aim/+silent+hill+5+no+camera+invert&cd=3&hl=en&ct=clnk&gl=au&client=firefox-a

Matrix Mathematics Continued

• Matrix Cross Product

• We use this to create Normals

• Matrix Dot Product

• Normalising Matrcies

HAVE YOU REGISTERED TO ATTEND THE LARGEST ENGINEERING EXPO IN AUSTRALIA?

Come along to the BIGGEST FREE Engineering Expo on 25 March from 2.00pm to 7.00pm at Etihad Stadium, Docklands (Enter via Gate 9).

This event will provide you access to;• 70+ Exhibitors • Recruitment Opportunities• Career and Professional Development Advice • Engineering Industry Insight &Updates on Engineering Projects• Knowledge on Engineering Capability & Leadership Information• FREE Seminars

You must pre-register to attend.

For more information, please visit www.engineeringexpo.org.au

Don’t miss this showcase of Engineers that ‘Make it So’

This event is proudly sponsored by General Electric and Engineering Education Australia.

LIST OF EXHIBITORS AT 2010 ENGINEERING EXPOAbigroup Contractors

ADVEA Engineering Pty. Ltd.

Aecom

Aker Solutions Australia

Alcoa Of Australia

Arup

ATC Williams

Aurecon

Australian Institute Of Project Management

Australian Water Association

Baulderstone

Beca Pty Ltd

BMD

BMT Design & Technology Pty Ltd

Box Hill Institute Of TAFE

BP

Chisholm Institute

CitiPower & Powercor

City West Water

Citywide Service Solutions

Civil Contractors Federation

Coffey International Limited

CPG Australia

Dalton Consulting Engineers

Deakin University

Defence Force Recruiting

Defence Materiel Organisation

Engineering Education Australia

Fluor Australia Pty Ltd

Fulton Hogan

General Electric

GHD

GOULBURN-MURRAY WATER

GTA Consultant

Halcrow

Hatch

Holmesglen Institute

IAESTE Australia

Invensysy Rail Pty Ltd

Irwinconsult

Jemena

John Holland Group

K.B.R

La Trobe University

Leighton Contractors

Melbourne Water

MWH Global

OMCS International

Parsons Brinckerhoff

PSN

QR

Rio Tinto

RMIT English Worldwide

RMIT University

Siemens

Sinclair Knight Merz

SMEC / SMEC Urban

South East Water Limited

SP AusNet

Swinburne University of Technology

Teach For Australia

Thales

UGL

University of Ballarat

University Of Melbourne

URS

VicRoads

Victoria University - School Of Engineering & Science

Wood & Grieve Engineers

Monash University Engineering

Recommended