CS100433 Viewing and Modeling Basics - Tongji...

Post on 18-Jan-2020

4 views 0 download

Transcript of CS100433 Viewing and Modeling Basics - Tongji...

CS100433

Viewing and Modeling Basics

Junqiao Zhao 赵君峤

Department of Computer Science and Technology

College of Electronics and Information Engineering

Tongji University

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)

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

Synthetic Camera Model

Synthetic Camera Model

center of projection

image plane

projector

p

projection of p

Camera Specification

• Six degrees of freedom• Position of center of lens

• Orientation

• Lens

• 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

Viewing Transformations

(2013 Steve Marschner)

Part of the Vertex processing in the Graphics Pipeline

Normalized Device coordinates (NDC)

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

• Why?

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

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

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

2D viewing

• How to implement Zooming?• Zoom in

• Zoom out

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

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

The 3D viewing pipeline

Before the virtual camera..

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

Orthographic view volume

(Ken Power 2011)

Orthographic projection

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

NDCVC

(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

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

Perspective projection

Perspective projection

(Ken Power 2011)

Perspective view volume

• Also a 3D clipping volume called frustum

(2013 Steve Marschner)

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

NDCVC

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

Perspective projection

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)

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

Moving the camera

default frames

frames after translation by –d

d > 0

(2005 Angel)

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

(2005 Angel)

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

• Questions?

What is a (3D) model ?

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

Dimensions of Space and Object

• 0D?

• 1D?

• 2D?

• 3D?

Geometry vs Topology

• Point -> Vertex

• Line Segment -> Edge

• Surface -> Face

Geometry vs Topology

• Same geometry, different topology

• Same topology, different geometry

(2013 Steve Marschner)

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

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

Solid modeling

• Surface-based

• Volume-based

http://www.kellbot.com/

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)

B-rep (cont’)

• Geometry• Surfaces, Curves, Points

• Topology• Faces, Edges, Vertices Wikipedia

Euler’s formula V-E+F= 2

Polygonal mesh

Wikipedia

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

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

Primitive solid

• Cube

• Sphere

• Cylinders

• …

• Must be solids!

Point-set topology

• Boundary

• Interior

• Exterior

• Closure

𝑥2 + 𝑦2 + 𝑧2 = 1

𝑥2 + 𝑦2 + 𝑧2 < 1

𝑥2 + 𝑦2 + 𝑧2 > 1

𝑥2 + 𝑦2 + 𝑧2 ≤ 1

Boolean operations

• Union

• Difference

• Intersection

• Regularised

Wikipedia

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

Volume-based representation

• Spatial decomposition• Voxels

• Octree

• BSP

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

Cubic worlds

Minecraft

Volume4D Rockware

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

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”

Point based representation

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

stereo image matching

• No connectivity

• Widely used!

Questions?zhaojunqiao@tongji.edu.cn

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