basic 3d concepts. overview 1.coordinate systems 2.transformations 3.projection 4.rasterization
TRANSCRIPT
![Page 1: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/1.jpg)
Basic 3D Concepts
![Page 2: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/2.jpg)
Basic 3D Concepts
Overview1. Coordinate systems
2. Transformations
3. Projection
4. Rasterization
![Page 3: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/3.jpg)
ESTABLISHING A COORDINATE SYSTEM
![Page 4: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/4.jpg)
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?
![Page 5: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/5.jpg)
Representing the 3D world
How do we represent triangles? By 3 points - the 3 vertices of the
triangle.
How are the points represented?
![Page 6: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/6.jpg)
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
![Page 7: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/7.jpg)
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?
![Page 8: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/8.jpg)
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 );
}
![Page 9: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/9.jpg)
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.
![Page 10: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/10.jpg)
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:
+, -, *, /, ==, !=
![Page 11: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/11.jpg)
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”
![Page 12: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/12.jpg)
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.
![Page 13: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/13.jpg)
Representing objects Objects (models) are composed of polygons
which are composed of triangles.
But these triangles aren’t arbitrary!
![Page 14: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/14.jpg)
Representing objects
Objects (models) are composed of polygons which are composed of triangles.
But these triangles aren’t arbitrary!
![Page 15: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/15.jpg)
![Page 16: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/16.jpg)
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?
![Page 17: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/17.jpg)
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?
![Page 18: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/18.jpg)
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.
![Page 19: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/19.jpg)
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?
![Page 20: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/20.jpg)
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?
P
z
P
y
P
xzyx
P
ii
P
ii
P
ii
111 ,,,,
![Page 21: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/21.jpg)
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?
![Page 22: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/22.jpg)
TRANSFORMATIONS
![Page 23: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/23.jpg)
Transformation
Conversion from object coordinates to world coordinates. Consists of:
Rotation Translation Scale
![Page 24: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/24.jpg)
Transformation
Translation
![Page 25: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/25.jpg)
Transformation
Scale
![Page 26: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/26.jpg)
Transformation
Rotation
![Page 27: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/27.jpg)
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.
![Page 28: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/28.jpg)
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).
![Page 29: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/29.jpg)
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.
![Page 30: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/30.jpg)
PROJECTION
![Page 31: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/31.jpg)
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!
![Page 32: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/32.jpg)
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
![Page 33: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/33.jpg)
Parallel (orthographic) projection
The distance from the camera doesn't affect how large an object appears.
![Page 34: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/34.jpg)
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.
![Page 35: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/35.jpg)
Controlling perspective projection
In both scenes, the fence appears to be relatively close, but the mountains vary greatly.
![Page 36: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/36.jpg)
Controlling perspective projection
![Page 37: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/37.jpg)
Controlling perspective projection
![Page 38: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/38.jpg)
Entire transformation process
![Page 39: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/39.jpg)
RASTERIZATION
![Page 40: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/40.jpg)
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?
![Page 41: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/41.jpg)
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.
![Page 42: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/42.jpg)
Rendering examples
![Page 43: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/43.jpg)
Rendering examples
Note uniformity across face of triangle.
![Page 44: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/44.jpg)
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))
![Page 45: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/45.jpg)
Rendering
Typically involves a z-buffer (because many points may be projected to the same point on the screen).
![Page 46: Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649f565503460f94c7b2ed/html5/thumbnails/46.jpg)
PHEW!