2013-08-08 01:08:38 +08:00
|
|
|
/* Copyright Robert Osfield, Licensed under the GPL
|
|
|
|
*
|
|
|
|
* Experimental base for refactor of Present3D
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <osg/Geode>
|
|
|
|
#include <osg/Geometry>
|
2013-08-10 00:51:06 +08:00
|
|
|
#include <osg/ScriptEngine>
|
|
|
|
#include <osg/UserDataContainer>
|
2013-08-08 01:08:38 +08:00
|
|
|
|
2013-08-22 15:49:22 +08:00
|
|
|
#include <osgPresentation/Presentation>
|
|
|
|
#include <osgPresentation/Slide>
|
|
|
|
#include <osgPresentation/Layer>
|
|
|
|
#include <osgPresentation/Element>
|
2013-09-02 16:29:09 +08:00
|
|
|
#include <osgPresentation/Model>
|
|
|
|
#include <osgPresentation/Volume>
|
|
|
|
#include <osgPresentation/Image>
|
|
|
|
#include <osgPresentation/Movie>
|
|
|
|
#include <osgPresentation/Text>
|
|
|
|
#include <osgPresentation/Audio>
|
2013-08-22 15:49:22 +08:00
|
|
|
|
2013-08-08 01:08:38 +08:00
|
|
|
#include <osgDB/ReadFile>
|
2013-08-22 15:49:22 +08:00
|
|
|
#include <osgDB/WriteFile>
|
2013-08-08 01:08:38 +08:00
|
|
|
#include <osgDB/FileUtils>
|
|
|
|
|
|
|
|
#include <osgGA/TrackballManipulator>
|
|
|
|
#include <osgViewer/Viewer>
|
|
|
|
|
2013-09-20 00:19:32 +08:00
|
|
|
#include <osg/io_utils>
|
|
|
|
|
2014-07-14 22:09:08 +08:00
|
|
|
#include<osgDB/ClassInterface>
|
2013-08-08 01:08:38 +08:00
|
|
|
|
2013-08-10 00:51:06 +08:00
|
|
|
int main(int argc, char** argv)
|
2013-08-08 01:08:38 +08:00
|
|
|
{
|
2013-08-10 00:51:06 +08:00
|
|
|
osg::ArgumentParser arguments(&argc, argv);
|
2013-08-08 01:08:38 +08:00
|
|
|
|
2013-08-10 00:51:06 +08:00
|
|
|
osgViewer::Viewer viewer(arguments);
|
2013-08-08 01:08:38 +08:00
|
|
|
|
2013-09-05 00:25:18 +08:00
|
|
|
#if 0
|
2013-08-10 00:51:06 +08:00
|
|
|
typedef std::list< osg::ref_ptr<osg::Script> > Scripts;
|
|
|
|
Scripts scripts;
|
2013-08-08 01:08:38 +08:00
|
|
|
|
2014-07-14 23:59:06 +08:00
|
|
|
osg::ref_ptr<osg::Group> model = new osg::Group;
|
|
|
|
|
2013-08-10 00:51:06 +08:00
|
|
|
std::string filename;
|
|
|
|
while(arguments.read("--script",filename))
|
2013-08-08 01:08:38 +08:00
|
|
|
{
|
2014-07-14 23:59:06 +08:00
|
|
|
osg::ref_ptr<osg::Script> script = osgDB::readScriptFile(filename);
|
2013-08-10 00:51:06 +08:00
|
|
|
if (script.valid()) scripts.push_back(script.get());
|
2013-08-08 01:08:38 +08:00
|
|
|
}
|
|
|
|
|
2018-04-21 00:18:22 +08:00
|
|
|
// assign script engine to scene graphs
|
2013-08-10 00:51:06 +08:00
|
|
|
model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile<osg::ScriptEngine>("ScriptEngine.lua"));
|
|
|
|
model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile<osg::ScriptEngine>("ScriptEngine.python"));
|
|
|
|
model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile<osg::ScriptEngine>("ScriptEngine.js"));
|
2013-08-08 01:08:38 +08:00
|
|
|
|
2013-08-10 00:51:06 +08:00
|
|
|
// assign scripts to scene graph
|
|
|
|
for(Scripts::iterator itr = scripts.begin();
|
|
|
|
itr != scripts.end();
|
|
|
|
++itr)
|
|
|
|
{
|
2014-02-01 00:20:29 +08:00
|
|
|
model->addUpdateCallback(new osg::ScriptNodeCallback(itr->get()));
|
2013-08-10 00:51:06 +08:00
|
|
|
}
|
2013-08-08 01:08:38 +08:00
|
|
|
|
2013-08-10 00:51:06 +08:00
|
|
|
std::string str;
|
|
|
|
osg::ref_ptr<osg::ScriptEngine> luaScriptEngine = osgDB::readFile<osg::ScriptEngine>("ScriptEngine.lua");
|
|
|
|
if (luaScriptEngine.valid())
|
2013-08-08 01:08:38 +08:00
|
|
|
{
|
2013-08-10 00:51:06 +08:00
|
|
|
while (arguments.read("--lua", str))
|
|
|
|
{
|
2014-07-14 23:59:06 +08:00
|
|
|
osg::ref_ptr<osg::Script> script = osgDB::readScriptFile(str);
|
2013-08-10 00:51:06 +08:00
|
|
|
if (script.valid())
|
|
|
|
{
|
|
|
|
luaScriptEngine->run(script.get());
|
2013-08-08 01:08:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-10 00:51:06 +08:00
|
|
|
osg::ref_ptr<osg::ScriptEngine> v8ScriptEngine = osgDB::readFile<osg::ScriptEngine>("ScriptEngine.V8");
|
|
|
|
if (v8ScriptEngine.valid())
|
2013-08-08 01:08:38 +08:00
|
|
|
{
|
2013-08-10 00:51:06 +08:00
|
|
|
while (arguments.read("--js",str))
|
2013-08-08 01:08:38 +08:00
|
|
|
{
|
2014-07-14 23:59:06 +08:00
|
|
|
osg::ref_ptr<osg::Script> script = osgDB::readScriptFile(str);
|
2013-08-10 00:51:06 +08:00
|
|
|
if (script.valid())
|
2013-08-08 01:08:38 +08:00
|
|
|
{
|
2013-08-10 00:51:06 +08:00
|
|
|
v8ScriptEngine->run(script.get());
|
2013-08-08 01:08:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-10 00:51:06 +08:00
|
|
|
osg::ref_ptr<osg::ScriptEngine> pythonScriptEngine = osgDB::readFile<osg::ScriptEngine>("ScriptEngine.python");
|
|
|
|
if (pythonScriptEngine.valid())
|
2013-08-08 01:08:38 +08:00
|
|
|
{
|
2013-08-10 00:51:06 +08:00
|
|
|
while (arguments.read("--python",str))
|
|
|
|
{
|
2014-07-14 23:59:06 +08:00
|
|
|
osg::ref_ptr<osg::Script> script = osgDB::readScriptFile(str);
|
2013-08-10 00:51:06 +08:00
|
|
|
if (script.valid())
|
|
|
|
{
|
|
|
|
pythonScriptEngine->run(script.get());
|
|
|
|
}
|
|
|
|
}
|
2013-08-08 01:08:38 +08:00
|
|
|
}
|
2014-07-14 23:59:06 +08:00
|
|
|
|
|
|
|
return 0;
|
2013-08-08 01:08:38 +08:00
|
|
|
#endif
|
|
|
|
|
2014-07-14 23:59:06 +08:00
|
|
|
#if 1
|
2013-08-08 01:08:38 +08:00
|
|
|
|
2013-08-22 15:49:22 +08:00
|
|
|
osg::ref_ptr<osgPresentation::Presentation> presentation = new osgPresentation::Presentation;
|
|
|
|
osg::ref_ptr<osgPresentation::Slide> slide = new osgPresentation::Slide;
|
|
|
|
osg::ref_ptr<osgPresentation::Layer> layer = new osgPresentation::Layer;
|
|
|
|
osg::ref_ptr<osgPresentation::Group> group = new osgPresentation::Group;
|
|
|
|
osg::ref_ptr<osgPresentation::Element> element = new osgPresentation::Element;
|
2013-09-05 00:25:18 +08:00
|
|
|
osg::ref_ptr<osgPresentation::Text> text = new osgPresentation::Text;
|
|
|
|
osg::ref_ptr<osgPresentation::Model> model = new osgPresentation::Model;
|
2013-09-06 17:35:56 +08:00
|
|
|
osg::ref_ptr<osgPresentation::Audio> audio = new osgPresentation::Audio;
|
|
|
|
osg::ref_ptr<osgPresentation::Image> image = new osgPresentation::Image;
|
|
|
|
osg::ref_ptr<osgPresentation::Movie> movie = new osgPresentation::Movie;
|
|
|
|
osg::ref_ptr<osgPresentation::Volume> volume = new osgPresentation::Volume;
|
2013-08-22 15:49:22 +08:00
|
|
|
presentation->addChild(slide.get());
|
|
|
|
slide->addChild(layer.get());
|
|
|
|
//layer->addChild(element.get());
|
2013-09-06 17:35:56 +08:00
|
|
|
//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());
|
2013-08-22 15:49:22 +08:00
|
|
|
|
2013-09-04 18:33:11 +08:00
|
|
|
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"));
|
|
|
|
|
2013-09-05 00:25:18 +08:00
|
|
|
model->setProperty("filename", std::string("dumptruck.osgt"));
|
2013-09-06 17:35:56 +08:00
|
|
|
|
|
|
|
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);
|
2013-09-05 00:25:18 +08:00
|
|
|
|
2013-09-24 23:17:42 +08:00
|
|
|
#if 0
|
2013-09-04 23:39:17 +08:00
|
|
|
osgPresentation::PrintSupportedProperties psp(std::cout);
|
2013-09-03 23:50:28 +08:00
|
|
|
presentation->accept(psp);
|
|
|
|
|
2013-09-05 00:25:18 +08:00
|
|
|
osgPresentation::PrintProperties pp(std::cout);
|
|
|
|
presentation->accept(pp);
|
2013-09-24 23:17:42 +08:00
|
|
|
#endif
|
2013-09-05 00:25:18 +08:00
|
|
|
|
2013-09-04 18:33:11 +08:00
|
|
|
osgPresentation::LoadAction load;
|
|
|
|
presentation->accept( load );
|
|
|
|
|
2013-08-22 15:49:22 +08:00
|
|
|
viewer.setSceneData( presentation.get() );
|
|
|
|
|
|
|
|
|
|
|
|
osgDB::writeNodeFile(*presentation, "pres.osgt");
|
|
|
|
|
2014-07-14 22:09:08 +08:00
|
|
|
osgDB::ClassInterface pi;
|
2013-09-20 00:19:32 +08:00
|
|
|
|
2013-09-20 18:44:24 +08:00
|
|
|
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
|
2013-09-20 00:19:32 +08:00
|
|
|
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<<std::endl<<"Wrapper : "<<itr->first<<", Domain="<<ow->getDomain()<<", Name="<<ow->getName()<<std::endl;
|
|
|
|
|
|
|
|
const osgDB::StringList& associates = ow->getAssociates();
|
|
|
|
for(osgDB::StringList::const_iterator aitr = associates.begin();
|
|
|
|
aitr != associates.end();
|
|
|
|
++aitr)
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<" associate = "<<*aitr<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
osgDB::StringList properties;
|
2013-09-20 18:04:50 +08:00
|
|
|
osgDB::ObjectWrapper::TypeList types;
|
2013-09-20 00:19:32 +08:00
|
|
|
ow->writeSchema(properties, types);
|
|
|
|
OSG_NOTICE<<" properties.size() = "<<properties.size()<<", types.size() = "<<types.size()<<std::endl;
|
|
|
|
unsigned int numProperties = std::min(properties.size(), types.size());
|
|
|
|
for(unsigned int i=0; i<numProperties; ++i)
|
|
|
|
{
|
2013-09-20 18:04:50 +08:00
|
|
|
OSG_NOTICE<<" property = "<<properties[i]<<", type = "<<types[i]<<", typeName = "<<pi.getTypeName(types[i])<<std::endl;
|
2013-09-20 00:19:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2013-09-20 18:04:50 +08:00
|
|
|
#if 1
|
2013-09-20 00:19:32 +08:00
|
|
|
osgDB::ObjectWrapperManager::IntLookupMap& intLookupMap = owm->getLookupMap();
|
|
|
|
for(osgDB::ObjectWrapperManager::IntLookupMap::iterator itr = intLookupMap.begin();
|
|
|
|
itr != intLookupMap.end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<std::endl<<"IntLookMap["<<itr->first<<"]"<<std::endl;
|
|
|
|
osgDB::IntLookup::StringToValue& stv = itr->second.getStringToValue();
|
|
|
|
for(osgDB::IntLookup::StringToValue::iterator sitr = stv.begin();
|
|
|
|
sitr != stv.end();
|
|
|
|
++sitr)
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<" "<<sitr->first<<", "<<sitr->second<<std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
2013-09-24 23:17:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-20 00:19:32 +08:00
|
|
|
presentation->setName("[this is a test]");
|
|
|
|
|
2013-09-24 23:17:42 +08:00
|
|
|
#if 0
|
|
|
|
|
2013-09-20 00:19:32 +08:00
|
|
|
if (pi.setProperty(presentation.get(), "Name", std::string("[this is new improved test]")))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"setProperty(presentation.get(), Name) succeeded."<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"setProperty(presentation.get(), Name) failed."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
if (pi.getProperty(presentation.get(), "Name", name))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"getProperty(presentation.get(), Name) succeeded, Name = "<<name<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"getProperty(presentation.get(), Name) failed."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OSG_NOTICE<<std::endl;
|
|
|
|
// presentation->setDataVariance(osg::Object::DYNAMIC);
|
|
|
|
|
|
|
|
int variance = 1234;
|
|
|
|
if (pi.getProperty(presentation.get(), "DataVariance", variance))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"getProperty(presentation.get(), DataVariance) succeeded, variance = "<<variance<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"getProperty(presentation.get(), DataVariance) failed."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
OSG_NOTICE<<std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
if (pi.setProperty(presentation.get(), "DataVariance", 1))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"setProperty(presentation.get(), DataVariance) succeeded."<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"setProperty(presentation.get(), DataVariance) failed."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
OSG_NOTICE<<std::endl;
|
|
|
|
|
|
|
|
if (pi.getProperty(presentation.get(), "DataVariance", variance))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"2nd getProperty(presentation.get(), DataVariance) succeeded, variance = "<<variance<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"2nd getProperty(presentation.get(), DataVariance) failed."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
OSG_NOTICE<<std::endl;
|
|
|
|
|
|
|
|
presentation->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)))
|
|
|
|
{
|
2016-05-30 19:30:05 +08:00
|
|
|
OSG_NOTICE<<"setProperty(..,Matrix) succeeded."<<std::endl;
|
2013-09-20 00:19:32 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"setProperty(..,Matrix) failed."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
osg::Matrixd matrix;
|
|
|
|
if (pi.getProperty(presentation.get(), "Matrix", matrix))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"getProperty(presentation.get(), ...) succeeded, Matrix = "<<matrix<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"getProperty(presentation.get(), ...) failed."<<std::endl;
|
|
|
|
}
|
|
|
|
#if 1
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
|
|
|
|
osg::ref_ptr<osg::Node> node = new osg::Node;
|
2014-07-14 22:09:08 +08:00
|
|
|
osgDB::ClassInterface::PropertyMap properties;
|
2013-09-20 00:19:32 +08:00
|
|
|
if (pi.getSupportedProperties(presentation.get(), properties, true))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Have supported properites found."<<std::endl;
|
2014-07-14 22:09:08 +08:00
|
|
|
for(osgDB::ClassInterface::PropertyMap::iterator itr = properties.begin();
|
2013-09-20 00:19:32 +08:00
|
|
|
itr != properties.end();
|
|
|
|
++itr)
|
|
|
|
{
|
2013-09-20 18:44:24 +08:00
|
|
|
OSG_NOTICE<<" Property "<<itr->first<<", "<<pi.getTypeName(itr->second)<<std::endl;
|
2013-09-20 00:19:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"No supported properites found."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OSG_NOTICE<<"Type(float) = "<<osgDB::getTypeEnum<float>()<<", "<<osgDB::getTypeString<float>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(bool) = "<<osgDB::getTypeEnum<bool>()<<", "<<osgDB::getTypeString<bool>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(osg::Vec3) = "<<osgDB::getTypeEnum<osg::Vec3>()<<", "<<osgDB::getTypeString<osg::Vec3>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(osg::Matrixd) = "<<osgDB::getTypeEnum<osg::Matrixd>()<<", "<<osgDB::getTypeString<osg::Matrixd>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(osg::Vec2ui) = "<<osgDB::getTypeEnum<osg::Vec2ui>()<<", "<<osgDB::getTypeString<osg::Vec2ui>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(GLenum) = "<<osgDB::getTypeEnum<GLenum>()<<", "<<osgDB::getTypeString<GLenum>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(int) = "<<osgDB::getTypeEnum<int>()<<", "<<osgDB::getTypeString<int>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(osg::Image*) = "<<osgDB::getTypeEnum<osg::Image*>()<<", "<<osgDB::getTypeString<osg::Image*>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(osg::Object*) = "<<osgDB::getTypeEnum<osg::Object*>()<<", "<<osgDB::getTypeString<osg::Object*>()<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(osg::Referenced*) = "<<osgDB::getTypeEnum<osg::Referenced*>()<<", "<<osgDB::getTypeString<osg::Referenced*>()<<std::endl;
|
|
|
|
|
|
|
|
osg::Object* ptr = presentation.get();
|
|
|
|
OSG_NOTICE<<"Type(ptr) = "<<osgDB::getTypeEnumFromPtr(ptr)<<", "<<osgDB::getTypeStringFromPtr(ptr)<<std::endl;
|
|
|
|
OSG_NOTICE<<"Type(presentation) = "<<osgDB::getTypeEnumFromPtr(presentation.get())<<", "<<osgDB::getTypeStringFromPtr(presentation.get())<<std::endl;
|
|
|
|
|
|
|
|
osg::Image* image2 = 0;
|
|
|
|
OSG_NOTICE<<"Type(image) = "<<osgDB::getTypeEnumFromPtr(image2)<<", "<<osgDB::getTypeStringFromPtr(image2)<<std::endl;
|
|
|
|
|
|
|
|
osg::Vec3 pos;
|
|
|
|
OSG_NOTICE<<"Type(pos) = "<<osgDB::getTypeEnumFrom(pos)<<", "<<osgDB::getTypeStringFrom(pos)<<std::endl;
|
|
|
|
|
|
|
|
OSG_NOTICE<<"Type(std::string) = "<<osgDB::getTypeEnum<std::string>()<<", "<<osgDB::getTypeString<std::string>()<<std::endl;
|
|
|
|
|
|
|
|
osgDB::BaseSerializer::Type type;
|
|
|
|
if (pi.getPropertyType(presentation.get(), "Name", type))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Property Type, Name = "<< type<<std::endl;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
osg::Matrixd mymatrix = osg::Matrix::translate(-1,2,3);
|
|
|
|
pi.setProperty(presentation.get(), "mymatrix", mymatrix);
|
|
|
|
|
|
|
|
osg::Matrixd copyofmatrix;
|
|
|
|
if (pi.getProperty(presentation.get(), "mymatrix", copyofmatrix))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"mymatrix = "<<copyofmatrix<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pi.getProperty(presentation.get(), "Matrix", copyofmatrix))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Matrix = "<<copyofmatrix<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string teststring="Another test";
|
|
|
|
pi.setProperty(presentation.get(),"mystring",teststring);
|
|
|
|
|
|
|
|
std::string astring;
|
|
|
|
if (pi.getProperty(presentation.get(),"mystring",astring))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"mystring = "<<astring<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"failed to get mystring"<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PRINT_TYPE(O,PN) \
|
|
|
|
{ \
|
|
|
|
osgDB::BaseSerializer::Type type; \
|
|
|
|
if (pi.getPropertyType(O, #PN, type)) \
|
|
|
|
{ \
|
2013-09-20 18:04:50 +08:00
|
|
|
OSG_NOTICE<<#PN<<" : type "<<type<<", "<<pi.getTypeName(type)<<std::endl; \
|
2013-09-20 00:19:32 +08:00
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
OSG_NOTICE<<#PN<<" : failed to get type"<<std::endl; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRINT_TYPE(presentation.get(), Name)
|
|
|
|
PRINT_TYPE(presentation.get(), Matrix)
|
|
|
|
PRINT_TYPE(presentation.get(), DataVariance)
|
|
|
|
PRINT_TYPE(presentation.get(), mystring)
|
|
|
|
PRINT_TYPE(presentation.get(), mymatrix)
|
|
|
|
|
2013-09-23 22:10:36 +08:00
|
|
|
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
|
|
|
|
if (pi.getSupportedProperties(event.get(), properties, true))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Have supported properites found."<<std::endl;
|
2014-07-14 22:09:08 +08:00
|
|
|
for(osgDB::ClassInterface::PropertyMap::iterator itr = properties.begin();
|
2013-09-23 22:10:36 +08:00
|
|
|
itr != properties.end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<" Property "<<itr->first<<", "<<pi.getTypeName(itr->second)<<std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"No supported properites found."<<std::endl;
|
|
|
|
}
|
2013-09-24 23:17:42 +08:00
|
|
|
#endif
|
|
|
|
|
2013-09-27 01:27:49 +08:00
|
|
|
osg::Vec3f pos(1.5,3.0,4.5);
|
|
|
|
presentation->setProperty("position",pos);
|
|
|
|
|
2013-09-27 21:04:04 +08:00
|
|
|
osg::Vec2f texcoord(0.5f,0.20f);
|
|
|
|
presentation->setProperty("texcoord",texcoord);
|
|
|
|
|
2013-09-24 23:17:42 +08:00
|
|
|
osg::ref_ptr<osg::ScriptEngine> luaScriptEngine = osgDB::readFile<osg::ScriptEngine>("ScriptEngine.lua");
|
|
|
|
if (luaScriptEngine.valid())
|
|
|
|
{
|
|
|
|
presentation->getOrCreateUserDataContainer()->addUserObject(luaScriptEngine.get());
|
|
|
|
std::string str;
|
|
|
|
while (arguments.read("--lua", str))
|
|
|
|
{
|
2014-07-14 23:59:06 +08:00
|
|
|
osg::ref_ptr<osg::Script> script = osgDB::readScriptFile(str);
|
2013-09-24 23:17:42 +08:00
|
|
|
if (script.valid())
|
|
|
|
{
|
2014-02-01 00:20:29 +08:00
|
|
|
presentation->addUpdateCallback(new osg::ScriptNodeCallback(script.get(),"update"));
|
2013-09-24 23:17:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (arguments.read("--test", str))
|
|
|
|
{
|
2014-07-14 23:59:06 +08:00
|
|
|
osg::ref_ptr<osg::Script> script = osgDB::readScriptFile(str);
|
2013-09-24 23:17:42 +08:00
|
|
|
if (script.valid())
|
|
|
|
{
|
2013-12-26 01:36:32 +08:00
|
|
|
osg::Parameters inputParameters;
|
|
|
|
osg::Parameters outputParameters;
|
2013-09-24 23:17:42 +08:00
|
|
|
|
|
|
|
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<osg::MatrixdValueObject> 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 = "<<svo->getValue()<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"script run failed"<<std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-23 22:10:36 +08:00
|
|
|
|
2013-09-20 00:19:32 +08:00
|
|
|
|
2013-10-05 00:30:25 +08:00
|
|
|
osg::ref_ptr<osg::Object> obj = pi.createObject("osgVolume::VolumeTile");
|
|
|
|
if (obj.valid()) { OSG_NOTICE<<"obj created "<<obj->getCompoundClassName()<<std::endl; }
|
|
|
|
else { OSG_NOTICE<<"obj creation failed "<<std::endl; }
|
2014-07-14 22:09:08 +08:00
|
|
|
osgDB::ClassInterface::PropertyMap properties;
|
2013-10-05 00:30:25 +08:00
|
|
|
|
|
|
|
if (pi.getSupportedProperties(obj.get(), properties, true))
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Have supported properites found."<<std::endl;
|
2014-07-14 22:09:08 +08:00
|
|
|
for(osgDB::ClassInterface::PropertyMap::iterator itr = properties.begin();
|
2013-10-05 00:30:25 +08:00
|
|
|
itr != properties.end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<" Property "<<itr->first<<", "<<pi.getTypeName(itr->second)<<std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"No supported properites found."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//return 0;
|
|
|
|
|
2013-09-24 23:17:42 +08:00
|
|
|
return viewer.run();
|
2013-09-20 00:19:32 +08:00
|
|
|
|
2014-07-14 23:59:06 +08:00
|
|
|
#endif
|
2013-08-08 01:08:38 +08:00
|
|
|
}
|