double PointLight::getCumulativeIndex() { if (m_refractive_index > 0) return m_refractive_index; //calculate the refractive index std::default_random_engine generator; //randomly pick a ray ray r = getPhoton(generator); //trace the ray multiset<const SceneObject*> objs; isect i; while (scene->intersect(r, i)) { if (i.obj->hasInterior()) { //only care about volumetric shapes if (r.getDirection().dot(i.N) > RAY_EPSILON) { //going out of the material if (objs.find(i.obj) == objs.end()) { //not found in the set //that must be one. m_refractive_index *= i.getMaterial().index; r = ray(r.at(i.t), r.getDirection()); } else { //found the same object already objs.erase(i.obj); r = ray(r.at(i.t), r.getDirection()); } } else { //going into the material objs.insert(i.obj); r = ray(r.at(i.t), r.getDirection()); } } } return m_refractive_index; }
void PhotonMap::renderGL() { glBegin(GL_POINTS); for (int i = 0; i < stored_photons; ++i) { Photon ph = getPhoton(i); glVertex3f(ph.pos[0], ph.pos[1], ph.pos[2]); } glEnd(); }