Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | Static Public Member Functions | List of all members
Mezzanine::RayQueryTool Class Reference

This provides a number of optional tools for working with a Mezzanine::World. More...

#include <rayquerytool.h>

Public Member Functions

 RayQueryTool ()
 Blank constructor. More...
 
 RayQueryTool (World *QueryWorld)
 Create a RayQueryTool ready for querying. More...
 
Boole ClearReturns ()
 Clears an previously stored return values. More...
 
Boole GetFirstObjectOnRayByAABB (Ray ObjectRay, Whole ObjectFlags)
 Partially implemented. This should find the first Object that is on or almost on the a given Ray. More...
 
Boole GetFirstObjectOnRayByPolygon (Ray ObjectRay, Whole ObjectFlags)
 This will find the first Object to intesect the Given ray. More...
 
WorldObjectLastQueryResultsObjectPtr () const
 It is common to ray query for WorldObjects, if so the results can be retrieved with this. More...
 
Vector3 LastQueryResultsOffset () const
 Get an offset from the last query. Depending on the last query, this could be an Offset from a variety of things. More...
 
Boole LastQueryResultsValid () const
 Check to see if the last query found anything. More...
 
void ProtoDeSerialize (const XML::Node &OneNode)
 Take the data stored in an XML and overwrite this instance of this object with it. More...
 
void ProtoSerialize (XML::Node &CurrentRoot) const
 Convert this class to an XML::Node ready for serialization. More...
 
Boole RayPlaneIntersection (const Ray &QueryRay, const Plane &QueryPlane)
 Where does this Ray Meet this Plane? More...
 
void SetWorld (World *QueryWorld)
 Sets the World in which the ray query is to be performed. More...
 

Static Public Member Functions

static Ray GetMouseRay ()
 Get a Ray from the current viewport, following the mouse. More...
 
static String GetSerializableName ()
 Get the name of the the XML tag this class will leave behind as its instances are serialized. More...
 

Detailed Description

This provides a number of optional tools for working with a Mezzanine::World.

Currently this allows for more seamless mouse use, including 'picking' of objects with the mouse, and associated functionality.

Definition at line 67 of file rayquerytool.h.

Constructor & Destructor Documentation

Mezzanine::RayQueryTool::RayQueryTool ( )

Blank constructor.

Warning
A world must be set before using this class.

Definition at line 158 of file rayquerytool.cpp.

Mezzanine::RayQueryTool::RayQueryTool ( World QueryWorld)

Create a RayQueryTool ready for querying.

Parameters
QueryWorldThe world in which to perform the ray queries.

Definition at line 164 of file rayquerytool.cpp.

Member Function Documentation

Boole Mezzanine::RayQueryTool::ClearReturns ( )

Clears an previously stored return values.

returns false.

Definition at line 179 of file rayquerytool.cpp.

Boole Mezzanine::RayQueryTool::GetFirstObjectOnRayByAABB ( Ray  ObjectRay,
Whole  ObjectFlags 
)

Partially implemented. This should find the first Object that is on or almost on the a given Ray.

This casts a ray through the gameworld. The first actor with an Axis Aligned Bounding Box that intersects that ray is returned. Presently this is untested and does not return the Offset of the intersection. This should perform faster than WorldQueryTool::GetFirstActorOnRayByPolygon but not by a known amount.

Parameters
ActorRayThe Ray to search along.
ObjectFlagsA whole comprising all the valid objects to be checked in the scene. See WorldAndSceneObjectType in enumerations.h for a listing of objects to use as flags.
Returns
True if something is found, false otherwise. Use LastQueryResultsActorPtr() for more details. Any return Offset is empty
Todo:
TODO: The function WorldQueryTool::GetFirstActorOnRayByAABB does not return an valid offset. This needs to be calculated somehow.
Todo:
TODO: The function WorldQueryTool::GetFirstActorOnRayByAABB has not been tested and needs to be tested
Todo:
TODO: The function WorldQueryTool::GetFirstActorOnRayByAABB does not take other obstructions into account

Definition at line 278 of file rayquerytool.cpp.

Boole Mezzanine::RayQueryTool::GetFirstObjectOnRayByPolygon ( Ray  ObjectRay,
Whole  ObjectFlags 
)

This will find the first Object to intesect the Given ray.

This use the graphics subsystem to cast a ray in the world. If the ray passes through any the triangles in an actor This will return that actor. This function runs in linear time relative to the amount of triangles in 3d meshes near the the ray being cast. This will start at ray.from and go to ray.to .

Parameters
ActorRayThe Ray to search along.
ObjectFlagsA whole comprising all the valid objects to be checked in the scene. See WorldAndSceneObjectType in enumerations.h for a listing of objects to use as flags.
Returns
True if something is found, false otherwise. Use LastQueryResultsOffset() and LastQueryResultsActorPtr() for more details.
Todo:
Modify this so we can check for more movable types than just entities.

Definition at line 199 of file rayquerytool.cpp.

Ray Mezzanine::RayQueryTool::GetMouseRay ( )
static

Get a Ray from the current viewport, following the mouse.

This calls on the graphics subsystem to get a ray from the location of the current camera

Returns
This returns a ray that matches originates at the camera and goes out in 3d space behind the mouse pointer.

Definition at line 369 of file rayquerytool.cpp.

Mezzanine::String Mezzanine::RayQueryTool::GetSerializableName ( )
static

Get the name of the the XML tag this class will leave behind as its instances are serialized.

Returns
A string containing "Vector3"

Definition at line 454 of file rayquerytool.cpp.

WorldObject * Mezzanine::RayQueryTool::LastQueryResultsObjectPtr ( ) const

It is common to ray query for WorldObjects, if so the results can be retrieved with this.

Returns
A pointer to an WorldObject if the last query returns a WorldObject and worked, a Null pointer otherwise. Use LastQueryResultsValid() Prior to this.
Warning
Does not confer ownership of WorldObject, do not delete pointers returned by this unless you have taken special steps.

Definition at line 193 of file rayquerytool.cpp.

Vector3 Mezzanine::RayQueryTool::LastQueryResultsOffset ( ) const

Get an offset from the last query. Depending on the last query, this could be an Offset from a variety of things.

Returns
A Vector3 if the last query worked and returns an Offset, A empty vector otherwise. Use LastQueryResultsValid() Prior to this.

Definition at line 190 of file rayquerytool.cpp.

Boole Mezzanine::RayQueryTool::LastQueryResultsValid ( ) const

Check to see if the last query found anything.

Returns
True if something was found, false otherwise.

Definition at line 187 of file rayquerytool.cpp.

void Mezzanine::RayQueryTool::ProtoDeSerialize ( const XML::Node OneNode)

Take the data stored in an XML and overwrite this instance of this object with it.

Parameters
OneNodeand XML::Node containing the data.
Todo:
This is temporary code that should be replaced with something more robust to find the proper world object.

Definition at line 420 of file rayquerytool.cpp.

void Mezzanine::RayQueryTool::ProtoSerialize ( XML::Node CurrentRoot) const

Convert this class to an XML::Node ready for serialization.

Parameters
CurrentRootThe point in the XML hierarchy that all this vector3 should be appended to.

Definition at line 382 of file rayquerytool.cpp.

Boole Mezzanine::RayQueryTool::RayPlaneIntersection ( const Ray QueryRay,
const Plane QueryPlane 
)

Where does this Ray Meet this Plane?

This does some fancy math to return the point where the ray and the plane intersent.

Parameters
QueryRayThis is the Ray that could intersent the plane
QueryPlaneThis is the plane to be interesected.
Returns
True if something is found, false otherwise. Use LastQueryResultsOffset() for more details. Any return Actor Pointer is NULL;

Definition at line 303 of file rayquerytool.cpp.

void Mezzanine::RayQueryTool::SetWorld ( World QueryWorld)

Sets the World in which the ray query is to be performed.

Parameters
QueryWorldThe world in which to perform the ray queries.

Definition at line 173 of file rayquerytool.cpp.


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