本文整理汇总了C++中Hit::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Hit::getObject方法的具体用法?C++ Hit::getObject怎么用?C++ Hit::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hit
的用法示例。
在下文中一共展示了Hit::getObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lanceRayon
Color Scene::lanceRayon(const Rayon& ray, int iteration) const
{
this->addObjectsTabToBinder();
Color result(0.0,0.0,0.0);
float minDist(1000.0) ;
float dist (0.0) ;
Hit hit ;
if (binder->intersect(ray,0.0,100.0,hit))
{
//result = hit.getObject()->getOptic()->getColor(hit.getU(),hit.getV());
//result = hit.getObject()->getOptic()->getColor(0.5,0.5);
Color coulObj(hit.getObject()->getOptic()->getColor(hit.getU(),hit.getV()));
for ( std::vector<std::shared_ptr<LightSource>>::const_iterator it = lightsTab.begin(); it != lightsTab.end() ; ++it)
// pour chaque source
{
//d = calcul distance point intersection source
Vector directi(it->get()->getOrigin()-hit.getImpactPoint());
float distInterSource = directi.getNorm() ;
directi.normalize();
//initialiser Ray : point intersect, direction(point intersect, source), couleur = on s'en fout
Color c(0.0,0.0,0.0);
Color resultNorm(0.0,0.0,0.0);
Rayon ray(hit.getImpactPoint(),directi,c);
if (! binder->intersect(ray, 0, distInterSource))
{
Color diff(it->get()->getColor()*coulObj*(dotProduct(hit.getNormal(),ray.getDirect())));
Vector moinsV(-directi.getX(),-directi.getY(),-directi.getZ());
Vector miroirV(moinsV + hit.getNormal()*(2*(dotProduct(directi,hit.getNormal()))));
//Vmir = V symétrique par rapport à N
//spec = coulspec(obj)* (tronquerAZero(RayS.Vmir))^n * coul(source)
Color spec(it->get()->getColor()*coulObj*dotProduct(ray.getDirect(),miroirV));
resultNorm = diff + spec ;
if ( iteration < 2)
{
//Res2 = influence rayon réfléchi
Rayon reflected(hit.getImpactPoint(),miroirV,c);
Color reflectedColor(0.0,0.0,0.0);
reflectedColor = this->lanceRayon(reflected,iteration+1);
//return pourcent1*Res + ourcent2*Res2
result = resultNorm*0.8 + reflectedColor*0.2 ;
}
else
{
result = resultNorm ;
}
}
}
}
return result;
}