Constructive Solid Geometry (CSG) and other modelling techniques€¦ · COSC342 Constructive Solid...
Transcript of Constructive Solid Geometry (CSG) and other modelling techniques€¦ · COSC342 Constructive Solid...
Constructive Solid Geometry (CSG)and other modelling techniques
COSC342
Lecture 2112 May 2015
There are many ways to model objects
É So far we have represented objects as sets of transformed, ray tracedprimitives.
É In this lecture we will explore some other techniques for modellingreal-world objects.
É Constructive Solid Geometry (CSG)
É Parametric Patches
É Subdivision Surfaces
É Implicit Surfaces
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 2
Constructive Solid Geometry (CSG)
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 3
Building a simple object using CSG
É A sequence of images from the (Otago) Mirage CSG engine built bystudent David Mason.
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 4
Direct ray tracing example
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 5
Our object and its CSG ‘tree’
É We show the two ‘subtract’ nodes in the CSG tree on the right.
É Yellow volumes are subtracted from our resulting shape.
−
−
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 6
Classifying the ray
É There are five intersections between the ray and CSG tree geometry:
É . . . these are labelled ‘a’ to ‘e’ in the figures below.
aedb c
−
−
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 7
Classification at a CSG subtract node
Right tree child
In Out Border
Lef
ttr
eech
ild In Out In Border
Out Out Out Out
Border Out Border “yuck”
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 8
Subtract nodes for our object
É Consider point ‘a’.
É It’s outside the hemisphere
É . . . and outside our object.
aedb c
a a
a
−
a
a
−
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 9
Right tree childIn Out Border
Lef
tt.
c. In Out In BorderOut Out Out Out
Border Out Border
Subtract nodes for our object
É Now consider point ‘b’.
É It’s outside hemisphere
É . . . and outside our object
aedb c
b b
b
−
b
b
−
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 10
Right tree childIn Out Border
Lef
tt.
c. In Out In BorderOut Out Out Out
Border Out Border
Subtract nodes for our object
É Next consider point ‘c’.
É It’s on hemisphere’s border
É . . . but still outside object
aedb c
c c
c
−
c
c
−
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 11
Right tree childIn Out Border
Lef
tt.
c. In Out In BorderOut Out Out Out
Border Out Border
Subtract nodes for our object
É Finally, consider point ‘d’.
É It’s inside the hemisphere
É . . . on our object’s border.
aedb c
d d
d
−
d
d
−
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 12
Right tree childIn Out Border
Lef
tt.
c. In Out In BorderOut Out Out Out
Border Out Border
Classification at an add node
Right tree child
In Out Border
Lef
ttr
eech
ild In In In In
Out In Out Border
Border In Border
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 13
Pros and cons of CSG
É Ø Engineering objects can be created easily.
É Ø CSG is directly ray traceable.
É Ø CSG can be used to compute volume properties.
É ✗ It is difficult to make free-form shapes.
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 14
Parametric patches
É Polygons are flat.
É Most objects have curved faces.
É Can we fit a mathematical curve through particular points in space?
É Can we fit a surface to points in space?
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 15
Curve fitting
É We can define y = f (x), e.g. f (x) = c1(x1 − x)(x2 − x)(x3 − x) + c2É Alternatively, we can define a start and end point and two control
points that influence curvature.É This is still just four pieces of information.
X
Y
X
Y
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 16
But how do we do this one?
É We are likely to want to fitcurves to shapes where y isn’tjust a function of x .
É We can use a parameter (e.g. t).
É Define two functions y = f1(t)and x = f2(t).
É Aside: this figure is defined by:x(t) = 0.9 + 0.9t cos t andy(t) = 0.4 + t sin t
X
Y
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 17
Defining a circle using a parameter, θ
θ
X
θ
Y
X
Y
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 18
Patches
É Beyond generating a curve in space, we can generate a surface if weuse two parameters: e.g. s and t.
É (The uv coordinates used in texture mapping are a similar concept.)
s
t
É Coordinates of point p = (x , y , z) on the green patch are given by:x = fx(s, t) y = fy (s, t) z = fz(s, t)
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 19
Function for x in a bicubic patch
É If we use degree 3 polynomials in s and t to define the x coordinateof point p, we get the following form of equation:
fx(s, t) =
x3,3s3t3+x3,2s
3t2+x3,1s3t+x3,0s
3+x2,3s
2t3+x2,2s2t2+x2,1s
2t+x2,0s2+
x1,3st3+ x1,2st
2+ x1,1st+x1,0s+x0,3t
3+ x0,2t2+ x0,1t+x0,0
É As well as these sixteen constant xi ,j coefficients, we need coefficientsfor y and z , for 48 in total!
É Often these coefficients will be grouped into 16 points ui ,.j .
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 20
Pros and cons of parametric patches
É Ø We can make a huge variety of shapes.
É Ø Smooth surfaces are produced.
É Ø Spheres and cylinders can be represented well.É ✗ It is difficult to coordinate boundary conditions.
É e.g. patches meeting other patches.
É ✗ Parametric patches only define the surface—there’s no ‘inside’.
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 21
Subdivision surfaces
É A recursive approach to adding detail.
É For example, Catmull-Clark mesh subdivision:(steps are only sketched out here)
É Add a point at centroid of each face.É Add new ‘average’ edge points.É ‘Smooth out’ original vertices.
É In the limit, a cube becomes a sphere.
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 22
Implicit surfaces
É Instead of generating points p explicitly using parameters, e.g.
p =�
fx(s, t), fy (s, t), fz(s, t)�
É . . . implicitly define the conditions for a point p to be on a surface:f (p) = k
É For example, p2 = 1 defines a sphere.
É Usually f (p) will be a function of distance, such as the function below:
d
f (d)
maximum D
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 23
Example implicit surfaces
É Thermodynamics analogy: think of each red control point as a heater.
É The implicit surface is defined where the air temperature crosses acertain threshold.
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 24
Pros and cons of implicit surfaces
É Ø Intuitive overall construction concept.
É Ø Guaranteed inside/outside for objects—no holes.
É Ø Fairly easily ray traceable.
É Ø Can straightforwardly change topology.
É ✗ There is no obvious way to draw a surface.
É ✗ Good design seems to be by black art.
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 25
Examples of various modelling techniques
CSG in CAD Parametric surface teapot
Implicit surfaces “Swirling sweepers”
COSC342 Constructive Solid Geometry (CSG) and other modelling techniques 26