Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
The RayIntersector class is used to detect the intersection points between a Ray and a set of Actor[s]. More...
#include <RayIntersector.hpp>
Public Member Functions | |
RayIntersector () | |
const ActorCollection * | actors () const |
The Actors against which the intersection test is performed. | |
ActorCollection * | actors () |
The Actors against which the intersection test is performed. | |
const Ray & | ray () const |
The ray in world coordinates to be intersected with the actors() | |
void | setRay (const Ray &ray) |
The ray in world coordinates to be intersected with the actors() | |
const Frustum & | frustum () const |
The frustum in world coordinates used to cull the objects. | |
void | setFrustum (const Frustum &frustum) |
The frustum in world coordinates used to cull the objects. | |
const std::vector< ref < RayIntersection > > & | intersections () const |
The intersection points detected by the last intersect() call sorted according to their distance (the first one is the closest). | |
void | intersect () |
Executes the intersection test. | |
void | intersect (const Ray &ray, SceneManager *scene_manager) |
Computes the intersections between the given ray and the Actor[s] contained in the given scene manager. | |
Protected Member Functions | |
void | intersect (Actor *act) |
void | intersectGeometry (Actor *act, Geometry *geom) |
template<class T > | |
void | intersectTriangle (const T &a, const T &b, const T &c, int ia, int ib, int ic, Actor *, Geometry *geom, DrawCall *prim, int prim_idx) |
template<class T > | |
void | intersectLine (const T &a, const T &b, int ia, int ib, Actor *, Geometry *geom, DrawCall *prim, int prim_idx) |
template<class T > | |
void | intersectPoint (const T &a, int ia, Actor *, Geometry *geom, DrawCall *prim, int prim_idx) |
Static Protected Member Functions | |
static bool | sorter (const ref< RayIntersection > &a, const ref< RayIntersection > &b) |
Protected Attributes | |
Frustum | mFrustum |
std::vector< ref < RayIntersection > > | mIntersections |
ref< ActorCollection > | mActors |
Ray | mRay |
The RayIntersector class is used to detect the intersection points between a Ray and a set of Actor[s].
Definition at line 148 of file RayIntersector.hpp.
vl::RayIntersector::RayIntersector | ( | ) | [inline] |
Definition at line 153 of file RayIntersector.hpp.
References VL_DEBUG_SET_OBJECT_NAME.
const ActorCollection* vl::RayIntersector::actors | ( | ) | const [inline] |
The Actors against which the intersection test is performed.
Definition at line 160 of file RayIntersector.hpp.
Referenced by intersect().
ActorCollection* vl::RayIntersector::actors | ( | ) | [inline] |
The Actors against which the intersection test is performed.
Definition at line 162 of file RayIntersector.hpp.
const Ray& vl::RayIntersector::ray | ( | ) | const [inline] |
The ray in world coordinates to be intersected with the actors()
Definition at line 165 of file RayIntersector.hpp.
Referenced by intersectLine(), intersectPoint(), and intersectTriangle().
void vl::RayIntersector::setRay | ( | const Ray & | ray | ) | [inline] |
The ray in world coordinates to be intersected with the actors()
Definition at line 167 of file RayIntersector.hpp.
Referenced by intersect().
const Frustum& vl::RayIntersector::frustum | ( | ) | const [inline] |
The frustum in world coordinates used to cull the objects.
Definition at line 170 of file RayIntersector.hpp.
Referenced by intersect().
void vl::RayIntersector::setFrustum | ( | const Frustum & | frustum | ) | [inline] |
The frustum in world coordinates used to cull the objects.
Definition at line 172 of file RayIntersector.hpp.
const std::vector< ref<RayIntersection> >& vl::RayIntersector::intersections | ( | ) | const [inline] |
The intersection points detected by the last intersect() call sorted according to their distance (the first one is the closest).
Definition at line 175 of file RayIntersector.hpp.
void RayIntersector::intersect | ( | ) |
Executes the intersection test.
Definition at line 48 of file RayIntersector.cpp.
References actors(), vl::Frustum::cull(), frustum(), mIntersections, vl::Collection< T >::size(), and sorter().
Referenced by intersect().
void RayIntersector::intersect | ( | const Ray & | ray, |
SceneManager * | scene_manager | ||
) |
Computes the intersections between the given ray and the Actor[s] contained in the given scene manager.
This is an utility function equivalent to:
intersector->actors()->clear(); scene_manager->extractActors( *intersector->actors() ); intersector->setRay(ray); intersector->intersect();
Definition at line 40 of file RayIntersector.cpp.
References actors(), vl::Collection< T >::clear(), vl::SceneManager::extractActors(), intersect(), and setRay().
static bool vl::RayIntersector::sorter | ( | const ref< RayIntersection > & | a, |
const ref< RayIntersection > & | b | ||
) | [inline, static, protected] |
Definition at line 195 of file RayIntersector.hpp.
Referenced by intersect().
void RayIntersector::intersect | ( | Actor * | act | ) | [protected] |
Definition at line 62 of file RayIntersector.cpp.
References intersectGeometry(), and vl::Actor::lod().
Definition at line 69 of file RayIntersector.cpp.
References vl::Collection< T >::at(), vl::VertexAttribInfo::data(), vl::Geometry::drawCalls(), vl::ArrayAbstract::getAsVec3(), vl::TriangleIterator::hasNext(), vl::LineIterator::hasNext(), intersectLine(), intersectPoint(), intersectTriangle(), vl::DrawCall::lineIterator(), NULL, vl::DrawCall::primitiveType(), vl::PT_LINE_LOOP, vl::PT_LINE_STRIP, vl::PT_LINES, vl::PT_POINTS, vl::ArrayAbstract::size(), vl::Collection< T >::size(), vl::Actor::transform(), vl::DrawCall::triangleIterator(), vl::VA_Position, vl::Geometry::vertexArray(), vl::Geometry::vertexAttribArray(), and vl::Transform::worldMatrix().
Referenced by intersect().
void RayIntersector::intersectTriangle | ( | const T & | a, |
const T & | b, | ||
const T & | c, | ||
int | ia, | ||
int | ib, | ||
int | ic, | ||
Actor * | act, | ||
Geometry * | geom, | ||
DrawCall * | prim, | ||
int | prim_idx | ||
) | [protected] |
Definition at line 134 of file RayIntersector.cpp.
References vl::cross(), vl::Ray::direction(), vl::dot(), vl::Vector3< T_Scalar >::length(), mIntersections, vl::Vector3< T_Scalar >::normalize(), vl::Ray::origin(), and ray().
Referenced by intersectGeometry().
void RayIntersector::intersectLine | ( | const T & | a, |
const T & | b, | ||
int | ia, | ||
int | ib, | ||
Actor * | act, | ||
Geometry * | geom, | ||
DrawCall * | prim, | ||
int | prim_idx | ||
) | [protected] |
Definition at line 213 of file RayIntersector.cpp.
References vl::Ray::direction(), vl::dot(), mIntersections, vl::Ray::origin(), ray(), vl::Vector3< T_Scalar >::x(), and vl::Vector3< T_Scalar >::y().
Referenced by intersectGeometry().
void RayIntersector::intersectPoint | ( | const T & | a, |
int | ia, | ||
Actor * | act, | ||
Geometry * | geom, | ||
DrawCall * | prim, | ||
int | prim_idx | ||
) | [protected] |
Definition at line 281 of file RayIntersector.cpp.
References vl::Ray::direction(), vl::distance(), vl::length(), mIntersections, vl::Ray::origin(), ray(), vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().
Referenced by intersectGeometry().
Frustum vl::RayIntersector::mFrustum [protected] |
Definition at line 211 of file RayIntersector.hpp.
std::vector< ref<RayIntersection> > vl::RayIntersector::mIntersections [protected] |
Definition at line 212 of file RayIntersector.hpp.
Referenced by intersect(), intersectLine(), intersectPoint(), and intersectTriangle().
ref<ActorCollection> vl::RayIntersector::mActors [protected] |
Definition at line 213 of file RayIntersector.hpp.
Ray vl::RayIntersector::mRay [protected] |
Definition at line 214 of file RayIntersector.hpp.