Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Class TRaysWindow
Unit
CastleRays
Declaration
type TRaysWindow = class(TObject)
Description
Calculate primary rays for given camera settings and screen size.
Hierarchy
Overview
Methods
Properties
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).
|
 |
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.
|
Generated by PasDoc 0.12.1 on 2013-02-04 20:26:51
|