
July 11th, 2011, 01:36 AM
#1
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 crosssection. I can extrude the crosssection shape successfully down the path. The problem is the vertex order on each crosssection shape to generate my final index list for the total vertices array.
To generate the crosssection, 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 crossproduct 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 crosssection 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 crosssection 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, 08:25 PM
#2
Re: Extruded form along a curve
I'm thinking a fairly simple hack might be to resort the vertices on each crosssection, so they line up properly  something like find the closest vertex to vertex 0 on the 1st crosssection; then reorder vertices if needed.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
This a Codeguru.com survey!
