00001 /* 00002 File: AnaMesh.cc 00003 00004 Function: See header file 00005 00006 Author(s): Andrew Willmott 00007 00008 Copyright: (c) 1997-2000, Andrew Willmott 00009 00010 */ 00011 00012 #include "AnaMesh.h" 00013 #include "AnaRad.h" 00014 00015 Colour AnaGrid::Sample(Coord c) 00016 // calculate radiosity using PatchFactor directly 00017 { 00018 Int i, j; 00019 Colour patchCol; 00020 GCLReal s = c[0]; 00021 GCLReal t = c[1]; 00022 AnaRad *rad = (AnaRad*) gRadControl->radObject; 00023 00024 Point p = Vertex(1) + s * (Vertex(2) - Vertex(1)) 00025 + t * (Vertex(0) - Vertex(1)); 00026 00027 patchCol = cBlack; 00028 00029 for (j = 0; j < rad->lights.NumItems(); j++) 00030 patchCol += rad->lights[j]->Emittance() 00031 * rad->lights[j]->PatchFactor(p, Normal()); 00032 00033 patchCol *= Reflectance(); 00034 patchCol += Emittance(); 00035 00036 return(patchCol); 00037 }