/* Copyright Robert Osfield, Licensed under the GPL * * Experimental base for refactor of Present3D * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char** argv) { osg::ArgumentParser arguments(&argc, argv); osgViewer::Viewer viewer(arguments); #if 0 typedef std::list< osg::ref_ptr > Scripts; Scripts scripts; osg::ref_ptr model = new osg::Group; std::string filename; while(arguments.read("--script",filename)) { osg::ref_ptr script = osgDB::readScriptFile(filename); if (script.valid()) scripts.push_back(script.get()); } // assgin script engine to scene graphs model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile("ScriptEngine.lua")); model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile("ScriptEngine.python")); model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile("ScriptEngine.js")); // assign scripts to scene graph for(Scripts::iterator itr = scripts.begin(); itr != scripts.end(); ++itr) { model->addUpdateCallback(new osg::ScriptNodeCallback(itr->get())); } std::string str; osg::ref_ptr luaScriptEngine = osgDB::readFile("ScriptEngine.lua"); if (luaScriptEngine.valid()) { while (arguments.read("--lua", str)) { osg::ref_ptr script = osgDB::readScriptFile(str); if (script.valid()) { luaScriptEngine->run(script.get()); } } } osg::ref_ptr v8ScriptEngine = osgDB::readFile("ScriptEngine.V8"); if (v8ScriptEngine.valid()) { while (arguments.read("--js",str)) { osg::ref_ptr script = osgDB::readScriptFile(str); if (script.valid()) { v8ScriptEngine->run(script.get()); } } } osg::ref_ptr pythonScriptEngine = osgDB::readFile("ScriptEngine.python"); if (pythonScriptEngine.valid()) { while (arguments.read("--python",str)) { osg::ref_ptr script = osgDB::readScriptFile(str); if (script.valid()) { pythonScriptEngine->run(script.get()); } } } return 0; #endif #if 1 osg::ref_ptr presentation = new osgPresentation::Presentation; osg::ref_ptr slide = new osgPresentation::Slide; osg::ref_ptr layer = new osgPresentation::Layer; osg::ref_ptr group = new osgPresentation::Group; osg::ref_ptr element = new osgPresentation::Element; osg::ref_ptr text = new osgPresentation::Text; osg::ref_ptr model = new osgPresentation::Model; osg::ref_ptr audio = new osgPresentation::Audio; osg::ref_ptr image = new osgPresentation::Image; osg::ref_ptr movie = new osgPresentation::Movie; osg::ref_ptr volume = new osgPresentation::Volume; presentation->addChild(slide.get()); slide->addChild(layer.get()); //layer->addChild(element.get()); //layer->addChild(group.get()); layer->addChild(element.get()); // layer->addChild(model.get()); layer->addChild(text.get()); layer->addChild(audio.get()); layer->addChild(image.get()); layer->addChild(movie.get()); layer->addChild(volume.get()); text->setProperty("string",std::string("This is a first test")); text->setProperty("font",std::string("times.ttf")); text->setProperty("character_size",2.2); text->setProperty("width",std::string("103.2")); model->setProperty("filename", std::string("dumptruck.osgt")); image->setProperty("filename", std::string("Images/lz.rgb")); image->setProperty("scale",0.75); movie->setProperty("filename", std::string("/home/robert/Data/Movie/big_buck_bunny_1080p_stereo.ogg")); movie->setProperty("scale",0.75); volume->setProperty("filename", std::string("/home/robert/Data/MaleVisibleHumanHead")); volume->setProperty("scale",0.75); volume->setProperty("technique",std::string("iso-surface")); presentation->setProperty("scale",1.0); #if 0 osgPresentation::PrintSupportedProperties psp(std::cout); presentation->accept(psp); osgPresentation::PrintProperties pp(std::cout); presentation->accept(pp); #endif osgPresentation::LoadAction load; presentation->accept( load ); viewer.setSceneData( presentation.get() ); osgDB::writeNodeFile(*presentation, "pres.osgt"); osgDB::ClassInterface pi; pi.getWhiteList()["osgPresentation::Presentation"]["filename"]=osgDB::BaseSerializer::RW_STRING; pi.getBlackList()["osgPresentation::Presentation"]["Children"]; pi.getBlackList()["osgPresentation::Presentation"]["UserDataContainer"]; pi.getBlackList()["osgPresentation::Presentation"]["UserData"]; pi.getBlackList()["osgPresentation::Presentation"]["CullCallback"]; pi.getBlackList()["osgPresentation::Presentation"]["ComputeBoundingSphereCallback"]; #if 0 osgDB::ObjectWrapperManager* owm = osgDB::Registry::instance()->getObjectWrapperManager(); if (owm) { const osgDB::ObjectWrapperManager::WrapperMap& wrapperMap = owm->getWrapperMap(); for(osgDB::ObjectWrapperManager::WrapperMap::const_iterator itr = wrapperMap.begin(); itr != wrapperMap.end(); ++itr) { osgDB::ObjectWrapper* ow = itr->second.get(); OSG_NOTICE<first<<", Domain="<getDomain()<<", Name="<getName()<getAssociates(); for(osgDB::StringList::const_iterator aitr = associates.begin(); aitr != associates.end(); ++aitr) { OSG_NOTICE<<" associate = "<<*aitr<writeSchema(properties, types); OSG_NOTICE<<" properties.size() = "<first<<"]"<second.getStringToValue(); for(osgDB::IntLookup::StringToValue::iterator sitr = stv.begin(); sitr != stv.end(); ++sitr) { OSG_NOTICE<<" "<first<<", "<second<setName("[this is a test]"); #if 0 if (pi.setProperty(presentation.get(), "Name", std::string("[this is new improved test]"))) { OSG_NOTICE<<"setProperty(presentation.get(), Name) succeeded."<setDataVariance(osg::Object::DYNAMIC); int variance = 1234; if (pi.getProperty(presentation.get(), "DataVariance", variance)) { OSG_NOTICE<<"getProperty(presentation.get(), DataVariance) succeeded, variance = "<setMatrix(osg::Matrixd::translate(osg::Vec3d(1.0,2.0,3.0))); // if (pi.setProperty(presentation.get(), "Matrix", osg::Matrixd::scale(1.0,2.0,2.0))) if (pi.setProperty(presentation.get(), "Matrix", osg::Matrixd::scale(2.0,2.0,2.0))) { OSG_NOTICE<<"setProperty(..,Matrix) succedded."< geometry = new osg::Geometry; osg::ref_ptr node = new osg::Node; osgDB::ClassInterface::PropertyMap properties; if (pi.getSupportedProperties(presentation.get(), properties, true)) { OSG_NOTICE<<"Have supported properites found."<first<<", "<second)<()<()<()<()<()<()<()<()<()<()<()< event = new osgGA::GUIEventAdapter; if (pi.getSupportedProperties(event.get(), properties, true)) { OSG_NOTICE<<"Have supported properites found."<first<<", "<second)<setProperty("position",pos); osg::Vec2f texcoord(0.5f,0.20f); presentation->setProperty("texcoord",texcoord); osg::ref_ptr luaScriptEngine = osgDB::readFile("ScriptEngine.lua"); if (luaScriptEngine.valid()) { presentation->getOrCreateUserDataContainer()->addUserObject(luaScriptEngine.get()); std::string str; while (arguments.read("--lua", str)) { osg::ref_ptr script = osgDB::readScriptFile(str); if (script.valid()) { presentation->addUpdateCallback(new osg::ScriptNodeCallback(script.get(),"update")); } } if (arguments.read("--test", str)) { osg::ref_ptr script = osgDB::readScriptFile(str); if (script.valid()) { osg::Parameters inputParameters; osg::Parameters outputParameters; inputParameters.push_back(new osg::StringValueObject("string","my very first string input")); inputParameters.push_back(new osg::DoubleValueObject("double",1.234)); inputParameters.push_back(new osg::MatrixfValueObject("matrix",osg::Matrixf())); osg::ref_ptr svo = new osg::MatrixdValueObject("return", osg::Matrixd()); outputParameters.push_back(svo.get()); if (luaScriptEngine->run(script.get(), "test", inputParameters, outputParameters)) { OSG_NOTICE<<"Successfully ran script : return value = "<getValue()< obj = pi.createObject("osgVolume::VolumeTile"); if (obj.valid()) { OSG_NOTICE<<"obj created "<getCompoundClassName()<first<<", "<second)<