Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modeling Modeling is simply the process of creating 3D objects –Many different processes to create models –Many different representations of model data.

Similar presentations

Presentation on theme: "Modeling Modeling is simply the process of creating 3D objects –Many different processes to create models –Many different representations of model data."— Presentation transcript:

1 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

2 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

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

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

5 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

6 LOD 50 Vertices500 Vertices2000 Vertices

7 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

8 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

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

10 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

11 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

12 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

13 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

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

15 CSG Operations Primitives: Union: Intersection: Difference:

16 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

17 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

18 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

19 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

20 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

21 Parametric representation, parameter t Case of 2 control points P 0, P 1, –P 0, P 1, may be points in 2D, or in 3D –b i (t) are basis functions – fixed. –b i (t) blend points P 0, P 1

22 Linear Interpolation Case of 2 control points P 0, P 1, parameter t –b 0 (t)=1-t, b 1 (t)=t are the basis functions. –Polynomial of degree 1 –b 0 (t) + b 1 (t)= (1-t) + t = 1 for all t Q(t) : straight line join between P 0 and P 1

23 Curve Fitting Parametric representation, parameter t –P 0, P 1, P 2, P 3 may be points in 2D, or in 3D –b i (t) are basis functions – fixed. –b i (t) blend points P 0, P 1, P 2, P 3

24 Curve Fitting Case of 4 control points P 0, P 1, P 2, P 3, As t varies (e.g. between 0 and 1), Q(t) assumes different point values a weighted combination of P 0, P 1, P 2, P 3 weights vary, via b i (t), with t

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

26 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 4 th out of plane point)

27 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 InterpolateApproximate Control points Convex hull knot points

28 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) QuadraticCubicQuarticQuintic Splines

29 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) Splines

30 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 individual cubic segments –without further constraints these will not join smoothly smoothnon-smooth

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

32 Continuity Continuity C k indicates adjacent curves have the same kth derivative at their joints

33 C 0 Continuity Adjacent curves share … –Same endpoints: Q i (1) = Q i+1 (0) Aside: discontinuous curves sometimes called C -1

34 C 1 Continuity Adjacent curves share … –Same endpoints: Q i (1) = Q i+1 (0) –Same derivatives: Q i (1) = Q i+1 (0)

35 C 2 Continuity Adjacent curves share … –Same endpoints: Q i (1) = Q i+1 (0) –Same derivatives: Q i (1) = Q i+1 (0) –Same second derivatives: Q i (1) = Q i+1 (0)

36 Examples of Continuity

37 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

38 Curve Fitting The row matrix of polynomials can be written as

39 Curve Fitting and for Q(t), write

40 Curve Fitting Substitute:

41 Bézier Curves Pierre Bézier, a French designer, first used them in the 1960s 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]

42 Bézier Cubics P1P1 P2P2 P3P3 P0P0

43 For Bézier cubic curves, the coefficients a ij are chosen for 4 properties Q(0)=P 0 Q(1)=P 3 Q(0) is in the direction of P 1 – P 0 Q(1) is in the direction of P 3 – P 2

44 Bézier Cubics Example P0P0 P1P1 P3P3 P2P2

45 Bézier Cubics Example P0P0 P1P1 P3P3 P2P2

46 Bézier Cubics Example P 1 –P 0 P 2 –P 3 P0P0 P1P1 P3P3 P2P2

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

48 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 doesnt 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)

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

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

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

52 Note: Differentiation of the powers of t gives:

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

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

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

56 Piecewise continuity Piecewise Bézier curves can be constructed to have C 1 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.

57 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

58 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!

59 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

60 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

61 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 curves 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

62 Bézier Curves –C2 continuity means the curves 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

63 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 cameras orientation jumps Not C2 means the change in the cameras orientation has sudden jumps

64 11/19/02 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

65 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

66 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

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

68 B-Spline Cubics B-Spline cubic curves achieve C 2 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.

69 B-Spline Cubics Control Points P 0, P 1, P 2, P 3 t=0 t=1

70 B-Spline Cubics Control Points P 0, P 1, P 2, P 3 t=0 t=1 Effect of moving P 3

71 B-Spline Cubics Control Points P 1, P 2, P 3, P 4 t=0 t=1 Effect of adding P 4

72 B-Spline Cubics Control Points P 0, P 1, P 2, P 3, P 4 The curve has C 2 continuity at the join point P 2

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

74 B-Splines – Properties check So, (property 1) – P 1, P 2, P 3 weighted towards P 2 continuity at the join of Q and :

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

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

77 B-Splines – Properties check So, (property 3) – acceleration is in the direction of (P 3 – P 2 ) – (P 2 – P 1 ) continuity at the join of Q and :

78 B-Spline Curves So just like with Bézier curves, we have control points (P i ) and blending functions (B i (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

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

80 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

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

82 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

83 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 1 st tangent Partial derivative in the v direction is 2 nd tangent Take their cross product and normalize to produce the normal vector

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

85 Polygonal Representation

86 Polygonal Representation

87 Rendered

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

89 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!

90 Bézier Patches Evaluation: coarse1 patch, 4x4 controls

91 Bézier Patches Evaluation: fine1 patch, 4x4 controls

92 Bézier Patches





97 The following is an example of the control point lattice:

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

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

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

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

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

103 Bézier Patches Thus: Now substitute the matrix expression for P 0 (u).. P 3 (u) :

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

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

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

107 For reference: T Bézier Polynomials = =

108 Bézier Patches 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

109 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

110 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

111 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

112 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

113 P1P1 P2P2 P3P3 P0P0

114 P1P1 P2P2 P3P3 P0P0 See this as 2D or 3D, as appropriate Convex hull of

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

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

117 = = = 1

118 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

119 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

120 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

121 Rendering Patches Or we can use an adaptive subdivision 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

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

Download ppt "Modeling Modeling is simply the process of creating 3D objects –Many different processes to create models –Many different representations of model data."

Similar presentations

Ads by Google