|
|
Ben Chambers wrote:
>
> Hmm, seems just a little bit messy. Where on the triangle are the
> control points placed? (One thing I wanted to achieve with mine is
> that it uses no more data than the original triangle - three points,
> and three normals, so control points don't have to be generated).
There is a site that has a PDF describing how to get the control
points for a cubic Bezier triangular patch, derived from the corners
and normals of that corner. It's here:
http://www-courses.cs.uiuc.edu/~cs319/subdiv.pdf
It won't handle sharp edges (which are important for most work). Note
that this is for CUBIC patches, whereas the code I gave above is for
quartic patches. For cubic patches, you'd need this macro:
// start of macro code
#macro CubicTriPatch(A,B,C,D,E,F,G,H,I,J,cD)
#if(cD<1)
smooth_triangle { A,vcross(C-A,B-A),
G,vcross(D-G,H-G),J,vcross(I-J,F-J) }
#else
CubicTriPatch(A,(A+B)/2,(A+C)/2,(A+2*B+D)/4,(A+B+C+E)/4,(A+2*C+F)/4,
(A+3*B+3*D+G)/8,(A+2*B+D+C+2*E+H)/8,(A+B+2*C+2*E+F+I)/8,
(A+3*C+3*F+J)/8,cD-1 )
CubicTriPatch(G,(G+H)/2,(D+G)/2,(G+2*H+I)/4,(D+E+G+H)/4,(B+2*D+G)/4,
(G+3*H+3*I+J)/8,(D+2*E+F+G+2*H+I)/8,(G+H+2*D+2*E+B+C)/8,
(A+3*B+3*D+G)/8,cD-1 )
CubicTriPatch(J,(J+F)/2,(I+J)/2,(J+2*F+C)/4,(E+F+I+J)/4,(H+2*I+J)/4,
(A+3*C+3*F+J)/8,(I+2*E+B+J+2*F+C)/8,(J+F+2*I+2*E+H+D)/8,
(G+3*H+3*I+J)/8,cD-1 )
CubicTriPatch((A+3*B+3*D+G)/8,(A+2*B+D+C+2*E+H)/8,
(A+B+2*C+2*E+F+I)/8,(A+3*C+3*F+J)/8,(G+H+2*D+2*E+B+C)/8,
(B+C+D+2*E+F+H+I)/8,(I+2*E+B+J+2*F+C)/8,(D+2*E+F+G+2*H+I)/8,
(D+2*E+F+H+2*I+J)/8,(G+3*H+3*I+J)/8,cD-1 )
#end
#end
// end of macro code
Regards,
John
Post a reply to this message
|
|