Unit RaysWindow

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Calculating rays that correspond to the given points on 2D screen. This is used in situations such as by ray-tracing (that casts a ray for each image pixel) and when "picking" objects (e.g. user clicks with a mouse on window, and we want to know what object in 3D space he picked).

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TRaysWindow This is used to calculate primary rays for given camera settings and screen size.

Functions and Procedures

function AdjustViewAngleDegToAspectRatio(const FirstViewAngleDeg, SecondToFirstRatio: Single): Single;
function AdjustViewAngleRadToAspectRatio(const FirstViewAngleRad, SecondToFirstRatio: Single): Single;
function PrimaryRay(const x, y: Single; const ScreenWidth, ScreenHeight: Integer; const CamPosition, CamDirection, CamUp: TVector3_Single; const ViewAngleDegX, ViewAngleDegY: Single): TVector3_Single;

Description

Functions and Procedures

function AdjustViewAngleDegToAspectRatio(const FirstViewAngleDeg, SecondToFirstRatio: Single): Single;

Given one viewing angle of 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 deformed (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;
 
function PrimaryRay(const x, y: Single; const ScreenWidth, ScreenHeight: Integer; const CamPosition, CamDirection, CamUp: TVector3_Single; const ViewAngleDegX, ViewAngleDegY: Single): TVector3_Single;

Oblicz promien pierwotny na podstawie ulozenia kamery i ViewAngleXY. Ta funkcja tworzy rzutnie, pyta ja o jeden PrimaryRay i zwraca go. Jak juz napisalem przy TRaysWindow to jest bardzo nieefektywne zachowanie wiec czesto bedziesz chcial uzyc typu TRaysWindow a nie tej funkcji ale czasem rzeczywiscie nie zalezy ci na czasie - np. do wykonania mechanizmu picking (jaki obiekt jest wyswietlany na pixlu ekranu x, y ?) - takie picking bedzie poprawne o ile oryginalny rysunek ktory widzi user byl wykonany z dokladnie takimi samymi ustawieniami perspektywy - no i do picking wystarczy nam pozniej wysledzenie tego jednego promienia wiec rzeczywiscie nie ma sensu pieprzyc sie z klasa TRaysWindow.


Generated by PasDoc 0.11.0 on 2008-09-12 11:58:32