MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 ()
 Create a RayQueryTool ready for querying.
 
Boolean ClearReturns ()
 Clears an previously stored return values. More...
 
Boolean GetFirstObjectOnRayByAABB (Ray ObjectRay, Whole ObjectFlags)
 Partially implemented. This should find the first Object that is on or almost on the a given Ray. More...
 
Boolean 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...
 
Boolean 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...
 
Boolean RayPlaneIntersection (const Ray &QueryRay, const Plane &QueryPlane)
 Where does this Ray Meet this Plane? More...
 

Static Public Member Functions

static Ray GetMouseRay (Real Length=1000)
 Get a Ray from the current viewport, following the mouse. More...
 
static String SerializableName ()
 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.

Member Function Documentation

Boolean Mezzanine::RayQueryTool::ClearReturns ( )

Clears an previously stored return values.

returns false.

Definition at line 151 of file rayquerytool.cpp.

Boolean 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 267 of file rayquerytool.cpp.

Boolean 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.

Definition at line 176 of file rayquerytool.cpp.

Ray Mezzanine::RayQueryTool::GetMouseRay ( Real  Length = 1000)
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

Parameters
Lengthhow long of a ray do you want? Thsi defaults to 1000
Returns
This returns a ray that matches originates at the camera and goes out in 3d space behind the mouse pointer.

Definition at line 353 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 165 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 162 of file rayquerytool.cpp.

Boolean Mezzanine::RayQueryTool::LastQueryResultsValid ( ) const

Check to see if the last query found anything.

Returns
True if something was found, false otherwise.

Definition at line 159 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 406 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 368 of file rayquerytool.cpp.

Boolean 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 291 of file rayquerytool.cpp.

Mezzanine::String Mezzanine::RayQueryTool::SerializableName ( )
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 440 of file rayquerytool.cpp.


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