Hi Paulo,

The osg::ShapeDrawable really isn't for this type of work, you should
create your own geometry, see the osggeometry.

Robert.

On 6/8/07, Paulo Barthelmess <[EMAIL PROTECTED]> wrote:




I'm trying to clip the ends of cylinders according to specific angles (such
that they will look like pipe segments welded together at different angles).



I pursued this in two different ways, both with problems:



1) Created 2 clipping planes and set the state of the Cylinder Shape
Drawable.

      osg::ref_ptr<osg::ShapeDrawable> sd1 =
CylinderSegment(startPt, endPt, height, radius, color); // Draw cylinder
along the axis def by the points

      // Build a cutting planes – make them a fixed angle for now

      osg::ref_ptr<osg::ClipPlane> cliplaneStart (new osg::ClipPlane);


cliplaneStart->setClipPlane(osg::Plane(osg::Vec3(+1.0, 0.0,
0.0),startPt));



      osg::ref_ptr<osg::ClipPlane> cliplaneEnd (new osg::ClipPlane);

      cliplaneEnd->setClipPlane(osg::Plane(osg::Vec3(-1.0,
0.0, 0.0),endPt));



      // Apply the trimming

      osg::ref_ptr<osg::StateSet> stateset = sd1->getOrCreateStateSet();

stateset->setAttributeAndModes(cliplaneEnd.get(),osg::StateAttribute::ON);


stateset->setAttributeAndModes(cliplaneStart.get(),osg::StateAttribute::ON);



What I see is that only the last stateset takes effect. I assume that just a
single cutting plane can be associated to a drawable via this method.



2) Used a ClipNode. To be more specific, I created one ClipNode per
cylinder, added the planes to it. The cylinder shape drawable was added to
the ClipNode; the ClipNode was then added to a group.

This works as expected for a single segment, but as more segments are added,
just the two latest planes (i.e. the latest ClipNode) seem to remain in
effect – all other planes previously defined are discarded. What is worse,
the cutting planes of the latest cylinder are applied to all cylinders, even
though these are siblings in a group. So adding a new segment causes for
example all segments to it's right and left to disappear.



It looks like the ClipNode sets some global state rather than one tha
applies just to the descendants (?)



Its clear that I'm approaching this the wrong way. Is there a more
straightforward way to cutting out multiple parts of a shape? Or ways to fix
the above problems?



Thanks in advance for any suggestions!

--P>>


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to