Reputation: 717
I am writing a simple path editor in Unity3D by storing a series of points, in/out tangents, and drawing a bezier between each pair of points:
The data for the path:
What I'm finding is the tangents don't behave as I would expect. I'm very much used to image editing applications where the tangents are actually tangental to the curve:
But if you look back to my first image you can see that the tangents have to be moved to more perpendicular angles to get a smooth shape.
At this point I think there are a few possibilities:
Does anyone have any advice for me on how I can improve my usage of beziers?
Thanks, Ves
Upvotes: 0
Views: 1887
Reputation: 717
Alrighty, I figured out the problem.
The unity documentation is extremely unclear on what the tangents are supposed to be. In my code I was using local vectors for the tangents, when the DrawBezier method actually wants the absolute positions of the tangent points.
I've been able to fix the curve drawing by doing the following:
Handles.DrawBezier(pointA.position,
pointB.position,
pointA.position + pointA.outTangent,
pointB.position + pointB.inTangent,
Handles.color,
null,
1.0f);
The solution made sense when I understood what Heisenbug was saying about the 4 points in a cubic bezier. Thanks a ton guys!
Upvotes: 1