# Modeling Modeling is simply the process of creating 3D objects

## Presentation on theme: "Modeling Modeling is simply the process of creating 3D objects"— Presentation transcript:

Modeling Modeling is simply the process of creating 3D objects
Many different processes to create models Many different representations of model data Once the models are obtained, one can transform them to the correct locations in space, place a virtual camera in space, and render a 2D image of the scene

1 Polygonal Complex objects are broken down into many simple polygons
Polygons form the “skin” of the object Objects are hollow Polygons have a front face and a back face

Triangulation How are triangles obtained?
Triangulating a set of surface points Several different triangulation approaches Delaunay triangulations attempt to equalize triangle angles (reduces long skinny triangles)

How Many Triangles? More triangles are needed in surface areas that require more geometric detail Higher curvature  more triangles necessary

Level Of Detail (LOD) It can be very costly to always display an entire object at the greatest level of detail Less detail is necessary the farther away you are from on object Also depends on the viewing angle and screen size Solution: create several models of the object at different levels of detail Display the correct one for the viewing distance

LOD 50 Vertices 500 Vertices 2000 Vertices

LOD How to create the same model in multiple levels of detail?
Ex: start with most detailed, resample with less vertices, and then re-triangulate When to switch models when rendering? Based on distance and screen size Ex: 640x480 screen  307,200 pixels Object takes up half of screen  150K pixels  Any more than 300K triangles (half are facing away from the camera) is overkill at this distance and screen size Visual artifacts can occur at switching point

Creating the Surface Points
Triangulation works on a set of points One needs to create this surface point set Many different approaches: Manual placement Mathematical (geometrical) generation Scanning real objects

Mathematical Generation
Solids of Revolution Rotation of a cross-section around an axis Spheres Cones Cylinders

Mathematical Generation
Extrusion Extrude a cross-section along a profile curve Scale may vary along the profile Many metal and plastic parts Cones Cylinders Bottles

Scanning Real Objects Laser scanning Tomographic methods
Scanning Real Objects Laser scanning Tomographic methods Medical scanning (Xray, CT, MRI) Radar Recovered 3D model Hand-held laser scanner                                                           Slice of brain from CT scan Recovered 3D model of lungs

Triangle Representations
Graphics cards do most of the triangle work Need an efficient way to send triangles to the card Some typical primitive triangle representations: Lists Fans Strips 1.6 vertices per triangle 1.5 vertices per triangle 3.0 vertices per triangle

Constructive Solid Geometry
Unlike polygonal approaches, CSG models are “solids” Polygonal models are “skins” Solid approaches are often better suited for medical applications because Cutting slices through objects Representing internal functional data

CSG Trees CSG models are stored in trees Leaves are primitive shapes
Spheres, Cubes, Cones, etc. Nodes are Boolean operations Union, Difference, Intersection

CSG Operations Primitives: Union: Intersection: Difference:

CSG Rendering CSG models can be rendered by:
Computing surface points and triangulating Rendering can then be performed by standard hardware Use of special CSG rendering routines Not hardware optimized

Representing Curves There are many different methods of representing general curves (rather than attempt to model all surfaces as some existing function, say a Sine or Cosine). The most common are: Cubic Splines Bezier Curves B-splines NURBS and -splines

Curve Fitting Find a simple formula that follows the trend of given discrete data points Allows positions in between data points to be calculated and drawn Satisfies a pre-specified amount of smoothness

Curve Fitting Two approaches
Interpolation – fit the discrete data points exactly Approximation – follow the trend of the data points closely, but satisfy other criteria, e.g. satisfy a pre-specified amount of smoothness

Curve Fitting General approach
build the curve fitting function from a restricted class of easily computed functions Usually polynomials of low degree Sine and cosine functions are common in theoretical curve fitting applications (e.g. smoothing of data), but in practice these may be computationally too expensive.

Curve Fitting Parametric representation, parameter t
Case of 2 control points P0 , P1 , P0 , P1 , may be points in 2D, or in 3D bi(t) are basis functions – fixed. bi(t) “blend” points P0 , P1

Linear Interpolation Case of 2 control points P0 , P1 , parameter t
b0(t)=1-t, b1(t)=t are the basis functions. Polynomial of degree 1 b0(t) + b1(t)= (1-t) + t = 1 for all t Q(t) : straight line join between P0 and P1

Curve Fitting Parametric representation, parameter t
P0 , P1 , P2 , P3 may be points in 2D, or in 3D bi(t) are basis functions – fixed. bi(t) “blend” points P0 , P1 , P2 , P3

Curve Fitting Case of 4 control points P0 , P1 , P2 , P3 ,
As t varies (e.g. between 0 and 1), Q(t) assumes different point values a weighted combination of P0 , P1 , P2 , P3 weights vary, via bi(t), with t

Curve Fitting Weights bi(t) are commonly chosen to be cubic polynomials in t Polynomial evaluation requires only arithmetic operations (+,-,*)

Curve Fitting A cubic polynomial has 4 coefficients, and can be determined from the data of 4 points. The cubic is the lowest degree polynomial that can accommodate a non-planar path (3 points define a plane, so need the 4th out of plane point)

Interpolation vs. Approximation
Given a set of n points, to create a curve we either interpolate the points (curve passes through all points) approximate the points (points describe convex hull of curve) Points on curve = knot points Points on convex hull (off curve) = control points Interpolate Approximate Control points Convex hull knot points

Splines If we have more than 4 points we require a polynomial of higher degree higher degree polynomials are more difficult to control they exhibit unwanted wiggles (oscillations) Quadratic Cubic Quartic Quintic

Splines In general we use cubic polynomials for curves in CG:
minimal wiggles and faster to compute than high degree polynomials lowest degree which allows non-planar curves (quadratics require 3 points, 3 points always lie in the same plane)

Defining the Cubic Spline
Normally we supply 4 points we wish the spline to pass through. If we have more than 4 points we must employ more than 1 spline  use a piecewise cubic polynomial for n points, we have (n-1)/3 individual cubic segments without further constraints these will not join smoothly non-smooth smooth

Piecewise Polynomial Curves
Idea: Use different polynomial functions for different parts of the curve Advantage: Flexibility Local control Issue: Smoothness at “joints” (continuity)

Continuity Continuity Ck indicates adjacent curves have the same kth derivative at their joints

C0 Continuity Adjacent curves share …
Same endpoints: Qi(1) = Qi+1(0) Aside: discontinuous curves sometimes called “C-1”

C1 Continuity Adjacent curves share … Same endpoints: Qi(1) = Qi+1(0)
Same derivatives: Qi ’(1) = Qi+1 ’(0)

C2 Continuity Adjacent curves share … Same endpoints: Qi(1) = Qi+1(0)
Same derivatives: Qi ’(1) = Qi+1 ’(0) Same second derivatives: Qi ’’(1) = Qi+1 ’’(0)

Examples of Continuity

Parametric Curves and Patches
We will start be examining curves Bézier curves B-Spline curves Then we will expand to surface patches Bézier patches B-Spline patches

Curve Fitting The row matrix of polynomials can be written as

Curve Fitting and for Q(t), write

Curve Fitting Substitute:

Bézier Curves Pierre Bézier, a French designer, first used them in the 1960’s in the design of Renault car bodies. Same time de Casteljau (Citroen) Since, they have been heavily used by Adobe in their fonts as well as in graphic applications A Bézier curve is a parametric curve The function C(u) defines the curve points (x, y, z) as the parameter u varies through [0..1]

Bézier Cubics P0 P3 P1 P2

Bézier Cubics For Bézier cubic curves,
the coefficients aij are chosen for 4 properties Q(0)=P0 Q(1)=P3 Q’(0) is in the direction of P1 – P0 Q’(1) is in the direction of P3 – P2

Bézier Cubics Example P3 P1 P0 P2

Bézier Cubics Example P3 P1 P0 P2

Bézier Cubics Example P0 P1 P3 P2 P1 –P0 P2 –P3

Bézier Curves The blending functions make much more sense graphically

Bézier Curves Due to the setup of the blending functions:
The curve goes through the end points control points P0 and P3 The curve doesn’t go through the interior control points The interior control influence the curve The curve is pulled in the direction of the control point Moving a control point changes the shape of the entire curve (called global control)

Bézier - coefficients The 4x4 matrix coefficients are chosen to satisfy the above 4 properties:

Bézier – Properties check
at t=0: So, (property 1)

Bézier – Properties check
at t=1: So, (property 2)

Note: Differentiation of the powers of t gives:

Bézier – Properties check
first derivative (gradient, velocity) at t: where

Bézier – Properties check
first derivative (gradient, velocity) at t=0: So is in the direction of (property 3)

Bézier – Properties check
first derivative (gradient, velocity) at t=1: So is in the direction of (property 4)

Piecewise continuity Piecewise Bézier curves can be constructed to have C1 continuity, by ensuring the last two control points (2,3) of one segment first two control points (3,4) of next segment are in line.

Bézier Curves A Bézier Curve can only “curve” as much as its degree allows Degree 1 (linear) is a line Degree 2 (quadratic) can curve once Degree 3 (cubic) can curve twice The number of control points is always 1 larger than the degree

Bézier Curves So what if you want a really “curvy” curve?
You could increase the degree of the curve The downfall of this approach is that each control point has global control over the curve shape That is, changing a single control point will modify the shape of the entire curve (not great for modeling) High degree curves are “unstable” It is computationally expensive You could join multiple cubic curves together Each control point only has influence over its piece of the curve (local control w.r.t. the entire joined curve) Hardware can be optimized for cubic curves But, we must maintain continuity across the joins!

Bézier Curves So how are we going to maintain continuity?
Notice that the line between the first 2 control points specify the tangent of the curve at t=0 And the line between the last 2 control points specify the tangent of the curve at t=1

Bézier Curves So if we line up P2P3 with Q0Q1, then we have the same tangent at end t=1 point of curve P and t=0 point of curve Q

Bézier Curves Continuity put into more formal terms:
C0 continuity means the curve points vary smoothly That is, the curve is a set of connected points For our joined example, it means the two joined segments share the same endpoints P3 is the same point as Q0 C1 continuity means the curve’s first derivatives vary smoothly (plus C0 continuity) For our joined example, it means the tangents at the end endpoints must be the same (P2, P3, Q0, Q1 must form a line) And P0, P1 must form a line with the curve before it and Q2, Q3 must form a line with the curve after it  all 4 control points are constrained to some extent

Bézier Curves C2 continuity means the curve’s second derivatives vary smoothly (plus C1 continuity) Second derivative corresponds to curvature For our joined example, it implies constrains on P1, P2, P3, Q0, Q1, and Q2 Plus P0, P1, and P2 are constrained from the curve before it and Q1, Q2, and Q3 are constrained from the curve after it Thus, although it can be achieved, there are so many constrains on the positions of the control points that joined cubic Bézier curves are almost never C2 continuous

Bézier Curves Do we care about C2 continuity?
Probably not for simple modeling But if the curve is being used to specify the path/orientation of a camera: Not C0 means the camera position jumps Not C1 means the camera’s orientation jumps Not C2 means the change in the camera’s orientation has sudden jumps

Rendering Bezier Curves (1)
Evaluate the curve at a fixed set of parameter values and join the points with straight lines Advantage: Very simple Disadvantages: Expensive to evaluate the curve at many points No easy way of knowing how fine to sample points, and maybe sampling rate must be different along curve No easy way to adapt. In particular, it is hard to measure the deviation of a line segment from the exact curve 11/19/02

Rendering Bezier Curves (2)
Recall that a Bezier curve lies entirely within the convex hull of its control vertices If the control vertices are nearly collinear, then the convex hull is a good approximation to the curve Also, a cubic Bezier curve can be broken into two shorter cubic Bezier curves that exactly cover the original curve This suggests a rendering algorithm: Keep breaking the curve into sub-curves Stop when the control points of each sub-curve are nearly collinear Draw the control polygon - the polygon formed by the control points 11/19/02 (

B-Spline Curves B-Splines fix two major problems of Béziers:
Global control of control points Relationship between degree of the curve and the number of control points This is achieved by letting the user specify any number of control points and automatically constructing a set of cubic curves that are C2 This is similar to a set of joined cubic Bézier curves Joined cubic Bézier curves can have any number of control points and are still cubic, and each control point only influences its local cubic curve But B-Splines are C2 and have no constraints on control point locations as joined cubic Bézier curves

B-Spline Cubics For B-Spline cubic curves, (basis splines)
the coefficients aij are chosen for 3 properties between adjacent segments

B-Spline Cubics B-Spline cubic curves achieve C2 continuity by sacrificing the interpolation at the end points. In fact, with control points only a segment between is drawn as t varies between 0 and 1, though its shape is influenced by as well.

B-Spline Cubics Control Points P0, P1, P2, P3 t=1 t=0

B-Spline Cubics Control Points P0, P1, P2, P3 t=0 t=1
Effect of moving P3

B-Spline Cubics Control Points P1, P2, P3, P4 t=0 t=1

B-Spline Cubics Control Points P0, P1, P2, P3, P4
The curve has C2 continuity at the join point P2

B-Splines - coefficients
The 4x4 matrix coefficients are chosen to satisfy the above 3 properties:

B-Splines – Properties check
continuity at the join of Q and : So, (property 1) – P1, P2, P3 weighted towards P2

B-Splines - coefficients
Note: Differentiation of the powers of t gives:

B-Splines – Properties check
continuity at the join of Q and : So, (property 2) – slope is in the direction joining P1 to P3

B-Splines – Properties check
continuity at the join of Q and : So, (property 3) – acceleration is in the direction of (P3 – P2 ) – (P2 – P1 )

B-Spline Curves So just like with Bézier curves, we have control points (Pi) and blending functions (Bi(u)) However, a full B-Spline curve of M+1 control points is really made up of M-2 curve segments, each being controlled by 4 of the control points Also, the blending functions are defined differently than with Bézier curves, with the two most popular variations being: Uniform Non-Uniform

Uniform B-Spline Curves
Uniform blending functions get their name from the fact that all the blending functions are uniform

Uniform B-Spline Curves
Recall that each curve segment composing the full B-Spline needs 4 control points modified by 4 blending functions This implies that only the section in yellow on the previous slide can be used to define the curve At either end there are not enough blending functions This also implies that the curve will not go through any of the control points, including the first and last (as was the case with Bézier) There are multiple non-zero blending functions at t=0 and t=1

Rational Curves A rational curve is a curve defined in 4D space that is then projected into 3D space The main point of using rational curves is that it allows you to define weights on the control points Giving a control point a higher weight causes the curve to be pulled more towards that control point One can have Rational Bézier curves or Rational B-Spline curves Or other types of curves not covered (Hermite, etc.)

Parametric Patches Parametric patches are used to model smooth curved surfaces and to allow dynamic control over the shape of the surface Parametric patches are uses heavily in CAD application and animation Currently real-time applications are dominated by triangle meshes Patches hold many advantages over triangle meshes and if hardware support for them becomes widespread there could be a major shift to them

Rendering Patches To have proper lighting we also need normals for the triangles We can simply use the triangles normal Or, if we want to be more accurate, we can use the actual normal to the parametric surface Partial derivative in the u direction is 1st tangent Partial derivative in the v direction is 2nd tangent Take their cross product and normalize to produce the normal vector

Parametric Patches One of the first uses of parametric patches is the “Utah Teapot” The actual teapot is on the left

Polygonal Representation

Polygonal Representation

Rendered

Patches To represent a surface, the concept of “curve” needs to be generalised. We can construct a sequence of slowly changing curves, each displaced from the previous one in a 3D setting.

Patches In terms of the present work, we can construct a curve from its control points. To generate a surface, we place side by side the sequence of curves. Each curve in the sequence will have slightly different control points. We can arrange the displaced control points themselves to lie on a curve, itself generated from another set of control points!

Bézier Patches 1 patch, 4x4 controls Evaluation: coarse

Bézier Patches 1 patch, 4x4 controls Evaluation: fine

Bézier Patches

Bézier Patches

Bézier Patches

Bézier Patches

Bézier Patches

Bézier Patches The following is an example of the control point lattice:

Bézier Patches The surface that is created is based on the control points:

Bézier Patches The surface is based on Bézier curves
Thus, the surface only matches the control points at the 4 corners

Bézier Patches Approach: for a single curve, make the control points Pi variable depend on another parameter, u in [0,1], say : Pi (u). In this way, obtain a new (displaced) curve for each u. Thus, for u=0, ¼, …1, ...

Bézier Patches Generally:
Express the variability of itself as a Bézier curve: by introducing 4 control points for each control point function Pi (u),

Bézier Patches In total, we need 4x4 control points. We specify the control functions in matrix form:

Bézier Patches Thus: Now substitute the matrix expression for P0(u) .. P3(u) :

Bézier Patches Bézier Patches This has the form: T where

Bézier Patches An explicit form of is obtained by expressing
in polynomial form: T 2 3 1 T u u 2 1 -1 -3 3 -6 u 3 where B =

Bézier Patches Thus T 1 T u 2 3 u 2 u 3

Bézier Polynomials For reference: T = =

Bézier Patches All the same issue occur with patches as with curves
Adjusting the control points changes the shape of the surface: All the same issue occur with patches as with curves Control points have global control Increasing the number of control points will increase the degree of the patch

Bézier Patches Thus, we handle large curvy surfaces the same was as with curves: join patches together Recall the continuity constrains: C0 continuity: edges must match C1 continuity: colinear control points More difficult near joins of 4 patches

Midpoint Subdivision Repeatedly join midpoints to find new control vertices Do it first for each row of original control points: 4x4 -> 4x7 Then do it for each column of new control points:4x7 -> 7x7

A Potential Problem One (good) way to subdivide, is:
If a control mesh is flat enough – draw it Else, subdivide into 4 sub-patches and recurse on each Problem: Neighbouring patches may not be subdivided to the same level Cracks can appear because join edges have different control meshes This can be fixed by adding extra edges Crack

Convex Hull property Ideally, we want the “weights” of to be
between 0 and 1 sum to 1 Then the points will not lie outside the inter-joins of points , that is, be contained in their convex hull.

Convex Hull property P1 P2 P3 P0

Convex Hull property Convex hull of P0 P3 P1 P2
See this as 2D or 3D, as appropriate

Convex Hull property Holds for Bézier curves See Bézier Polynomials
Holds for B-Splines Proved similarly.

B-Splines – outline sum of weights
Note. From we also obtain:

B-Splines – outline sum of weights
= = = 1

B-Spline Patches B-Spline patches are similar to Bézier patches except that they are based on B-Spline curves This implies that: You can have any number of control points in either the u or v direction (4x4, 8x12, etc.) and still maintain piecewise C2 cubic patches With Uniform patches, the patch is will no go through the control points

Rendering Patches There are two types of ways we can render patches:
Render them directly from the parametric descriptions in hardware Must have hardware support Approximate the patch with a triangle mesh and render this mesh Usually done in software Standard pipeline can be used

Rendering Patches To approximate the patch with triangles, we can use a uniform subdivision Evaluate the surface at fixed (u,v) intervals and connect the points with triangle strips

Rendering Patches Or we can use an adaptive subdivision Pros: Cons:
Divide surface in quarters If approximation patch is “flat enough” relative to the actual surface patch, then draw it Otherwise, repeat the sub-division on that quarter Pros: More triangles are generated where the curvature is high, less triangles where curvature is low Cons: Problems with cracks Neighbors not subdivided to the same level Can be fixed by adding more edges

How to Choose a Spline Hermite curves are good for single segments where you know the parametric derivative or want easy control of it Bezier curves are good for single segments or patches where a user controls the points B-splines are good for large continuous curves and surfaces NURBS are the most general, and are good when that generality is useful, or when conic sections must be accurately represented (CAD)

Similar presentations