|
|
"Aj" <nomail@nomail> wrote:
You have knots ('fixed points') and handles. Define a grid of fixed points. Now
you can think of each row and column as the fixed points in a bezier curve. The
handles of the bezier curves have to be equally long and need to have the
opposite direction to keep the curve smooth. A Bezier patch is just a lattice of
Bezier curves, the same rules apply.
Altough I don't think it is helpfull, I dug op some very old code t create a
bezier cylinder with dimples:
---%<------%<------%<----
// Ingo Janssen
// 1999-04-22
// bicubic patch generation
#version 3.1;
global_settings{assumed_gamma 1.0}
light_source{<100,50,-500> rgb 1}
camera{
location <0,0,-20.0>
look_at <0,0, 0.0>
}
#macro GetRadius1(R)
#local Range=R*0.1;
#local Variation=Range+(((-Range)-Range)*rand(S));
#declare Rr=R+Variation;
#end
#macro BuildArray(H,R,NrBPH,NrBPC)
// H= height; R= radius
// NrBPH= number of patches in height
// NrBPC= number of patches in circumference
#local PH=((NrBPH*4)-NrBPH)+1;
#local PC=((NrBPC*4)-NrBPC)+1;
#local Ystep=H/PH;
// need one extra element in the array for C1 continuity.
#local BP_arr=array[PH+1][PC+1]
#local Ypos=0;
#local I=0;
#local J=0;
#while (I<PH+1)
#while (J<PC-1)
#local Phi=(J*(360/PC));//+(I*((-180+clock*360)/PH));
GetRadius1(R)
#declare BP_arr[I][J]=vrotate(<Rr,Ypos,0>,<0,Phi,0>);
#local J=J+1;
#end //while
// closed shape so last point is first point.
#local BP_arr[I][J]= BP_arr[I][0];
// the last-plus-one point must be the same as the second point, too.
#local BP_arr[I][J+1]= BP_arr[I][1];
#local J=0;
#local Ypos=Ypos+Ystep;
#local I=I+1;
#end //while
#declare OutArray= BP_arr
#end //macro
#macro BuildPatch(InArray)
// the arrays were made an element larger, so here we must compensate.
#local PH= dimension_size (InArray,1)-1;
#local PC= dimension_size (InArray,2)-1;
#local I= 0;
#local J= 0;
#while (I<PH-1)
#while (J<PC-1)
bicubic_patch {
type 1
u_steps 4
v_steps 4,
InArray[I][J],
InArray[I][J+1],
// notice that the third point in each row is constrained such
// that it, the last point in the row, and the second point
// in the equivalent row in the next patch are in a straight line.(Ron Parker)
2*InArray[I][J+3]-InArray[I][J+4],
InArray[I][J+3],
InArray[I+1][J],
InArray[I+1][J+1],
2*InArray[I+1][J+3]-InArray[I+1][J+4],
InArray[I+1][J+3],
// notice, too, that each point in the entire third row is
// constrained in this way with respect to the last row and
// to the second row of the next patch. Note the lack of any
// +2 terms in the whole patch definition. We calculated them
// above, but we never use them because we no longer have as
// much freedom as we did before we wanted smoothness.(Ron Parker)
2*InArray[I+3][J]-InArray[I+4][J],
2*InArray[I+3][J+1]-InArray[I+4][J+1],
2*(2*InArray[I+3][J+3]-InArray[I+4][J+3])-(2*InArray[I+3][J+4]-InArray[I+4][J+4]),
2*InArray[I+3][J+3]-InArray[I+4][J+3],
InArray[I+3][J],
InArray[I+3][J+1],
2*InArray[I+3][J+3]-InArray[I+3][J+4],
InArray[I+3][J+3]
pigment {rgb 1}
}
#local J=J+3;
#end //while
#local J=0;
#local I=I+3;
#end //while
#end //macro
#macro ScaleArray(InArray)
#local PH= dimension_size (InArray,1);
#local PC= dimension_size (InArray,2);
#local I= 0;
#local J= 0;
#local Phi= 0;
#while (I<PH)
#while (J<PC)
#local Scale=sin(Phi)+0.5;
#local InArray[I][J]=InArray[I][J]*<Scale,1,Scale>;
#local J= J+1;
#end //while
#local J= 0;
#local Phi=Phi+(pi/(PH-2));
#local I= I+1;
#end //while
#declare OutArray= InArray
#end //macro
#declare S=seed(7);
BuildArray(15,5,25,15)
ScaleArray(OutArray)
union{
BuildPatch(OutArray)
rotate <0,0,90>
translate <7.5,0,0>
}
---%<------%<------%<----
> I was trying to create a grid of 4x4 using bicubic_patch but unfortunately, I
> was unable to figure out how to achieve that. I was able to follow up with the
> documentation and created a 3x3 grid, Any suggestion on how that can be achieved
> would be really helpful.
Post a reply to this message
|
|