Hi Johannes,
Carsten is correct that I have written a node core called ScreenTransform
that may work for you.
*
What it does:
*
OSGScreenTransform is used to create a transformation that matches the
screen location of a beacon node it is attached to.
1. Performs an inverse transform of the cumulative transformation of
it's ancestor nodes. i.e. transforms into world space.
- This can be turned on/off with the InvertWorldTransform field.
2. Performs an inverse transform of a given view transformation. This
is a matrix field called View.
- This can be turned on/off with the InvertViewTransform field.
- The View field can be used to scale, translate, rotate as you
wish. Often times the view is a translation down the -z axis.
3. Calculates the screen location of the beacon node. This
translation is applied to the current transformation.
- This can be turned on/off with the ApplyBeaconScreenTranslation
field
4. Calculates the orientation from screen space to local space of the
beacon node. This rotation is applied to the current transformation.
- This can be turned on/off with the ApplyBeaconRotation field.
*How to use OSGScreenTransform:*
NodeRecPtr NodeToFollow; //Some node in the sg that you want
to follow in screen space, created by the user
NodeRecPtr ScreenTransfromGeometry; //Some node that you want
to render at the screen location of the beacon node, created by the
user.
ScreenTransformRecPtr TheScreenTransform = ScreenTransform::create();
Matrix ScreenTransformView;
ScreenTransformView.setTranslate(0.0f,0.0f,-8.0f);
TheScreenTransform->setView(ScreenTransformView);
TheScreenTransform->setApplyBeaconRotation(true);
TheScreenTransform->setApplyBeaconScreenTranslation(true);
TheScreenTransform->setInvertWorldTransform(true);
TheScreenTransform->setInvertViewTransform(true);
TheScreenTransfrom->setBeacon(NodeToFollow);
NodeRecPtr ScreenTransformNode = makeNodeFor(TheScreenTransform);
ScreenTransformNode->addChild(ScreenTransfromGeometry);
//ScreenTransformNode can now be attached anywhere in the scene graph.
//Note: Since the geometry for the ScreenTransfromation is
rendered into the scene, it is possible that under some circumstances
that it may fail
//the depth test. You may want to turn off the depth test for
the materials attached to the ScreeTransfromGeometry.
**
*Where it can be used:*
This can be used to create GUI manipulators like are used in 3DSMax,
Maya, etc. For these tools the manipulators(translate, rotate,scale)
"follow" the location of a selected node in the scene graph, but the
geometry for the manipulators is always rendered at the same distance from
the camera, so there never appears to be any change in size as the
viewpoint is moved.
The code is not yet merged with the main branch of OpenSG 2, but is in the
precess. In the meantime, you could grab the source files from github here:
OSGScreenTransform.cpp<https://github.com/gerritvoss/OpenSGDevMaster_Toolbox/tree/toolbox_not_merged/Source/System/NodeCores/Groups/Misc>
OSGScreenTransform.fcd<https://github.com/gerritvoss/OpenSGDevMaster_Toolbox/blob/toolbox_not_merged/Source/System/NodeCores/Groups/Misc/OSGScreenTransform.fcd>
OSGScreenTransform.h<https://github.com/gerritvoss/OpenSGDevMaster_Toolbox/blob/toolbox_not_merged/Source/System/NodeCores/Groups/Misc/OSGScreenTransform.h>
OSGScreenTransform.inl<https://github.com/gerritvoss/OpenSGDevMaster_Toolbox/blob/toolbox_not_merged/Source/System/NodeCores/Groups/Misc/OSGScreenTransform.inl>
OSGScreenTransformBase.h<https://github.com/gerritvoss/OpenSGDevMaster_Toolbox/blob/toolbox_not_merged/Source/System/NodeCores/Groups/Misc/OSGScreenTransformBase.h>
OSGScreenTransformBase.inl<https://github.com/gerritvoss/OpenSGDevMaster_Toolbox/blob/toolbox_not_merged/Source/System/NodeCores/Groups/Misc/OSGScreenTransformBase.inl>
OSGScreenTransformBase.cpp<https://github.com/gerritvoss/OpenSGDevMaster_Toolbox/blob/toolbox_not_merged/Source/System/NodeCores/Groups/Misc/OSGScreenTransformBase.cpp>
I hope this helps.
On Thu, Dec 1, 2011 at 10:17 AM, Carsten Neumann <carsten_neum...@gmx.net>wrote:
> Hello Johannes,
>
> On 12/01/2011 09:47 AM, Johannes Brunen wrote:
> > I have a scene setup with an orthographic or perspective camera. Now, I
> > have to add some geometry which shoud not change its size on camera
> > zooming in the scene. I.e. the size of the geometry should always appear
> > the same, indepent of the view distance.
>
> so you'd need something that looks at the size of the projected bounding
> sphere on the screen, compares it with a target size and derives a scale
> factor from that. Then translate to the center of the bounding volume,
> apply the scale and translate back?
>
> > How should I tackle this problem? Does OpenSG have something to support
> > such a scenario?
>
> I'm not sure we have something that matches your needs exactly, but the
> merge of David Kabala's toolbox brought in ScreenTransform which IIUC
> keeps an object at the same screen position as a beacon object. I'm not
> sure what it does about scaling, but it's worth taking a look.
>
> Cheers,
> Carsten
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Opensg-users mailing list
> Opensg-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users