• No results found

TNM046: Datorgrafik Triangle and Normal

N/A
N/A
Protected

Academic year: 2021

Share "TNM046: Datorgrafik Triangle and Normal"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

TNM046: Datorgrafik Triangle and Normal

Sasan Gooran VT 2014

2

Computer Graphics

What?

“Almost everything on computers that is not text or sound “ The representation and manipulation of image data by computer

Techniques to create and manipulate images

Where?

Television, Newspapers (weather reports), Medical investigations and surgical procedures

3

Computer Graphics

Applications:

Entertainments (Movies, Video games) Computer Aided Design (CAD) Medical Applications Scientific Visualization Virtual Reality

….

(2)

4

Computer Graphics

5

Computer Graphics, Objects

In order to define an object, you need to first specify the coordinates of the vertices. Then you define the triangles the object consists of. Each triangle is defined by specifying its three vertices.

In order to perform different transformations (e.g. scaling, translation, rotation etc.) on an object you transform the object’s vertices. This is done by multiplying the appropriate transformation matrix with the coordinates of the vertices.

6

Computer Graphics, TNM046

Triangle and Normal 2D and 3D Transformations Light Sources and Shading Perspective Projection Culling and Clipping Texture Mapping

(3)

7

Vertex and Triangle

Vertex:

(

x y z

)

Triangle: array of Vertex (vertices) 3D object: array of Triangle (triangles)

Example: Triangle[1] : (10,10,10), (10,20,10), (10,20,20) Triangle[2] : (10,10,10), (10,20,10), (10,10,20)

Not a good approach Every vertex is repeated

8

Vertex and Triangle

Vertex:

(

x y z

)

Vertex table: array of Vertex Triangle table: array of integers

Example: Vertex table: (10,10,10) , (10,20,10) , (10,20,20), (10,10,20), …..

Triangle table: (1,2,3) , (1,2,4) , ….

3D object: Vertex table + Triangle table

Now all vertices in the object is in one list (table).

9

Vertex and Triangle

Example: Present the following object using vertex and triangle table. The distance from P1, P2 and P3 to the origin (P0) is unity (1).

x

y z

p0 p1

p2 p3

Triangle 0: p0p1p2 Triangle 1:

p0p1p3

Triangle 2:

p0p2p3

Triangle 3:

p1p2p3

Vertex table:

p0: (0,0,0) p1: (1,0,0) p2: (0,1,0) p3: (0,0,1) Answer:

Triangle table:

Triangle 0: (0,1,2) Triangle 1: (0,1,3) Triangle 2: (0,2,3) Triangle 3: (1,2,3)

(4)

10

Vertex and Triangle

Assume triangle 1 (p0p1p3).

p0 = (0,0,0), p1 = (1,0,0), p3 = (0,0,1),

x z

p0 p1

p3

d0 d1 d2

Difference vectors:

d0= (1, 0, 0) − (0, 0, 0) = (1, 0, 0) d1= (0, 0,1) − (1, 0, 0) = (−1, 0,1) d2= (0, 0, 0) − (0, 0,1) = (0, 0, −1)

11

Triangle and Normal

x z

p0 p1

p3

d0

d1 d2

x

y z

p0 p1

p2 p3 Triangle 1:

p0p1p3

d0×

d1= (1, 0, 0) × (−1, 0,1) =

ˆx ˆy ˆz

1 0 0

−1 0 1

= (0, −1, 0) This normal vector points outwards (the object) d1×

d2= (−1, 0,1) × (0, 0, −1) = (0, −1, 0) d2×

d0= (0, 0, −1) × (1, 0, 0) = (0, −1, 0)

12

Triangle and Normal

x z

p0 p1

p3

d0 d1 d2

Triangle 1:

p0p1p3 N1= d0×

d1= d1×

d2= d2×

d0

Three possible starting points For this triangle three lists are possible:

(0,1,3) or (1,3,0) or (3,0,1)

In order to calculate the normal pointing outwards:

Find the vector from the first point to the second (call A1) Find the vector from the second point to the third (call A2)

N1= A1×

A2 points outwards

(5)

13

Triangle and Normal

Triangle table: Let your thumb of the right hand stick out of the object. Pick the first point, then the sense of your fingers gives you the other two points in the right sequence.

x

y z

p0 p1

p2 p3

Triangle 0: p0p1p2 Triangle 1:

p0p1p3

Triangle 2:

p0p2p3

Triangle 3:

p1p2p3

Triangle table:

Triangle 0: (0,2,1) Triangle 1: (0,1,3) Triangle 2: (0,3,2) Triangle 3: (1,2,3)

Compare this triangle table with the one on page 4.

14

Triangle and Normal

Therefore the following 3D object can be defined as:

x

y z

p0 p1

p2 p3

Triangle table:

0: (0,2,1) 1: (0,1,3) 2: (0,3,2) 3: (1,2,3) Vertex table:

0: (0,0,0) 1: (1,0,0) 2: (0,1,0) 3: (0,0,1)

15

Triangle and Normal

In OpenGL, together with the vertex coordinate you also specify the normal vector and the texture coordinates (for texture mapping). Texture mapping will be discussed later.

x

y z

p0 p1

p2 p3

Let us know look at vertex 0 (p0) Vertex 0 is the junction oft hree triangles, each of which has its own normal vector, i.e., (0,0,-1), (0, -1, 0) and (-1, 0, 0). Therefore vertex 0 is defined three times:

Vertex p0:

Nr coordinate normal 0: (0,0,0) (0, 0, -1) 1: (0,0,0) (0, -1, 0) 2: (0,0,0) (-1, 0, 0)

(6)

16

Triangle and Normal

x

y z

p0 p1

p2 p3

Vertex table:

Nr coordinate normal 0: (0,0,0) (0, 0, -1) 1: (0,0,0) (0, -1, 0) 2: (0,0,0) (-1, 0, 0) 3: (1,0,0) (0, 0, -1) 4: (1,0,0) (0, -1, 0)

5: (1,0,0) (0.577,0.577,0.577) 6: Fill the rest, will be discussed in the class (första lektionen)

17

Triangle and Normal

x

y z

p0 p1

p2

p3 Triangle table:

Nr

0: (0,?,3) 1: (?,?,?) 2: (?,?,?) 3: (?,?,?)

Fill the rest, will be discussed in the class (första lektionen)

Triangle 0, consists of (p0, p2, p1). For p0 we now have three vertices, 0, 1 and 2. We choose the one that has the normal associated with Triangle 0, which will be vertex 0.

For p1 we should choose between vertex nr 3, 4 and 5.

The correct one in this case is vertex nr 3 because it has the normal vector associated with Triangle 0.

References

Related documents

•  Apply an illumination model to each vertex to calculate the vertex intensity (Ambient light or/and diffuse light or/and specular reflection). •  Linearly interpolate

•  Apply an illumination model to each vertex to calculate the vertex intensity (Ambient light or/and diffuse light or/and specular reflection). •  Linearly interpolate

Source: Teaching Texture Mapping Visually, Rosalee Wolfe, DePaul

Source: Teaching Texture Mapping Visually, Rosalee Wolfe, DePaul University The color remains constant when

In OpenGL, together with the vertex coordinate you also specify the normal vector and the texture coordinates (for texture mapping). Texture mapping will be

Rotation about an axis parallel to one of the coordinate planes Step 1: Translate the object so that the rotation axis passes through the coordinate origin. This vector is now on

Here, you can enjoy shopping in lots of stores and you can also see landmarks like The Statue of Liberty, Empire State Building, Central Park..

Keywords: sign language, object marking, differential object marking, argument structure, transitivity, valency, directionality, handshape, pronoun, perspective, Swedish Sign