From: <sv...@ww...> - 2004-12-19 06:54:38
|
Author: mkrose Date: 2004-12-18 22:54:29 -0800 (Sat, 18 Dec 2004) New Revision: 1412 Modified: trunk/CSP/CSPSim/CHANGES.current trunk/CSP/CSPSim/Source/Console.cpp trunk/CSP/CSPSim/Source/ConsoleCommands.cpp trunk/CSP/CSPSim/Source/ObjectModel.cpp trunk/CSP/CSPSim/Source/ScreenInfo.cpp trunk/CSP/CSPSim/Source/ScreenInfoManager.cpp trunk/CSP/CSPSim/Source/SmokeEffects.cpp trunk/CSP/CSPSim/Source/VirtualScene.cpp Log: Minor patches to make CSPSim work with OSG 0.9.8. This changes are not backwards compatible with OSG 0.9.6. To continue using the older version, modify the build file to define OSG_096 (e.g. /DOSG_096 with MSVC on the command line, or -DOSG_096 for gcc). If you upgrade to OSG 098, be sure to eliminate all traces of the older version. Also for SCons builds, run 'scons -c all; scons config' before rebuilding. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1412 Modified: trunk/CSP/CSPSim/CHANGES.current =================================================================== --- trunk/CSP/CSPSim/CHANGES.current 2004-12-18 11:48:11 UTC (rev 1411) +++ trunk/CSP/CSPSim/CHANGES.current 2004-12-19 06:54:29 UTC (rev 1412) @@ -2,6 +2,14 @@ =========================== 2004-12-18: onsight + * Minor patches to make CSPSim work with OSG 0.9.8. This changes are + not backwards compatible with OSG 0.9.6. To continue using the older + version, modify the build file to define OSG_096 (e.g. /DOSG_096 with + MSVC on the command line, or -DOSG_096 for gcc). If you upgrade to + OSG 098, be sure to eliminate all traces of the older version. Also + for SCons builds, run 'scons -c all; scons config' before rebuilding. + +2004-12-18: onsight * Add hooks in GameScreen to catch player join/quit events and display a message on the screen. Modified: trunk/CSP/CSPSim/Source/Console.cpp =================================================================== --- trunk/CSP/CSPSim/Source/Console.cpp 2004-12-18 11:48:11 UTC (rev 1411) +++ trunk/CSP/CSPSim/Source/Console.cpp 2004-12-19 06:54:29 UTC (rev 1412) @@ -71,6 +71,7 @@ Console::Console(const Console ©, const osg::CopyOp ©op) : osg::Geode(copy, copyop), + std::basic_streambuf<char>(), _text(static_cast<osgText::Text *>(copyop(copy._text.get()))), _cursor(static_cast<osgText::Text *>(copyop(copy._cursor.get()))), _token(static_cast<osgText::Text *>(copyop(copy._token.get()))), @@ -108,7 +109,11 @@ void Console::_setFont(osg::ref_ptr<osgText::Text> &text, std::string const &font, int size) { text->setFont(font); +#ifdef OSG096 text->setFontSize(size, size); +#else + text->setFontResolution(size, size); +#endif // OSG096 text->setCharacterSize(size, 1.0); text->setColor(osg::Vec4(1, 1, 1, 1)); text->setAlignment(osgText::Text::LEFT_TOP); Modified: trunk/CSP/CSPSim/Source/ConsoleCommands.cpp =================================================================== --- trunk/CSP/CSPSim/Source/ConsoleCommands.cpp 2004-12-18 11:48:11 UTC (rev 1411) +++ trunk/CSP/CSPSim/Source/ConsoleCommands.cpp 2004-12-19 06:54:29 UTC (rev 1412) @@ -56,7 +56,11 @@ setMatrix(osg::Matrix::ortho2D(0, ScreenWidth, 0, ScreenHeight)); m_ModelViewAbs = new osg::MatrixTransform; +#ifdef OSG096 m_ModelViewAbs->setReferenceFrame(osg::Transform::RELATIVE_TO_ABSOLUTE); +#else + m_ModelViewAbs->setReferenceFrame(osg::Transform::ABSOLUTE_RF); +#endif // OSG096 m_ModelViewAbs->setMatrix(osg::Matrix::identity()); addChild(m_ModelViewAbs.get()); @@ -175,13 +179,11 @@ if (result.size() > 0) { result = result + "\n"; } - std::cout << "print\n"; m_Console->print(result); } m_Command = ""; update(); setCursor(0); - std::cout << "done\n"; return true; } return false; Modified: trunk/CSP/CSPSim/Source/ObjectModel.cpp =================================================================== --- trunk/CSP/CSPSim/Source/ObjectModel.cpp 2004-12-18 11:48:11 UTC (rev 1411) +++ trunk/CSP/CSPSim/Source/ObjectModel.cpp 2004-12-19 06:54:29 UTC (rev 1412) @@ -35,7 +35,11 @@ #include <osgDB/ReadFile> #include <osgFX/SpecularHighlights> #include <osgUtil/SmoothingVisitor> +#ifdef OSG096 #include <osgUtil/DisplayListVisitor> +#else +#include <osgUtil/GLObjectsVisitor> +#endif #include <osgUtil/Optimizer> #include <osg/CullFace> #include <osg/NodeVisitor> @@ -193,7 +197,12 @@ osg::StateSet::TextureAttributeList& attr = set->getTextureAttributeList(); osg::StateSet::TextureAttributeList::iterator i; for (i = attr.begin(); i != attr.end(); i++) { +#ifdef OSG096 osg::StateSet::AttributeList::iterator tex = i->find(osg::StateAttribute::TEXTURE); +#else + // TODO don't we need to consider other members within the TEXTURE group? + osg::StateSet::AttributeList::iterator tex = i->find(osg::StateAttribute::TypeMemberPair(osg::StateAttribute::TEXTURE, 0)); +#endif // OSG096 if (tex != i->end()) { osg::Texture* texture = dynamic_cast<osg::Texture*>(tex->second.first.get()); if (texture) { @@ -414,11 +423,20 @@ addContactMarkers(); osg::ref_ptr<osg::State> state = new osg::State; + +#ifdef OSG096 osgUtil::DisplayListVisitor dlv(osgUtil::DisplayListVisitor::COMPILE_DISPLAY_LISTS); dlv.setState(state.get()); dlv.setNodeMaskOverride(0xffffffff); m_Model->accept(dlv); m_DebugMarkers->accept(dlv); +#else + osgUtil::GLObjectsVisitor ov; + ov.setState(state.get()); + ov.setNodeMaskOverride(0xffffffff); + m_Model->accept(ov); + m_DebugMarkers->accept(ov); +#endif // OSG096 // XXX: there is a really weird bug on vs with the optimizer: // 1) it rarely appears in the release built (never when called from this exact line) @@ -541,7 +559,11 @@ m_Label = new osgText::Text(); m_Label->setFont("screeninfo.ttf"); +#ifdef OSG096 m_Label->setFontSize(16, 16); +#else + m_Label->setFontResolution(16, 16); +#endif // OSG096 m_Label->setColor(osg::Vec4(0.3f, 0.4f, 1.0f, 1.0f)); m_Label->setCharacterSize(100.0, 1.0); m_Label->setPosition(osg::Vec3(6, 0, 0)); @@ -554,7 +576,11 @@ label->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); //setMatrix(osg::Matrix::ortho2D(0,ScreenWidth,0,ScreenHeight)); osg::MatrixTransform *m_modelview_abs = new osg::MatrixTransform; +#ifdef OSG096 m_modelview_abs->setReferenceFrame(osg::Transform::RELATIVE_TO_ABSOLUTE); +#else + m_modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF); +#endif // OSG096 m_modelview_abs->setMatrix(osg::Matrix::identity()); m_modelview_abs->addChild(label); @@ -566,6 +592,7 @@ } SceneModel::~SceneModel() { + // FIXME shouldn't we be removing the copy? osg::Node *model_node = m_Model->getModel().get(); assert(model_node); m_Transform->removeChild(model_node); Modified: trunk/CSP/CSPSim/Source/ScreenInfo.cpp =================================================================== --- trunk/CSP/CSPSim/Source/ScreenInfo.cpp 2004-12-18 11:48:11 UTC (rev 1411) +++ trunk/CSP/CSPSim/Source/ScreenInfo.cpp 2004-12-19 06:54:29 UTC (rev 1412) @@ -93,7 +93,11 @@ osgText::Text *ScreenInfo::makeText(float pos_x, float pos_y, std::string const &string_text) { osgText::Text *text = new osgText::Text; text->setFont(m_TTFPath); +#ifdef OSG096 text->setFontSize(m_FontSize, m_FontSize); +#else + text->setFontResolution(m_FontSize, m_FontSize); +#endif // OSG096 text->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); text->setCharacterSize(m_CharacterSize, 1.0); text->setPosition(osg::Vec3(pos_x, pos_y, 0)); Modified: trunk/CSP/CSPSim/Source/ScreenInfoManager.cpp =================================================================== --- trunk/CSP/CSPSim/Source/ScreenInfoManager.cpp 2004-12-18 11:48:11 UTC (rev 1411) +++ trunk/CSP/CSPSim/Source/ScreenInfoManager.cpp 2004-12-19 06:54:29 UTC (rev 1412) @@ -54,7 +54,11 @@ setMatrix(osg::Matrix::ortho2D(0,ScreenWidth,0,ScreenHeight)); m_modelview_abs = new osg::MatrixTransform; +#ifdef OSG096 m_modelview_abs->setReferenceFrame(osg::Transform::RELATIVE_TO_ABSOLUTE); +#else + m_modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF); +#endif // OSG096 m_modelview_abs->setMatrix(osg::Matrix::identity()); set2dScene(m_modelview_abs,ScreenWidth,ScreenHeight); Modified: trunk/CSP/CSPSim/Source/SmokeEffects.cpp =================================================================== --- trunk/CSP/CSPSim/Source/SmokeEffects.cpp 2004-12-18 11:48:11 UTC (rev 1411) +++ trunk/CSP/CSPSim/Source/SmokeEffects.cpp 2004-12-19 06:54:29 UTC (rev 1412) @@ -140,7 +140,11 @@ P->setVelocity(simdata::toOSG(wind) + push.get_random()); place += d_place; wind += d_wind; +#ifdef OSG096 if (getReferenceFrame() == RELATIVE_TO_PARENTS) { +#else + if (getReferenceFrame() == RELATIVE_RF) { +#endif // OSG096 P->transformPositionVelocity(getLocalToWorldMatrix()); //P->transformPositionVelocity(getWorldToLocalMatrix()); } Modified: trunk/CSP/CSPSim/Source/VirtualScene.cpp =================================================================== --- trunk/CSP/CSPSim/Source/VirtualScene.cpp 2004-12-18 11:48:11 UTC (rev 1411) +++ trunk/CSP/CSPSim/Source/VirtualScene.cpp 2004-12-19 06:54:29 UTC (rev 1412) @@ -50,7 +50,6 @@ #include <osgUtil/SceneView> #include <osgUtil/Optimizer> #include <osgUtil/CullVisitor> -#include <osgUtil/DisplayListVisitor> #include <osg/Material> #include <osg/BlendFunc> |