Greetings, Chris,

    I received the tip below from Mr. Borges.  It was, as you would expect
from him, an excellent tip.  I used the his classes as examples to create a
tube from a series of points that defined the path.  The source is on the
following site: http://www.idx3d.ch/idx3d/idx3d.html.  Since it is in Java,
it was all the easier; I would just make sure to credit Peter Walser.  If
you have any questions, feel free to ask.

    Regards,

    Chet Urata




--- Chris Fenton <[EMAIL PROTECTED]> wrote:
> I have been struggling a bit with this.
> I have a 3D line, I would like to generate a 3D tube.
>
> Any Hints,
>
> Chris
>
>


--- Alessandro Borges <[EMAIL PROTECTED]> wrote:
> Hi,
> In case you did not find a Java3D source code to do it, you can adapt
> the below code
> In the IDX3D (a small 3D engine, 100% software) package  there is
> utility class called idx3d_ObjectFactory.java
> This class implements a Tube method.
> I will not try to explain how it works, but is simple and produce
> nice curve tubes.
> Obviously more faces and more path points will give smoother curve.
>
> NOTE:
> This is NOT Java3D !!  But the concepts are the same.
> Convert it first to Java3D BEFORE use !!
>
> Alessandro
>
> Tube method below:
>
> /**
>  *Sourcve code by Peter Walser
> * http://www2.active.ch/~proxima
> * "On the eigth day, God started debugging"
> **/
>  public static idx3d_Object TUBE(idx3d_Vector[] path, float r, int
> steps, boolean closed)
>  {
>   idx3d_Vector[] circle=new idx3d_Vector[steps];
>   float angle;
>   for (int i=0; i<steps; i++)
>   {
>    angle=2*3.14159265f*(float)i/(float)steps;
>    circle[i]= new
> idx3d_Vector(r*idx3d_Math.cos(angle),r*idx3d_Math.sin(angle),0f);
>   }
>
>   idx3d_Object newObject=new idx3d_Object();
>   int segments=path.length;
>   idx3d_Vector forward,up,right;
>   idx3d_Matrix frenetmatrix;
>   idx3d_Vertex tempvertex;
>   float relx,rely;
>   int a,b,c,d;
>
>   for (int i=0;i<segments;i++)
>   {
>    // Calculate frenet frame matrix
>
>     if (i!=segments-1) forward=idx3d_Vector.sub(path[i+1],path[i]);
>     else
>     {
>      if (!closed) forward=idx3d_Vector.sub(path[i],path[i-1]);
>      else  forward=idx3d_Vector.sub(path[1],path[0]);
>     }
>
>     forward.normalize();
>     up=new idx3d_Vector(0f,0f,1f);
>     right=idx3d_Vector.getNormal(forward,up);
>     up=idx3d_Vector.getNormal(forward,right);
>     frenetmatrix=new idx3d_Matrix(right,up,forward);
>     frenetmatrix.shift(path[i].x,path[i].y,path[i].z);
>
>    // Add nodes
>
>     relx=(float)i/(float)(segments-1);
>     for (int k=0; k<steps; k++)
>     {
>      rely=(float)k/(float)steps;
>      tempvertex=new idx3d_Vertex(circle[k].transform(frenetmatrix));
>      tempvertex.u=relx; tempvertex.v=rely;
>      newObject.addVertex(tempvertex);
>     }
>   }
>
>   for (int i=0;i<segments-1;i++)
>   {
>    for (int k=0; k<steps-1; k++)
>    {
>     a=i*steps+k; b=a+1; c=a+steps; d=b+steps;
>     newObject.addTriangle(a,c,b);
>     newObject.addTriangle(b,c,d);
>    }
>    a=(i+1)*steps-1; b=a+1-steps; c=a+steps; d=b+steps;
>    newObject.addTriangle(a,c,b);
>    newObject.addTriangle(b,c,d);
>   }
>
>   return newObject;
>  }
>
>
>
>
>
> ----- Original Message -----
> From: "Nitin.Jain" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, April 14, 2003 7:58 AM
> Subject: Re: [JAVA3D] AW: [JAVA3D] AW: [JAVA3D] Curvy Tube
>
>
> Florin,
>
> I had the similar problem a few months back and struggled a lot to
> create
> such a geometry. What I was trying to do was to implement the
> sweeping
> surface algorithm, which I was not able to implement quite perfactly.
> The
> geometry I was trying to make was having rectangular cross-section
> and the
> path was a bezier curve.
> I would appreciate if you tell us more about your algo.
>
> Thanks,
> Nitin
>
> -----Original Message-----
> From: Florin Herinean [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 14, 2003 4:22 PM
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] AW: [JAVA3D] AW: [JAVA3D] Curvy Tube
>
>
> Well, it looks like you need to generate the geometry by yourself.
>
> You need to have a "tube" with constant shape (eventualy circle, but
> not
> necessary) to follow a specific path, or a tube with a deformation on
> it's
> side, like being hit with something ? I must confess that I didn't
> understand very well what you need. If it's the first case, I can
> describe
> you the algorithm I'm using.
>
> Cheers,
>
> Florin
>
> -----Urspr�ngliche Nachricht-----
> Von: Chet Urata [mailto:[EMAIL PROTECTED]
> Gesendet: Montag, 14. April 2003 12:43
> An: [EMAIL PROTECTED]
> Betreff: Re: [JAVA3D] AW: [JAVA3D] Curvy Tube
>
>
> Greetings, Florin,
>
>         Thanks for the suggestions.  Yes, if I do not receive or find
> any
> other
> info, I will indeed create the tube geometry by hand, so to speak.  I
> plan
> on looking at some examples in OpenGL to see if I can figure out how
> they do
> it.
>
>         However, which I should have mentioned in my first e-mail,
> the tube
> needs
> to be able to be dynamically re-routed.  I am not sure, but I think
> your
> second suggestion would not allow this to be easily done, unless
> there is
> some reasonable way to modify the geometry of such an object to
> conform to a
> path.
>
>         Any other suggestions are welcome.
>
>         Chet Urata
>
>
>
>
> -----Original Message-----
> From: Discussion list for Java 3D API
> [mailto:[EMAIL PROTECTED] Behalf Of Florin Herinean
> Sent: Monday, April 14, 2003 2:14 AM
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] AW: [JAVA3D] Curvy Tube
>
>
> There are two ways:
>
> 1. generate the tube geometry by hand (it might be easier than you
> think);
> 2. Use an external tool like 3D Studio, Maya, Pro-E, etc., to create
> the
> geometry and import it into your app.
>
> Cheers,
>
> Florin
>
> -----Urspr�ngliche Nachricht-----
> Von: Chet Urata [mailto:[EMAIL PROTECTED]
> Gesendet: Freitag, 11. April 2003 21:56
> An: [EMAIL PROTECTED]
> Betreff: [JAVA3D] Curvy Tube
>
>
>
=== message truncated ===

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to