本文整理汇总了C++中Ray::Intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ Ray::Intersects方法的具体用法?C++ Ray::Intersects怎么用?C++ Ray::Intersects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ray
的用法示例。
在下文中一共展示了Ray::Intersects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Impulse
void TranslationTool::Impulse(const Ray& ray) {
Vector3f position = transformable->GetPosition();
switch(type) {
case XAxis: {
F32 distance;
if (ray.Intersects(Plane(Vector3f::Up, -position.y), &distance)) {
Vector3f intersection = ray.GetOrigin() + ray.GetDirection() * distance;
F32 deltaX = intersection.x - prevPoint.x;
transformable->SetPosition(Vector3f(position.x + deltaX, position.y, position.z));
prevPoint = intersection;
}
break;
}
case YAxis: {
F32 distance;
if (ray.Intersects(Plane(Vector3f::Backward, -position.z), &distance)) {
Vector3f intersection = ray.GetOrigin() + ray.GetDirection() * distance;
F32 deltaY = intersection.y - prevPoint.y;
transformable->SetPosition(Vector3f(position.x, position.y + deltaY, position.z));
prevPoint = intersection;
}
break;
}
case ZAxis: {
F32 distance;
if (ray.Intersects(Plane(Vector3f::Right, -position.x), &distance)) {
Vector3f intersection = ray.GetOrigin() + ray.GetDirection() * distance;
F32 deltaZ = intersection.z - prevPoint.z;
transformable->SetPosition(Vector3f(position.x, position.y, position.z + deltaZ));
prevPoint = intersection;
}
break;
}
}
}
示例2: Intersects
IResult Intersects(const Ray& ray, const Transformation& objT) const{
if (!mBV)
return IResult(false, FLT_MAX);
Ray localRay = objT.ApplyInverse(ray, false);
Ray::IResult ret = localRay.Intersects(mBV.get());
return ret;
}
示例3: IntersectsDisc
bool Circle::IntersectsDisc(const Ray &ray) const
{
float d;
bool intersectsPlane = ray.Intersects(ContainingPlane(), &d);
if (intersectsPlane)
return false;
return ray.GetPoint(d).DistanceSq(pos) <= r*r;
}
示例4: ImpulseBegin
void TranslationTool::ImpulseBegin(const Ray& ray) {
UpdateScale();
Vector3f position = transformable->GetPosition();
Matrix transform = Matrix::CreateScale(Vector3f(scale)) * Matrix::CreateTranslation(position);
BoundingBox xBox = BoundingBox::Transform(xAxisBBox, transform);
BoundingBox yBox = BoundingBox::Transform(yAxisBBox, transform);
BoundingBox zBox = BoundingBox::Transform(zAxisBBox, transform);
F32 distance;
if (ray.Intersects(xBox, &distance)) {
if (ray.Intersects(Plane(Vector3f::Up, -position.y), &distance)) {
type = XAxis;
prevPoint = ray.GetOrigin() + ray.GetDirection() * distance;
}
} else if (ray.Intersects(yBox, &distance)) {
if (ray.Intersects(Plane(Vector3f::Backward, -position.z), &distance)) {
type = YAxis;
prevPoint = ray.GetOrigin() + ray.GetDirection() * distance;
}
} else if (ray.Intersects(zBox, &distance)) {
if (ray.Intersects(Plane(Vector3f::Right, -position.x), &distance)) {
type = ZAxis;
prevPoint = ray.GetOrigin() + ray.GetDirection() * distance;
}
}
}
示例5: Intersects
bool AABB::Intersects(const Ray& r) const { return r.Intersects(*this); }
示例6: Intersects
bool Plane::Intersects(const Ray& r,
CollisionInfo* const pInfo /*= NULL*/) const {
return r.Intersects(*this, pInfo);
}