# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes

# vl::RayIntersector Class Reference

The RayIntersector class is used to detect the intersection points between a Ray and a set of Actor[s]. More...

`#include <RayIntersector.hpp>`

Inheritance diagram for vl::RayIntersector:

List of all members.

## Public Member Functions

virtual const char * | className ()
| Returns the name of the class.
| 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, 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

## Detailed Description

The RayIntersector class is used to detect the intersection points between a Ray and a set of Actor[s].

Definition at line 131 of file RayIntersector.hpp.

## Constructor & Destructor Documentation

vl::RayIntersector::RayIntersector | ( | ) | `[inline]`

Definition at line 135 of file RayIntersector.hpp.

References VL_DEBUG_SET_OBJECT_NAME.

## Member Function Documentation

virtual const char* vl::RayIntersector::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::Object.

Definition at line 134 of file RayIntersector.hpp.

const ActorCollection* vl::RayIntersector::actors | ( | ) | const`[inline]`

The Actors against which the intersection test is performed.

Definition at line 142 of file RayIntersector.hpp.

Referenced by intersect().

ActorCollection* vl::RayIntersector::actors | ( | ) | `[inline]`

The Actors against which the intersection test is performed.

Definition at line 144 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 147 of file RayIntersector.hpp.

Referenced by intersectTriangle().

void vl::RayIntersector::setRay | ( | const Ray & | ray ) | `[inline]`

The ray in world coordinates to be intersected with the actors()

Definition at line 149 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 152 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 154 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 157 of file RayIntersector.hpp.

void RayIntersector::intersect | ( | ) |

Executes the intersection test.

Note:
  Before calling this function the transforms and the bounding volumes of the Actor[s] to be intersected must be updated, in this order.
  All the intersections are mande on the Actor's LOD level #0.

Definition at line 46 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 38 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 177 of file RayIntersector.hpp.

Referenced by intersect().

void RayIntersector::intersect | ( | Actor * | act ) | `[protected]`

Definition at line 60 of file RayIntersector.cpp.

References vl::ref< T >::get(), intersectGeometry(), and vl::Actor::lod().

void RayIntersector::intersectGeometry | ( | Actor * | act,
|  | Geometry * | geom
| ) |  | `[protected]`

Definition at line 67 of file RayIntersector.cpp.

References vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::at(), vl::Collection< T >::at(), vl::Geometry::drawCalls(), intersectTriangle(), vl::TriangleIterator::isEnd(), vl::Collection< T >::size(), vl::Actor::transform(), vl::DrawCall::triangleIterator(), vl::Geometry::vertexArray(), and vl::ITransform::worldMatrix().

Referenced by intersect().

template<class T >

void RayIntersector::intersectTriangle | ( | const T & | a,
|  | const T & | b,
|  | const T & | c,
|  | Actor * | act,
|  | Geometry * | geom,
|  | DrawCall * | prim,
|  | int | prim_idx
| ) |  | `[protected]`

Definition at line 143 of file RayIntersector.cpp.

References vl::cross(), vl::Ray::direction(), vl::dot(), mIntersections, vl::Vector3< T_Scalar >::normalize(), vl::Ray::origin(), and ray().

Referenced by intersectGeometry().

## Member Data Documentation

Frustum vl::RayIntersector::mFrustum`[protected]`

Definition at line 187 of file RayIntersector.hpp.

std::vector< ref<RayIntersection> > vl::RayIntersector::mIntersections`[protected]`

Definition at line 188 of file RayIntersector.hpp.

Referenced by intersect(), and intersectTriangle().

ref<ActorCollection> vl::RayIntersector::mActors`[protected]`

Definition at line 189 of file RayIntersector.hpp.

Ray vl::RayIntersector::mRay`[protected]`

Definition at line 190 of file RayIntersector.hpp.

The documentation for this class was generated from the following files:

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/RayIntersector.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/RayIntersector.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:43.
Permission is granted to use this page to write and publish articles regarding Visualization Library.