Added inital cut of PrimitiveSetSet wrappers to scripting
This commit is contained in:
parent
42705bff3f
commit
cb805d7be5
@ -374,6 +374,7 @@ class DrawElements : public PrimitiveSet
|
||||
/** Get the const ElementBufferObject. If no EBO is assigned returns NULL*/
|
||||
inline const osg::ElementBufferObject* getElementBufferObject() const { return dynamic_cast<const osg::ElementBufferObject*>(_bufferObject.get()); }
|
||||
|
||||
virtual void resizeElements(unsigned int numIndices) = 0;
|
||||
virtual void reserveElements(unsigned int numIndices) = 0;
|
||||
virtual void setElement(unsigned int, unsigned int) = 0;
|
||||
virtual unsigned int getElement(unsigned int) = 0;
|
||||
@ -430,6 +431,7 @@ class OSG_EXPORT DrawElementsUByte : public DrawElements, public VectorGLubyte
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
||||
virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
|
||||
virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
|
||||
virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
|
||||
@ -492,6 +494,7 @@ class OSG_EXPORT DrawElementsUShort : public DrawElements, public VectorGLushort
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
||||
virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
|
||||
virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
|
||||
virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
|
||||
@ -554,6 +557,7 @@ class OSG_EXPORT DrawElementsUInt : public DrawElements, public VectorGLuint
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
||||
virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
|
||||
virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
|
||||
virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
|
||||
|
@ -111,7 +111,7 @@ REGISTER_OBJECT_WRAPPER( Array,
|
||||
}
|
||||
|
||||
#define ARRAY_WRAPPERS( ARRAY ) \
|
||||
namespace Wrappers##ARRAY { REGISTER_OBJECT_WRAPPER( ARRAY, new osg::ARRAY, osg::ARRAY, "osg::Object osg::Array "#ARRAY ) {} }
|
||||
namespace Wrappers##ARRAY { REGISTER_OBJECT_WRAPPER( ARRAY, new osg::ARRAY, osg::ARRAY, "osg::Object osg::Array osg::"#ARRAY ) {} }
|
||||
|
||||
ARRAY_WRAPPERS(FloatArray)
|
||||
ARRAY_WRAPPERS(Vec2Array)
|
||||
|
90
src/osgWrappers/serializers/osg/PrimitiveSet.cpp
Normal file
90
src/osgWrappers/serializers/osg/PrimitiveSet.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#include <osg/PrimitiveSet>
|
||||
#include <osg/ValueObject>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
namespace PrimitiveSetWrapper {
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( PrimitiveSet,
|
||||
0,
|
||||
osg::PrimitiveSet,
|
||||
"osg::Object osg::PrimitiveSet" )
|
||||
{
|
||||
|
||||
BEGIN_ENUM_SERIALIZER_NO_SET( Type, PrimitiveType );
|
||||
ADD_ENUM_VALUE( PrimitiveType );
|
||||
ADD_ENUM_VALUE( DrawArraysPrimitiveType );
|
||||
ADD_ENUM_VALUE( DrawArrayLengthsPrimitiveType );
|
||||
ADD_ENUM_VALUE( DrawElementsUBytePrimitiveType );
|
||||
ADD_ENUM_VALUE( DrawElementsUShortPrimitiveType );
|
||||
ADD_ENUM_VALUE( DrawElementsUIntPrimitiveType );
|
||||
END_ENUM_SERIALIZER();
|
||||
|
||||
ADD_GLENUM_SERIALIZER( Mode, GLenum, GL_NONE );
|
||||
|
||||
ADD_UINT_SERIALIZER_NO_SET( TotalDataSize, 0);
|
||||
ADD_UINT_SERIALIZER_NO_SET( NumPrimitives, 0);
|
||||
|
||||
wrapper->addSerializer(
|
||||
new osgDB::PropByValSerializer< osg::PrimitiveSet, bool > ("supportsBufferObject", false, &osg::PrimitiveSet::supportsBufferObject, 0, osgDB::BaseSerializer::RW_BOOL )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace DrawArraysWrapper {
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( DrawArrays,
|
||||
new osg::DrawArrays,
|
||||
osg::DrawArrays,
|
||||
"osg::Object osg::PrimitiveSet osg::DrawArrays" )
|
||||
{
|
||||
ADD_GLINT_SERIALIZER( First, 0);
|
||||
ADD_GLINT_SERIALIZER( Count, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace DrawElementsWrapper {
|
||||
|
||||
struct ResizeDrawElements : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
|
||||
{
|
||||
if (inputParameters.empty()) return false;
|
||||
|
||||
osg::Object* indexObject = inputParameters[0].get();
|
||||
|
||||
unsigned int index = 0;
|
||||
osg::DoubleValueObject* dvo = dynamic_cast<osg::DoubleValueObject*>(indexObject);
|
||||
if (dvo) index = static_cast<unsigned int>(dvo->getValue());
|
||||
else
|
||||
{
|
||||
osg::UIntValueObject* uivo = dynamic_cast<osg::UIntValueObject*>(indexObject);
|
||||
if (uivo) index = uivo->getValue();
|
||||
}
|
||||
osg::DrawElements* de = reinterpret_cast<osg::DrawElements*>(objectPtr);
|
||||
de->resizeElements(index);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( DrawElements,
|
||||
0,
|
||||
osg::DrawElements,
|
||||
"osg::Object osg::PrimitiveSet osg::DrawElements" )
|
||||
{
|
||||
ADD_METHOD_OBJECT( "resizeElements", ResizeDrawElements );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#define DRAW_ELEMENTS_WRAPPER( DRAWELEMENTS ) \
|
||||
namespace Wrapper##DRAWELEMENTS { REGISTER_OBJECT_WRAPPER( DRAWELEMENTS, new osg::DRAWELEMENTS, osg::DRAWELEMENTS, "osg::Object osg::PrimitiveSet osg::DrawElements "#DRAWELEMENTS) {} }
|
||||
|
||||
DRAW_ELEMENTS_WRAPPER( DrawElementsUByte )
|
||||
DRAW_ELEMENTS_WRAPPER( DrawElementsUShort )
|
||||
DRAW_ELEMENTS_WRAPPER( DrawElementsUInt )
|
Loading…
Reference in New Issue
Block a user