Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

12
Introduction to 3D Computer Graphics and Virtual Reality McConnell text

Transcript of Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Page 1: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Introduction to 3D Computer Graphics and Virtual Reality

McConnell text

Page 2: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Vectors

• Vectors have direction and magnitude – generally given in terms of three coordinates and hence the representation is an arrow from the origin to that point

• Vectors are important for viewpoint, orientation, scaling, rotating and other transformations

(3,1,1)

Page 3: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Vectors (con’t)

• Length: ||v||=

• Addition, scalar multiplication

• Dot product:

• Cross-product: vector that is perpendicular to both

2 2 2x y z

|| || || || cosv w v w

Courtesy Wikipedia for symbols

Page 4: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Camera

• Point of view of a camera; viewpoint

• Clipping window is the part of the scene that is visible

• View direction

• What is up?

Page 5: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Coordinate Systems• 3D coordinate system – right or left handed (curl

fingers from pos X-axis to pos Y-axis: thumb points pos Z)– Virtools is left-handed, Processing is left-handed, but the y axes (and hence the z axes) point in opposite directions

X

Virtools Processing

Z Y

• 2D screen coordinate system:

X

Z

Y

X

Y

Page 6: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Coordinate System: 3D Environments

• Most 3D environments have at least two coordinate systems: a world coordinate system and a local coordinate system for each object (sometimes parts of objects)

• The world coordinate system does not change

• The local coordinate system is generally located in the “middle” or in a corner of the object and is set in the 3D modeling program.

Page 7: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Coordinate Systems (con’t)

• Clipping window is the visible area of the 3D scene (it is 2D)- window through which you look

• Viewport is where on the screen (also 2D) the visible scene appears; uses the coordinate system of the screen

• The viewport and the clipping window may be different sizes, in which case there is stretching or squishing

• Aspect ratio= width/height- easier if both clipping window and viewport have same

Page 8: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Interplay of 2D and 3D systems

• There are often 2D objects (buttons, interfaces, screen text) – these are in the 2D system

• 3D objects must actually be rendered on the screen so they ultimately end up with 2D coordinates

• This projection onto the screen must take into account the z-position of objects, as well as perspective

Page 9: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Orientation

• Objects in a 3D world have spatial location (position) and orientation

• Orientation is given in many different forms: pitch, roll, yaw or Euler angles (around each axis); quaternions

• In Processing can rotate in 2D or in 3D around the axes

• In the Virtools setup Euler angles are used for orientation

Page 10: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Object Representation• 3D objects are represented with meshes; points

that are joined together in convex, planar polygons (faces); typically these polygons are triangles because then there is assurance that they will be planar

• The set of points forms the mesh• Each face of the mesh may have a material

associated with it; these materials can be textures and/or colors

• Details (and realism) increase with the numbers of polygons

Page 11: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Point Representation

• These representations allow for algorithms for calculation of intersections, collisions, positioning

• Also have algorithms to find which objects are in front, partial view, occlusion

• For speed, objects can be surrounded by a bounding box – allows quick calculation of intersections

Page 12: Introduction to 3D Computer Graphics and Virtual Reality McConnell text.

Graphics Pipeline

• Model the individual objects (color, transformations, realism, where located) and together they constitute a scene

• Render the scene (lights, shading, camera, etc.) in an image

• Display the image as output

• If in a virtual environment have real-time, interaction and navigation