Harton
Member
|
How use function ColorLerp
I would like change object color from colorMin to colorMax and vice versa from colorMax to colorMin. I use function ColorLerp but this function work oddly.
Example:
Code:
// in class declaration
Color color, colorMin, colorMax;
bool up;
// in class function - update()
if(up == true)
{
color = ColorLerp(color, colorMax, 0.5);
if(color==colorMax)
up = false;
}
else
{
color = ColorLerp(color, colorMin, 0.5);
if(color==colorMin)
up = true;
}
object.color = color.asVec4();
What is wrong? Variable 'up' never change...
|
|
05-23-2011 12:38 AM |
|
Driklyn
Member
|
RE: How use function ColorLerp
I would recommend using a timer-based solution:
Code:
Flt colorStep;
Bool update()
{
colorStep += Time.d() * ((up) ? 1 : -1);
Clamp(colorStep, 0, 1);
color = ColorLerp(colorMin, colorMax, colorStep);
// ...
}
|
|
05-23-2011 06:05 AM |
|
Harton
Member
|
RE: How use function ColorLerp
Thanks!
A small fix and it's working.
|
|
05-23-2011 08:51 AM |
|