Added Vector serialization and support in lua plugin top enable script users to set/get vector properties such as osg::Array, osg::PrimitiveSet and children lists.

This commit is contained in:
Robert Osfield 2014-02-24 10:19:48 +00:00
parent 6d68718fba
commit 4ef5d9eb5f
15 changed files with 1566 additions and 103 deletions

View File

@ -48,8 +48,8 @@ PROJECT(OpenSceneGraph)
SET(OPENSCENEGRAPH_MAJOR_VERSION 3) SET(OPENSCENEGRAPH_MAJOR_VERSION 3)
SET(OPENSCENEGRAPH_MINOR_VERSION 3) SET(OPENSCENEGRAPH_MINOR_VERSION 3)
SET(OPENSCENEGRAPH_PATCH_VERSION 1) SET(OPENSCENEGRAPH_PATCH_VERSION 2)
SET(OPENSCENEGRAPH_SOVERSION 111) SET(OPENSCENEGRAPH_SOVERSION 112)
# set to 0 when not a release candidate, non zero means that any generated # set to 0 when not a release candidate, non zero means that any generated
# svn tags will be treated as release candidates of given number # svn tags will be treated as release candidates of given number

View File

@ -53,44 +53,50 @@ class OSG_EXPORT Geometry : public Drawable
const Array* getVertexArray() const { return _vertexArray.get(); } const Array* getVertexArray() const { return _vertexArray.get(); }
void setNormalArray(Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED); void setNormalArray(Array* array) { setNormalArray(array, osg::Array::BIND_UNDEFINED); }
void setNormalArray(Array* array, osg::Array::Binding binding);
Array* getNormalArray() { return _normalArray.get(); } Array* getNormalArray() { return _normalArray.get(); }
const Array* getNormalArray() const { return _normalArray.get(); } const Array* getNormalArray() const { return _normalArray.get(); }
void setColorArray(Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED); void setColorArray(Array* array) { setColorArray(array, osg::Array::BIND_UNDEFINED); }
void setColorArray(Array* array, osg::Array::Binding binding);
Array* getColorArray() { return _colorArray.get(); } Array* getColorArray() { return _colorArray.get(); }
const Array* getColorArray() const { return _colorArray.get(); } const Array* getColorArray() const { return _colorArray.get(); }
void setSecondaryColorArray(Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED); void setSecondaryColorArray(Array* array) { setSecondaryColorArray(array, osg::Array::BIND_UNDEFINED); }
void setSecondaryColorArray(Array* array, osg::Array::Binding binding);
Array* getSecondaryColorArray() { return _secondaryColorArray.get(); } Array* getSecondaryColorArray() { return _secondaryColorArray.get(); }
const Array* getSecondaryColorArray() const { return _secondaryColorArray.get(); } const Array* getSecondaryColorArray() const { return _secondaryColorArray.get(); }
void setFogCoordArray(Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED); void setFogCoordArray(Array* array) { setFogCoordArray(array, osg::Array::BIND_UNDEFINED); }
void setFogCoordArray(Array* array, osg::Array::Binding binding);
Array* getFogCoordArray() { return _fogCoordArray.get(); } Array* getFogCoordArray() { return _fogCoordArray.get(); }
const Array* getFogCoordArray() const { return _fogCoordArray.get(); } const Array* getFogCoordArray() const { return _fogCoordArray.get(); }
void setTexCoordArray(unsigned int unit,Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED); void setTexCoordArray(unsigned int unit, Array* array) { setTexCoordArray(unit, array, osg::Array::BIND_UNDEFINED); }
void setTexCoordArray(unsigned int unit, Array* array, osg::Array::Binding binding);
Array* getTexCoordArray(unsigned int unit); Array* getTexCoordArray(unsigned int unit);
const Array* getTexCoordArray(unsigned int unit) const; const Array* getTexCoordArray(unsigned int unit) const;
unsigned int getNumTexCoordArrays() const { return static_cast<unsigned int>(_texCoordList.size()); } unsigned int getNumTexCoordArrays() const { return static_cast<unsigned int>(_texCoordList.size()); }
void setTexCoordArrayList(const ArrayList& arrrayList);
ArrayList& getTexCoordArrayList() { return _texCoordList; } ArrayList& getTexCoordArrayList() { return _texCoordList; }
const ArrayList& getTexCoordArrayList() const { return _texCoordList; } const ArrayList& getTexCoordArrayList() const { return _texCoordList; }
void setVertexAttribArray(unsigned int index, Array* array) { setVertexAttribArray(index, array, osg::Array::BIND_UNDEFINED); }
void setVertexAttribArray(unsigned int index, Array* array, osg::Array::Binding binding);
void setVertexAttribArray(unsigned int index, Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED);
Array *getVertexAttribArray(unsigned int index); Array *getVertexAttribArray(unsigned int index);
const Array *getVertexAttribArray(unsigned int index) const; const Array *getVertexAttribArray(unsigned int index) const;
unsigned int getNumVertexAttribArrays() const { return static_cast<unsigned int>(_vertexAttribList.size()); } unsigned int getNumVertexAttribArrays() const { return static_cast<unsigned int>(_vertexAttribList.size()); }
void setVertexAttribArrayList(const ArrayList& arrayList);
ArrayList& getVertexAttribArrayList() { return _vertexAttribList; } ArrayList& getVertexAttribArrayList() { return _vertexAttribList; }
const ArrayList& getVertexAttribArrayList() const { return _vertexAttribList; } const ArrayList& getVertexAttribArrayList() const { return _vertexAttribList; }
@ -175,7 +181,7 @@ class OSG_EXPORT Geometry : public Drawable
/** Set up the vertex arrays for the purpose of rendering, called by drawImplemtation() prior to it calling drawPrimitivesImplementation().*/ /** Set up the vertex arrays for the purpose of rendering, called by drawImplemtation() prior to it calling drawPrimitivesImplementation().*/
void drawVertexArraysImplementation(RenderInfo& renderInfo) const; void drawVertexArraysImplementation(RenderInfo& renderInfo) const;
/** dispatch the primitives to OpenGL, called by drawImplemtation() after calling drawVertexArraysImplementation().*/ /** dispatch the primitives to OpenGL, called by drawImplemtation() after calling drawVertexArraysImplementation().*/
void drawPrimitivesImplementation(RenderInfo& renderInfo) const; void drawPrimitivesImplementation(RenderInfo& renderInfo) const;

View File

@ -20,8 +20,8 @@ extern "C" {
#define OPENSCENEGRAPH_MAJOR_VERSION 3 #define OPENSCENEGRAPH_MAJOR_VERSION 3
#define OPENSCENEGRAPH_MINOR_VERSION 3 #define OPENSCENEGRAPH_MINOR_VERSION 3
#define OPENSCENEGRAPH_PATCH_VERSION 1 #define OPENSCENEGRAPH_PATCH_VERSION 2
#define OPENSCENEGRAPH_SOVERSION 111 #define OPENSCENEGRAPH_SOVERSION 112
/* Convenience macro that can be used to decide whether a feature is present or not i.e. /* Convenience macro that can be used to decide whether a feature is present or not i.e.
* #if OSG_MIN_VERSION_REQUIRED(2,9,5) * #if OSG_MIN_VERSION_REQUIRED(2,9,5)

View File

@ -137,14 +137,14 @@ public:
InputStream& operator>>( osg::BoundingSpheref& bs ); InputStream& operator>>( osg::BoundingSpheref& bs );
InputStream& operator>>( osg::BoundingSphered& bs ); InputStream& operator>>( osg::BoundingSphered& bs );
InputStream& operator>>( osg::Array*& a ) { a = readArray(); return *this; }
InputStream& operator>>( osg::Image*& img ) { img = readImage(); return *this; } InputStream& operator>>( osg::Image*& img ) { img = readImage(); return *this; }
InputStream& operator>>( osg::PrimitiveSet*& p ) { p = readPrimitiveSet(); return *this; } InputStream& operator>>( osg::Array*& a ) { if (_fileVersion>=112) a = readObjectOfType<osg::Array>(); else a = readArray(); return *this; }
InputStream& operator>>( osg::PrimitiveSet*& p ) { if (_fileVersion>=112) p = readObjectOfType<osg::PrimitiveSet>(); else p = readPrimitiveSet(); return *this; }
InputStream& operator>>( osg::Object*& obj ) { obj = readObject(); return *this; } InputStream& operator>>( osg::Object*& obj ) { obj = readObject(); return *this; }
InputStream& operator>>( osg::ref_ptr<osg::Array>& ptr ) { ptr = readArray(); return *this; }
InputStream& operator>>( osg::ref_ptr<osg::Image>& ptr ) { ptr = readImage(); return *this; } InputStream& operator>>( osg::ref_ptr<osg::Image>& ptr ) { ptr = readImage(); return *this; }
InputStream& operator>>( osg::ref_ptr<osg::PrimitiveSet>& ptr ) { ptr = readPrimitiveSet(); return *this; } InputStream& operator>>( osg::ref_ptr<osg::Array>& ptr ) { if (_fileVersion>=112) ptr = readObjectOfType<osg::Array>(); else ptr = readArray(); return *this; }
InputStream& operator>>( osg::ref_ptr<osg::PrimitiveSet>& ptr ) { if (_fileVersion>=112) ptr = readObjectOfType<osg::PrimitiveSet>(); else ptr = readPrimitiveSet(); return *this; }
template<typename T> InputStream& operator>>( osg::ref_ptr<T>& ptr ) template<typename T> InputStream& operator>>( osg::ref_ptr<T>& ptr )
{ ptr = static_cast<T*>(readObject()); return *this; } { ptr = static_cast<T*>(readObject()); return *this; }
@ -163,7 +163,19 @@ public:
osg::Array* readArray(); osg::Array* readArray();
osg::PrimitiveSet* readPrimitiveSet(); osg::PrimitiveSet* readPrimitiveSet();
osg::Image* readImage(bool readFromExternal=true); osg::Image* readImage(bool readFromExternal=true);
template<typename T>
T* readObjectOfType()
{
osg::ref_ptr<osg::Object> obj = readObject();
T* ptr = dynamic_cast<T*>(obj.get());
if (ptr) { obj.release(); return ptr; }
else return 0;
}
osg::Object* readObject( osg::Object* existingObj=0 ); osg::Object* readObject( osg::Object* existingObj=0 );
osg::Object* readObjectFields( const std::string& className, unsigned int id, osg::Object* existingObj=0); osg::Object* readObjectFields( const std::string& className, unsigned int id, osg::Object* existingObj=0);
/// set an input iterator, used directly when not using InputStream with a traditional file releated stream. /// set an input iterator, used directly when not using InputStream with a traditional file releated stream.

View File

@ -15,6 +15,7 @@
#ifndef OSGDB_OUTPUTSTREAM #ifndef OSGDB_OUTPUTSTREAM
#define OSGDB_OUTPUTSTREAM #define OSGDB_OUTPUTSTREAM
#include <osg/Version>
#include <osg/Vec2> #include <osg/Vec2>
#include <osg/Vec3> #include <osg/Vec3>
#include <osg/Vec4> #include <osg/Vec4>
@ -142,17 +143,16 @@ public:
OutputStream& operator<<( const osg::BoundingSpheref& bb ); OutputStream& operator<<( const osg::BoundingSpheref& bb );
OutputStream& operator<<( const osg::BoundingSphered& bb ); OutputStream& operator<<( const osg::BoundingSphered& bb );
OutputStream& operator<<( const osg::Array* a ) { writeArray(a); return *this; }
OutputStream& operator<<( const osg::Image* img ) { writeImage(img); return *this; } OutputStream& operator<<( const osg::Image* img ) { writeImage(img); return *this; }
OutputStream& operator<<( const osg::PrimitiveSet* p ) { writePrimitiveSet(p); return *this; } OutputStream& operator<<( const osg::Array* a ) { if (OPENSCENEGRAPH_SOVERSION>=112) writeObject(a); else writeArray(a); return *this; }
OutputStream& operator<<( const osg::PrimitiveSet* p ) { if (OPENSCENEGRAPH_SOVERSION>=112) writeObject(p); else writePrimitiveSet(p); return *this; }
OutputStream& operator<<( const osg::Object* obj ) { writeObject(obj); return *this; } OutputStream& operator<<( const osg::Object* obj ) { writeObject(obj); return *this; }
OutputStream& operator<<( const osg::ref_ptr<osg::Array>& ptr ) { writeArray(ptr.get()); return *this; }
OutputStream& operator<<( const osg::ref_ptr<osg::Image>& ptr ) { writeImage(ptr.get()); return *this; } OutputStream& operator<<( const osg::ref_ptr<osg::Image>& ptr ) { writeImage(ptr.get()); return *this; }
OutputStream& operator<<( const osg::ref_ptr<osg::PrimitiveSet>& ptr ) { writePrimitiveSet(ptr.get()); return *this; } OutputStream& operator<<( const osg::ref_ptr<osg::Array>& ptr ) { if (OPENSCENEGRAPH_SOVERSION>=112) writeObject(ptr.get()); else writeArray(ptr.get()); return *this; }
OutputStream& operator<<( const osg::ref_ptr<osg::PrimitiveSet>& ptr ) { if (OPENSCENEGRAPH_SOVERSION>=112) writeObject(ptr.get()); else writePrimitiveSet(ptr.get()); return *this; }
template<typename T> OutputStream& operator<<( const osg::ref_ptr<T>& ptr ) template<typename T> OutputStream& operator<<( const osg::ref_ptr<T>& ptr ) { writeObject(ptr.get()); return *this; }
{ writeObject(ptr.get()); return *this; }
// Convenient methods for writing // Convenient methods for writing
void writeWrappedString( const std::string& str ) { _out->writeWrappedString(str); } void writeWrappedString( const std::string& str ) { _out->writeWrappedString(str); }

View File

@ -135,7 +135,6 @@ public:
/** create an object of specified type for provided compound class name in the form libraryName::className. */ /** create an object of specified type for provided compound class name in the form libraryName::className. */
osg::Object* createObject(const std::string& compoundClassdName) const; osg::Object* createObject(const std::string& compoundClassdName) const;
/// template method for getting property data, return true if property available and the type is compatible, otherwise returns false. /// template method for getting property data, return true if property available and the type is compatible, otherwise returns false.
template<typename T> template<typename T>
bool getProperty(const osg::Object* object, const std::string& propertyName, T& value); bool getProperty(const osg::Object* object, const std::string& propertyName, T& value);
@ -250,7 +249,7 @@ inline bool PropertyInterface::getProperty(const osg::Object* object, const std:
if (copyPropertyObjectFromObject(object, propertyName, &value, sizeof(ObjectPtr), getTypeEnum<ObjectPtr>())) return true; if (copyPropertyObjectFromObject(object, propertyName, &value, sizeof(ObjectPtr), getTypeEnum<ObjectPtr>())) return true;
else else
{ {
OSG_NOTICE<<"PropertyInterface::getProperty("<<propertyName<<", "<<value->className()<<") Checking UserDataContainer for object ptr"<<std::endl; OSG_NOTICE<<"PropertyInterface::getProperty("<<propertyName<<", Checking UserDataContainer for object ptr"<<std::endl;
const osg::UserDataContainer* udc = object->getUserDataContainer(); const osg::UserDataContainer* udc = object->getUserDataContainer();
if (udc) if (udc)
{ {
@ -294,6 +293,7 @@ inline bool PropertyInterface::setProperty(osg::Object* object, const std::strin
} }
} }
} }
#endif #endif

View File

@ -135,7 +135,8 @@ public:
RW_VEC3B, RW_VEC3UB, RW_VEC3S, RW_VEC3US, RW_VEC3I, RW_VEC3UI, RW_VEC3B, RW_VEC3UB, RW_VEC3S, RW_VEC3US, RW_VEC3I, RW_VEC3UI,
RW_VEC4B, RW_VEC4UB, RW_VEC4S, RW_VEC4US, RW_VEC4I, RW_VEC4UI, RW_VEC4B, RW_VEC4UB, RW_VEC4S, RW_VEC4US, RW_VEC4I, RW_VEC4UI,
RW_BOUNDINGBOXF, RW_BOUNDINGBOXD, RW_BOUNDINGBOXF, RW_BOUNDINGBOXD,
RW_BOUNDINGSPHEREF, RW_BOUNDINGSPHERED RW_BOUNDINGSPHEREF, RW_BOUNDINGSPHERED,
RW_VECTOR
}; };
BaseSerializer() : _firstVersion(0), _lastVersion(INT_MAX) {} BaseSerializer() : _firstVersion(0), _lastVersion(INT_MAX) {}
@ -784,6 +785,345 @@ public:
Setter _setter; Setter _setter;
}; };
class VectorBaseSerializer : public BaseSerializer
{
public:
VectorBaseSerializer(BaseSerializer::Type elementType):_elementType(elementType) {}
Type getElementType() const { return _elementType; }
virtual unsigned int size(const osg::Object& obj) const { return 0; }
virtual void resize(osg::Object& obj, unsigned int numElements) const {}
virtual void reserve(osg::Object& obj, unsigned int numElements) const {}
virtual void clear(osg::Object& obj) const {}
virtual void addElement(osg::Object& obj, void* ptr) const {}
virtual void insertElement(osg::Object& obj, unsigned int index, void* ptr) const {}
virtual void setElement(osg::Object& obj, unsigned int index, void* ptr) const {}
virtual void* getElement(osg::Object& obj, unsigned int index) const { return 0; }
virtual const void* getElement(const osg::Object& obj, unsigned int index) const { return 0; }
protected:
Type _elementType;
};
template<typename C, typename P>
class VectorSerializer : public VectorBaseSerializer
{
public:
typedef typename P::value_type ValueType;
typedef typename P::const_iterator ConstIterator;
typedef P& (C::*Getter)();
typedef const P& (C::*ConstGetter)() const;
typedef void (C::*Setter)( const P& );
VectorSerializer( const char* name, ConstGetter cgf, Getter gf, Setter sf, BaseSerializer::Type elementType, unsigned int numElementsOnRow):
VectorBaseSerializer(elementType),
_name(name),
_constgetter(cgf), _getter(gf), _setter(sf),
_numElementsOnRow(numElementsOnRow) {}
virtual const std::string& getName() const { return _name; }
virtual unsigned int size(const osg::Object& obj) const
{
const C& object = OBJECT_CAST<const C&>(obj);
const P& list = (object.*_constgetter)();
return static_cast<unsigned int>(list.size());
}
virtual void resize(osg::Object& obj, unsigned int numElements) const
{
C& object = OBJECT_CAST<C&>(obj);
P& list = (object.*_getter)();
list.resize(numElements);
}
virtual void reserve(osg::Object& obj, unsigned int numElements) const
{
C& object = OBJECT_CAST<C&>(obj);
P& list = (object.*_getter)();
list.reserve(numElements);
}
virtual void clear(osg::Object& obj) const
{
C& object = OBJECT_CAST<C&>(obj);
P& list = (object.*_getter)();
list.clear();
}
virtual void addElement(osg::Object& obj, void* ptr) const
{
C& object = OBJECT_CAST<C&>(obj);
P& list = (object.*_getter)();
list.push_back(*reinterpret_cast<ValueType*>(ptr));
}
virtual void insertElement(osg::Object& obj, unsigned int index, void* ptr) const
{
C& object = OBJECT_CAST<C&>(obj);
P& list = (object.*_getter)();
if (index>=list.size()) list.resize(index+1);
list.insert(list.begin()+index, *reinterpret_cast<ValueType*>(ptr));
}
virtual void setElement(osg::Object& obj, unsigned int index, void* ptr) const
{
C& object = OBJECT_CAST<C&>(obj);
P& list = (object.*_getter)();
if (index>=list.size()) list.resize(index+1);
list[index] = *reinterpret_cast<ValueType*>(ptr);
}
virtual void* getElement(osg::Object& obj, unsigned int index) const
{
C& object = OBJECT_CAST<C&>(obj);
P& list = (object.*_getter)();
if (index>=list.size()) return 0;
else return &list[index];
}
virtual const void* getElement(const osg::Object& obj, unsigned int index) const
{
const C& object = OBJECT_CAST<const C&>(obj);
const P& list = (object.*_constgetter)();
if (index>=list.size()) return 0;
else return &list[index];
}
virtual bool read( InputStream& is, osg::Object& obj )
{
C& object = OBJECT_CAST<C&>(obj);
unsigned int size = 0;
P list;
if ( is.isBinary() )
{
is >> size;
for ( unsigned int i=0; i<size; ++i )
{
ValueType value;
is >> value;
list.push_back( value );
}
if ( size>0 ) (object.*_setter)( list );
}
else if ( is.matchString(_name) )
{
is >> size;
if ( size>0 ) is >> is.BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
ValueType value;
is >> value;
list.push_back( value );
}
if ( size>0 )
{
is >> is.END_BRACKET;
(object.*_setter)( list );
}
}
return true;
}
virtual bool write( OutputStream& os, const osg::Object& obj )
{
const C& object = OBJECT_CAST<const C&>(obj);
const P& list = (object.*_constgetter)();
unsigned int size = (unsigned int)list.size();
if ( os.isBinary() )
{
os << size;
for ( ConstIterator itr=list.begin();
itr!=list.end(); ++itr )
{
os << (*itr);
}
}
else if ( size>0 )
{
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << std::endl;
if (_numElementsOnRow==0)
{
for ( ConstIterator itr=list.begin(); itr!=list.end(); ++itr )
{
os << (*itr);
}
}
else if (_numElementsOnRow==1)
{
for ( ConstIterator itr=list.begin(); itr!=list.end(); ++itr )
{
os << (*itr); os << std::endl;
}
}
else
{
unsigned int i = _numElementsOnRow-1;
for (ConstIterator itr=list.begin(); itr!=list.end(); ++itr)
{
os << (*itr);
if (i==0) { os << std::endl; i = _numElementsOnRow-1; }
else --i;
}
if (i!=_numElementsOnRow) os << std::endl;
}
os << os.END_BRACKET << std::endl;
}
return true;
}
public:
std::string _name;
ConstGetter _constgetter;
Getter _getter;
Setter _setter;
unsigned int _numElementsOnRow;
};
template<typename C>
class IsAVectorSerializer : public VectorBaseSerializer
{
public:
typedef typename C::value_type ValueType;
typedef typename C::const_iterator ConstIterator;
IsAVectorSerializer( const char* name, BaseSerializer::Type elementType, unsigned int numElementsOnRow) :
VectorBaseSerializer(elementType),
_name(name),
_numElementsOnRow(numElementsOnRow) {}
virtual const std::string& getName() const { return _name; }
virtual unsigned int size(const osg::Object& obj) const
{
const C& list = OBJECT_CAST<const C&>(obj);
return static_cast<unsigned int>(list.size());
}
virtual void resize(osg::Object& obj, unsigned int numElements) const
{
C& list = OBJECT_CAST<C&>(obj);
list.resize(numElements);
}
virtual void reserve(osg::Object& obj, unsigned int numElements) const
{
C& list = OBJECT_CAST<C&>(obj);
list.reserve(numElements);
}
virtual void clear(osg::Object& obj) const
{
C& list = OBJECT_CAST<C&>(obj);
list.clear();
}
virtual void addElement(osg::Object& obj, void* ptr) const
{
C& list = OBJECT_CAST<C&>(obj);
list.push_back(*reinterpret_cast<ValueType*>(ptr));
}
virtual void insertElement(osg::Object& obj, unsigned int index, void* ptr) const
{
C& list = OBJECT_CAST<C&>(obj);
if (index>=list.size()) list.resize(index+1);
list.insert(list.begin()+index, *reinterpret_cast<ValueType*>(ptr));
}
virtual void setElement(osg::Object& obj, unsigned int index, void* ptr) const
{
C& list = OBJECT_CAST<C&>(obj);
if (index>=list.size()) list.resize(index+1);
list[index] = *reinterpret_cast<ValueType*>(ptr);
}
virtual void* getElement(osg::Object& obj, unsigned int index) const
{
C& list = OBJECT_CAST<C&>(obj);
if (index>=list.size()) return 0;
else return &list[index];
}
virtual const void* getElement(const osg::Object& obj, unsigned int index) const
{
const C& list = OBJECT_CAST<const C&>(obj);
if (index>=list.size()) return 0;
else return &list[index];
}
virtual bool read( InputStream& is, osg::Object& obj )
{
C& list = OBJECT_CAST<C&>(obj);
unsigned int size = 0;
if ( is.isBinary() )
{
is >> size;
for ( unsigned int i=0; i<size; ++i )
{
ValueType value;
is >> value;
list.push_back( value );
}
}
else if ( is.matchString(_name) )
{
is >> size;
if ( size>0 ) is >> is.BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
ValueType value;
is >> value;
list.push_back( value );
}
if ( size>0 )
{
is >> is.END_BRACKET;
}
}
return true;
}
virtual bool write( OutputStream& os, const osg::Object& obj )
{
const C& list = OBJECT_CAST<const C&>(obj);
unsigned int size = (unsigned int)list.size();
if ( os.isBinary() )
{
os << size;
for ( ConstIterator itr=list.begin();
itr!=list.end(); ++itr )
{
os << (*itr);
}
}
else if ( size>0 )
{
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << std::endl;
if (_numElementsOnRow==0)
{
for ( ConstIterator itr=list.begin(); itr!=list.end(); ++itr )
{
os << (*itr);
}
}
else if (_numElementsOnRow==1)
{
for ( ConstIterator itr=list.begin(); itr!=list.end(); ++itr )
{
os << (*itr); os << std::endl;
}
}
else
{
unsigned int i = _numElementsOnRow-1;
for (ConstIterator itr=list.begin(); itr!=list.end(); ++itr)
{
os << (*itr);
if (i==0) { os << std::endl; i = _numElementsOnRow-1; }
else --i;
}
if (i!=_numElementsOnRow) os << std::endl;
}
os << os.END_BRACKET << std::endl;
}
return true;
}
public:
std::string _name;
unsigned int _numElementsOnRow;
};
// ADDING MANIPULATORS // ADDING MANIPULATORS
#define ADD_SERIALIZER(S) \ #define ADD_SERIALIZER(S) \
wrapper->addSerializer( (S) ) wrapper->addSerializer( (S) )
@ -1062,6 +1402,14 @@ public:
wrapper->addSerializer( new osgDB::ListSerializer< MyClass, TYPE >( \ wrapper->addSerializer( new osgDB::ListSerializer< MyClass, TYPE >( \
#PROP, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_LIST ) #PROP, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_LIST )
#define ADD_VECTOR_SERIALIZER(PROP, TYPE, ELEMENTTYPE, NUMELEMENTSONROW) \
wrapper->addSerializer( new osgDB::VectorSerializer< MyClass, TYPE >( \
#PROP, &MyClass::get##PROP, &MyClass::get##PROP, &MyClass::set##PROP, ELEMENTTYPE, NUMELEMENTSONROW), osgDB::BaseSerializer::RW_VECTOR )
#define ADD_ISAVECTOR_SERIALIZER(PROP, ELEMENTTYPE, NUMELEMENTSONROW) \
wrapper->addSerializer( new osgDB::IsAVectorSerializer< MyClass >( #PROP, ELEMENTTYPE, NUMELEMENTSONROW), osgDB::BaseSerializer::RW_VECTOR )
#define BEGIN_ENUM_SERIALIZER(PROP, DEF) \ #define BEGIN_ENUM_SERIALIZER(PROP, DEF) \
{ typedef osgDB::EnumSerializer<MyClass, MyClass::PROP, void> MySerializer; \ { typedef osgDB::EnumSerializer<MyClass, MyClass::PROP, void> MySerializer; \
osg::ref_ptr<MySerializer> serializer = new MySerializer( \ osg::ref_ptr<MySerializer> serializer = new MySerializer( \

View File

@ -189,6 +189,22 @@ const Array* Geometry::getTexCoordArray(unsigned int index) const
else return 0; else return 0;
} }
void Geometry::setTexCoordArrayList(const ArrayList& arrayList)
{
_texCoordList = arrayList;
dirtyDisplayList();
if (_useVertexBufferObjects)
{
for(ArrayList::iterator itr = _texCoordList.begin();
itr != _texCoordList.end();
++itr)
{
addVertexBufferObjectIfRequired(itr->get());
}
}
}
void Geometry::setVertexAttribArray(unsigned int index, Array* array, osg::Array::Binding binding) void Geometry::setVertexAttribArray(unsigned int index, Array* array, osg::Array::Binding binding)
{ {
@ -216,6 +232,23 @@ const Array *Geometry::getVertexAttribArray(unsigned int index) const
else return 0; else return 0;
} }
void Geometry::setVertexAttribArrayList(const ArrayList& arrayList)
{
_vertexAttribList = arrayList;
dirtyDisplayList();
if (_useVertexBufferObjects)
{
for(ArrayList::iterator itr = _vertexAttribList.begin();
itr != _vertexAttribList.end();
++itr)
{
addVertexBufferObjectIfRequired(itr->get());
}
}
}
bool Geometry::addPrimitiveSet(PrimitiveSet* primitiveset) bool Geometry::addPrimitiveSet(PrimitiveSet* primitiveset)
{ {
@ -712,7 +745,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
// draw the primitives themselves. // draw the primitives themselves.
// //
drawPrimitivesImplementation(renderInfo); drawPrimitivesImplementation(renderInfo);
// unbind the VBO's if any are used. // unbind the VBO's if any are used.
state.unbindVertexBufferObject(); state.unbindVertexBufferObject();
state.unbindElementBufferObject(); state.unbindElementBufferObject();

View File

@ -12,7 +12,6 @@
*/ */
// Written by Wang Rui, (C) 2010 // Written by Wang Rui, (C) 2010
#include <osg/Version>
#include <osg/Notify> #include <osg/Notify>
#include <osgDB/FileUtils> #include <osgDB/FileUtils>
#include <osgDB/WriteFile> #include <osgDB/WriteFile>

View File

@ -239,6 +239,9 @@ PropertyInterface::PropertyInterface():
TYPENAME(VEC4US) TYPENAME(VEC4US)
TYPENAME(VEC4I) TYPENAME(VEC4I)
TYPENAME(VEC4UI) TYPENAME(VEC4UI)
TYPENAME(LIST)
TYPENAME(VECTOR)
} }
@ -371,7 +374,7 @@ bool PropertyInterface::copyPropertyDataToObject(osg::Object* object, const std:
} }
else else
{ {
OSG_NOTICE<<"PropertyInterface::copyPropertyDataToObject() Types are not compatible, valueType = "<<valueType<<", destinationType="<<destinationType<<std::endl; OSG_NOTICE<<"PropertyInterface::copyPropertyDataToObject() Types are not compatible, valueType = "<<valueType<<" ["<<getTypeName(valueType)<<"] , destinationType="<<destinationType<<" ["<<getTypeName(destinationType)<<"]"<<std::endl;
return false; return false;
} }
} }
@ -394,7 +397,7 @@ bool PropertyInterface::copyPropertyObjectFromObject(const osg::Object* object,
} }
else else
{ {
OSG_NOTICE<<"PropertyInterface::copyPropertyObjectFromObject() Types are not compatible, valueType = "<<valueType<<", destinationType="<<sourceType<<std::endl; OSG_NOTICE<<"PropertyInterface::copyPropertyObjectFromObject() Types are not compatible, valueType = "<<valueType<<" ["<<getTypeName(valueType)<<"] , sourceType="<<sourceType<<" ["<<getTypeName(sourceType)<<"]"<<std::endl;
return false; return false;
} }
} }
@ -636,6 +639,7 @@ bool PropertyInterface::hasMethod(const osg::Object* object, const std::string&
return hasMethod(object->getCompoundClassName(), methodName); return hasMethod(object->getCompoundClassName(), methodName);
} }
} // end of osgDB namespace } // end of osgDB namespace

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,56 @@ namespace lua
// forward declare // forward declare
class LuaScriptEngine; class LuaScriptEngine;
struct SerializerScratchPad : public osg::Referenced
{
SerializerScratchPad(unsigned int s=256):dataType(osgDB::BaseSerializer::RW_UNDEFINED),dataSize(0) { maxDataSize = s; data = new char[s]; }
unsigned int maxDataSize;
char* data;
osgDB::BaseSerializer::Type dataType;
unsigned int dataSize;
void reset()
{
dataType = osgDB::BaseSerializer::RW_UNDEFINED;
dataSize = 0;
}
template<typename T>
bool set(const T& t)
{
if (sizeof(T)<=maxDataSize)
{
*(reinterpret_cast<T*>(data)) = t;
dataType = osgDB::getTypeEnum<T>();
dataSize = sizeof(T);
return true;
}
else
{
dataSize = 0;
dataType = osgDB::BaseSerializer::RW_UNDEFINED;
return false;
}
}
template<typename T>
bool get(T& t) const
{
if (sizeof(T)==dataSize && dataType == osgDB::getTypeEnum<T>())
{
t = *(reinterpret_cast<T*>(data));
return true;
}
else
{
return false;
}
}
};
class LuaScriptEngine : public osg::ScriptEngine class LuaScriptEngine : public osg::ScriptEngine
{ {
public: public:
@ -47,6 +97,9 @@ class LuaScriptEngine : public osg::ScriptEngine
osgDB::PropertyInterface& getPropertyInterface() const { return _pi; } osgDB::PropertyInterface& getPropertyInterface() const { return _pi; }
int pushDataToStack(SerializerScratchPad* ssp) const;
int popDataFromStack(SerializerScratchPad* ssp, osgDB::BaseSerializer::Type type) const;
int pushPropertyToStack(osg::Object* object, const std::string& propertyName) const; int pushPropertyToStack(osg::Object* object, const std::string& propertyName) const;
int setPropertyFromStack(osg::Object* object, const std::string& propertyName) const; int setPropertyFromStack(osg::Object* object, const std::string& propertyName) const;
@ -109,6 +162,7 @@ class LuaScriptEngine : public osg::ScriptEngine
bool popParameter(osg::Object* object) const; bool popParameter(osg::Object* object) const;
osg::Object* popParameterObject() const; osg::Object* popParameterObject() const;
void pushContainer(osg::Object* object, const std::string& propertyName) const;
void createAndPushObject(const std::string& compoundName) const; void createAndPushObject(const std::string& compoundName) const;
void pushObject(osg::Object* object) const; void pushObject(osg::Object* object) const;
@ -133,6 +187,24 @@ class LuaScriptEngine : public osg::ScriptEngine
else return 0; else return 0;
} }
std::string getStringFromTable(int pos, const std::string& field) const
{
std::string result;
if (lua_type(_lua, pos)==LUA_TTABLE)
{
lua_pushstring(_lua, field.c_str());
lua_rawget(_lua, pos);
if (lua_type(_lua, -1)==LUA_TSTRING)
{
result = lua_tostring(_lua, -1);
}
lua_pop(_lua,1);
}
return result;
}
std::string getObjectCompoundClassName(int pos) const std::string getObjectCompoundClassName(int pos) const
{ {
if (lua_type(_lua, pos)==LUA_TTABLE) if (lua_type(_lua, pos)==LUA_TTABLE)

View File

@ -6,6 +6,7 @@
namespace ArrayWrappers { namespace ArrayWrappers {
#if 0
struct ResizeArray : public osgDB::MethodObject struct ResizeArray : public osgDB::MethodObject
{ {
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
@ -28,14 +29,14 @@ struct ResizeArray : public osgDB::MethodObject
return true; return true;
} }
}; };
#endif
REGISTER_OBJECT_WRAPPER( Array, REGISTER_OBJECT_WRAPPER( Array,
0, 0,
osg::Array, osg::Array,
"osg::Object osg::Array" ) "osg::Object osg::Array" )
{ {
#if 0
BEGIN_ENUM_SERIALIZER_NO_SET( Type, ArrayType ); BEGIN_ENUM_SERIALIZER_NO_SET( Type, ArrayType );
ADD_ENUM_VALUE( ArrayType ); ADD_ENUM_VALUE( ArrayType );
@ -94,6 +95,8 @@ REGISTER_OBJECT_WRAPPER( Array,
ADD_UINT_SERIALIZER_NO_SET( TotalDataSize, 0); ADD_UINT_SERIALIZER_NO_SET( TotalDataSize, 0);
ADD_UINT_SERIALIZER_NO_SET( NumElements, 0); ADD_UINT_SERIALIZER_NO_SET( NumElements, 0);
ADD_METHOD_OBJECT( "resizeArray", ResizeArray );
#endif
BEGIN_ENUM_SERIALIZER( Binding, BIND_UNDEFINED ); BEGIN_ENUM_SERIALIZER( Binding, BIND_UNDEFINED );
ADD_ENUM_VALUE( BIND_UNDEFINED ); ADD_ENUM_VALUE( BIND_UNDEFINED );
ADD_ENUM_VALUE( BIND_OFF ); ADD_ENUM_VALUE( BIND_OFF );
@ -105,50 +108,54 @@ REGISTER_OBJECT_WRAPPER( Array,
ADD_BOOL_SERIALIZER(Normalize, false); ADD_BOOL_SERIALIZER(Normalize, false);
ADD_BOOL_SERIALIZER(PreserveDataType, false); ADD_BOOL_SERIALIZER(PreserveDataType, false);
ADD_METHOD_OBJECT( "resizeArray", ResizeArray );
} }
} }
#define ARRAY_WRAPPERS( ARRAY ) \ #define ARRAY_WRAPPERS( ARRAY, ELEMENTTYPE, NUMELEMENTSONROW ) \
namespace Wrappers##ARRAY { REGISTER_OBJECT_WRAPPER( ARRAY, new osg::ARRAY, osg::ARRAY, "osg::Object osg::Array osg::"#ARRAY ) {} } namespace Wrappers##ARRAY { \
REGISTER_OBJECT_WRAPPER( ARRAY, new osg::ARRAY, osg::ARRAY, "osg::Object osg::Array osg::"#ARRAY) \
{ \
ADD_ISAVECTOR_SERIALIZER( vector, osgDB::BaseSerializer::ELEMENTTYPE, NUMELEMENTSONROW ); \
} \
}
ARRAY_WRAPPERS(FloatArray) ARRAY_WRAPPERS(FloatArray, RW_FLOAT, 4)
ARRAY_WRAPPERS(Vec2Array) ARRAY_WRAPPERS(Vec2Array, RW_VEC2F, 1)
ARRAY_WRAPPERS(Vec3Array) ARRAY_WRAPPERS(Vec3Array, RW_VEC3F, 1)
ARRAY_WRAPPERS(Vec4Array) ARRAY_WRAPPERS(Vec4Array, RW_VEC4F, 1)
ARRAY_WRAPPERS(DoubleArray) ARRAY_WRAPPERS(DoubleArray, RW_DOUBLE, 4)
ARRAY_WRAPPERS(Vec2dArray) ARRAY_WRAPPERS(Vec2dArray, RW_VEC2D, 1)
ARRAY_WRAPPERS(Vec3dArray) ARRAY_WRAPPERS(Vec3dArray, RW_VEC3D, 1)
ARRAY_WRAPPERS(Vec4dArray) ARRAY_WRAPPERS(Vec4dArray, RW_VEC4D, 1)
ARRAY_WRAPPERS(ByteArray) ARRAY_WRAPPERS(ByteArray, RW_CHAR, 4)
ARRAY_WRAPPERS(Vec2bArray) ARRAY_WRAPPERS(Vec2bArray, RW_VEC2B, 1)
ARRAY_WRAPPERS(Vec3bArray) ARRAY_WRAPPERS(Vec3bArray, RW_VEC3B, 1)
ARRAY_WRAPPERS(Vec4bArray) ARRAY_WRAPPERS(Vec4bArray, RW_VEC4B, 1)
ARRAY_WRAPPERS(UByteArray) ARRAY_WRAPPERS(UByteArray, RW_UCHAR, 4)
ARRAY_WRAPPERS(Vec2ubArray) ARRAY_WRAPPERS(Vec2ubArray, RW_VEC2UB, 1)
ARRAY_WRAPPERS(Vec3ubArray) ARRAY_WRAPPERS(Vec3ubArray, RW_VEC3UB, 1)
ARRAY_WRAPPERS(Vec4ubArray) ARRAY_WRAPPERS(Vec4ubArray, RW_VEC4UB, 1)
ARRAY_WRAPPERS(ShortArray) ARRAY_WRAPPERS(ShortArray, RW_SHORT, 4)
ARRAY_WRAPPERS(Vec2sArray) ARRAY_WRAPPERS(Vec2sArray, RW_VEC2S, 1)
ARRAY_WRAPPERS(Vec3sArray) ARRAY_WRAPPERS(Vec3sArray, RW_VEC3S, 1)
ARRAY_WRAPPERS(Vec4sArray) ARRAY_WRAPPERS(Vec4sArray, RW_VEC4S, 1)
ARRAY_WRAPPERS(UShortArray) ARRAY_WRAPPERS(UShortArray, RW_USHORT, 4)
ARRAY_WRAPPERS(Vec2usArray) ARRAY_WRAPPERS(Vec2usArray, RW_VEC2US, 1)
ARRAY_WRAPPERS(Vec3usArray) ARRAY_WRAPPERS(Vec3usArray, RW_VEC3US, 1)
ARRAY_WRAPPERS(Vec4usArray) ARRAY_WRAPPERS(Vec4usArray, RW_VEC4US, 1)
ARRAY_WRAPPERS(IntArray) ARRAY_WRAPPERS(IntArray, RW_INT, 4)
ARRAY_WRAPPERS(Vec2iArray) ARRAY_WRAPPERS(Vec2iArray, RW_VEC2I, 1)
ARRAY_WRAPPERS(Vec3iArray) ARRAY_WRAPPERS(Vec3iArray, RW_VEC3I, 1)
ARRAY_WRAPPERS(Vec4iArray) ARRAY_WRAPPERS(Vec4iArray, RW_VEC4I, 1)
ARRAY_WRAPPERS(UIntArray) ARRAY_WRAPPERS(UIntArray, RW_UINT, 4)
ARRAY_WRAPPERS(Vec2uiArray) ARRAY_WRAPPERS(Vec2uiArray, RW_VEC2UI, 1)
ARRAY_WRAPPERS(Vec3uiArray) ARRAY_WRAPPERS(Vec3uiArray, RW_VEC3UI, 1)
ARRAY_WRAPPERS(Vec4uiArray) ARRAY_WRAPPERS(Vec4uiArray, RW_VEC4UI, 1)

View File

@ -146,7 +146,9 @@ REGISTER_OBJECT_WRAPPER( Geometry,
osg::Geometry, osg::Geometry,
"osg::Object osg::Drawable osg::Geometry" ) "osg::Object osg::Drawable osg::Geometry" )
{ {
ADD_LIST_SERIALIZER( PrimitiveSetList, osg::Geometry::PrimitiveSetList ); // _primitives //ADD_LIST_SERIALIZER( PrimitiveSetList, osg::Geometry::PrimitiveSetList ); // _primitives
ADD_VECTOR_SERIALIZER( PrimitiveSetList, osg::Geometry::PrimitiveSetList, osgDB::BaseSerializer::RW_OBJECT, 0 );
ADD_USER_SERIALIZER( VertexData ); // _vertexData ADD_USER_SERIALIZER( VertexData ); // _vertexData
ADD_USER_SERIALIZER( NormalData ); // _normalData ADD_USER_SERIALIZER( NormalData ); // _normalData
ADD_USER_SERIALIZER( ColorData ); // _colorData ADD_USER_SERIALIZER( ColorData ); // _colorData
@ -157,5 +159,27 @@ REGISTER_OBJECT_WRAPPER( Geometry,
ADD_USER_SERIALIZER( FastPathHint ); // _fastPathHint ADD_USER_SERIALIZER( FastPathHint ); // _fastPathHint
{
UPDATE_TO_VERSION_SCOPED( 112 )
REMOVE_SERIALIZER( VertexData );
REMOVE_SERIALIZER( NormalData );
REMOVE_SERIALIZER( ColorData );
REMOVE_SERIALIZER( SecondaryColorData );
REMOVE_SERIALIZER( FogCoordData );
REMOVE_SERIALIZER( TexCoordData );
REMOVE_SERIALIZER( VertexAttribData );
REMOVE_SERIALIZER( FastPathHint );
ADD_OBJECT_SERIALIZER( VertexArray, osg::Array, NULL );
ADD_OBJECT_SERIALIZER( NormalArray, osg::Array, NULL );
ADD_OBJECT_SERIALIZER( ColorArray, osg::Array, NULL );
ADD_OBJECT_SERIALIZER( SecondaryColorArray, osg::Array, NULL );
ADD_OBJECT_SERIALIZER( FogCoordArray, osg::Array, NULL );
ADD_VECTOR_SERIALIZER( TexCoordArrayList, osg::Geometry::ArrayList, osgDB::BaseSerializer::RW_OBJECT, 0 );
ADD_VECTOR_SERIALIZER( VertexAttribArrayList, osg::Geometry::ArrayList, osgDB::BaseSerializer::RW_OBJECT, 0 );
}
wrapper->addFinishedObjectReadCallback( new GeometryFinishedObjectReadCallback() ); wrapper->addFinishedObjectReadCallback( new GeometryFinishedObjectReadCallback() );
} }

View File

@ -6,12 +6,54 @@
namespace PrimitiveSetWrapper { namespace PrimitiveSetWrapper {
#define CUSTOM_BEGIN_ENUM_SERIALIZER(PROP, DEF) \
{ typedef osgDB::EnumSerializer<MyClass, MyClass::PROP, void> MySerializer; \
osg::ref_ptr<MySerializer> serializer = new MySerializer( \
#PROP, MyClass::DEF, &MyClass::get##PROP, &MyClass::set##PROP)
REGISTER_OBJECT_WRAPPER( PrimitiveSet, REGISTER_OBJECT_WRAPPER( PrimitiveSet,
0, 0,
osg::PrimitiveSet, osg::PrimitiveSet,
"osg::Object osg::PrimitiveSet" ) "osg::Object osg::PrimitiveSet" )
{ {
ADD_INT_SERIALIZER( NumInstances, 0);
#if 1
{
typedef osgDB::EnumSerializer<MyClass, MyClass::Mode, void> MySerializer;
typedef osg::PrimitiveSet::Mode (osg::PrimitiveSet::*Getter)() const;
typedef void (osg::PrimitiveSet::*Setter)( osg::PrimitiveSet::Mode );
osg::ref_ptr<MySerializer> serializer = new MySerializer( "Mode", osg::PrimitiveSet::POINTS,
reinterpret_cast<Getter>(&osg::PrimitiveSet::getMode),
reinterpret_cast<Setter>(&osg::PrimitiveSet::setMode));
ADD_ENUM_VALUE( POINTS );
ADD_ENUM_VALUE( LINES );
ADD_ENUM_VALUE( LINE_STRIP );
ADD_ENUM_VALUE( LINE_LOOP );
ADD_ENUM_VALUE( TRIANGLES );
ADD_ENUM_VALUE( TRIANGLE_STRIP );
ADD_ENUM_VALUE( TRIANGLE_FAN );
ADD_ENUM_VALUE( QUADS );
ADD_ENUM_VALUE( QUAD_STRIP );
ADD_ENUM_VALUE( POLYGON );
ADD_ENUM_VALUE( LINES_ADJACENCY );
ADD_ENUM_VALUE( LINE_STRIP_ADJACENCY );
ADD_ENUM_VALUE( TRIANGLES_ADJACENCY );
ADD_ENUM_VALUE( TRIANGLE_STRIP_ADJACENCY );
ADD_ENUM_VALUE( PATCHES );
wrapper->addSerializer(serializer.get(), osgDB::BaseSerializer::RW_ENUM);
}
#else
ADD_GLENUM_SERIALIZER( Mode, GLenum, GL_NONE );
#endif
#if 0
BEGIN_ENUM_SERIALIZER_NO_SET( Type, PrimitiveType ); BEGIN_ENUM_SERIALIZER_NO_SET( Type, PrimitiveType );
ADD_ENUM_VALUE( PrimitiveType ); ADD_ENUM_VALUE( PrimitiveType );
ADD_ENUM_VALUE( DrawArraysPrimitiveType ); ADD_ENUM_VALUE( DrawArraysPrimitiveType );
@ -21,17 +63,14 @@ REGISTER_OBJECT_WRAPPER( PrimitiveSet,
ADD_ENUM_VALUE( DrawElementsUIntPrimitiveType ); ADD_ENUM_VALUE( DrawElementsUIntPrimitiveType );
END_ENUM_SERIALIZER(); END_ENUM_SERIALIZER();
ADD_INT_SERIALIZER( NumInstances, 0);
ADD_GLENUM_SERIALIZER( Mode, GLenum, GL_NONE );
ADD_UINT_SERIALIZER_NO_SET( TotalDataSize, 0); ADD_UINT_SERIALIZER_NO_SET( TotalDataSize, 0);
ADD_UINT_SERIALIZER_NO_SET( NumPrimitives, 0); ADD_UINT_SERIALIZER_NO_SET( NumPrimitives, 0);
ADD_UINT_SERIALIZER_NO_SET( NumIndices, 0); ADD_UINT_SERIALIZER_NO_SET( NumIndices, 0);
wrapper->addSerializer( wrapper->addSerializer(
new osgDB::PropByValSerializer< osg::PrimitiveSet, bool > ("supportsBufferObject", false, &osg::PrimitiveSet::supportsBufferObject, 0, osgDB::BaseSerializer::RW_BOOL ) new osgDB::PropByValSerializer< osg::PrimitiveSet, bool > ("supportsBufferObject", false, &osg::PrimitiveSet::supportsBufferObject, 0, osgDB::BaseSerializer::RW_BOOL )
); );
#endif
} }
} }
@ -49,6 +88,20 @@ REGISTER_OBJECT_WRAPPER( DrawArrays,
} }
namespace DrawArrayLengthsWrapper {
REGISTER_OBJECT_WRAPPER( DrawArrayLengths,
new osg::DrawArrayLengths,
osg::DrawArrayLengths,
"osg::Object osg::PrimitiveSet osg::DrawArrayLengths" )
{
ADD_GLINT_SERIALIZER( First, 0);
ADD_ISAVECTOR_SERIALIZER( vector, osgDB::BaseSerializer::RW_INT, 4 );
}
}
#if 0
namespace DrawElementsWrapper { namespace DrawElementsWrapper {
struct ResizeDrawElements : public osgDB::MethodObject struct ResizeDrawElements : public osgDB::MethodObject
@ -74,7 +127,6 @@ struct ResizeDrawElements : public osgDB::MethodObject
} }
}; };
REGISTER_OBJECT_WRAPPER( DrawElements, REGISTER_OBJECT_WRAPPER( DrawElements,
0, 0,
osg::DrawElements, osg::DrawElements,
@ -84,10 +136,16 @@ REGISTER_OBJECT_WRAPPER( DrawElements,
} }
} }
#endif
#define DRAW_ELEMENTS_WRAPPER( DRAWELEMENTS ) \ #define DRAW_ELEMENTS_WRAPPER( DRAWELEMENTS, ELEMENTTYPE ) \
namespace Wrapper##DRAWELEMENTS { REGISTER_OBJECT_WRAPPER( DRAWELEMENTS, new osg::DRAWELEMENTS, osg::DRAWELEMENTS, "osg::Object osg::PrimitiveSet osg::DrawElements "#DRAWELEMENTS) {} } namespace Wrapper##DRAWELEMENTS { \
REGISTER_OBJECT_WRAPPER( DRAWELEMENTS, new osg::DRAWELEMENTS, osg::DRAWELEMENTS, "osg::Object osg::PrimitiveSet osg::"#DRAWELEMENTS) \
{ \
ADD_ISAVECTOR_SERIALIZER( vector, osgDB::BaseSerializer::ELEMENTTYPE, 4 ); \
} \
}
DRAW_ELEMENTS_WRAPPER( DrawElementsUByte ) DRAW_ELEMENTS_WRAPPER( DrawElementsUByte, RW_UCHAR )
DRAW_ELEMENTS_WRAPPER( DrawElementsUShort ) DRAW_ELEMENTS_WRAPPER( DrawElementsUShort, RW_USHORT )
DRAW_ELEMENTS_WRAPPER( DrawElementsUInt ) DRAW_ELEMENTS_WRAPPER( DrawElementsUInt, RW_UINT )