本文整理汇总了C++中Vec3f::Fix255方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec3f::Fix255方法的具体用法?C++ Vec3f::Fix255怎么用?C++ Vec3f::Fix255使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec3f
的用法示例。
在下文中一共展示了Vec3f::Fix255方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RayTracer
Vec3f Scene::RayTracer(Line l,Vec3f& IntersectPoint,double strength) const{
if (strength < 0.01)
return Vec3f(0,0,0);
Vec3f N;
Material material;
Vec3f Color;
if (getIntersection(l,N,IntersectPoint,Color,material)){
double len = (IntersectPoint - l.start_point).Len();
if ((l.start_point + l.dir * len - IntersectPoint).Len() > EPS){
qDebug() << "fuck" << (l.start_point + l.dir * len - IntersectPoint).Len();
l.start_point.debug();
l.dir.debug();
IntersectPoint.debug();
}
if (material.refract_n > 1)
strength *= exp(0.05 -len * material.absorptivity);
double I = 0;
/*for (unsigned i = 0; i < _lightsources.size();i++){
Line light(IntersectPoint,_lightsources[i] - IntersectPoint);
if (!getIntersection(light,a,b,c,d,Len(_lightsources[i] - IntersectPoint)- EPS)){
Vec3f Ref = light.dir - N * 2 * (light.dir * N);
double Ii = material.Kd * abs(N * light.dir);
if (Ref * l.dir > EPS)
Ii += material.Ks * pow(Ref * l.dir,material.Ksn);
I += Ii * Ii/_lightsources.size();
}
}*/
Line light(IntersectPoint,_lightsources[0] - IntersectPoint);
Vec3f Ref = light.dir - N * 2 * (light.dir * N);
double Ii = material.Kd * abs(N * light.dir);
if (Ref * l.dir > EPS)
Ii += material.Ks * pow(Ref * l.dir,material.Ksn);
double Brightness;
if (softshape){
bools Done,Reach;
memset(Done,0,sizeof(Done));
//Brightness = getBrightness(LightUL,LightUR,LightDR,LightDL,IntersectPoint);
Brightness = getBrightness(0,LightNum,0,LightNum,IntersectPoint,Done,Reach);
}
else{
Vec3f a,b,c;
Material d;
Brightness = getIntersection(light,a,b,c,d,Len(_lightsources[0] - IntersectPoint)- EPS)?0:1;
}
I = Ii * Brightness + material.Ka;
if (I > 1 - EPS){
I = 1 - EPS;
}
I = I * strength;
double Cosi = l.dir * N;
double Sini = abs(Cosi) < 1 - EPS?sqrt(1 - Cosi * Cosi):0;
double Sinr = Sini * material.refract_n;
Line reflect(IntersectPoint,l.dir - N * 2 * Cosi);
Line refract = reflect;
if (Sinr < 1 - EPS){
double Cosr = sqrt(1 - Sinr * Sinr);
Vec3f tmp = l.dir - N * Cosi;
tmp.Normalize();
Vec3f rf = N * Cosr + tmp * Sinr;
refract = Line(IntersectPoint,rf);
}
if (REF){
Vec3f iii;
Color = Color * I * material.diffuse_reflectance
+ Color.mul(RayTracer(reflect,iii,material.reflect_rate * strength))
+ Color.mul(RayTracer(refract,iii,material.refract_rate * strength));
}
else
Color = Color * I * material.diffuse_reflectance;
Color.Fix255();
return Color;
}
else{
double I = 1;
for (unsigned i = 0; i < _lightsources.size();i++){
}
return Vec3f(0,0,0) * I * strength;
}
}