本文整理汇总了C++中Medium::transportPhoton方法的典型用法代码示例。如果您正苦于以下问题:C++ Medium::transportPhoton方法的具体用法?C++ Medium::transportPhoton怎么用?C++ Medium::transportPhoton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Medium
的用法示例。
在下文中一共展示了Medium::transportPhoton方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CastGlobalPhoton
void PhotonMappingRenderer::CastGlobalPhoton(Scenery& scenery,
MultispectralPhoton& photon,
bool direct, int depth,
Object* last_object_hit) {
if(depth <= 0)
return;
//Computing nearest intersection
Real distance = -1;
Object* nearest_object = 0;
Point intersection;
//If there is no intersection photon is lost
Ray ray;
ray.v = photon.direction;
ray.o = photon.position;
Basis local_basis;
Point2D surface_coordinate;
if(!scenery.getNearestIntersection(ray, distance, nearest_object,
local_basis, surface_coordinate,
last_object_hit))
return;
//Adding photon to global map
photon.position = local_basis.o;
photon.distance = distance * m_scale;
photon.normal = local_basis.k;
//Compute medium absorption
Medium* medium = 0;
if(photon.direction.dot(local_basis.k) < 0) {
medium = nearest_object->getOuterMedium();
} else {
medium = nearest_object->getInnerMedium();
}
if(!medium->transportPhoton(photon))
return;
if(!direct || m_nb_samples > 0) {
if(photon.direction.dot(local_basis.k) < 0) {
m_global_map_out[nearest_object->getIndex()]->addPhoton(photon);
} else {
m_global_map_in[nearest_object->getIndex()]->addPhoton(photon);
}
}
//Photon bounce
bool specular;
if(nearest_object->bouncePhoton(local_basis, surface_coordinate,
photon, specular)) {
CastGlobalPhoton(scenery, photon, false, depth - 1, nearest_object);
}
}