本文整理汇总了C++中Color4::GetFromRGB方法的典型用法代码示例。如果您正苦于以下问题:C++ Color4::GetFromRGB方法的具体用法?C++ Color4::GetFromRGB怎么用?C++ Color4::GetFromRGB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color4
的用法示例。
在下文中一共展示了Color4::GetFromRGB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Light
void Light(float colorOut[4], const float colorIn[4], Vec3 pos, Vec3 normal, float dots[4])
{
// could cache a lot of stuff, such as ambient, across vertices...
bool doShadeMapping = (gstate.texmapmode & 0x3) == 2;
if (!doShadeMapping && !(gstate.lightEnable[0]&1) && !(gstate.lightEnable[1]&1) && !(gstate.lightEnable[2]&1) && !(gstate.lightEnable[3]&1))
{
memcpy(colorOut, colorIn, sizeof(float) * 4);
return;
}
Color4 emissive;
emissive.GetFromRGB(gstate.materialemissive);
Color4 globalAmbient;
globalAmbient.GetFromRGB(gstate.ambientcolor);
globalAmbient.GetFromA(gstate.ambientalpha);
Vec3 norm = normal.Normalized();
Color4 in(colorIn);
Color4 ambient;
if (gstate.materialupdate & 1)
{
ambient = in;
}
else
{
ambient.GetFromRGB(gstate.materialambient);
ambient.a=1.0f;
}
Color4 diffuse;
if (gstate.materialupdate & 2)
{
diffuse = in;
}
else
{
diffuse.GetFromRGB(gstate.materialdiffuse);
diffuse.a=1.0f;
}
Color4 specular;
if (gstate.materialupdate & 4)
{
specular = in;
}
else
{
specular.GetFromRGB(gstate.materialspecular);
specular.a=1.0f;
}
float specCoef = getFloat24(gstate.materialspecularcoef);
norm.Normalize();
Vec3 viewer(gstate.viewMatrix[8], gstate.viewMatrix[9], gstate.viewMatrix[10]);
Color4 lightSum = globalAmbient * ambient + emissive;
// Try lights.elf - there's something wrong with the lighting
for (int l = 0; l < 4; l++)
{
// can we skip this light?
if ((gstate.lightEnable[l] & 1) == 0) // && !doShadeMapping)
continue;
GELightComputation comp = (GELightComputation)(gstate.ltype[l]&3);
GELightType type = (GELightType)((gstate.ltype[l]>>8)&3);
Vec3 toLight;
if (type == GE_LIGHTTYPE_DIRECTIONAL)
toLight = Vec3(gstate.lightpos[l]);
else
toLight = Vec3(gstate.lightpos[l]) - pos;
Vec3 dir = Vec3(gstate.lightdir[l]);
bool doSpecular = (comp != GE_LIGHTCOMP_ONLYDIFFUSE);
bool poweredDiffuse = comp == GE_LIGHTCOMP_BOTHWITHPOWDIFFUSE;
float distance = toLight.Normalize();
float lightScale = 1.0f;
if (type != GE_LIGHTTYPE_DIRECTIONAL)
{
lightScale = 1.0f / (gstate.lightatt[l][0] + gstate.lightatt[l][1]*distance + gstate.lightatt[l][2]*distance*distance);
if (lightScale>1.0f) lightScale=1.0f;
}
float dot = toLight * norm;
// Clamp dot to zero.
if (dot < 0.0f) dot = 0.0f;
if (poweredDiffuse)
dot = powf(dot, specCoef);
//.........这里部分代码省略.........