Commit fcc40c78 authored by Isaak Lim's avatar Isaak Lim

added color_cast from Vec3f and Vec4f to Vec3i and Vec3ui

refs #1405

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@812 fdac6126-5c0c-442c-9429-916003d36597
parent 708af706
......@@ -4,10 +4,10 @@
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
* *
* OpenMesh is free software: you can redistribute it and/or modify *
* OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
......@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
\*===========================================================================*/
/*===========================================================================*\
* *
* *
* $Revision$ *
* $Date$ *
* *
......@@ -114,6 +114,58 @@ struct color_caster<Vec3uc,Vec4f>
}
};
template <>
struct color_caster<Vec3i,Vec3f>
{
typedef Vec3i return_type;
inline static return_type cast(const Vec3f& _src)
{
return Vec3i( (int)(_src[0]* 255.0f + 0.5f),
(int)(_src[1]* 255.0f + 0.5f),
(int)(_src[2]* 255.0f + 0.5f) );
}
};
template <>
struct color_caster<Vec3i,Vec4f>
{
typedef Vec3i return_type;
inline static return_type cast(const Vec4f& _src)
{
return Vec3i( (int)(_src[0]* 255.0f + 0.5f),
(int)(_src[1]* 255.0f + 0.5f),
(int)(_src[2]* 255.0f + 0.5f) );
}
};
template <>
struct color_caster<Vec3ui,Vec3f>
{
typedef Vec3ui return_type;
inline static return_type cast(const Vec3f& _src)
{
return Vec3ui( (unsigned int)(_src[0]* 255.0f + 0.5f),
(unsigned int)(_src[1]* 255.0f + 0.5f),
(unsigned int)(_src[2]* 255.0f + 0.5f) );
}
};
template <>
struct color_caster<Vec3ui,Vec4f>
{
typedef Vec3ui return_type;
inline static return_type cast(const Vec4f& _src)
{
return Vec3ui( (unsigned int)(_src[0]* 255.0f + 0.5f),
(unsigned int)(_src[1]* 255.0f + 0.5f),
(unsigned int)(_src[2]* 255.0f + 0.5f) );
}
};
template <>
struct color_caster<Vec4uc,Vec3f>
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment