[osg-users] Problem with 2D and 3D text in the same scene

0 views
Skip to first unread message

frank...@jhmi.edu

unread,
Feb 18, 2009, 5:56:03 PM2/18/09
to osg-...@lists.openscenegraph.org
Greetings,

I am experiencing problems rendering osgText::Text and osgText::Text3D
in the same scene. I have boiled it down to a nice bite-size chunk of
code which I have attached. I am running version 2.8.

Is this a bug?

Frank

Main.cpp

David Callu

unread,
Feb 19, 2009, 5:52:40 AM2/19/09
to OpenSceneGraph Users
Hi Frank,

This is a bug.
I take a look.

more in next episode.
Cheer

David Callu

2009/2/18 <frank...@jhmi.edu>
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


David Callu

unread,
Feb 19, 2009, 8:08:00 AM2/19/09
to OpenSceneGraph Users
Hi Frank

Problem:
     osgText::Text and osgText::Text3D use the same font file.
     The first really load the file and obtain an osgText::Font object,
     the second use the cache created during the first load of the
     font file, and so obtain an osgText::Font object instead of
     osgText::Font3D object. To obtain an osgText::Font3D object,
     osgText::Text3D call osgDB::readObjectFile(...) with an option
     to specify the plugin we want an osgText::Font3D instead of
     osgText::Font.

Generalised Problem:
    In osgDB::Registry, loaded file cache is referenced by the name
    of this file, so if I load a file with some options, and the cache
    already contain object for this filename, I obtain an object
    potentially not loaded with my options.


Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.


Text3D case:
    Delegate the cache coherence of font file in osgText to the user
    is not a good idea. So to fix this I think to 2 solution:
        - never use the cache when load a font for a Text3D. Just because
          to load a Font3D, we use option in osgDB::readObjectFile()
        - move osgText::Font3D implementation in osgText::Font,
          suffix ex-Font3D method with "3D" in osgText::Font
          (so osgText::Font3D::getGlyph() become osgText::Font::getGlyph3D() )
          And so Text and Text3D use the same osgText::Font object which contain
          2D and 3D glyph.


Thought, Robert, Other ?

David Callu


2009/2/19 David Callu <led...@gmail.com>

Robert Osfield

unread,
Feb 19, 2009, 8:28:59 AM2/19/09
to OpenSceneGraph Users
Hi David,

Thanks for looking into this problem.

On Thu, Feb 19, 2009 at 1:08 PM, David Callu <led...@gmail.com> wrote:
> Text3D case:
> Delegate the cache coherence of font file in osgText to the user
> is not a good idea. So to fix this I think to 2 solution:
> - never use the cache when load a font for a Text3D. Just because
> to load a Font3D, we use option in osgDB::readObjectFile()
> - move osgText::Font3D implementation in osgText::Font,
> suffix ex-Font3D method with "3D" in osgText::Font
> (so osgText::Font3D::getGlyph() become osgText::Font::getGlyph3D()
> )
> And so Text and Text3D use the same osgText::Font object which
> contain
> 2D and 3D glyph.

I think merging the osgText::Font and Fon3D implementations would be
the cleanest approach.

Another, more hacky approach would be to postfix the font file name by
.Text3D or something similar and then have the freetype plugin return
Font3D when it detects this.

Robert.

Robert.

David Callu

unread,
Feb 19, 2009, 11:58:59 AM2/19/09
to OpenSceneGraph Users
Hi Robert


I think merging the osgText::Font and Font3D implementations would be
the cleanest approach.
I think too ... but ...
 

Another, more hacky approach would be to postfix the font file name by
.Text3D or something similar and then have the freetype plugin return
Font3D when it detects this.

This solution is really smart, it not break the scalability of osgText.
I don't know which use can be done with a font except 2D or 3D glyph,
but this keep the door open to other thing.

osgText::Text3D have to ensure that name of font file is ended by .Text3D and
font file cache coherence is not delegate to the user.

I have try this solution and work fine.

I prepare a submission if you prefer the second solution.
Or implement the first one otherwise.

As you want.

David


Reply all
Reply to author
Forward
0 new messages