From 6f49d85f884af51b22b6aa2dcc9118a6a66df567 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 8 Sep 2010 11:02:39 +0000 Subject: [PATCH] Cleaned up debug info, and changed Text3D across to using GL_NORMALIZE instead of GL_RESCALE_NORMAL. --- src/osgPlugins/freetype/FreeTypeFont.cpp | 1 - src/osgText/Font.cpp | 4 --- src/osgText/Glyph.cpp | 10 +------ src/osgText/Text3D.cpp | 34 +++++++++++++++--------- src/osgUtil/SmoothingVisitor.cpp | 2 +- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index dd0f25b84..ce6512ab9 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -80,7 +80,6 @@ struct Char3DInfo if (!(_currentPrimitiveSet->empty()) && (*_verts)[(*_currentPrimitiveSet)[0]] == pos) { - OSG_NOTICE<<"Repeating first index "<<(*_currentPrimitiveSet)[0]<<", "<<(*_verts)[(*_currentPrimitiveSet)[0]]<<", pos="<push_back( (*_currentPrimitiveSet)[0] ); } else diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index b5abd6499..72d3a24ea 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -342,8 +342,6 @@ osg::Texture::FilterMode Font::getMagFilterHint() const Glyph* Font::getGlyph(const FontResolution& fontRes, unsigned int charcode) { - OSG_NOTICE<<"Font::getGlyph("< lock(_glyphMapMutex); FontSizeGlyphMap::iterator itr = _sizeGlyphMap.find(fontRes); @@ -366,8 +364,6 @@ Glyph* Font::getGlyph(const FontResolution& fontRes, unsigned int charcode) Glyph3D* Font::getGlyph3D(unsigned int charcode) { - OSG_NOTICE<<"Font::getGlyph3D("< lock(_glyphMapMutex); Glyph3DMap::iterator itr = _glyph3DMap.find(charcode); diff --git a/src/osgText/Glyph.cpp b/src/osgText/Glyph.cpp index 75b188be7..14e969644 100644 --- a/src/osgText/Glyph.cpp +++ b/src/osgText/Glyph.cpp @@ -498,8 +498,6 @@ void Glyph3D::setThreadSafeRefUnref(bool threadSafe) void Glyph3D::computeText3DGeometryData() { - OSG_NOTICE<<"Glyph3D::computeText3DGeometryData()"<getFontDepth(); bool smooth = true; @@ -510,7 +508,7 @@ void Glyph3D::computeText3DGeometryData() // create the normals if (smooth && textGeometry.valid()) { - osgUtil::SmoothingVisitor::smooth(*textGeometry); + osgUtil::SmoothingVisitor::smooth(*textGeometry, osg::DegreesToRadians(creaseAngle)); } _vertexArray = dynamic_cast(textGeometry->getVertexArray()); @@ -525,10 +523,4 @@ void Glyph3D::computeText3DGeometryData() else if (prim->getName()=="back") _backPrimitiveSetList.push_back(prim); else if (prim->getName()=="wall") _wallPrimitiveSetList.push_back(prim); } - - OSG_NOTICE<<" _frontPrimitiveSetList.size()=="<<_frontPrimitiveSetList.size()<end(); for (it = itLine->begin(); it!=end; ++it) { - osg::ref_ptr vertices = it->_glyph->getVertexArray(); + osg::Vec3Array* vertices = it->_glyph->getVertexArray(); - if (vertices->empty()) + if (!vertices || vertices->empty()) continue; //skip over spaces //pf.setVertexArray(it->_glyph->getVertexArray()->size(),&(it->_glyph->getVertexArray()->front())); @@ -69,7 +69,7 @@ void Text3D::accept(osg::PrimitiveFunctor& pf) const // now apply matrix to the glyphs. osg::ref_ptr transformedVertices = new osg::Vec3Array; osg::Matrix matrix = _autoTransformCache[0]._matrix;//osg::Matrix(); - matrix.postMultTranslate(matrix*it->_position); + matrix.preMultTranslate(it->_position); transformedVertices->reserve(vertices->size()); for (osg::Vec3Array::iterator itr=vertices->begin(); itr!=vertices->end(); itr++) { @@ -602,8 +602,7 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const renderInfo.getState()->disableAllVertexArrays(); #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) - glPushAttrib(GL_TRANSFORM_BIT); - glEnable(GL_RESCALE_NORMAL); + renderInfo.getState()->applyMode(GL_NORMALIZE, true); #endif switch(_renderMode) @@ -612,10 +611,6 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const case PER_GLYPH: default: renderPerGlyph(*renderInfo.getState()); break; } - - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) - glPopAttrib(); - #endif } @@ -640,11 +635,19 @@ void Text3D::renderPerGlyph(osg::State & state) const matrix.preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); state.applyModelViewMatrix(matrix); + state.lazyDisablingOfVertexAttributes(); + // ** apply the vertex array state.setVertexPointer(it->_glyph->getVertexArray()); +#if 1 + state.setNormalPointer(it->_glyph->getNormalArray()); +#else // ** render the front face of the glyph state.Normal(0.0f,0.0f,1.0f); +#endif + state.applyDisablingOfVertexAttributes(); + osg::Geometry::PrimitiveSetList & pslFront = it->_glyph->getFrontPrimitiveSetList(); for(osg::Geometry::PrimitiveSetList::const_iterator itr=pslFront.begin(), end = pslFront.end(); itr!=end; ++itr) @@ -653,17 +656,20 @@ void Text3D::renderPerGlyph(osg::State & state) const } // ** render the wall face of the glyph +#if 0 state.setNormalPointer(it->_glyph->getNormalArray()); +#endif osg::Geometry::PrimitiveSetList & pslWall = it->_glyph->getWallPrimitiveSetList(); for(osg::Geometry::PrimitiveSetList::const_iterator itr=pslWall.begin(), end=pslWall.end(); itr!=end; ++itr) { (*itr)->draw(state, false); } +#if 0 state.disableNormalPointer(); // ** render the back face of the glyph state.Normal(0.0f,0.0f,-1.0f); - +#endif osg::Geometry::PrimitiveSetList & pslBack = it->_glyph->getBackPrimitiveSetList(); for(osg::Geometry::PrimitiveSetList::const_iterator itr=pslBack.begin(), end=pslBack.end(); itr!=end; ++itr) { @@ -676,9 +682,10 @@ void Text3D::renderPerGlyph(osg::State & state) const void Text3D::renderPerFace(osg::State & state) const { osg::Matrix original_modelview = state.getModelViewMatrix(); - +#if 0 // ** render all front faces state.Normal(0.0f,0.0f,1.0f); +#endif TextRenderInfo::const_iterator itLine, endLine = _textRenderInfo.end(); for (itLine = _textRenderInfo.begin(); itLine!=endLine; ++itLine) @@ -692,6 +699,7 @@ void Text3D::renderPerFace(osg::State & state) const state.applyModelViewMatrix(matrix); state.setVertexPointer(it->_glyph->getVertexArray()); + state.setNormalPointer(it->_glyph->getNormalArray()); // ** render the front face of the glyph osg::Geometry::PrimitiveSetList & psl = it->_glyph->getFrontPrimitiveSetList(); @@ -724,11 +732,12 @@ void Text3D::renderPerFace(osg::State & state) const } } } +#if 0 state.disableNormalPointer(); // ** render all back face of the text state.Normal(0.0f,0.0f,-1.0f); - +#endif for (itLine = _textRenderInfo.begin(); itLine!=endLine; ++itLine) { // ** for each glyph in the line, do ... @@ -740,6 +749,7 @@ void Text3D::renderPerFace(osg::State & state) const state.applyModelViewMatrix(matrix); state.setVertexPointer(it->_glyph->getVertexArray()); + state.setNormalPointer(it->_glyph->getNormalArray()); // ** render the back face of the glyph osg::Geometry::PrimitiveSetList & psl = it->_glyph->getBackPrimitiveSetList(); diff --git a/src/osgUtil/SmoothingVisitor.cpp b/src/osgUtil/SmoothingVisitor.cpp index cb0c85f9c..742658917 100644 --- a/src/osgUtil/SmoothingVisitor.cpp +++ b/src/osgUtil/SmoothingVisitor.cpp @@ -614,7 +614,7 @@ struct FindSharpEdgesFunctor static void smooth_new(osg::Geometry& geom, double creaseAngle) { - OSG_NOTICE<<"smooth_new("<<&geom<<", "<(geom.getVertexArray()); if (!vertices) return;