From bdff0955dc2b8660ba6a1bddc7c0f43d0f22e3f0 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 20 Dec 2017 20:13:33 +0000 Subject: [PATCH] Added TextureCubeMap::setImage/getImage() methpds --- .../serializers/osg/TextureCubeMap.cpp | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/osgWrappers/serializers/osg/TextureCubeMap.cpp b/src/osgWrappers/serializers/osg/TextureCubeMap.cpp index 62de76594..cc648cbd5 100644 --- a/src/osgWrappers/serializers/osg/TextureCubeMap.cpp +++ b/src/osgWrappers/serializers/osg/TextureCubeMap.cpp @@ -31,6 +31,44 @@ FACE_IMAGE_FUNCTION( NegY, osg::TextureCubeMap::NEGATIVE_Y ) FACE_IMAGE_FUNCTION( PosZ, osg::TextureCubeMap::POSITIVE_Z ) FACE_IMAGE_FUNCTION( NegZ, osg::TextureCubeMap::NEGATIVE_Z ) +struct TextureCubeGetValue : public osgDB::MethodObject +{ + virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const + { + if (inputParameters.empty()) return false; + + unsigned int index = 0; + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); + + osg::TextureCubeMap* tcm = reinterpret_cast(objectPtr); + outputParameters.push_back(tcm->getImage(index)); + + return true; + } +}; + + +struct TextureCubeSetValue : public osgDB::MethodObject +{ + virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const + { + if (inputParameters.size()<2) return false; + + unsigned int index = 0; + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); + + osg::Image* image = inputParameters[1]->asImage(); + if (!image) return false; + + osg::TextureCubeMap* tcm = reinterpret_cast(objectPtr); + tcm->setImage(index, image); + + return true; + } +}; + REGISTER_OBJECT_WRAPPER( TextureCubeMap, new osg::TextureCubeMap, osg::TextureCubeMap, @@ -45,4 +83,7 @@ REGISTER_OBJECT_WRAPPER( TextureCubeMap, ADD_INT_SERIALIZER( TextureWidth, 0 ); // _textureWidth ADD_INT_SERIALIZER( TextureHeight, 0 ); // _textureHeight + + ADD_METHOD_OBJECT( "getImage", TextureCubeGetValue ); + ADD_METHOD_OBJECT( "setImage", TextureCubeSetValue ); }