OGRE  1.9.0
OgreRay.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __Ray_H_
29#define __Ray_H_
30
31// Precompiler options
32#include "OgrePrerequisites.h"
33
34#include "OgreVector3.h"
36
37namespace Ogre {
38
47 {
48 protected:
51 public:
52 Ray():mOrigin(Vector3::ZERO), mDirection(Vector3::UNIT_Z) {}
53 Ray(const Vector3& origin, const Vector3& direction)
54 :mOrigin(origin), mDirection(direction) {}
55
57 void setOrigin(const Vector3& origin) {mOrigin = origin;}
59 const Vector3& getOrigin(void) const {return mOrigin;}
60
62 void setDirection(const Vector3& dir) {mDirection = dir;}
64 const Vector3& getDirection(void) const {return mDirection;}
65
68 return Vector3(mOrigin + (mDirection * t));
69 }
70
73 return getPoint(t);
74 }
75
82 std::pair<bool, Real> intersects(const Plane& p) const
83 {
84 return Math::intersects(*this, p);
85 }
92 std::pair<bool, Real> intersects(const PlaneBoundedVolume& p) const
93 {
94 return Math::intersects(*this, p.planes, p.outside == Plane::POSITIVE_SIDE);
95 }
102 std::pair<bool, Real> intersects(const Sphere& s) const
103 {
104 return Math::intersects(*this, s);
105 }
112 std::pair<bool, Real> intersects(const AxisAlignedBox& box) const
113 {
114 return Math::intersects(*this, box);
115 }
116
117 };
121}
122#endif
#define _OgreExport
A 3D box aligned with the x/y/z axes.
Represents a convex volume bounded by planes.
Defines a plane in 3D space.
Definition OgrePlane.h:62
Representation of a ray in space, i.e.
Definition OgreRay.h:47
const Vector3 & getOrigin(void) const
Gets the origin of the ray.
Definition OgreRay.h:59
Vector3 mOrigin
Definition OgreRay.h:49
std::pair< bool, Real > intersects(const PlaneBoundedVolume &p) const
Tests whether this ray intersects the given plane bounded volume.
Definition OgreRay.h:92
std::pair< bool, Real > intersects(const Plane &p) const
Tests whether this ray intersects the given plane.
Definition OgreRay.h:82
void setOrigin(const Vector3 &origin)
Sets the origin of the ray.
Definition OgreRay.h:57
std::pair< bool, Real > intersects(const AxisAlignedBox &box) const
Tests whether this ray intersects the given box.
Definition OgreRay.h:112
Ray(const Vector3 &origin, const Vector3 &direction)
Definition OgreRay.h:53
Vector3 getPoint(Real t) const
Gets the position of a point t units along the ray.
Definition OgreRay.h:67
Vector3 mDirection
Definition OgreRay.h:50
void setDirection(const Vector3 &dir)
Sets the direction of the ray.
Definition OgreRay.h:62
std::pair< bool, Real > intersects(const Sphere &s) const
Tests whether this ray intersects the given sphere.
Definition OgreRay.h:102
const Vector3 & getDirection(void) const
Gets the direction of the ray.
Definition OgreRay.h:64
Vector3 operator*(Real t) const
Gets the position of a point t units along the ray.
Definition OgreRay.h:72
Reference-counted shared pointer, used for objects where implicit destruction is required.
A sphere primitive, mostly used for bounds checking.
Definition OgreSphere.h:52
Standard 3-dimensional vector.
Definition OgreVector3.h:52