1 / 31

Coordinate Systems

Coordinate Systems. a nd an introduction to matrices. The Local Coordinate System. Sometimes called “Object Space” It’s the coordinate system the model was made in. The Local Coordinate System. Sometimes called “Object Space” It’s the coordinate system the model was made in. (0, 0, 0).

iokina
Download Presentation

Coordinate Systems

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. Coordinate Systems and an introduction to matrices Jeff Chastine

  2. The Local Coordinate System • Sometimes called “Object Space” • It’s the coordinate system the model was made in Jeff Chastine

  3. The Local Coordinate System • Sometimes called “Object Space” • It’s the coordinate system the model was made in (0, 0, 0) Jeff Chastine

  4. The World SPACE • The coordinate system of the virtual environment (619, 10, 628) Jeff Chastine

  5. (619, 10, 628) Jeff Chastine

  6. Question • How did get the monster positioned correctly in the world? • Let’s come back to that… Jeff Chastine

  7. Camera Space • It’s all relative to the camera… Jeff Chastine

  8. Camera Space • It’s all relative to the camera… and the camera never moves! (0, 0, -10) Jeff Chastine

  9. The Big Picture • How to we get from space to space? ? ? Jeff Chastine

  10. The Big Picture • How to we get from space to space? • For every model • Have a (M)odel matrix! • Transforms from object to world space ? M Jeff Chastine

  11. The Big Picture • How to we get from space to space? • To put in camera space • Have a (V)iew matrix • Usually need only one of these V M Jeff Chastine

  12. The Big Picture • How to we get from space to space? • The ModelView matrix • Sometimes these are combined into one matrix • Usually keep them separate for convenience V M MV Jeff Chastine

  13. Matrix - What? • A mathematical structure that can: • Translate (a.k.a. move) • Rotate • Scale • Usually a 4x4 array of values • Idea: multiply each point by a matrix to get the new point • Your graphics card eats matrices for breakfast The Identity Matrix Jeff Chastine

  14. Back to The Big Picture • If you multiply a matrix by a matrix, you get a matrix! • How might we make the model matrix? M Jeff Chastine

  15. Back to The Big Picture Translation matrix T Rotation matrix R1 Rotation matrix R2 Scale matrix S • If you multiply a matrix by a matrix, you get a matrix! • How might we make the model matrix? M Jeff Chastine

  16. Back to The Big Picture Translation matrix T Rotation matrix R1 Rotation matrix R2 Scale matrix S • If you multiply a matrix by a matrix, you get a matrix! • How might we make the model matrix? M T * R1 * R2 * S = M Jeff Chastine

  17. Matrix Order • Multiply left to right • Results are drastically different (an angry vertex) Jeff Chastine

  18. Matrix Order • Multiply left to right • Results are drastically different • Order of operations • Rotate 45° Jeff Chastine

  19. Matrix Order • Multiply left to right • Results are drastically different • Order of operations • Rotate 45° • Translate 10 units Jeff Chastine

  20. Matrix Order • Multiply left to right • Results are drastically different • Order of operations • Rotate 45° • Translate 10 units before after Jeff Chastine

  21. Matrix Order • Multiply left to right • Results are drastically different • Order of operations Jeff Chastine

  22. Matrix Order • Multiply left to right • Results are drastically different • Order of operations • Translate 10 units Jeff Chastine

  23. Matrix Order • Multiply left to right • Results are drastically different • Order of operations • Translate 10 units • Rotate 45° Jeff Chastine

  24. Matrix Order • Multiply left to right • Results are drastically different • Order of operations • Translate 10 units • Rotate 45° after before Jeff Chastine

  25. Back to The Big Picture Translation matrix T Rotation matrix R1 Rotation matrix R2 Scale matrix S • If you multiply a matrix by a matrix, you get a matrix! • How might we make the model matrix? M T * R1 * R2 * S = M Backwards Jeff Chastine

  26. Back to The Big Picture Translation matrix T Rotation matrix R1 Rotation matrix R2 Scale matrix S • If you multiply a matrix by a matrix, you get a matrix! • How might we make the model matrix? M S * R1 * R2 * T = M Jeff Chastine

  27. The (P)rojection Matrix • Projects from 3D into 2D • Two kinds: • Orthographic: depth doesn’t matter, parallel remains parallel • Perspective: Used to give depth to the scene (a vanishing point) • End result: Normalized Device Coordinates (NDCs between -1.0 and +1.0) Jeff Chastine

  28. Orthographic vs. Perspective Jeff Chastine

  29. An Old Vertex Shader in vec4 vPosition; // The vertex in NDC void main () { gl_Position = vPosition; } Originally we passed using NDCs (-1 to +1) Jeff Chastine

  30. A Better Vertex Shader in vec4 vPosition; // The vertex in the local coordinate system uniform mat4 mM; // The matrix for the pose of the model uniform mat4 mV; // The matrix for the pose of the camera uniform mat4 mP; // The projection matrix (perspective) void main () { gl_Position = mP*mV*mM*vPosition; } New position in NDC Original (local) position Jeff Chastine

  31. SMILE – It’s the END! Jeff Chastine

More Related