Class TRaysWindow
Unit
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: TVector3); |
![]() |
class function CreateDescendant( const ACamPosition, ACamDirection, ACamUp: TVector3; const Projection: TProjection): TRaysWindow; |
![]() |
procedure PrimaryRay(const x, y: Single; const ScreenWidth, ScreenHeight: Single; out RayOrigin, RayDirection: TVector3); virtual; abstract; |
Properties
![]() |
property CamPosition: TVector3 read FCamPosition; |
![]() |
property CamDirection: TVector3 read FCamDirection; |
![]() |
property CamUp: TVector3 read FCamUp; |
Description
Methods
![]() |
constructor Create(const ACamPosition, ACamDirection, ACamUp: TVector3); |
|
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: TVector3; 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: Single; out RayOrigin, RayDirection: TVector3); 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: TVector3 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: TVector3 read FCamDirection; |
![]() |
property CamUp: TVector3 read FCamUp; |
Generated by PasDoc 0.16.0.
