July 11th, 2011, 12:36 AM
Extruded form along a curve
What seems like a relatively simple problem has proven otherwise.
What I have so far:
A 3d spline curve randomly generated, which I use as a path to extrude a form, defined by a polygon cross-section. I can extrude the cross-section shape successfully down the path. The problem is the vertex order on each cross-section shape to generate my final index list for the total vertices array.
To generate the cross-section, I find a line perpendicular to the direction vector of each path segment along the spline. This is where I'm getting messed up.
What I've been doing thus far is calculating the cross-product of the segment vector and one of the cardinal axes, based on the component of the segment vector with the least magnitude–so if the segment vector is [-3, 2, 1], I use [0,0,1] as my 2nd vector. The cross product does give me a perpendicular line to the segment. However, because the spline is randomly generated, I never know which axis will get selected (again based on the component with the least magnitude). So my starting point from which I calculate plot the cross-section shape can be in different positions around the shape (i.e. a different initial value for theta). If I instead simply select one of the axes as the 2nd vector for all the segments, it actually works better, but still there is some flipping in position of starting point on the cross-section shapes.
I can't seem to find any info on the web about an alternate way to find a perpendicular line to a single 3D vector. (or maybe there's a much simpler way to extrude a form along a curve ;-)
July 12th, 2011, 07:25 PM
Re: Extruded form along a curve
I'm thinking a fairly simple hack might be to resort the vertices on each cross-section, so they line up properly - something like find the closest vertex to vertex 0 on the 1st cross-section; then reorder vertices if needed.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!