PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PureCamera Class Reference

Camera class. More...

Detailed Description

Camera class.

Camera is the eye from where the scene is rendered onto the screen.

Definition at line 45 of file PureCamera.h.

#include <PureCamera.h>

+ Inheritance diagram for PureCamera:

Classes

class  PureCameraImpl
 

Public Member Functions

 PureCamera ()
 Creates camera with default settings.
 
 PureCamera (const PureCamera &)
 
PureCameraoperator= (const PureCamera &)
 Assignment operator.
 
virtual ~PureCamera ()
 
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
const TRECTgetViewport () const
 Gets camera viewport.
 
void SetViewport (TPureUInt vx, TPureUInt vy, TPureUInt vsx, TPureUInt vsy)
 Sets viewport position and size.
 
TPureFloat getNearPlane () const
 Gets camera near plane distance from eye position.
 
void SetNearPlane (TPureFloat value)
 Sets camera near plane distance from eye position.
 
TPureFloat getFarPlane () const
 Gets camera far plane distance from eye position.
 
void SetFarPlane (TPureFloat value)
 Sets camera far plane distance from eye position.
 
TPureFloat getFieldOfView () const
 Gets camera field of view angle on Y direction in degrees.
 
void SetFieldOfView (TPureFloat value)
 Sets camera field of view angle on Y direction in degrees.
 
TPureFloat getAspectRatio () const
 Gets the camera's aspect ratio (usually viewport width / height).
 
void SetAspectRatio (TPureFloat value)
 Sets the camera's aspect ratio (usually viewport width / height).
 
TPURE_CLEAR_MODE getClearMode () const
 Gets clear mode.
 
void SetClearMode (TPURE_CLEAR_MODE mode)
 Sets clear mode.
 
TPURE_ASPECTRATIO_MODE getAspectRatioMode () const
 Gets aspect ratio mode.
 
void SetAspectRatioMode (TPURE_ASPECTRATIO_MODE mode)
 Sets aspect ratio mode.
 
PureColorgetBackgroundColor ()
 Gets camera background color.
 
const PureColorgetBackgroundColor () const
 Gets camera background color.
 
bool project3dTo2d (TPureFloat fWorldX, TPureFloat fWorldY, TPureFloat fWorldZ, PureVector &vecProjected) const
 Makes a projection from world-space to window/screen-space.
 
bool project2dTo3d (TPureUInt nScreenX, TPureUInt nScreenY, TPureFloat nScreenDepth, PureVector &vecUnprojected) const
 Makes a projection from window/screen-space to world-space.
 
- Public Member Functions inherited from PurePosUpTarget
 PurePosUpTarget ()
 Initializes the position vector to [0,0,0], the up vector to [0,1,0] and the target vector to [0,0,1].
 
 PurePosUpTarget (const PurePosUpTarget &cm)
 
 PurePosUpTarget (const PureVector &pos, const PureVector &target, const PureVector &up)
 Initializes the position, up and target vectors with the given vectors.
 
PureVectorgetPosVec ()
 Gets Position vector.
 
const PureVectorgetPosVec () const
 Gets Position vector.
 
PureVectorgetTargetVec ()
 Gets Target vector.
 
const PureVectorgetTargetVec () const
 Gets Target vector.
 
PureVectorgetUpVec ()
 Gets Up vector.
 
const PureVectorgetUpVec () const
 Gets Up vector.
 
void Move (TPureFloat amount)
 Moves forward or backward by the specified amount based on current direction.
 
void Strafe (TPureFloat amount)
 Moves horizontally by the specified amount based on current direction.
 
void Elevate (TPureFloat amount)
 Changes Y-position by the specified amount.
 
void SetRotation (TPureFloat x, TPureFloat y, TPureFloat z)
 Sets direction.
 
TPureBool operator== (const PurePosUpTarget &clr) const
 Equals to operator.
 
TPureBool operator!= (const PurePosUpTarget &clr) const
 Not equals to operator.
 
PurePosUpTargetoperator= (const PurePosUpTarget &vec)
 Assignment operator.
 

Static Public Member Functions

static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 

Private Attributes

PureCameraImplpImpl
 

Constructor & Destructor Documentation

◆ PureCamera() [1/2]

PureCamera::PureCamera ( )

Creates camera with default settings.

Default settings:

  • clear mode: PURE_CLEAR_ZBUFFER_COLORBUFFER;
  • near plane: 1.0;
  • far plane: 10.0;
  • viewport X,Y: 0,0;
  • viewport W,H: 800,600;
  • field of view: 80.0;
  • aspect mode: PURE_AM_FIX;
  • aspect ratio: 800 / 600.0;
  • position, up and target vectors as initialized by PurePosUpTarget ctor.
Exceptions
std::bad_alloc- This class or its ancestor dynamically allocates memory with operator new, in case of failure the exception is not handled but propagated to caller.

Definition at line 276 of file PureCamera.cpp.

◆ PureCamera() [2/2]

PureCamera::PureCamera ( const PureCamera & other)
Exceptions
std::bad_alloc- This class or its ancestor dynamically allocates memory with operator new, in case of failure the exception is not handled but propagated to caller.

Definition at line 284 of file PureCamera.cpp.

◆ ~PureCamera()

PureCamera::~PureCamera ( )
virtual

Definition at line 318 of file PureCamera.cpp.

Member Function Documentation

◆ getAspectRatio()

TPureFloat PureCamera::getAspectRatio ( ) const

Gets the camera's aspect ratio (usually viewport width / height).

Definition at line 431 of file PureCamera.cpp.

◆ getAspectRatioMode()

TPURE_ASPECTRATIO_MODE PureCamera::getAspectRatioMode ( ) const

Gets aspect ratio mode.

Aspect ratio mode defines what aspect ratio to be used when viewport size changes. Default is PURE_AM_FIX.

Definition at line 474 of file PureCamera.cpp.

◆ getBackgroundColor() [1/2]

PureColor & PureCamera::getBackgroundColor ( )

Gets camera background color.

Camera background color defines with what color to clear the color buffer at the beginning of rendering. Note that color buffer is cleared with background color only if clear mode is PURE_CLEAR_ZBUFFER_COLORBUFFER.

Definition at line 495 of file PureCamera.cpp.

◆ getBackgroundColor() [2/2]

const PureColor & PureCamera::getBackgroundColor ( ) const

Gets camera background color.

Camera background color defines with what color to clear the color buffer at the beginning of rendering. Note that color buffer is cleared with background color only if clear mode is PURE_CLEAR_ZBUFFER_COLORBUFFER.

Definition at line 506 of file PureCamera.cpp.

◆ getClearMode()

TPURE_CLEAR_MODE PureCamera::getClearMode ( ) const

Gets clear mode.

Clear mode defines which buffers to clear when rendering starts. Default is PURE_CLEAR_ZBUFFER_COLORBUFFER.

Definition at line 453 of file PureCamera.cpp.

◆ getConsole()

CConsole & PureCamera::getConsole ( ) const

Returns access to console preset with logger module name as this class.

Intentionally not virtual, so the getConsole() in derived class should hide this instead of overriding.

Returns
Console instance used by this class.

Definition at line 330 of file PureCamera.cpp.

◆ getFarPlane()

TPureFloat PureCamera::getFarPlane ( ) const

Gets camera far plane distance from eye position.

Definition at line 390 of file PureCamera.cpp.

◆ getFieldOfView()

TPureFloat PureCamera::getFieldOfView ( ) const

Gets camera field of view angle on Y direction in degrees.

Default value is 80�.

Definition at line 411 of file PureCamera.cpp.

◆ getLoggerModuleName()

const char * PureCamera::getLoggerModuleName ( )
static

Returns the logger module name of this class.

Intentionally not virtual, so derived class should hide this instead of overriding. Not even private, so user can also access this from outside, for any reason like controlling log filtering per logger module name.

Returns
The logger module name of this class.

Definition at line 343 of file PureCamera.cpp.

◆ getNearPlane()

TPureFloat PureCamera::getNearPlane ( ) const

Gets camera near plane distance from eye position.

Definition at line 371 of file PureCamera.cpp.

◆ getViewport()

const TRECT & PureCamera::getViewport ( ) const

Gets camera viewport.

Definition at line 351 of file PureCamera.cpp.

◆ operator=()

PureCamera & PureCamera::operator= ( const PureCamera & other)

Assignment operator.

Definition at line 295 of file PureCamera.cpp.

◆ project2dTo3d()

bool PureCamera::project2dTo3d ( TPureUInt nScreenX,
TPureUInt nScreenY,
TPureFloat nScreenDepth,
PureVector & vecUnprojected ) const

Makes a projection from window/screen-space to world-space.

Makes an unprojection from window/screen-space to world-space.

Basically it calls PureProjection::project2dTo3d() will this camera's properties.

Parameters
nScreenX,nScreenYnScreenDepth The window/screen-space position coordinates to be unprojected to world-space.
vecUnprojectedThe unprojected 3D world-space coordinates. Valid only if the function returned true.
Returns
True if unprojection is successful, false otherwise.

Definition at line 549 of file PureCamera.cpp.

◆ project3dTo2d()

bool PureCamera::project3dTo2d ( TPureFloat fWorldX,
TPureFloat fWorldY,
TPureFloat fWorldZ,
PureVector & vecProjected ) const

Makes a projection from world-space to window/screen-space.

Basically it calls PureProjection::project3dTo2d() will this camera's properties. Note that for the projected coordinates, vecProjected = (0,0,z) represents the lower left corner of the window/screen, so if you want to have this projected coordinate vecProjected to be in the same coordinate system as the sticked objects, you need to subtract the half of the viewport's width from vecProjected.getX() and the half of the viewport's height from vecProjected.getY() because sticked objects have (0,0) as the center of the window/screen as the origin.

Parameters
fWorldX,fWorldY,fWorldZThe world-space position coordinates to be projected to window/screen-space.
vecProjectedThe projected 2D window/screen space coordinates. Valid only if the function returned true.
Returns
True if projection is successful, false otherwise.

Definition at line 528 of file PureCamera.cpp.

◆ SetAspectRatio()

void PureCamera::SetAspectRatio ( TPureFloat value)

Sets the camera's aspect ratio (usually viewport width / height).

This is similar to setting the field of view angle on X direction in degrees. Must be positive. No effect if invalid value is specified.

Definition at line 442 of file PureCamera.cpp.

◆ SetAspectRatioMode()

void PureCamera::SetAspectRatioMode ( TPURE_ASPECTRATIO_MODE mode)

Sets aspect ratio mode.

Aspect ratio mode defines what aspect ratio to be used when viewport size changes. Default is PURE_AM_FIX.

Definition at line 484 of file PureCamera.cpp.

◆ SetClearMode()

void PureCamera::SetClearMode ( TPURE_CLEAR_MODE mode)

Sets clear mode.

Clear mode defines which buffers to clear when rendering starts. Default is PURE_CLEAR_ZBUFFER_COLORBUFFER.

Definition at line 463 of file PureCamera.cpp.

◆ SetFarPlane()

void PureCamera::SetFarPlane ( TPureFloat value)

Sets camera far plane distance from eye position.

Only positive value is accepted. Cannot be less than or equal to the current near plane. No effect if invalid value is specified.

Definition at line 401 of file PureCamera.cpp.

◆ SetFieldOfView()

void PureCamera::SetFieldOfView ( TPureFloat value)

Sets camera field of view angle on Y direction in degrees.

Must be positive, cannot be greater than 180. No effect if invalid value is specified. Default value is 80�.

Definition at line 422 of file PureCamera.cpp.

◆ SetNearPlane()

void PureCamera::SetNearPlane ( TPureFloat value)

Sets camera near plane distance from eye position.

Only positive value is accepted. Cannot be greater than or equal to the current far plane. No effect if invalid value is specified.

Definition at line 381 of file PureCamera.cpp.

◆ SetViewport()

void PureCamera::SetViewport ( TPureUInt vx,
TPureUInt vy,
TPureUInt vsx,
TPureUInt vsy )

Sets viewport position and size.

Position values cannot be negative. Size values must be positive. No effect if invalid value is specified.

Definition at line 362 of file PureCamera.cpp.

Member Data Documentation

◆ pImpl

PureCameraImpl* PureCamera::pImpl
private

Definition at line 109 of file PureCamera.h.


The documentation for this class was generated from the following files: