Exemplo n.º 1
0
fl3  CCone::getColor(vector<CLight> Lights, int SceneLightCount)
{
  //здесь интенсивностb света от разных источников суммируютс¤. 
  if (CLight::light_model != CLight::LM_NO_LIGHT)
  {
    int n = Lights.size();
    if (n == 0) return fl3(0, 0, 0);
    calculatePointColor();
    calculateIntensity(Lights);
    fl3 col = fl3(0, 0, 0);
    for (int i = 0; i < n; i++)
    {
      fl3 clr = Lights[i].clr;
      float r = clr.m[0],
        g = clr.m[1],
        b = clr.m[2];
      fl3 intensity = SavedIntensity[i];
      float ir = intensity.m[0],
        ig = intensity.m[1],
        ib = intensity.m[2];
      col += fl3(r*ir, g*ig, b*ib);
    }
    col = SavedColor ^ col;
    //col /= (float)SceneLightCount;
    return col;
  }
  return SavedNormal;
}
Exemplo n.º 2
0
/**
 * Set pixle color r,g,b in raster for x,y
 */
void bkgl::setPixel(Point p)
{ 
  if (isInScreen(p) && isInViewport(p) && checkzbuffer(p))
  {
	Color light = calculateIntensity(p.world, p.normal.normalize());
	Color spec  = calculateSpecularColor(p.world, p.normal.normalize());
  
	Color newColor = applyLightToColor(light, p.color, spec);
	
	raster[((p.y*SCREENWIDTH) + p.x)*3 + 0] = newColor[0];
	raster[((p.y*SCREENWIDTH) + p.x)*3 + 1] = newColor[1];
	raster[((p.y*SCREENWIDTH) + p.x)*3 + 2] = newColor[2];
	if (gldepthTest)
	  zbuffer[(p.y*SCREENWIDTH) + p.x] = p.z;
  }
}