diff --git a/include/CMeshBuffer.h b/include/CMeshBuffer.h index bc66df7c..6f1ff368 100644 --- a/include/CMeshBuffer.h +++ b/include/CMeshBuffer.h @@ -176,6 +176,17 @@ namespace scene return Vertices[i].TCoords; } + //! returns color of vertex i + virtual video::SColor& getColor(u32 i) IRR_OVERRIDE + { + return Vertices[i].Color; + } + + //! returns color of vertex i + virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE + { + return Vertices[i].Color; + } //! Append the vertices and indices to the current buffer /** Only works for compatible types, i.e. either the same type diff --git a/include/IDynamicMeshBuffer.h b/include/IDynamicMeshBuffer.h index 3aed1265..8317f175 100644 --- a/include/IDynamicMeshBuffer.h +++ b/include/IDynamicMeshBuffer.h @@ -166,6 +166,18 @@ namespace scene { return getVertexBuffer()[i].Normal; } + + //! returns color of vertex i + virtual video::SColor& getColor(u32 i) IRR_OVERRIDE + { + return getVertexBuffer()[i].Color; + } + + //! returns color of vertex i + virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE + { + return getVertexBuffer()[i].Color; + } }; diff --git a/include/IMeshBuffer.h b/include/IMeshBuffer.h index 77ce995d..253d2712 100644 --- a/include/IMeshBuffer.h +++ b/include/IMeshBuffer.h @@ -119,6 +119,12 @@ namespace scene //! returns texture coord of vertex i virtual core::vector2df& getTCoords(u32 i) = 0; + //! returns color of vertex i + virtual video::SColor& getColor(u32 i) = 0; + + //! returns color of vertex i + virtual const video::SColor& getColor(u32 i) const = 0; + //! Append the vertices and indices to the current buffer /** Only works for compatible vertex types and not implemented for most buffers for now. diff --git a/include/SSharedMeshBuffer.h b/include/SSharedMeshBuffer.h index aac563d8..f894625b 100644 --- a/include/SSharedMeshBuffer.h +++ b/include/SSharedMeshBuffer.h @@ -171,6 +171,21 @@ namespace scene return (*Vertices)[Indices[i]].TCoords; } + //! returns color of vertex i + virtual video::SColor& getColor(u32 i) IRR_OVERRIDE + { + IRR_DEBUG_BREAK_IF(!Vertices); + return (*Vertices)[Indices[i]].Color; + } + + //! returns color of vertex i + virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE + { + IRR_DEBUG_BREAK_IF(!Vertices); + return (*Vertices)[Indices[i]].Color; + } + + //! append the vertices and indices to the current buffer virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE { diff --git a/include/SSkinMeshBuffer.h b/include/SSkinMeshBuffer.h index 52d480ce..b2b812b4 100644 --- a/include/SSkinMeshBuffer.h +++ b/include/SSkinMeshBuffer.h @@ -326,6 +326,34 @@ struct SSkinMeshBuffer : public IMeshBuffer } } + //! returns color of vertex i + virtual video::SColor& getColor(u32 i) IRR_OVERRIDE + { + switch (VertexType) + { + case video::EVT_2TCOORDS: + return Vertices_2TCoords[i].Color; + case video::EVT_TANGENTS: + return Vertices_Tangents[i].Color; + default: + return Vertices_Standard[i].Color; + } + } + + //! returns color of vertex i + virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE + { + switch (VertexType) + { + case video::EVT_2TCOORDS: + return Vertices_2TCoords[i].Color; + case video::EVT_TANGENTS: + return Vertices_Tangents[i].Color; + default: + return Vertices_Standard[i].Color; + } + } + //! append the vertices and indices to the current buffer virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE {}