diff --git a/examples/osgpresentation/osgpresentation.cpp b/examples/osgpresentation/osgpresentation.cpp index f28e00363..ef4c2f29c 100644 --- a/examples/osgpresentation/osgpresentation.cpp +++ b/examples/osgpresentation/osgpresentation.cpp @@ -34,6 +34,7 @@ int main(int argc, char** argv) osgViewer::Viewer viewer(arguments); +#if 0 typedef std::list< osg::ref_ptr > Scripts; Scripts scripts; @@ -44,10 +45,6 @@ int main(int argc, char** argv) if (script.valid()) scripts.push_back(script.get()); } - // create the model - osg::ref_ptr model = osgDB::readNodeFiles(arguments); - if (!model) return 1; - // assgin script engine to scene graphs model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile("ScriptEngine.lua")); model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile("ScriptEngine.python")); @@ -61,7 +58,6 @@ int main(int argc, char** argv) model->addUpdateCallback(new osg::ScriptCallback(itr->get())); } -#if 0 std::string str; osg::ref_ptr luaScriptEngine = osgDB::readFile("ScriptEngine.lua"); if (luaScriptEngine.valid()) @@ -110,14 +106,14 @@ int main(int argc, char** argv) 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 text = new osgPresentation::Text; + osg::ref_ptr model = new osgPresentation::Model; presentation->addChild(slide.get()); slide->addChild(layer.get()); //layer->addChild(element.get()); layer->addChild(group.get()); group->addChild(element.get()); - element->addChild(model.get()); - group->addChild(new osgPresentation::Model); + group->addChild(model.get()); group->addChild(text.get()); group->addChild(new osgPresentation::Audio); group->addChild(new osgPresentation::Movie); @@ -129,10 +125,16 @@ int main(int argc, char** argv) text->setProperty("character_size",2.2); text->setProperty("width",std::string("103.2")); + model->setProperty("filename", std::string("dumptruck.osgt")); + model->setProperty("scale",2.0); + osgPresentation::PrintSupportedProperties psp(std::cout); presentation->accept(psp); + osgPresentation::PrintProperties pp(std::cout); + presentation->accept(pp); + osgPresentation::LoadAction load; presentation->accept( load ); diff --git a/include/osgPresentation/Action b/include/osgPresentation/Action index 7ec72abdf..7ec6a7786 100644 --- a/include/osgPresentation/Action +++ b/include/osgPresentation/Action @@ -83,7 +83,16 @@ struct OSGPRESENTATION_EXPORT PlayAction : public Action void apply(osgPresentation::Element& element); }; -struct PrintSupportedProperties : public osgPresentation::Action +struct OSGPRESENTATION_EXPORT PrintProperties : public osgPresentation::Action +{ + PrintProperties(std::ostream& output) : osgPresentation::Action(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), _output(output) {} + + void apply(osgPresentation::Group& group); + + std::ostream& _output; +}; + +struct OSGPRESENTATION_EXPORT PrintSupportedProperties : public osgPresentation::Action { PrintSupportedProperties(std::ostream& output) : osgPresentation::Action(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), _output(output) {} diff --git a/include/osgPresentation/Model b/include/osgPresentation/Model index a74a15474..99d8c7e1d 100644 --- a/include/osgPresentation/Model +++ b/include/osgPresentation/Model @@ -31,6 +31,12 @@ class OSGPRESENTATION_EXPORT Model : public osgPresentation::Element META_Presentation(Model); + /** load the text subgraph.*/ + virtual bool load(); + + /** Get all types of Properties supported by Presentation Object type, return true if the Properties are supported, false otherwise.*/ + virtual bool getSupportedProperties(PropertyList&); + protected : virtual ~Model() {} diff --git a/src/osgPresentation/Action.cpp b/src/osgPresentation/Action.cpp index b6dc84f88..1c8febbe9 100644 --- a/src/osgPresentation/Action.cpp +++ b/src/osgPresentation/Action.cpp @@ -25,6 +25,8 @@ #include #include +#include + using namespace osgPresentation; ////////////////////////////////////////////////////////////////////////////////// @@ -120,9 +122,62 @@ void PlayAction::apply(osgPresentation::Element& element) element.play(); } +struct PrintValueVisitor: public osg::ValueObject::GetValueVisitor +{ + PrintValueVisitor(std::ostream& output) : _output(output) {} + + template + void print(const T& value) { _output << value; } + + virtual void apply(bool value) { print(value); } + virtual void apply(char value) { print(value); } + virtual void apply(unsigned char value) { print(value); } + virtual void apply(short value) { print(value); } + virtual void apply(unsigned short value) { print(value); } + virtual void apply(int value) { print(value); } + virtual void apply(unsigned int value) { print(value); } + virtual void apply(float value) { print(value); } + virtual void apply(double value) { print(value); } + virtual void apply(const std::string& value) { print(value); } + virtual void apply(const osg::Vec2f& value) { print(value); } + virtual void apply(const osg::Vec3f& value) { print(value); } + virtual void apply(const osg::Vec4f& value) { print(value); } + virtual void apply(const osg::Vec2d& value) { print(value); } + virtual void apply(const osg::Vec3d& value) { print(value); } + virtual void apply(const osg::Vec4d& value) { print(value); } + virtual void apply(const osg::Quat& value) { print(value); } + virtual void apply(const osg::Plane& value) { print(value); } + virtual void apply(const osg::Matrixf& value) { print(value); } + virtual void apply(const osg::Matrixd& value) { print(value); } + + std::ostream& _output; +}; + +void PrintProperties::apply(osgPresentation::Group& group) +{ + _output<<"PrintProperties osgPresentation object : "<getNumUserObjects(); ++i) + { + osg::ValueObject* value_object = dynamic_cast(udc->getUserObject(i)); + if (value_object) + { + _output<<" "<className()<<" : "<getName()<<" : "; + value_object->get(pvv); + _output<