aboutsummaryrefslogtreecommitdiff
path: root/src/mesh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh.cpp')
-rw-r--r--src/mesh.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp
index b5bf8660a..b68862d22 100644
--- a/src/mesh.cpp
+++ b/src/mesh.cpp
@@ -226,7 +226,27 @@ void setMeshColorByNormalXYZ(scene::IMesh *mesh,
vertex->Color = colorY;
else
vertex->Color = colorZ;
+ }
+ }
+}
+
+void setMeshColorByNormal(scene::IMesh *mesh, const v3f &normal,
+ const video::SColor &color)
+{
+ if (!mesh)
+ return;
+ u16 mc = mesh->getMeshBufferCount();
+ for (u16 j = 0; j < mc; j++) {
+ scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
+ const u32 stride = getVertexPitchFromType(buf->getVertexType());
+ u32 vertex_count = buf->getVertexCount();
+ u8 *vertices = (u8 *)buf->getVertices();
+ for (u32 i = 0; i < vertex_count; i++) {
+ video::S3DVertex *vertex = (video::S3DVertex *)(vertices + i * stride);
+ if (normal == vertex->Normal) {
+ vertex->Color = color;
+ }
}
}
}