当前位置: 首页>>代码示例>>C++>>正文


C++ Medium::transportPhoton方法代码示例

本文整理汇总了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);
  }
}
开发者ID:dysseus88,项目名称:virtuelium,代码行数:53,代码来源:PhotonMappingRenderer.cpp


注:本文中的Medium::transportPhoton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。