root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/TextureCubeMap.cpp @ 11018

Revision 11018, 1.8 kB (checked in by robert, 4 years ago)

From Wang Rui, "Changes:

1. Rewrite the reading/writing exception handlers to work like the ive
plugin exceptions.
2. Write a header writing/checking function in ReaderWriterOSG2.cpp,
which may help decide if the stream is ascii or binary. The
readInputIterator() function will return null pointer if the input
file is nither osgb nor osgt format, which indicates that the old .osg
format could be used here, in case we've merged the two plugins
together.
3. Add a new ForceReadingImage? option in the InputStream?, which will
allocate an empty image object with the filename if specifed external
image file is missed. It may be useful for format converting in some
cases.
4. Add new osgParticle wrappers, as well as some modification to the
osgParticle headers, for instance, change isEnabled() to getEnabled().
5. Some fixes to the osg serialization wrappers."

  • Property svn:executable set to *
Line 
1#include <osg/TextureCubeMap>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6#define FACE_IMAGE_FUNCTION( PROP, FACE ) \
7    static bool check##PROP( const osg::TextureCubeMap& tex ) { return true; } \
8    static bool read##PROP( osgDB::InputStream& is, osg::TextureCubeMap& tex ) { \
9        bool hasImage; is >> hasImage; \
10        if ( hasImage ) { \
11            is >> osgDB::BEGIN_BRACKET; tex.setImage(FACE, is.readImage()); \
12            is >> osgDB::END_BRACKET; \
13        } \
14        return true; \
15    } \
16    static bool write##PROP( osgDB::OutputStream& os, const osg::TextureCubeMap& tex ) { \
17        const osg::Image* image = tex.getImage(FACE); \
18        os << (image!=NULL); \
19        if ( image!=NULL ) { \
20            os << osgDB::BEGIN_BRACKET << std::endl << image; \
21            os << osgDB::END_BRACKET; \
22        } \
23        os << std::endl; \
24        return true; \
25    }
26
27FACE_IMAGE_FUNCTION( PosX, osg::TextureCubeMap::POSITIVE_X )
28FACE_IMAGE_FUNCTION( NegX, osg::TextureCubeMap::NEGATIVE_X )
29FACE_IMAGE_FUNCTION( PosY, osg::TextureCubeMap::POSITIVE_Y )
30FACE_IMAGE_FUNCTION( NegY, osg::TextureCubeMap::NEGATIVE_Y )
31FACE_IMAGE_FUNCTION( PosZ, osg::TextureCubeMap::POSITIVE_Z )
32FACE_IMAGE_FUNCTION( NegZ, osg::TextureCubeMap::NEGATIVE_Z )
33
34REGISTER_OBJECT_WRAPPER( TextureCubeMap,
35                         new osg::TextureCubeMap,
36                         osg::TextureCubeMap,
37                         "osg::Object osg::StateAttribute osg::Texture osg::TextureCubeMap" )
38{
39    ADD_USER_SERIALIZER( PosX );
40    ADD_USER_SERIALIZER( NegX );
41    ADD_USER_SERIALIZER( PosY );
42    ADD_USER_SERIALIZER( NegY );
43    ADD_USER_SERIALIZER( PosZ );
44    ADD_USER_SERIALIZER( NegZ );  // _images
45   
46    ADD_INT_SERIALIZER( TextureWidth, 0 );  // _textureWidth
47    ADD_INT_SERIALIZER( TextureHeight, 0 );  // _textureHeight
48}
Note: See TracBrowser for help on using the browser.