1 / 46

Basic 3D Concepts

Basic 3D Concepts. Basic 3D Concepts. Overview Coordinate systems Transformations Projection Rasterization. Establishing a coordinate system. Representing the 3D world. Typically, objects in our world consist of groups of triangles.

lujanv
Download Presentation

Basic 3D Concepts

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. Basic 3D Concepts

  2. Basic 3D Concepts Overview • Coordinate systems • Transformations • Projection • Rasterization

  3. Establishing a coordinate system

  4. Representing the 3D world • Typically, objects in our world consist of groups of triangles. • face = set of one or more contiguous coplanar adjacent triangles. • adjacency? • How do we represent triangles?

  5. Representing the 3D world • How do we represent triangles? • By 3 points - the 3 vertices of the triangle. • How are the points represented?

  6. Representing the 3D world • How are the points represented? • Since we are in 3D space, each point is a vector consisting of 3 values, <x,y,z>, in a cartesian coordinate system. (scalar, vector, matrix) 2D 3D

  7. Representing the 3D world • In TorqueScript, a vector is represented by a list/string of (typically) 3 numbers separated by a space. • Example $fred = “12.0 13 19”; $c0 = getword( $fred, 0 ); echo( $c0 ); //what does this print?

  8. Representing the 3D world • Unity, uses the Vector3 class. • example (JavaScript) var aPosition = Vector3(1, 1, 1); • example (C#) using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Vector3 aPosition = new Vector3( 1, 1, 1 ); }

  9. Unity’s Vector3 class • This structure is used throughout Unity to represent D positions and directions. • It also contains functions for doing common vector operations. • See http://unity3d.com/support/documentation/ScriptReference/Vector3.html for more information.

  10. Unity’s Vector3 class • class variables: • one, zero, forward, up, right • instance variables: • x, y, z • methods: • scale, normalize, cross, dot, reflect, distance, etc. • operators: • +, -, *, /, ==, !=

  11. Representing the 3D world • How does a vector such as “12.0 1 -5” map into the “real” world? • We don’t (yet) know if 1 above specifies the H, W, or D! • Furthermore, we don’t know the relationship (l or r, u or d, f or b) between “12.0 1 -5” and “12.0 2 -5”

  12. Representing the 3D world • How does a vector map into the “real” world? • Let’s establish a coordinate system • Left is left-handed; right is right-handed. • Index is +z, thumb is +y, middle is +x.

  13. Representing objects • Objects (models) are composed of polygons which are composed of triangles. • But these triangles aren’t arbitrary!

  14. Representing objects • Objects (models) are composed of polygons which are composed of triangles. • But these triangles aren’t arbitrary!

  15. Representing the 3D world • We don’t know where our object will be placed in the world. • It may even move in the world! • We may have more than one in the world too! • So we don’t/can’t fix the object coordinates in terms of world coordinates! • But we need to specify each of the triangle vertices as numbers. • So what can we do?

  16. Representing the 3D world • So we don’t/can’t fix the object coordinates in terms of world coordinates! • But we need to specify each of the triangle vertices as numbers. • So what can we do? • Each object has it’s own object coordinate system with it’s own origin (0,0,0). • So where is the model origin?

  17. Representing the 3D world • Each object has it’s own object coordinate system with it’s own origin (0,0,0). • So where is the model origin? • Anywhere! It can be any point on (or not on) the object. • It can be the left-most (or right-most or top-most or …) point on the object. • It can be the geometric center (centroid/center of mass) of the object.

  18. Representing the 3D world • Typically, it is the geometric center (centroid/center of mass) of the object. • Let P be the set of points in the object. • Let Pi=<xi,yi,zi> be a particular point. • How can we calculate the centroid of an object?

  19. Representing the 3D world • Typically, it is the geometric center (centroid/center of mass) of the object. • Let P be the set of points in the object. • Let Pi=<xi,yi,zi> be a particular point. • How can we calculate the centroid of an object?

  20. Representing the 3D world • Interesting property of the centroid: • This may not even be a point on the object! • Can you think of a real world object with a center that isn’t on the object?

  21. transformations

  22. Transformation • Conversion from object coordinates to world coordinates. • Consists of: • Rotation • Translation • Scale

  23. Transformation • Translation

  24. Transformation • Scale

  25. Transformation • Rotation

  26. Representing the 3D world • In Unity, the Transform Component determines the actual Position, Rotation, and Scale of all objects in the scene. • Every object has a Transform.

  27. Representing the 3D world • In Unity, … • Position • X, Y, and Z coordinates • Rotation • around the X, Y, and Z axes, measured in degrees • Scale • along X, Y, and Z axes • A value "1" is the original size (size at which the object was imported).

  28. Representing the 3D world • In Unity, … • All properties of a Transform are measured relative to the Transform's parent. • If the Transform has no parent, the properties are measured relative to World Space.

  29. projection

  30. Problem We have a 3D world consisting of height, width, and depth which is displayed on a 2D computer screen consisting only of height and width!

  31. Projection • Remember that our world is 3D and the computer monitor is 2D. • Projection is the conversion from world coordinates to screen coordinates. • Types: • parallel (orthographic) • perspective

  32. Parallel (orthographic) projection • The distance from the camera doesn't affect how large an object appears.

  33. Perspective projection • The further an object is from the camera (viewpoint), the smaller it appears. • Similar to how our eye and how a camera works.

  34. Controlling perspective projection In both scenes, the fence appears to be relatively close, but the mountains vary greatly.

  35. Controlling perspective projection

  36. Controlling perspective projection

  37. Entire transformation process

  38. rasterization

  39. Rendering (rasterization) • But that’s not all there is to do! • All we’ve done so far is to project the vertices of triangles onto the screen. • What about the points in between (the vertices)? • What about color? • What about light sources?

  40. Rendering (rasterization) • The process of converting the 3D model of an object into an on-screen 2D image. • Note: This is most often done by the video card hardware for speed.

  41. Rendering examples

  42. Rendering examples Note uniformity across face of triangle.

  43. Rendering Steps: • transformation • projection • scan conversion (filling in the triangles) • involves shading the surface (considers the orientation of the surface w.r.t. the location of the light(s))

  44. Rendering • Typically involves a z-buffer (because many points may be projected to the same point on the screen).

  45. Phew!

More Related