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


C++ Ray::Start方法代码示例

本文整理汇总了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;
}
开发者ID:nikolovp,项目名称:MacrosRaytracer,代码行数:32,代码来源:Plane.cpp

示例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;
}
开发者ID:tht-krisztian,项目名称:Grafika,代码行数:14,代码来源:jegyzet.cpp

示例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;
}
开发者ID:tht-krisztian,项目名称:Grafika,代码行数:22,代码来源:jegyzet.cpp


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