Castle Game Engine: CastleRays

# Unit CastleRays
Description | Uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables
## Description Calculating 3D rays that correspond to the given points on 2D screen. This is used by ray-tracing (casting a ray for each image pixel) or when picking objects (what 3D object/point is indicated by the current mouse position). ## Uses CastleVectors ## Overview ### Classes, Interfaces, Objects and Records
Name | Description
--- | ---
Object `TProjection` | Projection parameters.
Class `TRaysWindow` | Calculate primary rays for given camera settings and screen size.
Class `TPerspectiveRaysWindow` |
Class `TOrthographicRaysWindow` |
### Functions and Procedures
`function AdjustViewAngleDegToAspectRatio(const FirstViewAngleDeg, SecondToFirstRatio: Single): Single;`
`function AdjustViewAngleRadToAspectRatio(const FirstViewAngleRad, SecondToFirstRatio: Single): Single;`
`procedure PrimaryRay(const x, y: Single; const ScreenWidth, ScreenHeight: Integer; const CamPosition, CamDirection, CamUp: TVector3Single; const Projection: TProjection; out RayOrigin, RayDirection: TVector3Single);`
### Types
`TProjectionType = (...);`
## Description ### Functions and Procedures
`function AdjustViewAngleDegToAspectRatio(const FirstViewAngleDeg, SecondToFirstRatio: Single): Single;`
Calculate second viewing angle for perspective projection. Given one viewing angle of the camera (FirstViewAngleDeg) and aspect ratio of your window sizes (SecondToFirstRatio), calculate second viewing angle of the camera. The intention is that when projecting camera view (with given view angles) on a screen with given aspect ratio), the image will not be distorted (squeezed horizontally or vertically). For the "Deg" version both angles (given and returned) are in degress, for the "Rad" version both angles and in radians.
`function AdjustViewAngleRadToAspectRatio(const FirstViewAngleRad, SecondToFirstRatio: Single): Single;`
`procedure PrimaryRay(const x, y: Single; const ScreenWidth, ScreenHeight: Integer; const CamPosition, CamDirection, CamUp: TVector3Single; const Projection: TProjection; out RayOrigin, RayDirection: TVector3Single);`
Calculate position and direction of the primary ray cast from CamPosition, going through the pixel X, Y. Takes into account camera 3D settings and screen sizes. RayDirection will always be normalized, just like from TRaysWindow.PrimaryRay. If you want to call this many times for the same camera settings, it may be more optimal to create TRaysWindow instance first and call it's TRaysWindow.PrimaryRay method.
### Types
`TProjectionType = (...);`
###### Values ptOrthographic: ptPerspective:
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:11