OgreRay.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Ray_H_
#define __Ray_H_
// Precompiler options
#include "OgrePrerequisites.h"
#include "OgreVector3.h"
#include "OgrePlaneBoundedVolume.h"
namespace Ogre {
class _OgreExport Ray
{
protected:
Vector3 mOrigin;
Vector3 mDirection;
public:
Ray():mOrigin(Vector3::ZERO), mDirection(Vector3::UNIT_Z) {}
Ray(const Vector3& origin, const Vector3& direction)
:mOrigin(origin), mDirection(direction) {}
void setOrigin(const Vector3& origin) {mOrigin = origin;}
const Vector3& getOrigin(void) const {return mOrigin;}
void setDirection(const Vector3& dir) {mDirection = dir;}
const Vector3& getDirection(void) const {return mDirection;}
Vector3 getPoint(Real t) const {
return Vector3(mOrigin + (mDirection * t));
}
Vector3 operator*(Real t) const {
return getPoint(t);
}
std::pair<bool, Real> intersects(const Plane& p) const
{
return Math::intersects(*this, p);
}
std::pair<bool, Real> intersects(const PlaneBoundedVolume& p) const
{
return Math::intersects(*this, p.planes, p.outside == Plane::POSITIVE_SIDE);
}
std::pair<bool, Real> intersects(const Sphere& s) const
{
return Math::intersects(*this, s);
}
std::pair<bool, Real> intersects(const AxisAlignedBox& box) const
{
return Math::intersects(*this, box);
}
};
}
#endif
Ogre::Ray::intersects
std::pair< bool, Real > intersects(const PlaneBoundedVolume &p) const
Tests whether this ray intersects the given plane bounded volume.
Definition: OgreRay.h:92
OgreVector3.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Ray::getDirection
const Vector3 & getDirection(void) const
Gets the direction of the ray.
Definition: OgreRay.h:64
Ogre::Ray::intersects
std::pair< bool, Real > intersects(const Sphere &s) const
Tests whether this ray intersects the given sphere.
Definition: OgreRay.h:102
Ogre::PlaneBoundedVolume
Represents a convex volume bounded by planes.
Definition: OgrePlaneBoundedVolume.h:49
Ogre::Sphere
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Ray::intersects
std::pair< bool, Real > intersects(const Plane &p) const
Tests whether this ray intersects the given plane.
Definition: OgreRay.h:82
Ogre::Ray::setDirection
void setDirection(const Vector3 &dir)
Sets the direction of the ray.
Definition: OgreRay.h:62
Ogre::Ray::intersects
std::pair< bool, Real > intersects(const AxisAlignedBox &box) const
Tests whether this ray intersects the given box.
Definition: OgreRay.h:112
Ogre::Plane
Defines a plane in 3D space.
Definition: OgrePlane.h:61
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgrePlaneBoundedVolume.h
Ogre::Ray::Ray
Ray()
Definition: OgreRay.h:52
OgrePrerequisites.h
Ogre::Ray::setOrigin
void setOrigin(const Vector3 &origin)
Sets the origin of the ray.
Definition: OgreRay.h:57
Ogre::PlaneBoundedVolume::planes
PlaneList planes
Publicly accessible plane list, you can modify this direct.
Definition: OgrePlaneBoundedVolume.h:54
Ogre::Ray::operator*
Vector3 operator*(Real t) const
Gets the position of a point t units along the ray.
Definition: OgreRay.h:72
Ogre::Ray::mDirection
Vector3 mDirection
Definition: OgreRay.h:50
Ogre::Ray::getPoint
Vector3 getPoint(Real t) const
Gets the position of a point t units along the ray.
Definition: OgreRay.h:67
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Plane::POSITIVE_SIDE
Definition: OgrePlane.h:83
Ogre::Math::intersects
static std::pair< bool, Real > intersects(const Ray &ray, const Plane &plane)
Ray / plane intersection, returns boolean result and distance.
Ogre::Ray::getOrigin
const Vector3 & getOrigin(void) const
Gets the origin of the ray.
Definition: OgreRay.h:59
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::PlaneBoundedVolume::outside
Plane::Side outside
Definition: OgrePlaneBoundedVolume.h:55
Ogre::Ray::mOrigin
Vector3 mOrigin
Definition: OgreRay.h:49
Ogre::Ray::Ray
Ray(const Vector3 &origin, const Vector3 &direction)
Definition: OgreRay.h:53
Ogre::Ray
Representation of a ray in space, i.e.
Definition: OgreRay.h:46

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.