Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization."— Presentation transcript:

1 Basic 3D Concepts

2 Overview 1.Coordinate systems 2.Transformations 3.Projection 4.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,, in a cartesian coordinate system. (scalar, vector, matrix) 2D3D

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/documen tation/ScriptReference/Vector3.html for more information. http://unity3d.com/support/documen tation/ScriptReference/Vector3.html

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

16 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?

17 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?

18 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. 1.It can be the left-most (or right-most or top-most or …) point on the object. 2.It can be the geometric center (centroid/center of mass) of the 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 P i = be a particular point. How can we calculate the centroid of an object?

20 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 P i = be a particular point. How can we calculate the centroid of an object?

21 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?

22 TRANSFORMATIONS

23 Transformation  Conversion from object coordinates to world coordinates. Consists of:  Rotation  Translation  Scale

24 Transformation  Translation

25 Transformation  Scale

26 Transformation  Rotation

27 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.

28 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).

29 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.

30 PROJECTION

31 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!

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

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

34 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.

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

36 Controlling perspective projection

37

38 Entire transformation process

39 RASTERIZATION

40 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?

41 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.

42 Rendering examples

43 Note uniformity across face of triangle.

44 Rendering Steps: 1.transformation 2.projection 3.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))

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

46 PHEW!


Download ppt "Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization."

Similar presentations


Ads by Google