Modeling with Splines and NURBS

Transcription

Modeling with Splines and NURBS
ART 268 3D Computer Graphics Splines and NURBS What are Splines? Splines are a sequence of vertices, connected by lines, lying in 3D space. The shape of these connecting lines (straight or curved) is defined by the interpolation of the points connecting them. The spline itself is infinitely thin and is not visible when rendered. However, many complex 3D objects, among other things, can be constructed by using splines with NURBS objects. After the spline is created it can be pulled along its depth (extruded) in order to make tube-­‐
like objects. You can also rotate a spline around an axis (lathe) to create objects that have rotational symmetry, such as a wineglass. Or you can construct a skin over several splines (loft), with the finished object simulating the contours on a map. A Brief Guide to Spline Objects 1
Empty Spline -­‐ Creates an empty spline object to construct a spline from. You can set the spline type in the Attributes Manager. NOTE: This spline type is only available via the Create > Spline menu. Freehand -­‐ a hand drawn spline, used much like a pencil drawing tool in other applications. Bézier -­‐ a spline with a soft curve that runs through and between the vertices, but with moderate cornering that can be precisely adjusted by tangent control points. B-­‐Spline -­‐ a spline with a soft curve that runs between, but not through, the vertices. Linear -­‐ a spline with vertices connected by straight lines. Cubic -­‐ a spline with a soft curve that runs through and between the vertices, but with wide cornering. Akima -­‐ a spline with a soft curve that runs through and between the vertices, but with tight cornering. Arc -­‐ defines an arc-­‐shaped spline. Circle -­‐ defines a circular spline. Helix -­‐ defines a spiral spline. n-­‐Side -­‐ defines a regular, angular, closed spline with n number of sides. Rectangle -­‐ defines a rectangular spline. Star -­‐ defines a star-­‐shaped spline. Text -­‐ used for creating text objects using Extrude NURBS. Vectorizer -­‐ creates splines from bitmap pictures 4-­‐Side -­‐ creates trapeziums and parallelograms. Cissoid -­‐ creates a mathematical curve. Cog Wheel -­‐ creates a cog wheel spline. Cycloid -­‐ creates cycloids (rolling curve), hypocycloids (curve based on the inside of a circle), and epicycloids (curve based on the outside of a circle). Use to create geometric patterns based on a circle. 2
Formula -­‐ creates curves based on mathematical equations. Flower -­‐ creates a flower shaped spline. Profile -­‐ creates H, L, T, U, and Z profiles. Empty Spline (see Empty Spline in the above list) This command creates an empty spline object. Like the Polygon object, it is recognizable on screen only by its origin and axes. You can use this object for the construction of your own splines. The spline is always created on the axis of the active viewport. 1. Choose Create > Spline > Empty Spline to create an empty spline. 2. Select Points Mode. 3. Select the Move tool. 4. Select the view in which you wish to model the spline. 5. Create points for the spline by Ctrl-­‐clicking in each place where you want to create a point. The first point defines the start of the spline. 6. If you Ctrl-­‐click on spline line between two existing points, the new point will be placed on the spline between the points but without a connecting line. 7. If you click and drag when creating a point a point with Soft Interpolation will be created. 8. If you hold down the Shift and Ctrl keys while clicking, the new point will be created at the beginning of the spline, giving a new starting point. 9. If you Ctrl-­‐click the starting point, the spline will be closed. 10. You can move points by selecting them and then dragging in space (i.e., not on the point axis). 11. To select multiple points, Shift-­‐click each point (or use one of the selection tools). By default, from the starting point and moving towards the last the curve is gradated from white (first point) to blue (last point). This colored display is visible only when Points Mode is active. 3
Spline Types and Settings Linear: This simplest of all the spline types connects the vertices, which define the polygon, with straight, directly connected lines. You can use these splines to create angular objects or to simulate sharp jerky movements for animation. Cubic: This kind of spline has a soft curve between vertices. The interpolated curve passes directly through the vertices. Looking at the two points at the top right of the diagram, you can see that the curve bulges more than is probably required. This behavior is called overshooting, and it often appears with closed curvatures. This becomes clearer when you compare this section of the curve with the same section of the curve with Akima interpolation. Akima: This spline type creates a soft curve between vertices. The interpolated curve always passes directly through the vertices. Overshooting does not happen with this type of curve. Akima interpolation adheres very closely to the path of the curve directly between the vertices but, because of this, it can sometimes appear somewhat hard. If this is not required, you should use Cubic interpolation. B-­‐Spline: This kind of spline also creates a soft curve between the vertices. However, the curve does not pass directly through the vertices. This produces a very smooth curve. The vertices control only the approximate path of the curve. Distant points have less influence on the curve than those lying closer together. 4
Bezier: This spline type creates a soft curve path between the vertices, which can be controlled very precisely. The interpolated curve always passes through the vertices. Overshoot does not happen. Compared to the other spline types available, Bezier splines are the most functional, offering the most control. Therefore CINEMA 4D uses Bezier splines for its animation system. Working with a Bezier spline and its tangents If you activate a vertex of the spline (i.e. by clicking on it), additional control points at the tangents to the curve become visible. Changing the direction of the tangent handles controls the direction of the curve at each vertex. To do this, drag the tangent end point. By adjusting the length of these tangent handles, you can control the strength of the curvature. Drag the tangent end point towards the vertex point and observe the symmetrical movement of the opposite handle. In the previous illustrations all tangents lie horizontally. Now let’s rotate the tangent of the upper point through 180° so that the left tangent end point lies on the right, the right on the left. You can see the result in this illustration. 5
You can change the lengths of the tangents separately from each other. To do this, Shift-­‐drag a tangent end point. You may set different tangent directions on the right and on the left of the vertex. With this approach you can make the otherwise smooth path of a curve produce sharp corners and peaks, if required. To do this, Shift-­‐drag a tangent end point. If the tangents of two neighboring points have zero length, the segment that runs between the vertices will be linear. Thus, you can mix linear segments with curved spline shapes. If you double-­‐click on a Bezier vertex with the Move, Scale or Rotate tool active, a dialog opens that allows you to accurately enter both the position of the vertex (in the spline’s object coordinates) and the position of the tangent end points (relative to the vertex) numerically. If you convert a Bezier spline to a different type of spline, all tangent settings will be lost. If a spline is converted from a non-­‐Bezier type to a Bezier type, all tangents will be assigned default positions and orientations. 6
Close Spline Close Spline enabled (left) and disabled (right). Each spline segment can be closed or open. If a spline is closed, the start and end points are connected. There is a big difference between closing a spline (and interconnecting the start and end points) and simply positioning the start and end points together. In the first case, the transition from the start to the end point is soft, in the second case it is abrupt. To close the spline, Ctrl-­‐click the start point. Intermediate Points Number – the number of intermediate points to be created Angle – the angle of the intermediate points (0 – 90 degrees) Maximum Length – the maximum length of the tangents of the intermediate points Here you can define how the spline is further subdivided with intermediate points. This affects the number of subdivisions created when using the spline with NURBS objects. Even after you select the Interpolation type from the menu for the Intermediate Points, you can still make changes. None: This method of interpolation locates points only at the vertices of a spline, using no additional intermediate points. You cannot enter values into the Number or Angle boxes. For B-­‐splines, the vertices, and therefore points, might not be located on the spline curve. 7
Natural: This interpolation type first locates points at spline vertices. In the case of B-­‐splines, points are located at positions on the spline curve closest to the spline vertices. Number (N) corresponds to the number of intermediate points between vertices. The points are positioned closer together on areas of the spline with more curvature. You cannot enter values into the Angle box. The interpolation is not affected by reversing the point order. Uniform: This interpolation subdivides the spline so that the distance between any two consecutive points, as measured along the spline curvature, is constant. One point is always located at the beginning vertex. For open splines, a point is also located at the ending vertex. Other points generally do not coincide with vertices. You cannot enter values into the Angle box. The interpolation is not affected by reversing the point order. For Natural and Uniform interpolation, the number of intermediate points is calculated as follows: Open spline: ((Number + 1) * (number of vertices -­‐ 1)) + 1 Closed spline: (Number +1) * number of vertices So an open spline with four vertices and a number of 2 will contain ((2+1)*(4-­‐1))+1=10 intermediate points. If the spline is then closed, a further (virtual) vertex is added — the number of intermediate points will then be (2+1)*4=12. This ensures that a spline is not more roughly divided when you close it. Adaptive: This interpolation type sets intermediate points whenever the angle deviation of the curve is larger than the value given in Angle. The points of the resulting curve pass through the vertices. If a spline has several segments, then the value of Angle will apply to each segment. The Adaptive method gives the best results in rendering, hence it is the default interpolation method. You cannot enter values into the Number box. 8
Subdivided: Subdivided is similar to Adaptive. Additional intermediate points will be added until the intermediate segments are shorter than the defined Maximum Length, i.e. the point intervals will not necessarily be equal to the maximum length. Lower values will result in higher quality, along with the disadvantages of working with a high number of points -­‐ slower refresh times in the editor view, etc. Especially the render quality of deformed text can be greatly improved using this method. More or less perfect caps and edges without shading errors can be achieved by setting Maximum Length to the same value as Width in the Extrude NURBS (Caps tab, activated Regular Grid option). The subdivision of the letters and caps will match and must not be done manually. Left: Intermediate points Adaptive, Right: Subdivided, applied to an active formula deformation object. Note the defined edges at the right of the image. This setting controls the maximum spline segment length without adding intermediate points, and is only available if the Intermediate Points parameter is set to Subdivided. To create a new Spline Segment 1. Create a spline as described above. 2. Select the point that will be the start point of the new segment. 3. Choose Mesh > Spline > Break Segment. The connection to the previous segment is now broken. 4. Ctrl-­‐click to add further points. All new points belong to the new segment. 5. You can create further segments following the same process and they will all belong to the same spline, though there is no physical connection between them. To Separate Spline Segments into Individual Spline 1. Select the spline with multiple segments 2. Choose Mesh > Spline > Explode Segments. 9
To Project a Spline onto an Object 1. Hide any objects you do NOT wish the spline to project onto. 2. Select the spline you wish to project. Note: The spline must have been converted if it was created from one of the predefined spline shapes. 3. Choose Mesh > Spline > Project. 4. In the Attributes Manager select the projection Mode that projects the spline onto the object in the desired manner. Note: The object to be projected onto should be large than the spline. 5. Click on the Apply button. Spline-­‐based NURBS Objects NURBS is an abbreviation of Non-­‐Uniform Rational B-­‐Spline. Any spline can be used in a NURB object, although the different NURB objects each have different settings and spline requirements. The following NURBS objects depend on splines to define their geometry (unlike HyperNURBS and Bezier NURBS, both of which do not require any splines). Extrude NURBS (extrude means to thrust out) -­‐ extrudes a single spline to create an object with depth. Drag and drop the spline object onto the Extrude NURBS object in the Object Manager. Object Tab Movement [XYZ m]: Into these three input boxes, enter the extrusion distance along the X, Y and Z-­‐axes (based on the local axis system of the NURBS object). Subdivision [1..4000]: Defines the number of subdivisions along the extrusion axis. Iso Subdivision [2..4000]: Defines the number of isoparms used to display the Extrude NURBS when the isoparm display mode is active. Flip Normals: Flips (i.e. reverses the direction of) the normals of the Extrude NURBS. Usually, CINEMA 4D will point the normals in the correct direction. However, with open contours it is not possible for CINEMA 4D to know which way they should point. In this case, you can control the direction of the normals, either by changing the direction of the spline or by enabling the Flip Normals option. This option does not effect the caps, since their normals are always calculated correctly. Hierarchical: If this option is enabled, you can group, say, several splines within a Null object and place this group in an Extrude NURBS. Each spline of this group is now extruded separately. This is important especially for a text spline when you have enabled its 10
Separate Letters option. In this case, a separate spline is created for each letter; these splines are in an object group. The Hierarchical option must be enabled to extrude these separate letters. Caps Tab Start End: Change the rounding at the start/end of the NURBS object. If you set Cap And Rounding for start/end, you can set the following parameters: Steps [1..100]: Here you enter the number of subdivisions for the rounding at the start of the object. Radius [0..+∞m]: Determines the radius of the rounding at the start of the object. Steps [1..100]: The number of subdivisions for the rounding at the end of the object. Radius [0..+∞m]: The radius of the rounding at the end of the object. Fillet Type: Choose the shape of the rounding from this drop-­‐down list. When the constrained mode is active, all fillet types except the Engraved type extend the length of the extrusion of the NURBS object. 1. 1 Step 2. 2 Steps 3. Engraved 4. Linear 5. Convex 6. Concave 7. Half Circle Phong Angle [0..180°]: Defines the smoothing angle between adjacent polygons that are part of the fillet. 11
Hull Inwards/Hole Inwards: The examples below demonstrate rounding inwards and rounding outwards. Hole Inwards refers to hole segments — it is ignored if the spline has no hole segments. Constrain: This setting determines whether the object’s dimensions are preserved or whether the object should be inflated by the rounding. The thick line represents the initial spline Keep the following in mind when rounding with the Constrain option enabled. The 12
pictures below demonstrate this issue. The top picture shows the initial contour. Rounding the contour with a small radius produces the desired result (center picture). The final picture shows what happens if the rounding is set too high. CINEMA 4D cannot detect inappropriate settings for you in this case. It is up to you to use a sensible rounding radius. Rounding objects by inflating them always works, although it does increase the size of the hull. Type: Use this setting to define if the caps should consist of triangles, quads or n-­‐gons. Regular Grid Width [0.01..+∞m]: This option is especially useful if you intend to use deformation objects. If enabled the surface will not be built out of long triangles but out of regularly-­‐spaced quadrangles whose size you can enter into the Width box. Initially there appears to be no difference at all between the enabled and disabled option when you render or shade. However, if you disable the option and deform the spline so that it is no longer planar, artifacts will appear on the surface. The long triangles are now visible. You can reduce the artifacts by enabling the option. Although triangles will still be created at the edge, the quadrangles become smaller the more subdivisions you use, leading to fewer triangles. 13
Lathe NURBS -­‐ rotates a spline around its Y axis Object Tab Angle [-­‐∞..+∞°]: Here you define the angle through which the spline is to be rotated. 360° is one complete revolution. Subdivision [1..4000]: Defines the number of subdivisions along the rotation. Isoparm Subdivision [2..4000]: Defines the number of isoparms used to display the Lathe NURBS when the isoparm display mode is active. Movement [-­‐∞..+∞m]: Movement is the longitudinal distance from the beginning of the lathe to the end. If you set Movement to 0, the spline rotates on a circle. With any other value, it moves around a helix, enabling you to create shapes such as threads and screws. If you want to create several threads, set the Angle parameter to a large value such as 1800° for five revolutions and increase the Movement value so that the threads do not overlap. Scaling [0..+∞%]: Scaling determines the final scale of the spline. The spline is scaled with 14
respect to the origin of the local axis system of the NURBS object. Flip Normals: Flips (reverses the direction of) the normals of the Lathe NURBS. CINEMA 4D will usually point the normals in the correct direction. However, with open contours it is not possible to know which way they should point. In this case, you can control the direction of the normals, either by changing the direction of the spline or by enabling the Flip Normals option. This option does not effect the caps, since their normals are always calculated correctly. Caps Tab -­‐ Same as for Extrude NURBS (see above) Loft NURBS -­‐ uses at least two splines to build an object based on both. Object Tab Mesh Subdivision U [3..4000]: This gives the number of subdivisions in the U direction, i.e. along the circumference of the cross-­‐section. Tip: If you are using open splines, the number of subdivisions generated matches the Mesh Subdivision value exactly. However, if you are using closed splines, the first subdivision coincides with the last division, generating one subdivision less than the Mesh Subdivision value. 15
Two closed splines with an open spline between. Mesh Subdivision V [2..4000]: Defines the number of subdivisions created in the V direction, i.e. along the length of the loft. Isoparm Subdivision U [3..4000]: Defines the number of isoparms used to display the Loft NURBS when the isoparm display mode is active. Organic Form: If this option is disabled, the Loft NURBS lines pass directly though the spline points and the distances between the lines adapt to the spline points, resulting in a very tight form. If the option is enabled, the Loft NURBS lines no longer pass through the spline points exactly but maintain equal parametric distance to each other, creating a looser, more organic form. Organic Form enabled 16
Organic Form disabled Subdivision per Segment: You can use this option to choose whether the mesh subdivision is divided evenly over the entire length of the object or evenly per segment (a segment is the section between one spline and the next). Enabling this option gives you more control over the object’s appearance when splines are close to one another. If the option is disabled, the number of resultant subdivisions per segment is calculated using the average distance of the segments. This may be unsuitable for animation, but it generates more regular objects. Subdivision Per Segment enabled 17
Subdivision Per Segment disabled Loop: If this option is enabled, the first spline is connected to the last spline in the V direction. Linear Interpolation: Enable this option if you want linear interpolation between the splines; otherwise, the interpolation is soft. Adapt UV: Adapt UV is similar to Subdivision Per Segment, but refers to the texture instead. The texture must use UVW mapping for this option to have an effect. It is independent of the Subdivision Per Segment option. The texture is projected either per segment (enabled) or evenly over the entire object (disabled). Adapt UV enabled 18
Adapt UV disabled Flip Normals: Flips (i.e. reverses the direction of) the normals of the Loft NURBS. Usually, CINEMA 4D will point the normals in the correct direction. However, with open contours it is not possible for CINEMA 4D to know which way they should point. In this case, you can control the direction of the normals, either by changing the direction of the spline or by enabling the Flip Normals option. This option does not effect the caps, since their normals are always calculated correctly. Caps Tab -­‐ Same as for Extrude NURBS (see above) Sweep NURBS -­‐ creates a polygon based on the path of a one spline along another. The first spline within the Sweep NURBS object is the contour, the second the path, the optional third the rail. Object Tab Isoparm Subdivision [2..10000]: Defines the number of isoparms used to display the Sweep NURBS when the isoparm display mode is active. End Scale [0..+∞%]: Determines the size of the contour at the end of the path. The contour is 100% at the start of the path and the size is interpolated in between. End Rotation [-­‐∞..+∞°]: Defines the rotation about the Z axis that the contour has passed through by the time it reaches the end of the path. Start Growth [0..100%]: Works like End Growth, except that the Sweep NURBS can be adjusted from the opposite end of the spline, i.e. from the spline’s start along its length. 19
End Growth [0..100%]: This option can be used to let a spline grow. A value of 100% will result in the spline contour being extended along the entire path. If applied to a closed spline, caps (without rounding) can be defined for intermediate stages. You can animate the growth by recording the Growth parameter. For example, you can gradually write a word by using a circle spline (e.g. radius 4, XY plane) as the contour and a spline in the shape of the handwriting as the path. Finally, record two keyframes for Growth. Parallel Movement: If this option is enabled, the contour is swept in a parallel manner (i.e. it is not rotated at all). Constant Cross Section: This option is enabled by default. It is ignored if a rail path is used. It causes the contour spline to be scaled at hard edges in order to maintain a constant thickness throughout the sweep. The following star-­‐shaped path illustrates the effect. Constant Cross Section enabled 20
Constant Cross Section disabled Banking: If Banking is enabled, the contour spline will lean into the curves of the path spline (CINEMA 4D will calculate the banking by considering the curvature of the path). The initial banking angle is set to the average plane of the path spline, which is calculated from the position of the path’s spline points. The banking angle must be chosen at random for straight lines since they cannot define a plane. In this case, turn off banking to make the contour will run parallel to the path spline’s XZ plane. Keep Segments: This setting is only used if you have changed the value for Growth. Its effect is, by and large, only noticeable with animated growth. If the option is disabled, the animation growth is smooth. However, if you enable Keep Segments, the sweep grows segment by segment. The positions of the segments are determined by the path spline’s interpolation type (Type). An adaptive path spline will usually lead to a jerky growth animation if Keep Segments is enabled. Use Rail Direction: If this option is enabled, the rail spline will influence the rotation of the contour about its Z-­‐axis. The Z-­‐rotation applied to each contour position is equal to the angle between the contour’s local +X axis and the projection onto the contour’s local XY axis of the vector that connects the contour’s local origin to the matching point on the rail spline. This vector connects spline points on the path to corresponding spline points on the rail and applies linear interpolation to determine corresponding points on paths of the splines between points. 21
Use Rail Direction enabled Use Rail Direction disabled The best way to create a rail spline is to make a copy of the path spline, then adjust the location of the rail spline points to get the desired effect. 2-­‐Rail: If this option is enabled, the contour spline will be placed between the path and the rail; otherwise, the rail controls the contour’s rotation about its Z axis (provided Use Rail Direction is enabled). The 2-­‐Rail feature takes effect only if both the Use Rail Direction and Use Rail Scale checkboxes are checked. 2-­‐Rail enabled 22
2-­‐Rail disabled Use Rail Scale: If this option is enabled, the rail spline can be used to alter the scale of the contour along the path. The scale factor applied to each contour position is equal to the distance of the vector connecting the contour’s local origin to the matching point on the rail spline. This vector connects spline points on the path to corresponding spline points on the rail and applies linear interpolation to determine corresponding points on paths of the splines between points. Flip Normals: Flips (i.e. reverses the direction of) the normals of the Sweep NURBS. Usually, CINEMA 4D will point the normals in the correct direction. However, with open contours it is not possible for CINEMA 4D to know which way they should point. In this case, you can control the direction of the normals, either by changing the direction of the spline or by enabling the Flip Normals option. This option does not effect the caps, since their normals are always calculated correctly. Left, the object’s initial state (Start Growth=0%; End Growth=100%). The growth was restricted in both examples to the right: Center Stick UVs deactivated; right Stick UVs active. 23
Stick UVs : A Sweep NURBS’ U-­‐coordinates normally range from 0 to 1 over the entire length of the spline. If the length of the Sweep NURBS is reduced using either Start Growth or End Growth, the Stick UVs setting defines if U should continue to run along the entire length of the spline or if it should adapt to the length of the spline. The latter option will scale an applied texture when the Growth settings are modified. Details: Scale: Use these function graphs to adjust the diameter of the Sweep NURBS as desired along its entire length (the X axis symbolizes the spline length)
Left: Scale function graph; right: Rotate function graph. Details: Rotation: Use this function graph to twist the Sweep NURBS as desired along its entire length (the X axis symbolizes the spline length). The extent to which the rotation takes place is defined with the From (minimum) and To (maximum) settings, explained below. From [-­‐∞..+∞°] To [-­‐∞..+∞°]: Imagine these settings placed on the Y axis of the Rotation function graph. From represents null and To the maximum value. These settings are used to define the outer most rotational limits for the rotation of the Sweep NURBS. The rotation defined here will be added to any existing End Rotation value. Caps Tab -­‐ Same as for Extrude NURBS (see above) 24
Guidelines for working with Splines and NURBS 1. Always draw splines in one of the orthographic views (top, right, front), depending on which direction the NURBS object will operate. NEVER draw a spline in the perspective view. 2. Spline points are brown when not selected and orange when selected. 3. Try to keep the number of spline points to a minimum and use soft interpolation to create curves (rather than using multiple points). Curves can be created using just two points with soft interpolation. The less points on a spline the easier the spline is to work with and the less complex the resulting NURBS object. 4. If you accidentally create too many points on a spline, select the unwanted points and press Delete to delete them. 5. When using soft interpolation be sure to only adjust the curvature of the spline using the view you created the spline in, otherwise you will twist the spline and the resulting NURBS object will be distorted. 6. You can convert a point with hard interpolation to one with soft interpolation (and vice-­‐versa) as follows: a. Select the point to be converted b. Choose Mesh menu -­‐> Spline -­‐> Hard/Soft Interpolation (see image below) 7. For a closed Lathe NURBS object the x-­‐position of the first/last point(s) should be 0; the further a point moves from 0 the larger the opening in the object. For example, a 25
wine class would have its first point (at the top of the glass) to the right of 0 by distance equal to the radius of the glass; for the base however, the last point on the spline (at the bottom of the glass) would be aligned to 0 on the x-­‐axis. If the point is not on 0: a. Select the point on the spline you wish to move to 0. b. Type 0 into the Coordinates Manager X position and then click on the Apply button. 8. Use the NURBS objects’ Subdivision setting in the Attributes Manager to refine the shape of your object rather than adding points to your spline. 9. Use Bezier splines for creating simple curves requiring few points. Click to create a point with Hard Interpolation; click and drag to create a point with Soft Interpolation. 10. Extrude NURBS + 1 spline (use to create object with depth). 11. Lathe NURBS + 1 spline (use for bottles, glasses, vases, etc). 12. Sweep NURBS + 2 splines (use for string, cords, rope, etc) – a path and a profile (closed shape). 13. Loft NURBS + multiple splines (use to create more organic forms). 26