10 3D Modeling BW
-
Upload
ilyas-unknwn -
Category
Documents
-
view
218 -
download
0
Transcript of 10 3D Modeling BW
-
8/3/2019 10 3D Modeling BW
1/46
Instructor: Oscar Au
-
8/3/2019 10 3D Modeling BW
2/46
3-D Objects
Objects are virtual entities in a continuous environment
Include points, lines, shapes in 2-D and volume in 3-D 3-D modeling involves representation, position,manipulation, lighting, and rendering
Co-ordinate systems
The object is located in theWorld Coordinate System
(WCS) which is normally a right-handed Cartesian system
Camera defines its Camera
Coordinate System (CCS)
x
y
z
x
y
z
left-handedsystem
right-handed
system
Cameraview-point
-
8/3/2019 10 3D Modeling BW
3/46
Operation on OCS
Each object has an anchor point
(origin) and all its vertices are definedin the object coordinate system
Matrix operation can be performed on
the OCS
x
y
z
(x2,y2,z2)(x1,y1,z1)
Rotation by roll about the z-axis
=
z
yx
rollrollrollroll
z
yx
100
0)cos()sin(0)sin()cos(
'
''
rollx
y
z
(x2,y2,z2)(x1,y1,z1)
-
8/3/2019 10 3D Modeling BW
4/46
x
y
z
(x1,y1,z1)
=
z
yx
yawyaw
yawyaw
z
yx
)cos(0)sin(
010)sin(0)cos(
'
''
yaw
(x2,y
2,z
2)
=
z
yx
pitchpitch
pitchpitch
z
yx
)cos()sin(0
)sin()cos(0001
'
''
pitch
x
y
z
(x1,y1,z1)
(x2,y2,z2)
Rotation by yaw about the y-axis
Rotation by pitch about the x-axis
-
8/3/2019 10 3D Modeling BW
5/46
-
8/3/2019 10 3D Modeling BW
6/46
+
=
z
y
x
t
t
t
z
y
x
z
y
x
'
'
'
x
y
z
(x1,y1,z1)
(x2
,y2
,z2
)
(tX,tY,tZ)
Note: scaling should not be performed on rigid body
x
y
z
=
z
y
x
S
S
S
z
y
x
Z
Y
X
00
00
00
'
'
'(x
1
,y1
,z1
)(x2,y2,z2)
Scaling by (Sx, Sy, Sz)
Note: translation cannot be done by matrix multiplication
Translation by (tx, ty, tz)
-
8/3/2019 10 3D Modeling BW
7/46
Rotation, scaling and translation all by matrix multiplication
=
110001
'
'
'
z
y
x
TAAA
TAAA
TAAA
z
y
x
ZZZZYZX
YYZYYYX
XXZXYXX
General matrix operation
Deformation
Cannot be done by linear matrix operation General principle: ( )zyxFx X ,,'=
( )zyxFy Y ,,'=
( )zyxFz Z ,,'=
-
8/3/2019 10 3D Modeling BW
8/46
Tapering ( )zxFx 1'=
( )zyFy 2'=
zz='
Axis Twisting
Bending
( )[ ] ( )[ ]
( )[ ] ( )[ ]zz
zFyzFxy
zFyzFxx
=+=
=
'cossin'
sincos'
( )( ) 0
0
/1cos'
/1sin'
'
ykzz
ykzy
xx
+=+=
=
1/k: curvature of the bending
y0: center of bending = k(y-y0)
-
8/3/2019 10 3D Modeling BW
9/46
Object representation in WCS
The place where objects are assembled
Objects usually represented by a pointer to their origins
A WCS can become another OCS in a new WCS
xWCS
yWCS
zWCS
Rotation and scaling in WCS (1) is obtained by simple rotation
To obtain (2), either convert all pointsin the OCS to WCS, or calculate
(2)
(1)
the necessary rotation in OCS
Scaling can also be done in WCS or OCS (preferred)
Hierarchy and object-oriented approach preferred
-
8/3/2019 10 3D Modeling BW
10/46
Simple approach
Assume the camera is located at the origin of the WCS
facing the z-direction Assume also a projection screen is located at adistance dbehind the camera on the x-y plane
x
y
z
d
x
y
(x1,y1,z1)
(x1,y1)
cameraprojection
screen
coordinateof projectedimage
Note thatphysically, theprojected image is
in the left-handedcoordinate system
-
8/3/2019 10 3D Modeling BW
11/46
Calculating new coordinates on the projection
Using similar triangles
x1 = x1d/z
x
y
z
(x1,y1,z1)
d
y1
z
(x1,y1,z1)
x1
d
z1
z1
y1
x1
y1 = y1d/z
-
8/3/2019 10 3D Modeling BW
12/46
Perspective information
The distance dof the screen serves as a scaling factor
The new coordinates are divided by the zvalue of the oldsystem. Thus the further away the object, the smaller it ison the projection screen.
The new coordinate system needs another variable z = zfor each point to determine the front and backrelationship.
If 2 points at different distance results in the same (x,y),only the one with smaller zis displayed.
-
8/3/2019 10 3D Modeling BW
13/46
Field of viewing
The distance dalso defines the viewing angle
y
d
ltan() = l/d
z
Viewableregion
Camera position
Camera can be considered as an object and be placedat any location in the WCS by matrix transformation
Question: for a point (x, y, z) in the WCS, what is its
new position in CCS after camera motion?
-
8/3/2019 10 3D Modeling BW
14/46
Converting points in WCS to CCS
Assume camera is at the origin of WCS at beginning
Camera is then moved to a new location by a series ofmatrix transformation in the form of
( ) ( ) ( )( ) ( ) ( )
( ) ( ) ( )
1000,,,,,,
,,,,,,
,,,,,,
ZZZZYZX
YYZYYYX
XXZXYXX
TAAA
TAAA
TAAA
This can be viewed as WCS moved w.r.t. CCS. We can
perform the following transforms in same sequence( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )
1000
,,,,,,
,,,,,,
,,,,,,
ZZZZYZX
YYZYYYX
XXZXYXX
TAAA
TAAA
TAAA
-
8/3/2019 10 3D Modeling BW
15/46
Zooming is equivalent to moving the screen away from
the camera lens (increasing magnification factor d).
Moving camera closer to the object also results in theobject enlarged.
But they result in different distortion
original
screen
zViewableregion
zoomedscreen
closeup
screen
camera position
Zooming and camera position
-
8/3/2019 10 3D Modeling BW
16/46
Example:
reference image placing cameracloser to object
zoom in object
Depth of focus
In real situations, objects far fromthe focal planes should be blurred
simulate this by applying blurring
function that depends on z value
-
8/3/2019 10 3D Modeling BW
17/46
Edge represented object
Objects formed by lines defined by vertices
Used for quick visualization and transparent view
(1,5)(1,2)(0,4)(0,3)(0,1)Line
(0,1,0)(0,0,1)(1,0,1)(1,0,0)(0,0,0)Point43210Index
x
y
z
0
11
1
03
21
4 7
65
Difficult to remove lines masked by other surfaces
Not very common for modeling
-
8/3/2019 10 3D Modeling BW
18/46
Planar polygons
Formed by a chain of straight lines
(0,3,6,7,0)
(5,6,8,5)
(4,5,8,9,4)
(2,3,6,5,2)
(1,2,5,4,1)
Polygons
(0,1,2)(3,0,0)(4,0,2)(0,0,2)(0,0,0)Vertices
53210Index
x
z
13
5
4
9
2
68
y
Difficult in representing curved surface
Points are not free to move along different axes
1
5
2
?
Example: reducing the z-coordinate ofvertex (2) destroy the planar property onpolygon (0)
4
-
8/3/2019 10 3D Modeling BW
19/46
Planar triangles
Try to resolve the point motion in planar polygons by
breaking it down to triangles
Easier to edit object
Still a problem: how to representdisjoint boundaries such as holes?
Breakdown to more triangles
Subtraction space may be needed
x
z1
3
5
9
2
6
8y
4
(2,3,5)(5,8,9)(4,5,9)(2,4,5)(1,2,4)triangles
(0,1,2)(3,0,0)(4,0,2)(0,0,2)(0,0,0)Vertices
53210Index
Boundary 1
Boundary 2
-
8/3/2019 10 3D Modeling BW
20/46
Sectional polygons
Slice a 3-D object into cross-sections, and store each
cross-section in polygon form Object surface mesh is reconstructed by connectingcontours with those above and below
Require a central axis to align planes
Object
Central axis
Sectionalrepresentation
2 planes are necessary to
represent a simple object like this
-
8/3/2019 10 3D Modeling BW
21/46
Number of planes can be varied depending on thecomplexity of an object
Polar coordinates with the central axis as origin providean easy description of planner polygons
Still difficult to represent holes and back-curving lines
X-Section in polar coordinate X-Section with holes andback curving edges
holes back-curvingedges
-
8/3/2019 10 3D Modeling BW
22/46
Extrusion
One of the short-cut to overcome the tedious cross-
section in building up complex models A 2-D cross-section is extended to create a cylinder-like3-D object
x
y
z
x
y
z
X-Section
extrusiondirection
result
Can re-define size and rotation inextrusion
z
-
8/3/2019 10 3D Modeling BW
23/46
Object of revolution
Begin with a cross-section of an object and then rotate
the cross-section around a central axis Can represent a complicated object with very few datapoints
The cross-section can be off-axis to form torus-likeobjects y
x
z
-
8/3/2019 10 3D Modeling BW
24/46
Constructive Solid Geometry (CSG)
Intend to construct complicated objects from a set of
simple primitives such as cube, cone, sphere etc. Mathematical equations used to describe geometry
e.g. sphere is given by x2 + y2 + z2 = r2
To allow object interaction such as addition andsubtraction
-
8/3/2019 10 3D Modeling BW
25/46
Mathematical construction
A set of inequalities is used to determine if a point is
inside or outside the solid boundary
points outside sphere: x2+ y2+ z2> r2
points inside sphere: x2+ y2+ z2< r2
More complex geometry can be constructedby logical operations of the inequalities
x2+ y2+ z2> r12
e.g. points of hollow sphere with inner radius r1 and outer radiusr2have to satisfy both
x2+ y2+ z2< r22and
-
8/3/2019 10 3D Modeling BW
26/46
Spatial subdivision
Concept similar to a 3-D bitmap,
where objects are divided into smallcubes
Larger cubes are identified to savestorage space
More advanced models (will not be covered)
Spine objects (you may regard it as extrusion withcurved central axis)
Fractals
Soft objects interacting with neighboring objects
-
8/3/2019 10 3D Modeling BW
27/46
Definition of rendering
Viewing algorithm of how objects are drawn and
visualized by a viewer Usually objects are rendered in order
Different algorithms to handle different representations
Wire frame or line rendering
Simplest for rendering for quick visualization
Only required to figure out the vertices and connectrelated pairs
Overlapping/depth information need not be considered
Sometimes difficult to understand the object
-
8/3/2019 10 3D Modeling BW
28/46
Opaque surface rendering
Define the color of a polygon/surface and color the
entire surface with the single color Relatively simple, except that the visual order of thesurface has to be calculated
Project each object onto the cameras viewing screenand determine the paint color by comparing order withexisting points
Complex surface rendering Need to consider texture, perspective, lighting and otherfactors
Interaction between objects also needs to be considered
-
8/3/2019 10 3D Modeling BW
29/46
Ray tracing
Traces light backward from eye to scene to light
sourceTake into account perfect specular interaction
Ray-traced examples:
http://www.cse.buffalo.edu/pub/WWW/povray/
-
8/3/2019 10 3D Modeling BW
30/46
Ray tracing
Use analogy from thermal heat diffusion to model the
energy emitted from each surface patchHandle diffused interaction
http://freespace.virgin.net/hugo.elias/radiosity/radiosity.htm
-
8/3/2019 10 3D Modeling BW
31/46
Difficulty in simulating realistic illumination
Illumination of an object consists of many sources from
multiple reflection of surrounding surfaces (similar toreverberation in audio)
It is very difficult to trace all the sources to calculate theright color and luminosity or the resulting surface
Need to develop models to achieve trade-off betweenrealism and efficient rendering
www.siggraph.org/education/materials/
HyperGraph/radiosity/overview_1.htm
-
8/3/2019 10 3D Modeling BW
32/46
The simplest source with parameters of position, colorand intensity
The illumination intensity at a certain point iscalculated by inverse square law and angle of incident
(px,py,pz)
(x,y,z)
normal vectorn= [0, 1, 0]
s= [px-x, py-y, pzz]
-s n = |s||n| cos()
cos() = -s n / |s|
Recall vector dot product
( )3
z)y,(x,atonilluminatis
nsIr
rr
= whereI is the intensity at the source
Point light source
-
8/3/2019 10 3D Modeling BW
33/46
Spot light
Similar to point source except that intensity falls off
rapidly at location outside the cone of illumination(px,py,pz)
s
u
(x,y,z) (x0,y0,z0)
( )ususrr
rr
=)cos(
A point given by uiswithin the illumination
cone if < /2
- Position: (px,py,pz)- Direction: s
- Cone angle:
illumination can be calculated as afunction of and distance from source
example:( )
=
4
cosonIlluminati3
gsource
u
nuIr
rr
n
gcontrol the fading
sharpness of the sport
-
8/3/2019 10 3D Modeling BW
34/46
Multiple light sources
Superposition principle can be used to calculate final
equalization necessary to prevent saturation
Shadows
Need a model to handle the interaction between lightsources and objects
Simple method: treat opaque objects as negative lightsources to subtract out illumination
The magnitude of the negative light source defines thetransparency of the object surface to a third object
-
8/3/2019 10 3D Modeling BW
35/46
Ambient light reflection It refers to constant illumination naturally exists due tomultiple reflections that enable us to see objects
No light source is associated with it and independentof orientation and distance
Simply calculated by multiplying the light source colorcomponent and the reflection coefficient
R = IR-sourcex RR-object
G = IG-sourcex RG-objectB = IB-sourcex RB-object
Observed color
Note that the source color and surface color is in the
subtraction color space
-
8/3/2019 10 3D Modeling BW
36/46
Diffused reflection
It simulates reflection by rough surfaces that incident
lights are reflected in all directions Similar to ambient light reflection, perspective info dueto distance and orientation w.r.t. light sources areincluded
Easier to be represented using the HSV model suchthat the positional data can be represented by theintensity components without affecting the color
Example: surfaces are rendered by samecolor with different brightness
-
8/3/2019 10 3D Modeling BW
37/46
Reflection generated by polished surfaces creates a
highlight of the illuminating light source andsurrounding environment
Surface brightness is the sum of its ambient reflection
together with specular highlight
Perfectly reflected light follows the law of reflectionwith incident angle equal to the reflected angle
Depending on different material, some small amount ofdiffusion due to micro-surface roughness may occurresulting in slightly blurred surface
Specular reflection
-
8/3/2019 10 3D Modeling BW
38/46
(px,py,pz)
s r
(x,y,z)
(x,y,z)v
( )gssourceKIR cos=
- specular reflectioncomponent is modeled by
Example: g=10 gives a rough plastic effect whileg=150 gives metallic-like surface with small highlight
Have to find in term of vectors in the Cartesiansystem calculated from relative coordinates, we have
Isource is the source intensityKS is the specular coefficientgis the gross surface factor
( )( ) ( )[ ]gssource svvnsnKIRrrrrrr
= 2
-
8/3/2019 10 3D Modeling BW
39/46
Examples insurface rendering
-
8/3/2019 10 3D Modeling BW
40/46
Render order
In 2-D, the bottom-most plane is colored first and then
color is applied upward towards the top In 3-D, there are different orders to color the scene
Object order:
for each primitive Pdofor each pixel q within Pdo
update frame buffer based on color and visibility of P at q
Image order:for each pixel qdo
for each primitive P covering qdocompute Ps contribution to q, outputting q when finished
-
8/3/2019 10 3D Modeling BW
41/46
Remove all planes that face away from the camera
x
z
y
Can be tested by the dot productor the normal vector and the viewvector
The plane is facing away if anglebetween the vectors are > 90degree
forwardfacing
backfacing
Back-face removal
Assume solid objects with no 2-D plane exist
Only one side of a surface will be displayed, indicatedby the direction of its normal vector
-
8/3/2019 10 3D Modeling BW
42/46
-
8/3/2019 10 3D Modeling BW
43/46
Bitmap surface representation
Some surface texture can only be described by bitmap
but not object
Assume the texture is represented by a bitmap with u-vcoordinate
Can be mapped to any surface in WCS by complicated3-D mathematical transforms
The texture map defines the background ambient color
and additional effects are added by superpositionprinciple
-
8/3/2019 10 3D Modeling BW
44/46
Scaling problem
A distance from the camera which the texture map and
the object plane align must be defined When the plane is very close to the camera, the entireplane may be mapped only to 1-2 pixels in the texture
Similarly when the plane is very far, the entire texturemay will be scaled to a few pixels
Example: cylindrical mapping
Assume a texture map with U-Vcoordinate is mapped toa cylinder with radius rand height h
A point Pi(xi,yi,xi) will be mapped into T(u,v) in the texture
space
-
8/3/2019 10 3D Modeling BW
45/46
xz
y
h
r
u
vU
V
1
1
T(u,v)
0
P(xi,yi,zi)
The portion of the arc is:
v = yi/h
= cos-1(zi/r)
Vertical coordinate:
Horizontal coordinate:
u =/2
= cos-1
(zi/r)/2 Note: reflection of nearby objectscan be considered as texturemapping from camera screen
-
8/3/2019 10 3D Modeling BW
46/46
Further info Alan Watt, 3D Computer Graphics, 3rd Ed., Addison-Wesley 2000
Olin Lathrop, The Way Computer Graphics Works, John Wiley &
Sons, 1997 http://www.embedinc.com/book/index.htm Ray-tracing examples:
http://www.cse.buffalo.edu/pub/WWW/povray/
RadiosityReference:
http://www.siggraph.org/education/materials/HyperGraph/radiosity/radiosity.htmhttp://freespace.virgin.net/hugo.elias/radiosity/radiosity.htm
Polygonal representation and rendering:http://cis.csuohio.edu/~arndt/graphics.ppt
Bezier Curves: www.moshplant.com/direct-or/bezierwww.math.ucla.edu/~baker/java/hoefer/Bezier.htm
Parametric Patches:http://www.cs.wpi.edu/~matt/courses/cs563/talks/surface/bez_surf.html