From f2809ab63b92c9ec7d17c301dafaf2760ec9ded4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 23 May 2015 06:53:26 +0200 Subject: [PATCH] Delete nifosgtest again --- CMakeLists.txt | 2 - apps/nifosgtest/CMakeLists.txt | 7 -- apps/nifosgtest/test.cpp | 166 --------------------------------- 3 files changed, 175 deletions(-) delete mode 100644 apps/nifosgtest/CMakeLists.txt delete mode 100644 apps/nifosgtest/test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d0515a1fb..4b6ede3dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -473,8 +473,6 @@ if (BUILD_NIFTEST) endif(BUILD_NIFTEST) # Apps and tools -add_subdirectory( apps/nifosgtest ) - if (BUILD_OPENMW) add_subdirectory( apps/openmw ) endif() diff --git a/apps/nifosgtest/CMakeLists.txt b/apps/nifosgtest/CMakeLists.txt deleted file mode 100644 index 265577d98..000000000 --- a/apps/nifosgtest/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -set (FILES - test.cpp -) - -add_executable (test ${FILES}) - -target_link_libraries (test ${OPENSCENEGRAPH_LIBRARIES} "components") diff --git a/apps/nifosgtest/test.cpp b/apps/nifosgtest/test.cpp deleted file mode 100644 index 6d0586775..000000000 --- a/apps/nifosgtest/test.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -#include - -#include - -// EventHandler to toggle wireframe when 'w' key is pressed -class WireframeKeyHandler : public osgGA::GUIEventHandler -{ -public: - WireframeKeyHandler(osg::Node* node) - : mWireframe(false) - , mNode(node) - { - - } - - virtual bool handle(const osgGA::GUIEventAdapter& adapter,osgGA::GUIActionAdapter& action) - { - switch (adapter.getEventType()) - { - case osgGA::GUIEventAdapter::KEYDOWN: - if (adapter.getKey() == osgGA::GUIEventAdapter::KEY_W) - { - mWireframe = !mWireframe; - osg::PolygonMode* mode = new osg::PolygonMode; - mode->setMode(osg::PolygonMode::FRONT_AND_BACK, - mWireframe ? osg::PolygonMode::LINE : osg::PolygonMode::FILL); - - // Create a new stateset instead of changing the old one, this alleviates the need to set - // the StateSet to DYNAMIC DataVariance, which would have a performance impact. - - osg::StateSet* stateset = new osg::StateSet; - stateset->setAttributeAndModes(mode, osg::StateAttribute::ON); - stateset->setMode(GL_CULL_FACE, mWireframe ? osg::StateAttribute::OFF - : osg::StateAttribute::ON); - - mNode->setStateSet(stateset); - - return true; - } - default: - break; - } - return false; - } - -private: - bool mWireframe; - osg::Node* mNode; -}; - -int main(int argc, char** argv) -{ - if (argc < 2) - { - std::cout << "Usage: " << argv[0] << " " << std::endl; - return 1; - } - - Files::ConfigurationManager cfgMgr; - boost::program_options::options_description desc(""); - desc.add_options() - ("data", boost::program_options::value()->default_value(Files::PathContainer(), "data")->multitoken()->composing()) - ("fs-strict", boost::program_options::value()->implicit_value(true)->default_value(false)) - ("fallback-archive", boost::program_options::value >()-> - default_value(std::vector(), "fallback-archive")->multitoken()); - - boost::program_options::variables_map variables; - cfgMgr.readConfiguration(variables, desc); - - std::vector archives = variables["fallback-archive"].as >(); - bool fsStrict = variables["fs-strict"].as(); - Files::PathContainer dataDirs; - if (!variables["data"].empty()) { - dataDirs = Files::PathContainer(variables["data"].as()); - } - - cfgMgr.processPaths(dataDirs); - - VFS::Manager resourceMgr (fsStrict); - Files::Collections collections (dataDirs, !fsStrict); - - for (std::vector::const_iterator it = archives.begin(); it != archives.end(); ++it) - { - std::string filepath = collections.getPath(*it).string(); - resourceMgr.addArchive(new VFS::BsaArchive(filepath)); - } - for (Files::PathContainer::const_iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) - { - resourceMgr.addArchive(new VFS::FileSystemArchive(it->string())); - } - - resourceMgr.buildIndex(); - - Nif::NIFFilePtr nif(new Nif::NIFFile(resourceMgr.get(argv[1]), std::string(argv[1]))); - - // For NiStencilProperty - osg::DisplaySettings::instance()->setMinimumNumStencilBits(8); - - osgViewer::Viewer viewer; - - osg::ref_ptr root(new osg::Group()); - root->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON); - // To prevent lighting issues with scaled meshes - root->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); - - - //osgDB::writeNodeFile(*newNode, "out.osg"); - osg::Group* newNode = new osg::Group; - NifOsg::Loader loader; - Resource::TextureManager texMgr(&resourceMgr); - newNode->addChild(loader.load(nif, &texMgr)); - - SceneUtil::AssignControllerSourcesVisitor visitor(boost::shared_ptr(new SceneUtil::FrameTimeSource)); - newNode->accept(visitor); - - osg::PositionAttitudeTransform* trans = new osg::PositionAttitudeTransform; - root->addChild(trans); - - for (int x=0; x<1;++x) - { - //root->addChild(newNode); - trans->addChild(newNode); - } - - viewer.setSceneData(root); - - viewer.setUpViewInWindow(0, 0, 800, 600); - viewer.realize(); - viewer.setCameraManipulator(new osgGA::TrackballManipulator()); - viewer.addEventHandler(new WireframeKeyHandler(root)); - - // Mask to separate cull visitors from update visitors - viewer.getCamera()->setCullMask(~(0x1)); - - viewer.addEventHandler(new osgViewer::StatsHandler); - - while (!viewer.done()) - { - //trans->setAttitude(osg::Quat(viewer.getFrameStamp()->getSimulationTime()*5, osg::Vec3f(0,0,1))); - - viewer.frame(); - } - - return 0; -}