From 898c7168418440a2936bf32986a3ad5cde720b9f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 10 Sep 2013 09:23:30 +0000 Subject: [PATCH] Added osgPresentation::Show node and implementations with basic property reporting for various internal nodes of presentation graph --- include/osgPresentation/Layer | 3 ++ include/osgPresentation/Presentation | 3 ++ include/osgPresentation/Section | 3 ++ include/osgPresentation/Show | 44 +++++++++++++++++++ include/osgPresentation/Slide | 3 ++ src/osgPlugins/mdl/MDLReader.cpp | 29 ++++++------ src/osgPresentation/CMakeLists.txt | 6 +++ src/osgPresentation/Layer.cpp | 24 ++++++++++ src/osgPresentation/Presentation.cpp | 23 ++++++++++ src/osgPresentation/Section.cpp | 23 ++++++++++ src/osgPresentation/Show.cpp | 23 ++++++++++ src/osgPresentation/Slide.cpp | 23 ++++++++++ .../serializers/osgPresentation/Show.cpp | 11 +++++ 13 files changed, 205 insertions(+), 13 deletions(-) create mode 100644 include/osgPresentation/Show create mode 100644 src/osgPresentation/Layer.cpp create mode 100644 src/osgPresentation/Presentation.cpp create mode 100644 src/osgPresentation/Section.cpp create mode 100644 src/osgPresentation/Show.cpp create mode 100644 src/osgPresentation/Slide.cpp create mode 100644 src/osgWrappers/serializers/osgPresentation/Show.cpp diff --git a/include/osgPresentation/Layer b/include/osgPresentation/Layer index 2594dee70..c1dfe8c86 100644 --- a/include/osgPresentation/Layer +++ b/include/osgPresentation/Layer @@ -31,6 +31,9 @@ class OSGPRESENTATION_EXPORT Layer : public osgPresentation::Group META_Presentation(Layer); + /** 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 ~Layer() {} diff --git a/include/osgPresentation/Presentation b/include/osgPresentation/Presentation index 3616eef6f..87bc1d9d1 100644 --- a/include/osgPresentation/Presentation +++ b/include/osgPresentation/Presentation @@ -31,6 +31,9 @@ class OSGPRESENTATION_EXPORT Presentation : public osgPresentation::Group META_Presentation(Presentation); + /** 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 ~Presentation() {} diff --git a/include/osgPresentation/Section b/include/osgPresentation/Section index cd201384d..fb544671b 100644 --- a/include/osgPresentation/Section +++ b/include/osgPresentation/Section @@ -31,6 +31,9 @@ class OSGPRESENTATION_EXPORT Section : public osgPresentation::Group META_Presentation(Section); + /** 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 ~Section() {} diff --git a/include/osgPresentation/Show b/include/osgPresentation/Show new file mode 100644 index 000000000..cab5c1c9f --- /dev/null +++ b/include/osgPresentation/Show @@ -0,0 +1,44 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGPRESENTATION_SHOW +#define OSGPRESENTATION_SHOW 1 + +#include + +namespace osgPresentation { + +/** osgPresentation::Show +*/ +class OSGPRESENTATION_EXPORT Show : public osgPresentation::Group +{ + public : + + Show() {} + + /** Copy constructor using CopyOp to manage deep vs shallow copy. */ + Show(const Show& presentation,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osgPresentation::Group(presentation,copyop) {} + + META_Presentation(Show); + + /** 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 ~Show() {} +}; + +} + +#endif diff --git a/include/osgPresentation/Slide b/include/osgPresentation/Slide index 59e71a5b0..5281ec402 100644 --- a/include/osgPresentation/Slide +++ b/include/osgPresentation/Slide @@ -31,6 +31,9 @@ class OSGPRESENTATION_EXPORT Slide : public osgPresentation::Group META_Presentation(Slide); + /** 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 ~Slide() {} diff --git a/src/osgPlugins/mdl/MDLReader.cpp b/src/osgPlugins/mdl/MDLReader.cpp index 8883d65c5..6c0ed886d 100644 --- a/src/osgPlugins/mdl/MDLReader.cpp +++ b/src/osgPlugins/mdl/MDLReader.cpp @@ -148,20 +148,20 @@ std::string MDLReader::getToken(std::string str, const char * delim, ref_ptr MDLReader::readTextureFile(std::string textureName) { - std::string texFile; - std::string texPath; - osg::ref_ptr texImage; - osg::ref_ptr texture; - // Find the texture's image file - texFile = std::string(textureName) + ".vtf"; - texPath = findDataFile(texFile, CASE_INSENSITIVE); + std::string texExtension = osgDB::getFileExtensionIncludingDot(textureName); + std::string texBaseName = osgDB::getNameLessExtension(textureName); + + if (texExtension.empty()) texExtension = ".vtf"; + + std::string texFile = texBaseName + texExtension; + std::string texPath = findDataFile(texFile, CASE_INSENSITIVE); // If we don't find it right away, check in a "materials" subdirectory if (texPath.empty()) { // Check for a leading slash and concatenate appropriately - texPath = findFileInPath("materials", textureName, ".vtf"); + texPath = findFileInPath("materials", texBaseName, texExtension); // Check up one directory if we don't find it here (the map file is // usually located in the "maps" directory, adjacent to the materials @@ -169,18 +169,20 @@ ref_ptr MDLReader::readTextureFile(std::string textureName) if (texPath.empty()) { // Check for a leading slash and concatenate appropriately - texPath = findFileInPath("../materials", textureName, ".vtf"); + texPath = findFileInPath("../materials", texBaseName, texExtension); } } // If we found the file, read it, otherwise bail if (!texPath.empty()) { - texImage = readRefImageFile(texPath); + osg::ref_ptr texImage = readRefImageFile(texPath); // If we got the image, create the texture attribute if (texImage.valid()) { + osg::ref_ptr texture; + // Create the texture if (texImage->t() == 1) { @@ -202,6 +204,8 @@ ref_ptr MDLReader::readTextureFile(std::string textureName) texture->setFilter(Texture::MAG_FILTER, Texture::LINEAR); texture->setFilter(Texture::MIN_FILTER, Texture::LINEAR_MIPMAP_LINEAR); + + return texture; } else { @@ -209,7 +213,7 @@ ref_ptr MDLReader::readTextureFile(std::string textureName) OSG_WARN << "Couldn't find texture " << textureName << std::endl; // No texture - texture = NULL; + return NULL; } } else @@ -218,10 +222,9 @@ ref_ptr MDLReader::readTextureFile(std::string textureName) OSG_WARN << "Couldn't find texture " << textureName << std::endl; // No texture - texture = NULL; + return NULL; } - return texture; } diff --git a/src/osgPresentation/CMakeLists.txt b/src/osgPresentation/CMakeLists.txt index 7b1f68950..ec4aa0a1c 100644 --- a/src/osgPresentation/CMakeLists.txt +++ b/src/osgPresentation/CMakeLists.txt @@ -43,6 +43,12 @@ SET(TARGET_SRC Cursor.cpp Group.cpp + Show.cpp + Presentation.cpp + Section.cpp + Slide.cpp + Layer.cpp + Element.cpp Audio.cpp Image.cpp diff --git a/src/osgPresentation/Layer.cpp b/src/osgPresentation/Layer.cpp new file mode 100644 index 000000000..96d4b9615 --- /dev/null +++ b/src/osgPresentation/Layer.cpp @@ -0,0 +1,24 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include +#include + +using namespace osgPresentation; + +bool Layer::getSupportedProperties(PropertyList& pl) +{ + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("background_colour",osg::Vec4d(0.0,0.0,0.0,0.0)), std::string("Background colour."))); + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("text_colour",osg::Vec4d(1.0,1.0,1.0,1.0)), std::string("Text colour."))); + return true; +} diff --git a/src/osgPresentation/Presentation.cpp b/src/osgPresentation/Presentation.cpp new file mode 100644 index 000000000..7d75a2e00 --- /dev/null +++ b/src/osgPresentation/Presentation.cpp @@ -0,0 +1,23 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include + +using namespace osgPresentation; + +bool Presentation::getSupportedProperties(PropertyList& pl) +{ + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("background_colour",osg::Vec4d(0.0,0.0,0.0,0.0)), std::string("Background colour."))); + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("text_colour",osg::Vec4d(1.0,1.0,1.0,1.0)), std::string("Text colour."))); + return true; +} diff --git a/src/osgPresentation/Section.cpp b/src/osgPresentation/Section.cpp new file mode 100644 index 000000000..04a71763c --- /dev/null +++ b/src/osgPresentation/Section.cpp @@ -0,0 +1,23 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include + +using namespace osgPresentation; + +bool Section::getSupportedProperties(PropertyList& pl) +{ + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("background_colour",osg::Vec4d(0.0,0.0,0.0,0.0)), std::string("Background colour."))); + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("text_colour",osg::Vec4d(1.0,1.0,1.0,1.0)), std::string("Text colour."))); + return true; +} diff --git a/src/osgPresentation/Show.cpp b/src/osgPresentation/Show.cpp new file mode 100644 index 000000000..ff322688b --- /dev/null +++ b/src/osgPresentation/Show.cpp @@ -0,0 +1,23 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include + +using namespace osgPresentation; + +bool Show::getSupportedProperties(PropertyList& pl) +{ + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("background_colour",osg::Vec4d(0.0,0.0,0.0,0.0)), std::string("Background colour."))); + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("text_colour",osg::Vec4d(1.0,1.0,1.0,1.0)), std::string("Text colour."))); + return true; +} diff --git a/src/osgPresentation/Slide.cpp b/src/osgPresentation/Slide.cpp new file mode 100644 index 000000000..6d8c7f601 --- /dev/null +++ b/src/osgPresentation/Slide.cpp @@ -0,0 +1,23 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include + +using namespace osgPresentation; + +bool Slide::getSupportedProperties(PropertyList& pl) +{ + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("background_colour",osg::Vec4d(0.0,0.0,0.0,0.0)), std::string("Background colour."))); + pl.push_back(ObjectDescription(new osg::Vec4dValueObject("text_colour",osg::Vec4d(1.0,1.0,1.0,1.0)), std::string("Text colour."))); + return true; +} diff --git a/src/osgWrappers/serializers/osgPresentation/Show.cpp b/src/osgWrappers/serializers/osgPresentation/Show.cpp new file mode 100644 index 000000000..f110a34e5 --- /dev/null +++ b/src/osgWrappers/serializers/osgPresentation/Show.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgPresentation_Show, + new osgPresentation::Show, + osgPresentation::Show, + "osg::Object osg::Node osg::Group osg::Transform osg::MatrixTransform osgPresentation::Group osgPresentation::Show" ) +{ +}