From 9debed15de25ef2d8741e3f8a78025b4482cd137 Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 9 Jul 2008 15:19:06 +0000 Subject: [PATCH] Added Brighting function that increase/decrease the brightnes of the vertex colors --- vcg/complex/trimesh/update/color.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/vcg/complex/trimesh/update/color.h b/vcg/complex/trimesh/update/color.h index 9f0e5fef..628f87d4 100644 --- a/vcg/complex/trimesh/update/color.h +++ b/vcg/complex/trimesh/update/color.h @@ -314,6 +314,30 @@ static void VertexQuality(UpdateMeshType &m) VertexQuality(m,minq,maxq); } + +//Apply the brightness filter, with the given amount, to the mesh. +static int Brighting(UpdateMeshType &m, int amount, const bool ProcessSelected=false) +{ + int counter=0; + VertexIterator vi; + for(vi=m.vert.begin();vi!=m.vert.end();++vi) //scan all the vertex... + { + if(!(*vi).IsD()) //if it has not been deleted... + { + if(!ProcessSelected || (*vi).IsS()) //if this vertex has been selected, do transormation + { + (*vi).C() = Color4b( + math::Clamp(int((*vi).C()[0])+amount,0,255), + math::Clamp(int((*vi).C()[1])+amount,0,255), + math::Clamp(int((*vi).C()[2])+amount,0,255), + 255); + ++counter; + } + } + } + return counter; +} + }; }// end namespace