From: <sv...@ww...> - 2005-11-12 08:54:20
|
Author: mkrose Date: 2005-11-12 00:54:12 -0800 (Sat, 12 Nov 2005) New Revision: 1665 Modified: trunk/CSP/CSPSim/Include/VirtualScene.h trunk/CSP/CSPSim/Source/Animation.cpp trunk/CSP/CSPSim/Source/F16/SpecialFonts.h trunk/CSP/CSPSim/Source/Sky.cpp trunk/CSP/CSPSim/Source/Theater/ElevationCorrection.cpp trunk/CSP/CSPSim/Source/VirtualScene.cpp Log: Patch CSPSim to work with osg 0.9.9 while maintaining backwards compatability with 0.9.8. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1665 Modified: trunk/CSP/CSPSim/Include/VirtualScene.h =================================================================== --- trunk/CSP/CSPSim/Include/VirtualScene.h 2005-11-12 08:54:05 UTC (rev 1664) +++ trunk/CSP/CSPSim/Include/VirtualScene.h 2005-11-12 08:54:12 UTC (rev 1665) @@ -169,7 +169,6 @@ int _getFeatureTileIndex(simdata::Ref<FeatureGroup> feature) const; void _updateOrigin(simdata::Vector3 const &origin); - std::string logLookAt(); osgUtil::SceneView *makeSceneView(); Modified: trunk/CSP/CSPSim/Source/Animation.cpp =================================================================== --- trunk/CSP/CSPSim/Source/Animation.cpp 2005-11-12 08:54:05 UTC (rev 1664) +++ trunk/CSP/CSPSim/Source/Animation.cpp 2005-11-12 08:54:12 UTC (rev 1665) @@ -31,6 +31,7 @@ #include <osg/PositionAttitudeTransform> #include <osg/ref_ptr> #include <osg/Switch> +#include <osg/Version> #include <SimCore/Util/Log.h> #include <SimData/Enum.h> @@ -40,6 +41,9 @@ #include <SimData/Vector3.h> #include <SimData/ObjectInterface.h> +#ifndef OSG_VERSION_MAJOR +#define OSG_OLD_CONTROL_POINT_INTERFACE +#endif SIMDATA_XML_BEGIN(Animation) SIMDATA_DEF("model_id", m_NodeLabel, true) @@ -68,13 +72,24 @@ osg::Matrix matrix; _cp.getInverse(matrix); pat.setPosition(matrix.getTrans()); +#ifdef OSG_OLD_CONTROL_POINT_INTERFACE pat.setAttitude(_cp._rotation.inverse()); pat.setScale(osg::Vec3(1.0f/_cp._scale.x(),1.0f/_cp._scale.y(),1.0f/_cp._scale.z())); +#else + pat.setAttitude(_cp.getRotation().inverse()); + pat.setScale(osg::Vec3(1.0f/_cp.getScale().x(),1.0f/_cp.getScale().y(),1.0f/_cp.getScale().z())); +#endif pat.setPivotPoint(_pivotPoint); } else { +#ifdef OSG_OLD_CONTROL_POINT_INTERFACE pat.setPosition(_cp._position); pat.setAttitude(_cp._rotation); pat.setScale(_cp._scale); +#else + pat.setPosition(_cp.getPosition()); + pat.setAttitude(_cp.getRotation()); + pat.setScale(_cp.getScale()); +#endif pat.setPivotPoint(_pivotPoint); } } Modified: trunk/CSP/CSPSim/Source/F16/SpecialFonts.h =================================================================== --- trunk/CSP/CSPSim/Source/F16/SpecialFonts.h 2005-11-12 08:54:05 UTC (rev 1664) +++ trunk/CSP/CSPSim/Source/F16/SpecialFonts.h 2005-11-12 08:54:12 UTC (rev 1665) @@ -31,10 +31,15 @@ #ifndef __SPECIAL_FONTS__ #define __SPECIAL_FONTS__ +#include <osg/Version> #include <osgText/Font> #include <string> #include <algorithm> +// first defined in osg 0.9.9 +#ifndef OSG_VERSION_MAJOR +#define OSG_OLD_FONT_INTERFACE +#endif /** A specialized font for rendering normal and reverse video text. Character * codes 128-255 are reverse video representations of the glyphs for glyphs @@ -151,7 +156,11 @@ reverse->setVerticalAdvance(reference->getVerticalAdvance()); // finally add the new glyph so we don't repeat all this work! +#ifdef OSG_OLD_FONT_INTERFACE addGlyph(getWidth(), getHeight(), charcode, reverse); +#else + addGlyph(getFontWidth(), getFontHeight(), charcode, reverse); +#endif return reverse; } else { return _implementation->getGlyph(charcode); @@ -200,14 +209,22 @@ unsigned int original_height = _height; unsigned int new_width = static_cast<unsigned int>(_width * m_Scale); unsigned int new_height = static_cast<unsigned int>(_height * m_Scale); +#ifdef OSG_OLD_FONT_INTERFACE setSize(new_width, new_height); +#else + setFontResolution(new_width, new_height); +#endif Glyph *scaled_glyph = _implementation->getGlyph(normal_code); if (m_VCenter) { osg::Vec2 hbearing = scaled_glyph->getHorizontalBearing(); hbearing.y() += 0.5f * (normal_glyph->t() - scaled_glyph->t()); scaled_glyph->setHorizontalBearing(hbearing); } +#ifdef OSG_OLD_FONT_INTERFACE setSize(original_width, original_height); +#else + setFontResolution(original_width, original_height); +#endif _sizeGlyphMap[SizePair(_width, _height)][charcode] = scaled_glyph; return scaled_glyph; } else { Modified: trunk/CSP/CSPSim/Source/Sky.cpp =================================================================== --- trunk/CSP/CSPSim/Source/Sky.cpp 2005-11-12 08:54:05 UTC (rev 1664) +++ trunk/CSP/CSPSim/Source/Sky.cpp 2005-11-12 08:54:12 UTC (rev 1665) @@ -56,7 +56,11 @@ #include <osg/AlphaFunc> #include <osg/Billboard> #include <osg/MatrixTransform> +#include <osg/Version> +#ifndef OSG_VERSION_MAJOR +# define OSG_OLD_COMPUTE_BOUND +#endif using namespace osg; using simdata::toRadians; @@ -241,11 +245,20 @@ StarSystem(const StarSystem ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY): osg::Drawable(copy, copyop) { } +#ifdef OSG_OLD_COMPUTE_BOUND bool computeBound() const { _bbox._min = Vec3(-1000100.0, -1000100.0, 0.0); _bbox._max = Vec3( 1000100.0, 1000100.0, 1000100.0); return true; } +#else + BoundingBox computeBound() const { + BoundingBox bbox; + bbox._min = Vec3(-1000100.0, -1000100.0, 0.0); + bbox._max = Vec3( 1000100.0, 1000100.0, 1000100.0); + return bbox; + } +#endif //const bool computeBound() const { return true; } virtual void drawImplementation(osg::State &/*state*/) const { Modified: trunk/CSP/CSPSim/Source/Theater/ElevationCorrection.cpp =================================================================== --- trunk/CSP/CSPSim/Source/Theater/ElevationCorrection.cpp 2005-11-12 08:54:05 UTC (rev 1664) +++ trunk/CSP/CSPSim/Source/Theater/ElevationCorrection.cpp 2005-11-12 08:54:12 UTC (rev 1665) @@ -26,8 +26,14 @@ #include "Theater/ElevationCorrection.h" #include "TerrainObject.h" #include <SimCore/Util/Log.h> +#include <osg/Version> +// stream ops for vec3/matrix were moved to io_utils in osg 0.9.9 +#ifdef OSG_VERSION_MAJOR +#include <osg/io_utils> +#endif + ElevationCorrection::ElevationCorrection(TerrainObject *terrain, float x, float y, float angle): LayoutTransform(x, y, angle) { m_Terrain = terrain; } Modified: trunk/CSP/CSPSim/Source/VirtualScene.cpp =================================================================== --- trunk/CSP/CSPSim/Source/VirtualScene.cpp 2005-11-12 08:54:05 UTC (rev 1664) +++ trunk/CSP/CSPSim/Source/VirtualScene.cpp 2005-11-12 08:54:12 UTC (rev 1665) @@ -42,10 +42,11 @@ #include <SimData/FileUtility.h> #include <SimData/osg.h> -#include <osg/Fog> +#include <osg/AlphaFunc> #include <osg/BlendColor> #include <osg/BlendFunc> #include <osg/ColorMatrix> +#include <osg/Fog> #include <osg/LightSource> #include <osg/Material> #include <osg/Node> @@ -53,6 +54,7 @@ #include <osg/PolygonMode> #include <osg/PositionAttitudeTransform> #include <osg/StateSet> +#include <osg/TexEnv> #include <osgUtil/CullVisitor> #include <osgUtil/IntersectVisitor> #include <osgUtil/Optimizer> @@ -537,17 +539,6 @@ void VirtualScene::setCameraNode(osg::Node *) { } -std::string VirtualScene::logLookAt() { - osg::Vec3 _camEyePos; - osg::Vec3 _camLookPos; - osg::Vec3 _camUpVec; - m_FarView->getViewMatrixAsLookAt(_camEyePos, _camLookPos, _camUpVec); - - std::ostringstream os("VirtualScene::_setLookAt - eye: "); - os << _camEyePos << ", look: " << _camLookPos << ", up: " << _camUpVec; - return os.str(); -} - void VirtualScene::_setLookAt(const simdata::Vector3& eyePos, const simdata::Vector3& lookPos, const simdata::Vector3& upVec) { CSP_LOG(APP, DEBUG, "VirtualScene::setLookAt - eye: " << eyePos << ", look: " << lookPos << ", up: " << upVec); @@ -568,8 +559,6 @@ simdata::Vector3 tpos = m_Terrain->getOrigin(eyePos) - eyePos; m_TerrainGroup->setPosition(simdata::toOSG(tpos)); } - - CSP_LOG(APP, DEBUG, logLookAt()); } // TODO externalize a couple fixed parameters |