PDA

View Full Version : generate triangle strips from three interconnected cubic bezier curves

pat1il
07-08-2015, 08:42 PM
I have code to create triangle strips for a bezier surface ( 4 edge points and 12 control points).

I need to know how to create trangle strips for three interconnected bezier curves.
Is it possible to "cheat" and just duplicate one of the points somehow and my existing code?

GClements
07-08-2015, 10:38 PM
I need to know how to create trangle strips for three interconnected bezier curves.
Is it possible to "cheat" and just duplicate one of the points somehow and my existing code?
Not if you need to generate normals, as they will be undefined for a degenerate patch (where two of the corners are coincident).

Bezier triangles exist: 10 control points for the cubic case; 9 for the 3 edges, which are 3 curves, plus one interior point. But OpenGL's evaluators only generate rectangular grids. Tessellation shaders can handle triangular topology, but require OpenGL 4.0 or later.

Another option is to split the triangle into 3 patches, with a common corner at the centroid. But that takes 3 times as many patches.

Either way, maintaining C1 continuity across edges is significantly more complex when you start bringing triangles into it.

pat1il
07-09-2015, 07:46 AM
Is there a way to calculate the center control point or approximate the center control point if I have the three bezier interconnected curves? If I had the center control point, I could calculate interior points and subdivide the triangle sufficiently to render.

If that is not possible, could I split one of the bezier curves into two bezier curves and then use the 4 interconnected curves and their control points?

GClements
07-09-2015, 03:26 PM
Is there a way to calculate the center control point or approximate the center control point if I have the three bezier interconnected curves? If I had the center control point, I could calculate interior points and subdivide the triangle sufficiently to render.
There isn't a "correct" way to calculate it. The only obvious constraint is that it should be a weighted sum of the existing control points (so that the calculation is invariant under linear transformation) where the weights sum to one (so that the calculation is invariant under translation).

Although ... if you give the 3 corners a weight of 1/12 and the other 6 control points a weight of 1/8, then if the curves forming the edges are quadratic, the patch will also be quadratic. I have no idea whether that's relevant for your application.

The interior point doesn't affect the edges; these will always be the curves formed by the exterior control points.

If that is not possible, could I split one of the bezier curves into two bezier curves and then use the 4 interconnected curves and their control points?
Doing that will also result in a degenerate patch with invalid normals. The normals are calculated as the cross product of the tangents in the u and v directions. If the tangents are co-linear, the cross product will be zero. Even aside from the normals, the resulting patch is unlikely to be what you want.