|
楼主 |
发表于 2011-4-16 13:57:44
|
显示全部楼层
本帖最后由 baco_n 于 2011-4-16 14:00 编辑
回复 2# array
锐哥,这是OSG maillist中的一个问题与回答,请您过目。
问题:
Hi Paul,
> I've got the same thing working with OSG with the osgmanipulators
> however these manipulators (seem to?) rely on setupDefaultGeometry()
> to create handles. I would rather have the original subtle approach,
> where the object itself acts as the "handle" and the scene is not
> cluttered with other objects.
>> Is there an easy way to do this or will I have to create my own
> specialised dragger?
回答:
Check out the code for createDefaultGeometry() for your selected
dragger. You will see that it essentially creates some geometry under
the dragger (geodes as children of the dragger, which is a subclass of
MatrixTransform). Often, there is additional geometry created only to
make picking easier, but never displayed - for example:
- // Create an invisible cylinder for picking the line.
- {
- osg::Cylinder* cylinder =
- new osg::Cylinder (osg::Vec3(0.0f,0.0f,0.5f), 0.015f, 1.0f);
- osg::Drawable* geometry = new osg::ShapeDrawable(cylinder);
- setDrawableToAlwaysCull(*geometry);
- geode->addDrawable(geometry);
- }
复制代码
The important part is setDrawableToAlwaysCull(), which is a protected
method of osgManipulator:: Dragger. So if, for example, you want to
create a TranslatePlaneDragger which does not display its geometry, you
could just subclass TranslatePlaneDragger, and then in
createDefaultGeometry() you would only create an invisible quad which
would align with the plane you want to translate along, using is
setDrawableToAlwaysCull(). That way, intersections would be found on
that plane and the dragger would behave as you want, but it would not
display any geometry for the dragger itself.
Hope this helps,
J-S
他的回答中的createDefaultGeometry()应该指的就是setUpDaultGeometry(),按照他的意思,就是说可以在某个拖拽器类中写入setDrawableToAlwaysCull(),从而使得拖拽器不可见。这好像与您昨天的回答不一样。愿听ARRAY详解。谢谢!
|
|