I am working on a widget system and have problems with how osgText:Text
is layered. My text always ends up above the geometry.
I have a root node that has depth testing disabled. Under it is a hierachy
of rectangle-like panels. Some of them have text labels. All my geometry
layers as expected but the text always stays in front of everything else.
Text with text layers correctly too.
Any ideas why this happens?
Cheers,
stefan
------------------------
stefan hechenberger
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=18661#18661
osgWidget failed to be sufficient?
I can help you with this, of course (since I solved it in osgWidget),
but I'd be interested in knowing what it's missing that you wanted to
write you own. :)
> Cheers,
> stefan
>
> ------------------------
> stefan hechenberger
>
> http://linear.nortd.com
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=18661#18661
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-...@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
Follow us on Twitter! http://twitter.com/emperorlinux
+-----------------------------------------------------------------+
| Jeremy Moles | Phone: 1-888-651-6686 |
| Research & Development | in GA: (770)-612-1205 |
| EmperorLinux, Inc. | Fax: (770)-612-1210 |
| 900 Circle 75 Pkwy. | web: www.EmperorLinux.com |
| Suite 1380 | support: sup...@EmperorLinux.com |
| Atlanta, GA 30339 | email: jer...@EmperorLinux.com |
+-----------------------------------------------------------------+
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Because of the use of alpha and blending, osgText::Text implicitly
places text quad geometry in the transparent RenderBin. This is what you
typically want for any kind of translucent rendering -- unless you've
disabled depth and are using painter's algorithm, like you are doing.
You could turn depth test on and let depth handle the layering.
If you want to continue to use painter's algorithm, then you need to
force the Text into the opaque bin. See StateSet::setRenderBinDetails
for the various options; you should find a flag there that tells the
CullVisitor to not switch to another bin as it traverses the subgraph
during cull. You'd just need to set the render bin to the default bin,
and add this override flag, at some Group node above your Text. If you
do this correctly, the Text request to be placed in the transparent bin
will be ignored by the CullVisitor.
Paul Martz
Skew Matrix Software LLC
_http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
+1 303 859 9466
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
So, text is in the transparent RenderBin. Hmm that makes sense. I was
hoping there is simple explanation. I guess I could use depth testing. The
main problem I had with this was to come up with a fairly simple
algorithm to determine the z position. It would mean to layer the panels
close together so their size is not affected and still far enough away from
each other to not run into depth buffer resolution issues. An added
complication is that any panel may nest other panel/widgets on the fly
further making it harder to get the z distances right. I tried to roll my own
algo for this but it became it gathered too many uncertainties. So I opted
for the painter's algo.
Any ideas about doing the z position assignments with nested
panels/widgets?
Jeremy, osgWidget looks cool. I might end up using once I have a good
grip on it. Usually implementing my own is a way for me to learn.
Do you think it would be easy to adapt it for multi pointer/touch, doing
non-axis aligned windowing, and extending it for custom/experimental
widgets like two finger painting brushes?
Best,
stefan
------------------------
stefan hechenberger
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=18671#18671
Is there a reason you are using a perspective projection? This would not
be an issue with an orthographic projection.
> Any ideas about doing the z position assignments with nested
> panels/widgets?
The better way to go is to override the render bin so that the Text
stays in the same render bin as the rest of your geometry.
-Paul
So after some contemplation I am pretty sure I want to use the painter's
layering. The reason is that if for example I want to rotate a panel in
front of another one I don't want it to intersect with panals behind it. I
could use orthographic projection and dynamically change the z distances
based on bounding box but this just seems overkill if I could just disable
depth testing. I just want it 2.5D--looking 3D but layering 2D.
So I tried forcing the osgText in a the opaque render bin with the following
but without much luck.
mytextstateset->setRenderBinDetails(0, "RenderBin", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
Is there something else I need to do other than that? If I understand
correctly there are two default bins--"RenderBin" and "DepthSortedBin".
Former is sorted based on the binNum, latter based on the depth.
I guess what I don't understand is how does the binNum realate to the
other items in the default bin. I know they are rendered in the order they
are added to the scene. How to they relate to the binNum? Still a bit
confused.
Will read some more of the osg source code but let me know if you guy
know what I am doing wrong.
Thank you!
Cheers,
stefan
------------------------
stefan hechenberger
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=18733#18733
(For more information on RenderBins in general, search the mail list. I
almost hate to advise this, as the info is scattered all over the place,
and you'll need to do a lot of digging and reading. But it has been
discussed multiple times in the past, and I don't have the cycles to
regurgitate the salient info at the moment.)
Paul Martz
Skew Matrix Software LLC
_http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
+1 303 859 9466
Code:
PositionAttitudeTransform {
UniqueID PositionAttitudeTransform_15
nodeMask 0xffffffff
cullingActive TRUE
StateSet {
UniqueID StateSet_16
rendering_hint DEFAULT_BIN
renderBinMode INHERIT
GL_LIGHTING OFF
GL_DEPTH_TEST OFF
}
referenceFrame RELATIVE
position 0 0 0
attitude 0 0 0 1
scale 1 1 1
pivotPoint 0 0 0
num_children 1
Geode {
UniqueID Geode_17
UserData {
NodeCallback {
name "MyTextfield"
}
}
nodeMask 0xffffffff
cullingActive TRUE
StateSet {
UniqueID StateSet_18
rendering_hint DEFAULT_BIN
renderBinMode OVERRIDE
binNumber 1
binName RenderBin
}
num_drawables 1
}
}
The one drawable is the osgText. I am also :O new to writing osg files ... couldn't get it to write the drawable to file.
(Paul, I am still working on the minimal example)
Thank you!
Cheers,
stefan
------------------------
stefan hechenberger
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=18744#18744
I would put the StateSet with the override flag all the way at the
topmost Group in your UI, above all the Text and above all the other
geometry you're drawing with the text.
> The one drawable is the osgText. I am also :O new to writing osg
files ... couldn't get it to write the drawable to file.
You don't need to do anything special to get the Drawable output. The
fact that you are not getting the Drawable output would indicate that
OSG can't find the .osg plugin for osgText. Perhaps you have a bad install.
Paul Martz
Skew Matrix Software LLC
_http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
+1 303 859 9466
I would assume this is normal behavior. I think my main error was to assume that osg preserves the order of nodes when depth testing is switched off.
At the moment I have a unique z-value/render bin index on all of my nodes. It's a bit inelegant because I need to do reassign this z value to all my nodes whenever I add or remove nodes.
I think I will try to assign this z value only within each geode. I think this is possible because render bins are nested. Not sure yet how this will work then with my ray intersection--how I can determine the order my widgets are hit by the ray ... anyhow i will try to report back if I have a good solution for making this a bit more elegant.
Thanks for the help,
Thanks for the hint that I might be missing a plugin for writing out text drawables to the osg file,
/stefan
------------------------
stefan hechenberger
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=19077#19077