Re: [osg-users] Text Class Sizing Issue!

2012-04-02 Thread David Glenn

robertosfield wrote:
 Hi David,
 
 On 29 March 2012 17:34, David Glenn  wrote:
 
  Well, since it not a submission per say. Here is the sample source code 
  that John wanted me to so you all.
  
 
 The program doesn't compile for me, I presume because it has been
 updated to compile against recent OSG versions.
 
 Might I suggest that one tries a recent version of the OSG to see if
 that problem still exists.
 
 Robert.
 ___
 osg-users mailing list
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
  --
 Post generated by Mail2Forum


Hi Robert! Right now we are stuck in OSG 2.8.1 because in the long development 
cycle we have here at or lab! 

We will move to the newest stable release after the end of this development 
cycle, or if it fills a requirement that we need bad enough to upgrade. So far, 
nether event has happened. 

I Know that John did visualy compare the code and he told me that it does 
address an issue that is current in the present OSG 3.0.1 as we know it, and 
that the exampe code should be compatable in most cases. However, becouse we 
are not current on or own development systems at this time, one of us will have 
to set up on another box for testing the code under the current stable OSG 
version. 
I can do this when we can devote the time and resorces to do so in the future. 

Oh! For what its worth, we test things using QT develoment GUI. It makes it 
much faster to build quick makefiles though I dont recall any QT stuff being 
used in this example. 

Also, we did not try this under Windows OS, I'm not sure of the behaver there! 
In fact, I'm not doing any Windows OS development with OSG at the moment!


David Glenn
---
D Glenn 3D Computer Graphics amp; Media Systems.
www.dglenn.com

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46747#46747





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Text Class Sizing Issue!

2012-03-30 Thread Robert Osfield
Hi David,

On 29 March 2012 17:34, David Glenn david.e.glenn@navy.mil wrote:
 Well, since it not a submission per say. Here is the sample source code that 
 John wanted me to so you all.

The program doesn't compile for me, I presume because it has been
updated to compile against recent OSG versions.

Might I suggest that one tries a recent version of the OSG to see if
that problem still exists.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Text Class Sizing Issue!

2012-03-29 Thread David Glenn
Well, since it not a submission per say. Here is the sample source code that 
John wanted me to so you all. 


Enjoy! Comments welcome!!
... 

Laters!

D Glenn


David Glenn
---
D Glenn 3D Computer Graphics amp; Media Systems.
www.dglenn.com

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46681#46681



// Suggested Revisions to osgText::Text class.
// John Markano 3/21/2012
//
// The code below includes suggested fixes for two problems in osgText::Text
// in the OpenSceneGraph 2.8.1 release:
// (1) Text in object coordinates may be rendered with the wrong size.
// If an application requests a font resolution that the font doesn't
// support, OpenSceneGraph uses the closest supported
// resolution. osgText::Text does not handle this situation properly.
// It uses the requested resolution in some calculations where the
// actual resolution is more appropriate.
// (2) Text in screen coordinates may not be scaled properly when a
// perspective projection is specified. In particular, the displayed text
// size may vary with the field of view when it should remain constant
// relative to the screen.
//
// A class TextImproved is defined below to correct these problems. This class
// inherits osgText::Text and replaces three virtual functions in the parent
// class:
// - computeLastCharacterOnLine (for the first issue above)
// - computeGlyphRepresentation (for the first issue above)
// - computePositions (for the second issue above)
//
// Each of these functions includes suggested changes to the original code.
// The original code is also left in place for comparison. The preprocessor
// variable USE_ORIGINAL_CODE can be set to a non-zero value to compile the
// original code instead of the improved code.
//
// An example program is also provided below to provide a before-and-after
// illustration of these changes. This example program splits the screen
// into four quadrants, where
// - The upper left quadrant contains black text generated by osgText::Text
//   with screen coordinates specified. It changes size with the field of
//   view, but its size should be fixed.
// - The upper right quadrant contains black text generated by the
//   TextImproved class defined below. This text should, and does, appear
//   with a constant height of around 100 pixels. (No reference scale is
//   provided.)
// - The lower left quadrant contains red text generated by osgText::Text
//   with object coordinates specified. It should be one unit tall, but
//   its actual size varies depending on what the active font supports.
//   In this example, it's less than half as tall as the requested size
//   because the default font resolution of 32 is much higher than the
//   supported (by DefaultFont) resolution of 12.
// - The lower right quadrant contains red text generated by the TextImproved
//   class. It displays closer to the correct height of one unit.
//
// The example program allows the user to increase or decrease the field
// of view using keystrokes. Type '+' to increase the field of view, or '-'
// to decrease the field of view. The camera position is fixed, so this
// is the only available viewing parameter control.
//
// This code was developed and tested using Red Hat Enterprise Linux 5.5,
// Qt 4.5.2 and OpenSceneGraph 2.8.1.
//
// This fix uses an uppercase E to find the available font size. This is
// a kludge that is inappropriate for many fonts. A suggested
// improvement would be to add a function to osgText::Font (and the
// DefaultFont subclass) to return the supported font resolution that is
// closest to the requested resolution.

#include osg/Camera
#include osg/Geode
#include osg/Geometry
#include osg/GL
#include osg/Group
#include osg/Math
#include osg/Matrix
#include osg/Notify
#include osg/Vec3
#include osg/Vec3d
#include osgGA/GUIEventHandler
#include osgText/Text
#include osgViewer/Viewer

#define USE_ORIGINAL_CODE (0)

using namespace osg;
using namespace osgText;

class TextImproved : public osgText::Text
{
protected:

String::iterator computeLastCharacterOnLine(osg::Vec2 cursor, String::iterator 
first,String::iterator last)
{
Font* activefont = getActiveFont();
if (!activefont) return last;

#if USE_ORIGINAL_CODE
float hr = _characterHeight/getFontHeight();
#else
// Use an upper case E to determine which font size is available
// near the requested font resolution.
// Then compute a scale factor to scale the font to the requested
// character height. Include a factor of 0.7 to allow lower
// case characters to drop below the base of capital letters.
Font::Glyph* glyphGenericUpper = activefont-getGlyph(_fontSize, 'E');
float hr = 0.7 * (glyphGenericUpper
? _characterHeight/glyphGenericUpper-t()
: _characterHeight/getFontHeight());
#endif
float wr = hr/_characterAspectRatio;

bool kerning = true;
unsigned int 

[osg-users] Text Class Sizing Issue!

2012-03-26 Thread David Glenn
Greetings!

One of the issues that were brought up by my partner out here John Markano was 
that when the text is set to screen mode, the tendency is that the text stays 
static in zoom in and then it will reach a point that it will start to shrink. 
My understanding is that is not supposed to happen. He handed me a test program 
that uses the existing way to play text and a new way - that doesn’t have that 
problem.

John has expressed to me that he would like me to share the code for this if 
you all like! I studied it over and it works for me!

... 

D Glenn


David Glenn
---
D Glenn 3D Computer Graphics amp; Media Systems.
www.dglenn.com

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46600#46600





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org