本文整理汇总了C++中Ray::Start方法的典型用法代码示例。如果您正苦于以下问题:C++ Ray::Start方法的具体用法?C++ Ray::Start怎么用?C++ Ray::Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ray
的用法示例。
在下文中一共展示了Ray::Start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersect
bool Plane::intersect(const Ray& ray, IntersectionData& intersectionData)
{
if ((ray.Start().Y() > this->Y() && ray.Direction().Y() > VerySmall) ||
(ray.Start().Y() < this->Y() && ray.Direction().Y() < VerySmall))
{
return false;
}
double yRayDirection = ray.Direction().Y();
double yDifference = ray.Start().Y() - this->Y();
double multiplier = yDifference / -yRayDirection;
if (multiplier > intersectionData.getDistance())
{
return false;
}
Vector intersectionPoint = ray.Start() + ray.Direction() * multiplier;
if (fabs(intersectionPoint.X()) > this->Limit() || fabs(intersectionPoint.Z()) > this->Limit())
{
return false;
}
intersectionData.setIntersectionPoint(intersectionPoint);
intersectionData.setDistance(multiplier);
intersectionData.setNormal(Vector(0.0, 1.0, 0.0));
intersectionData.setTextureU(intersectionData.IntersectionPoint().X());
intersectionData.setTextureV(intersectionData.IntersectionPoint().Z());
return true;
}
示例2: IntersectShadow
//-------------------------------------------------------------
SColor Scene :: IntersectShadow( Ray r, float maxt ) {
//-------------------------------------------------------------
SColor att = SColor(1);
Primitive3D * p;
while( (p = world.NextPrimitive( )) != NULL ) {
float t = p -> Intersect( r );
if ( t > EPSILON && t < maxt) {
Point x = r.Start() + r.Dir() * t;
att *= p -> kt( x );
}
}
return att;
}
示例3: if
//-------------------------------------------------------------
float Sphere :: Intersect( Ray& r ) {
//-------------------------------------------------------------
Vector dist = r.Start() - center;
float b = (dist * r.Dir()) * 2.0;
float a = (r.Dir() * r.Dir());
float c = (dist * dist) - radius * radius;
float discr = b * b - 4.0 * a * c;
if ( discr < 0 ) return -1;
float sqrt_discr = sqrt( discr );
float t1 = (-b + sqrt_discr)/2.0/a;
float t2 = (-b - sqrt_discr)/2.0/a;
if (t1 < EPSILON) t1 = -EPSILON;
if (t2 < EPSILON) t2 = -EPSILON;
if (t1 < 0 && t2 < 0) return -1;
float t;
if ( t1 < 0 && t2 >= 0 ) t = t2;
else if ( t2 < 0 && t1 >= 0 ) t = t1;
else if (t1 < t2) t = t1;
else t = t2;
return t;
}