| |
|
|
||||
![]() |
||||||
| |
|
|||||
|
Introducing Bezier Volumes After defining Bezier curves and surfaces, the extension to volumes simply involves increasing the number of control points and adding another parameter to the Bezier equation. The array of control points P now contains 64 vectors in a 4x4x4 array, and the curve is defined in terms of three parameters as shown in Eq. 7:
One of the most basic structures we can form the Bezier volume into is a cubic shape. To do this we set all the control points up to form a 4x4x4 regular coordinate grid. In this case the control points, drawn using 3D space, would look as shown in Fig. 3. Only the control points on the front face of the cube are drawn in full. Figure 3
It's important to realize that a Bezier volume does not simply define a six-sided surface. It's a true volume, and you can freely alter the control points within it to produce a variety of volumes. As the control points are moved within the volume, the initially straight axes of the volume will deform to become Bezier curves. Listing 3 shows code that will evaluate a position inside a Bezier volume for given u, v, and w parameter values. Listing 3 CVector3D CEvaluator::EvalVolume(VOLUMECTRLPTS P, float u, float v, float w) { assert (P != NULL); assert (u >= 0.0f && u <= 1.0f); assert (v >= 0.0f && v <= 1.0f); float BU[4], BV[4], BW[4]; CVector3D Ret(0); BU[0] = (1.0f - u) * (1.0f - u) * (1.0f - u); BU[1] = 3.0f * u * (1 - u) * (1.0f - u); BU[2] = 3.0f * u * u * (1.0f - u); BU[3] = u * u * u; BV[0] = (1.0f - v) * (1.0f - v) * (1.0f - v); BV[1] = 3.0f * v * (1 - v) * (1.0f - v); BV[2] = 3.0f * v * v * (1.0f - v); BV[3] = v * v * v; BW[0] = (1.0f - w) * (1.0f - w) * (1.0f - w); BW[1] = 3.0f * w * (1 - w) * (1.0f - w); BW[2] = 3.0f * w * w * (1.0f - w); BW[3] = w * w * w;
for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { Ret += P[i][j] * (BU[i] * BV[j]); } } return Ret; } |
|
|