CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011

    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 ;-)

  2. #2
    Join Date
    Jul 2011

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.