Hi Sanat,

On 19/10/10 4:13 , Sanat Talmaki wrote:
> The code I hav is as below:
> 
> Every .ive file loads a line object around which I want to draw a cylinder 
> keeping that line as center. 
>... 

Having a .ive file to specify the location of your cylinders/pipes complicates 
things a
bit, but here goes:

- write a NodeVisitor to collect the vertex arrays object of each .ive node
  (look for Geode, then Drawable, then getVertexArray of each drawable)
- this gives you the start/end point of each line

For a quick proof of concept and convenience you can use ShapeDrawables for the 
cylinders.
 But you should replace this with properly constructed geometry.

- for each line, determine the length of the line
- create a cylinder of that height
- work out the orientation of the line
  (normalized(start - end) will give you a direction vector)
- rotate the cylinder from its up vector (0,0,1) to that direction vector
- move the cylinder to the position of the start point

That's only a rought outline of course.  You may want to skip the NodeVisitor 
bit for
starters and simply use a hard-coded list of start/end points.

Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to