CrystalSpace

Public API Reference

csEngineTools Class Reference

This is a class with static helper functions for working on engine data. More...

#include <cstool/enginetools.h>

List of all members.

Static Public Member Functions

static csScreenTargetResult FindScreenTarget (const csVector2 &pos, float maxdist, iCamera *camera, iCollideSystem *cdsys=0)
 Given a screen space coordinate (with (0,0) being top-left corner of screen) this will try to find the closest mesh there.
static csShortestDistanceResult FindShortestDistance (const csVector3 &source, iSector *sourceSector, const csVector3 &dest, iSector *destSector, float maxradius, bool accurate=false)
 Given two positions in the world, try to find the shortest distance (using portals if needed) between them and return the final squared distance.

Detailed Description

This is a class with static helper functions for working on engine data.

Definition at line 86 of file enginetools.h.


Member Function Documentation

static csScreenTargetResult csEngineTools::FindScreenTarget ( const csVector2 pos,
float  maxdist,
iCamera camera,
iCollideSystem cdsys = 0 
) [static]

Given a screen space coordinate (with (0,0) being top-left corner of screen) this will try to find the closest mesh there.

Parameters:
pos is the screen coordinate position.
maxdist is the maximum distance to check.
camera is the camera.
cdsys if 0 then this function will use iSector->HitBeamPortals() which is more accurate. Otherwise this function will use csColliderHelper::TraceBeam() which is faster but less accurate since it depends on collider information.
Returns:
an instance of csScreenTargetResult with the mesh that was possibly hit and an intersection point.
static csShortestDistanceResult csEngineTools::FindShortestDistance ( const csVector3 source,
iSector sourceSector,
const csVector3 dest,
iSector destSector,
float  maxradius,
bool  accurate = false 
) [static]

Given two positions in the world, try to find the shortest distance (using portals if needed) between them and return the final squared distance.

Note! This function will ignore all portals if the source and destination sectors are the same. Even if there might be a possible shorter path between the two positions using some space warping portal. An exception to this is if the distance is greater then the max distance. In that case this function will attempt to try out portals in the current sector to see if there is a shorter path anyway.

Note that this routine will ignore visibility. It will simply calculate the distance between the two points through some portal path. However, this function will check if the portal is oriented towards the source point (i.e it doesn't ignore visibility with regards to backface culling).

Note that this function (by default) only considers the center point of a portal for calculating the distance. This might skew results with very big portals. Set the 'accurate' parameter to true if you don't want this.

This function will correctly account for space warping portals.

Parameters:
source is the source position to start from.
sourceSector is the sector for that position.
dest is the destination position to start from.
destSector is the destination for that position.
maxradius is the maximum radius before we stop recursion.
accurate if this is true then this routine will use a more accurate distance test to see if the portal is close enough. With small portals this is probably rarely needed but if you need to be certain to find all cases then you can set this to true.
Returns:
an instance of csShortestDistanceResult which contains the squared distance between the two points or a negative number if the distance goes beyond the maximum radius. It also contains a space-warping corrected direction from the source point to the destination point.

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

Generated for Crystal Space 2.0 by doxygen 1.6.1