Index: include/COLLADASWConstants.h =================================================================== --- include/COLLADASWConstants.h (revision 587) +++ include/COLLADASWConstants.h (working copy) @@ -46,7 +46,8 @@ static const String CSW_ELEMENT_BLINN; static const String CSW_ELEMENT_BIND; static const String CSW_ELEMENT_BIND_MATERIAL; - static const String CSW_ELEMENT_BIND_SHAPE_MATRIX; + static const String CSW_ELEMENT_BIND_SHAPE_MATRIX; + static const String CSW_ELEMENT_BIND_VERTEX_INPUT; static const String CSW_ELEMENT_BORDER_COLOR; static const String CSW_ELEMENT_CAMERA; static const String CSW_ELEMENT_CAMERA_ORTHOGRAPHIC; @@ -219,7 +220,9 @@ static const String CSW_ATTRIBUTE_END; static const String CSW_ATTRIBUTE_FACE; static const String CSW_ATTRIBUTE_ID; - static const String CSW_ATTRIBUTE_INDEX; + static const String CSW_ATTRIBUTE_INDEX; + static const String CSW_ATTRIBUTE_INPUT_SEMANTIC; + static const String CSW_ATTRIBUTE_INPUT_SET; static const String CSW_ATTRIBUTE_MATERIAL; static const String CSW_ATTRIBUTE_METER; static const String CSW_ATTRIBUTE_METHOD; Index: include/COLLADASWInstanceMaterial.h =================================================================== --- include/COLLADASWInstanceMaterial.h (revision 587) +++ include/COLLADASWInstanceMaterial.h (working copy) @@ -22,14 +22,61 @@ namespace COLLADASW { + class BindVertexInput + { + private: + /** Which effect parameter to bind. Required.*/ + String mSemantic; + + /** Which input semantic to bind. Required.*/ + String mInputSemantic; + + /** Which input set to bind. Optional. -1 if not set.*/ + int mInputSet; + public: + + BindVertexInput(const COLLADASW::String& semantic, const COLLADASW::String& inputSemantic, int inputSet = -1) + : mSemantic(semantic), mInputSemantic(inputSemantic), mInputSet(inputSet){} + + /** Which effect parameter to bind. Required.*/ + const COLLADASW::String& getSemantic() const { return mSemantic; } + + /** Which effect parameter to bind. Required.*/ + void setSemantic(const COLLADASW::String& semantic) { mSemantic = semantic; } + + /** Which input semantic to bind. Required.*/ + const COLLADASW::String& getInputSemantic() const { return mInputSemantic; } + + /** Which input semantic to bind. Required.*/ + void setInputSemantic(const COLLADASW::String& inputSemantic) { mInputSemantic = inputSemantic; } + + /** Which input set to bind. Optional. -1 if not set.*/ + int getInputSet() const { return mInputSet; } + + /** Which input set to bind. Optional. -1 if not set.*/ + void setInputSet(int inputSet) { mInputSet = inputSet; } + + private: + /** Set this class a friend, so it can call the add() method. */ + friend class InstanceMaterial; + + /** Add all the instance materials, added using push_back(), to the stream*/ + void add( StreamWriter* sw); + + }; + + class InstanceMaterialList; /** A class that holds informations of an @a \ element*/ class InstanceMaterial { - + private: + /** List of all the BindVertexInput*/ + typedef std::list BindVertexInputList; private: + BindVertexInputList mBindVertexInputList; String mSymbol; URI mTarget; @@ -43,17 +90,22 @@ : mSymbol ( symbol ), mTarget ( target ) {} /** Returns the symbol*/ - const String & getSymbol() const - { - return mSymbol; - } + const String & getSymbol() const {return mSymbol; } /** Returns the target*/ - const URI & getTarget() const - { - return mTarget; - } + const URI & getTarget() const { return mTarget; } + /** Adds @a input to list of inputs that should be added*/ + void push_back ( const BindVertexInput& input ) { mBindVertexInputList.push_back ( input ); } + + private: + /** Set this class a friend, so it can call the add() method. */ + friend class InstanceMaterialList; + + /** Add all the instance materials, added using push_back(), to the stream*/ + void add( StreamWriter* sw); + + }; /** A class that hold a list of instances of InstanceMaterial and writes it to stream*/ @@ -70,16 +122,10 @@ virtual ~InstanceMaterialList() {} /** Adds @a input to list of inputs that should be added*/ - void push_back ( InstanceMaterial input ) - { - mList.push_back ( input ); - } + void push_back ( const InstanceMaterial& input ) { mList.push_back ( input ); } /** Return true, if the list of material bindings is empty, false otherwise*/ - bool empty() const - { - return mList.empty(); - } + bool empty() const { return mList.empty(); } private: Index: src/COLLADASWConstants.cpp =================================================================== --- src/COLLADASWConstants.cpp (revision 587) +++ src/COLLADASWConstants.cpp (working copy) @@ -38,7 +38,8 @@ const String CSWC::CSW_ELEMENT_BLINN = "blinn"; const String CSWC::CSW_ELEMENT_BIND = "bind"; const String CSWC::CSW_ELEMENT_BIND_MATERIAL = "bind_material"; - const String CSWC::CSW_ELEMENT_BIND_SHAPE_MATRIX = "bind_shape_matrix"; + const String CSWC::CSW_ELEMENT_BIND_SHAPE_MATRIX = "bind_shape_matrix"; + const String CSWC::CSW_ELEMENT_BIND_VERTEX_INPUT = "bind_vertex_input"; const String CSWC::CSW_ELEMENT_BORDER_COLOR = "border_color"; const String CSWC::CSW_ELEMENT_CAMERA = "camera"; const String CSWC::CSW_ELEMENT_CAMERA_ORTHOGRAPHIC = "orthographic"; @@ -209,7 +210,9 @@ const String CSWC::CSW_ATTRIBUTE_END = "end"; const String CSWC::CSW_ATTRIBUTE_FACE = "face"; const String CSWC::CSW_ATTRIBUTE_ID = "id"; - const String CSWC::CSW_ATTRIBUTE_INDEX = "index"; + const String CSWC::CSW_ATTRIBUTE_INDEX = "index"; + const String CSWC::CSW_ATTRIBUTE_INPUT_SEMANTIC = "input_semantic"; + const String CSWC::CSW_ATTRIBUTE_INPUT_SET = "input_set"; const String CSWC::CSW_ATTRIBUTE_MATERIAL = "material"; const String CSWC::CSW_ATTRIBUTE_METER = "meter"; const String CSWC::CSW_ATTRIBUTE_METHOD = "method"; Index: src/COLLADASWInstanceMaterial.cpp =================================================================== --- src/COLLADASWInstanceMaterial.cpp (revision 587) +++ src/COLLADASWInstanceMaterial.cpp (working copy) @@ -19,11 +19,32 @@ { for ( List::iterator it = mList.begin(); it != mList.end(); ++it ) { - mSW->openElement ( CSWC::CSW_ELEMENT_INSTANCE_MATERIAL ); - mSW->appendAttribute ( CSWC::CSW_ATTRIBUTE_SYMBOL, it->getSymbol() ); - mSW->appendURIAttribute ( CSWC::CSW_ATTRIBUTE_TARGET, it->getTarget() ); - mSW->closeElement(); + it->add( mSW ); } } + + //--------------------------------------------------------------- + void InstanceMaterial::add( StreamWriter* sw ) + { + sw->openElement ( CSWC::CSW_ELEMENT_INSTANCE_MATERIAL ); + sw->appendAttribute ( CSWC::CSW_ATTRIBUTE_SYMBOL, getSymbol() ); + sw->appendURIAttribute ( CSWC::CSW_ATTRIBUTE_TARGET, getTarget() ); + for ( BindVertexInputList::iterator it = mBindVertexInputList.begin(); it != mBindVertexInputList.end(); ++it) + { + it->add( sw ); + } + + sw->closeElement(); + } + + //--------------------------------------------------------------- + void BindVertexInput::add( StreamWriter* sw ) + { + sw->openElement ( CSWC::CSW_ELEMENT_INSTANCE_MATERIAL ); + sw->appendAttribute ( CSWC::CSW_ATTRIBUTE_SEMANTIC, getSemantic() ); + sw->appendAttribute ( CSWC::CSW_ATTRIBUTE_INPUT_SEMANTIC, getInputSemantic() ); + sw->appendAttribute ( CSWC::CSW_ATTRIBUTE_INPUT_SET, getInputSet() ); + sw->closeElement(); + } } //namespace COLLADASW