Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: include/CVertexBuffer.h
- ===================================================================
- --- include/CVertexBuffer.h (revision 4533)
- +++ include/CVertexBuffer.h (working copy)
- @@ -169,6 +169,8 @@
- return video::EVT_2TCOORDS;
- case sizeof(video::S3DVertexTangents):
- return video::EVT_TANGENTS;
- + case sizeof(video::S3DVertexBlended):
- + return video::EVT_BLENDED;
- default:
- return (video::E_VERTEX_TYPE)-1;
- }
- @@ -187,6 +189,7 @@
- typedef CVertexBuffer<video::S3DVertex> SVertexBuffer;
- typedef CVertexBuffer<video::S3DVertex2TCoords> SVertexBufferLightMap;
- typedef CVertexBuffer<video::S3DVertexTangents> SVertexBufferTangents;
- + typedef CVertexBuffer<video::S3DVertexBlended> SVertexBufferBlended;
- }
- }
- Index: include/S3DVertex.h
- ===================================================================
- --- include/S3DVertex.h (revision 4533)
- +++ include/S3DVertex.h (working copy)
- @@ -26,7 +26,11 @@
- //! Vertex with a tangent and binormal vector, video::S3DVertexTangents.
- /** Usually used for tangent space normal mapping. */
- - EVT_TANGENTS
- + EVT_TANGENTS,
- +
- + //! Vertex with a blend indices and wieghts, video::S3DVertexBlend.
- + /** Usually used for tangent space normal mapping. */
- + EVT_BLENDED
- };
- //! Array holding the built in vertex type names
- @@ -35,6 +39,7 @@
- "standard",
- "2tcoords",
- "tangents",
- + "blended",
- 0
- };
- @@ -251,8 +256,71 @@
- }
- };
- +//! Vertex with blend indices and weights along with a tangent and binormal vector.
- +/** Usually used for tangent space normal mapping. */
- +struct S3DVertexBlended : public S3DVertexTangents
- +{
- + //! default constructor
- + S3DVertexBlended() : S3DVertexTangents() { }
- + //! constructor
- + S3DVertexBlended(const core::vector3df& pos,
- + const core::vector3df& normal, SColor c,
- + const core::vector2df& tcoords,
- + const core::vector3df& tangent,
- + const core::vector3df& binormal,
- + const float blendIndices[4],
- + const float blendWeights[4],
- + const core::vector2df& tcoords2)
- + : S3DVertexTangents(pos, normal, c, tcoords, tangent, binormal), TCoords2(tcoords2) {
- + BlendIndices[0] = blendIndices[0];
- + BlendIndices[1] = blendIndices[1];
- + BlendIndices[2] = blendIndices[2];
- + BlendIndices[3] = blendIndices[3];
- + BlendWeights[0] = blendWeights[0];
- + BlendWeights[1] = blendWeights[1];
- + BlendWeights[2] = blendWeights[2];
- + BlendWeights[3] = blendWeights[3];
- + }
- +
- + //! Blend indices
- + float BlendIndices[4];
- +
- + //! Blend weights
- + float BlendWeights[4];
- +
- + //! Second set of texture coordinates
- + core::vector2d<f32> TCoords2;
- +
- + //! Equality operator
- + bool operator==(const S3DVertexBlended& other) const
- + {
- + return ((static_cast<S3DVertex>(*this)==other) &&
- + (TCoords2 == other.TCoords2));
- + }
- +
- + //! Inequality operator
- + bool operator!=(const S3DVertexBlended& other) const
- + {
- + return ((static_cast<S3DVertex>(*this)!=other) ||
- + (TCoords2 != other.TCoords2));
- + }
- +
- + bool operator<(const S3DVertexBlended& other) const
- + {
- + return ((static_cast<S3DVertex>(*this) < other) ||
- + ((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2)));
- + }
- +
- + E_VERTEX_TYPE getType() const
- + {
- + return EVT_BLENDED;
- + }
- +};
- +
- +
- +
- inline u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType)
- {
- switch (vertexType)
- @@ -261,6 +329,8 @@
- return sizeof(video::S3DVertex2TCoords);
- case video::EVT_TANGENTS:
- return sizeof(video::S3DVertexTangents);
- + case video::EVT_BLENDED:
- + return sizeof(video::S3DVertexBlended);
- default:
- return sizeof(video::S3DVertex);
- }
- Index: source/Irrlicht/CNullDriver.cpp
- ===================================================================
- --- source/Irrlicht/CNullDriver.cpp (revision 4533)
- +++ source/Irrlicht/CNullDriver.cpp (working copy)
- @@ -268,7 +268,19 @@
- VertexDescriptor[2]->addAttribute("inTexCoord0", 2, EVAS_TEXCOORD0, EVAT_FLOAT);
- VertexDescriptor[2]->addAttribute("inTangent", 3, EVAS_TANGENT, EVAT_FLOAT);
- VertexDescriptor[2]->addAttribute("inBinormal", 3, EVAS_BINORMAL, EVAT_FLOAT);
- +
- + addVertexDescriptor("blended");
- + VertexDescriptor[3]->addAttribute("inPosition", 3, EVAS_POSITION, EVAT_FLOAT);
- + VertexDescriptor[3]->addAttribute("inNormal", 3, EVAS_NORMAL, EVAT_FLOAT);
- + VertexDescriptor[3]->addAttribute("inColor", 4, EVAS_COLOR, EVAT_UBYTE);
- + VertexDescriptor[3]->addAttribute("inTexCoord0", 2, EVAS_TEXCOORD0, EVAT_FLOAT);
- + VertexDescriptor[3]->addAttribute("inTangent", 3, EVAS_TANGENT, EVAT_FLOAT);
- + VertexDescriptor[3]->addAttribute("inBinormal", 3, EVAS_BINORMAL, EVAT_FLOAT);
- + VertexDescriptor[3]->addAttribute("inBlendIndices", 4, EVAS_BLEND_INDICES, EVAT_FLOAT);
- + VertexDescriptor[3]->addAttribute("inBlendWeights", 4, EVAS_BLEND_WEIGHTS, EVAT_FLOAT);
- + VertexDescriptor[3]->addAttribute("inTexCoord1", 2, EVAS_TEXCOORD1, EVAT_FLOAT);
- +
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment