Top Banner
CS100433 Viewing and Modeling Basics Junqiao Zhao 赵君峤 Department of Computer Science and Technology College of Electronics and Information Engineering Tongji University
60

CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Jan 18, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

CS100433

Viewing and Modeling Basics

Junqiao Zhao 赵君峤

Department of Computer Science and Technology

College of Electronics and Information Engineering

Tongji University

Page 2: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Review the elements of Image formation• Objects

• Viewer

• Light source(s)

• Attributes (Materials)

• Attributes that govern how light interacts with the materials in the scene

• Note the independence of the objects, the viewer, and the light source(s)

Page 3: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Object Specification

• Primitives including• Points (0D object)

• Line segments (1D objects)

• Polygons (2D objects)

• Some curves and surfaces

• Quadrics

• Parametric polynomials

• All are defined through vertices, which are locations in space

Page 4: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Synthetic Camera Model

Page 5: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Synthetic Camera Model

center of projection

image plane

projector

p

projection of p

Page 6: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Camera Specification

• Six degrees of freedom• Position of center of lens

• Orientation

• Lens

• Film size

• Orientation of film plane

Page 7: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Viewing

•Analog to the physical viewing• Objects• Camera

• the position of camera

• the type of lens

• the position and the shape of film

•Viewing is based on the relationship among these elements

Page 8: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Viewing Transformations

(2013 Steve Marschner)

Part of the Vertex processing in the Graphics Pipeline

Page 9: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Normalized Device coordinates (NDC)

• Device-independent two-dimensional or three-dimensional Cartesian coordinate system whose coordinates are in the range -1 to 1.

• Why?

Page 10: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Coordinate frames

• Local coordinates (Local space)

• World coordinates (World space)

• Camera coordinates (Viewing space)

• Clip coordinates (Clip space)

• Normalized Device coordinates (NDC)

• Viewport coordinates

• Window coordinates (device coordinates)

3D/4D

2D

Page 11: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Viewing implementation

• Transform into camera coordinates.

•Perform projection into view volume.

•Clip geometry outside the view volume.

•Perform Perspective-division into NDC.

•Remove hidden surfaces

Page 12: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

2D viewing

• The Clipping Window• 2D NDC

• The Viewport• Mapped from NDC

What if the aspect ratio w/h is not 1?

Viewport vs Window

Page 13: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

2D viewing

• How to implement Zooming?• Zoom in

• Zoom out

• Should we adjust the Clipping window or the Viewport or the Window?

Page 14: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

OpenGL

• Defining the Clipping Window• glOrtho(left, right, bottom, top, -1, 1)

• Defining the Viewport• glViewport(x, y, width, height)

In Camera Coordinates

In Window Coordinates

Page 15: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

The 3D viewing pipeline

Page 16: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Before the virtual camera..

• The 2D clipping window => The 3D clipping volume

Page 17: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Orthographic view volume

(Ken Power 2011)

Page 18: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Orthographic projection

Page 19: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Defining an orthographic view volume• glOrtho(left, right, bottom, top, near, far)

NDCVC

Page 20: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

(2005 Angel)

Multiview Orthographic Projection

• Projection plane parallel to principal face

• Usually form front, top, side views

isometric front

sidetop

in CAD and architecture,

we often display three

multiviews plus isometric

Page 21: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Advantages and Disadvantages

• Preserves both distances and angles• Shapes preserved

• Can be used for measurements

• Building plans

• Manuals

• Cannot see what object really looks like because many surfaces hidden from view• Often we add the isometric

Page 22: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Perspective projection

Page 23: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Perspective projection

(Ken Power 2011)

Page 24: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Perspective view volume

• Also a 3D clipping volume called frustum

(2013 Steve Marschner)

Page 25: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Defining perspective viewing frustum• glFrustum(left, right, bottom, top, near, far)

NDCVC

Page 26: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Defining perspective viewing frustum• gluPerspective(fov, aspect, near, far)

Page 27: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Perspective projection

Page 28: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Advantages and Disadvantages

• Objects further from viewer are projected smaller than the same sized objects closer to the viewer (diminution)• Looks realistic

• Equal distances along a line are not projected into equal distances (nonuniform foreshortening)

• Angles preserved only in planes parallel to the projection plane

• More difficult to construct by hand than parallel projections (but not more difficult by computer)

Page 29: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Finally the camera

• the position of camera• The default camera is located at origin and

points in the negative z direction

• the type of lens and the position of the film• OpenGL also specifies a default view volume

that is a cube with sides of length 2 centered at the origin

• Orthogonal

Page 30: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Moving the camera

default frames

frames after translation by –d

d > 0

(2005 Angel)

Page 31: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

gluLookAtglLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz)

(2005 Angel)

Page 32: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

References

• Ed Angel, CS/EECE 433 Computer Graphics, University of New Mexico

• Steve Marschner, CS4620/5620 Computer Graphics, Cornell

• Tom Thorne, COMPUTER GRAPHICS, The University of Edinburgh

• Elif Tosun, Computer Graphics, The University of New York

• Lin Zhang, Computer Graphics, Tongji Unviersity

Page 33: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

• Questions?

Page 34: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

What is a (3D) model ?

Page 35: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

A (3D) model

• The data describing the size, position, and shape of (3D) objects (ISO10303 Abbrev.)

• The model describes the process of forming the shape of an (3D) object (Wikipedia)

Utah Teapot Stanford Bunny

Wikimedia Commons

Page 36: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Dimensions of Space and Object

• 0D?

• 1D?

• 2D?

• 3D?

Page 37: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Geometry vs Topology

• Point -> Vertex

• Line Segment -> Edge

• Surface -> Face

Page 38: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Geometry vs Topology

• Same geometry, different topology

• Same topology, different geometry

(2013 Steve Marschner)

Page 39: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Geometry vs Topology

•Generally it is a good idea to look for data structures that separate the geometry from the topology• Geometry: locations of the vertices• Topology: organization of the vertices and

edges• Topology holds even if geometry changes

Page 40: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Vertex Lists

• Put the geometry in an array

• Use pointers from the vertices into this array

• Introduce a polygon listx1 y1 z1

x2 y2 z2

x3 y3 z3

x4 y4 z4

x5 y5 z5.

x6 y6 z6

x7 y7 z7

x8 y8 z8

P1P2P3P4P5

v1v7v6

v8v5v6

topology geometry

Page 41: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Solid modeling

• Surface-based

• Volume-based

http://www.kellbot.com/

Page 42: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Boundary representation - B-rep

• A type of geometric model in which the size andshape of the solid is defined in terms of the faces,edges and vertices which make up its boundary(ISO10303).• Representation by bounding low-dimensional elements

• Organised collection of low dimensional elements

• Simple B-reps (planar faces, straight edges) and complexB-reps (curved surfaces and edges)

Page 43: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

B-rep (cont’)

• Geometry• Surfaces, Curves, Points

• Topology• Faces, Edges, Vertices Wikipedia

Euler’s formula V-E+F= 2

Page 44: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Polygonal mesh

Wikipedia

Page 45: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Pros and Cons

• Pros: flexible and computers can render themquickly. The vast majority of 3D models today arebuilt as textured polygonal models

• Cons: polygons are planar and need approximatecurved surfaces using many polygons,representation is not unique

Page 46: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Constructive solid geometry (CSG)

• A type of geometric modelling in which a solid isdefined as the result of a sequence of regularisedBoolean operations operating on solid models (ISO10303).

Wikipedia

Page 47: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Primitive solid

• Cube

• Sphere

• Cylinders

• …

• Must be solids!

Page 48: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Point-set topology

• Boundary

• Interior

• Exterior

• Closure

𝑥2 + 𝑦2 + 𝑧2 = 1

𝑥2 + 𝑦2 + 𝑧2 < 1

𝑥2 + 𝑦2 + 𝑧2 > 1

𝑥2 + 𝑦2 + 𝑧2 ≤ 1

Page 49: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Boolean operations

• Union

• Difference

• Intersection

• Regularised

Wikipedia

Page 50: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Pros and Cons

• Pros: Computer-Aided Manufacturing: a brick witha hole drilled through it is represented as “justthat” and CSG can easily assure that objects are“solid” or water-tight

• Cons: Relationships between objects might bevery complex (search the entire tree) Real worldobjects may get very complex

Page 51: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Volume-based representation

• Spatial decomposition• Voxels

• Octree

• BSP

Page 52: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Voxels

• A voxel is a volume element (3D “pixel”)

• A 3D cubical (or spherical array), with each elementholding one (or more) data value (boolean, real)

OpenVDB

Page 53: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Cubic worlds

Minecraft

Page 54: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Volume4D Rockware

Page 55: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Operations with voxels

• Voxel adjacencies:

• the 6-voxels: have adjacent face (1)

• the 18-voxels: have adjacent face and edge (2)

• the 26-voxel: have adjacent face, edge and vertex (3)

• N-path: a sequence of voxels is a 6-path (18-path, 26-path) ifevery two consecutive voxels along the sequence are 6-adjacent (18-adjacent, 26-adjacent).

Page 56: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Pros and cons

Pros:• Modelling continues phenomena: Medical, geology,

body, etc.

• Regular data

• Easy to compute volume, make slices

Cons:• Massive data for high resolution

• The surface is always somehow “rough”

Page 57: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.
Page 58: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

Point based representation

• Point cloud• Easily accessed with laser scanning, range camera or

stereo image matching

• No connectivity

• Widely used!

Page 60: CS100433 Viewing and Modeling Basics - Tongji Universitycs1.tongji.edu.cn/...2_viewing_modeling_basics.pdf · Viewing and Modeling Basics ... •Film size •Orientation of film plane.

References

• Ed Angel, CS/EECE 433 Computer Graphics, University of New Mexico

• Steve Marschner, CS4620/5620 Computer Graphics, Cornell

• Tom Thorne, COMPUTER GRAPHICS, The University of Edinburgh

• Elif Tosun, Computer Graphics, The University of New York