Castle Game Engine: CastleRays: Class TRaysWindow

# Class TRaysWindow
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleRays ## Declaration `type TRaysWindow = class(TObject)` ## Description Calculate primary rays for given camera settings and screen size. ## Hierarchy TObject TRaysWindow ## Overview ### Methods
| `constructor Create(const ACamPosition, ACamDirection, ACamUp: TVector3Single);`
| `class function CreateDescendant( const ACamPosition, ACamDirection, ACamUp: TVector3Single; const Projection: TProjection): TRaysWindow;`
| `procedure PrimaryRay(const x, y: Single; const ScreenWidth, ScreenHeight: Integer; out RayOrigin, RayDirection: TVector3Single); virtual; abstract;`
### Properties
| `property CamPosition: TVector3Single read FCamPosition;`
| `property CamDirection: TVector3Single read FCamDirection;`
| `property CamUp: TVector3Single read FCamUp;`
## Description ### Methods
| `constructor Create(const ACamPosition, ACamDirection, ACamUp: TVector3Single);`
Constructor. Calculates some values based on camera settings, this way many calls to PrimaryRay for the same camera settings are fast (useful for ray-tracers).
| `class function CreateDescendant( const ACamPosition, ACamDirection, ACamUp: TVector3Single; const Projection: TProjection): TRaysWindow;`
Create appropriate TRaysWindow instance. Constructs non-abstract descendant (TPerspectiveRaysWindow or TOrthographicRaysWindow, depending on Projection.ProjectionType).
| `procedure PrimaryRay(const x, y: Single; const ScreenWidth, ScreenHeight: Integer; out RayOrigin, RayDirection: TVector3Single); virtual; abstract;`
Calculate position and direction of the primary ray cast from CamPosition, going through the pixel X, Y. X, Y coordinates start from (0, 0) if bottom left (like in typical 2D OpenGL). When they are integers and in the range of X = 0..ScreenWidth-1 (left..right), Y = 0..ScreenHeight-1 (bottom..top) it's guaranteed that resulting ray will go exactly through the middle of the appropriate pixel (on imaginary "rzutnia" = image positioned paraller to view direction). But you can provide non-integer X, Y, useful for multisampling (taking many samples within the pixel, like (X, Y) = (PixX + Random - 0.5, PixY + Random - 0.5)). Resulting RayDirection is guaranteed to be normalized (this is in practice not costly to us, and it often helps — when ray direction is normalized, various distances from ray collisions are "real").
### Properties
| `property CamPosition: TVector3Single read FCamPosition;`
Camera vectors. Initialized in the constructor. Must be given already normalized. Note that CamUp may be changed in constructor, to be always perfectly orthogonal to CamDirection.
| `property CamDirection: TVector3Single read FCamDirection;`
| `property CamUp: TVector3Single read FCamUp;`
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:11