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 &position, float maxdist, iView *view, CS::Collisions::iCollisionSystem *collisionSystem)
 Given a screen space coordinate (with (0,0) being top-left corner of screen) this will try to find the closest mesh there.
static csScreenTargetResult FindScreenTarget (const csVector2 &position, float maxdist, iView *view, iCollideSystem *cdsys=nullptr)
 Given a screen space coordinate (with (0,0) being top-left corner of screen) this will try to find the closest mesh there.
static csScreenTargetResult FindScreenTarget (const csVector2 &position, float maxdist, iCamera *camera, size_t screenWidth, size_t screenHeight, iCollideSystem *cdsys=nullptr)
 Given a screen space coordinate (with (0,0) being top-left corner of screen) this will try to find the closest mesh there.
static csScreenTargetResult FindScreenTarget (const csVector2 &position, float maxdist, iCamera *camera, iCollideSystem *cdsys=nullptr)
 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.
static csVector2 NormalizedToScreen (const csVector2 &position, float screenWidth, float screenHeight)
 Transform a normalized screen space coordinate (-1 to 1) as used by a iCamera into screen space (i.e.
static csVector2 ScreenToNormalized (const csVector2 &position, float screenWidth, float screenHeight)
 Transform a screen space coordinate (in pixels) into a normalized screen coordinate (-1 to 1) as used by a iCamera.

Detailed Description

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

Definition at line 93 of file enginetools.h.


Member Function Documentation

static csScreenTargetResult csEngineTools::FindScreenTarget ( const csVector2 position,
float  maxdist,
iView view,
CS::Collisions::iCollisionSystem collisionSystem 
) [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:
position is the screen coordinate position, in pixels.
maxdist is the maximum distance to check.
camera is the camera.
collisionSystem if nullptr then this function will use iSector->HitBeamPortals() which is more accurate. Otherwise this function will use CS::Collisions::iCollisionSector::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 csScreenTargetResult csEngineTools::FindScreenTarget ( const csVector2 position,
float  maxdist,
iView view,
iCollideSystem cdsys = nullptr 
) [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:
position is the screen coordinate position, in pixels.
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 csScreenTargetResult csEngineTools::FindScreenTarget ( const csVector2 position,
float  maxdist,
iCamera camera,
size_t  screenWidth,
size_t  screenHeight,
iCollideSystem cdsys = nullptr 
) [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:
position is the screen coordinate position, in pixels.
maxdist is the maximum distance to check.
camera is the camera.
screenWidth The width of the screen, in pixels. This should usually be the value returned by iGraphics2D::GetWidth().
screenHeight The height of the screen, in pixels. This should usually be the value returned by iGraphics2D::GetHeight().
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 csScreenTargetResult csEngineTools::FindScreenTarget ( const csVector2 position,
float  maxdist,
iCamera camera,
iCollideSystem cdsys = nullptr 
) [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:
position is the screen coordinate position, in pixels.
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.
Deprecated:
Deprecated in 2.2. Use one of the other versions of FindScreenTarget() instead
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.
static csVector2 csEngineTools::NormalizedToScreen ( const csVector2 position,
float  screenWidth,
float  screenHeight 
) [static]

Transform a normalized screen space coordinate (-1 to 1) as used by a iCamera into screen space (i.e.

real pixels).

Remarks:
Unlike iView::NormalizedToScreen(), this method works in screen space, not in view space. That is, the screen coordinates are vertically mirrored in comparison to view space, i.e. y=0 is at the top of the viewport, and y=GetHeight() at the bottom.
Parameters:
position A position in normalized screen space coordinates.
screenWidth The width of the screen, in pixels. This should usually be the value returned by iGraphics2D::GetWidth().
screenHeight The height of the screen, in pixels. This should usually be the value returned by iGraphics2D::GetHeight().
See also:
ScreenToNormalized()
static csVector2 csEngineTools::ScreenToNormalized ( const csVector2 position,
float  screenWidth,
float  screenHeight 
) [static]

Transform a screen space coordinate (in pixels) into a normalized screen coordinate (-1 to 1) as used by a iCamera.

Remarks:
Unlike iView::NormalizedToScreen(), this method works in screen space, not in view space. That is, the screen coordinates are vertically mirrored in comparison to view space, i.e. y=0 is at the top of the viewport, and y=GetHeight() at the bottom.
Parameters:
position A position in pixel coordinates.
screenWidth The width of the screen, in pixels. This should usually be the value returned by iGraphics2D::GetWidth().
screenHeight The height of the screen, in pixels. This should usually be the value returned by iGraphics2D::GetHeight().
See also:
NormalizedToScreen()

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

Generated for Crystal Space 2.1 by doxygen 1.6.1