CrystalSpace

Public API Reference

csView Class Reference

Default implementation of a iView. More...

#include <cstool/csview.h>

Inheritance diagram for csView:

List of all members.

Public Member Functions

virtual void AddViewVertex (int x, int y)
 Add a vertex to the clipping polygon (non-rectangular clipping).
virtual void ClearView ()
 Clear the clipper in order to start building a new polygon-based clipper.
 csView (iEngine *iEngine, iGraphics3D *ig3d)
 Constructor.
virtual void Draw (iMeshWrapper *mesh=0)
 Render the scene as seen from the camera.
virtual void DrawBackground (iGraphics3D *g3d)
 Draw the background of this view.
virtual const csColor4GetBackgroundColor () const
 Get the background color of this view.
virtual iTextureHandleGetBackgroundTexture (int &sx, int &sy, int &sw, int &sh, int &tx, int &ty, int &tw, int &th, uint8 &alpha, bool &tiled) const
 Get the background texture of this view.
virtual iCameraGetCamera ()
 Get the current camera.
virtual iClipper2DGetClipper ()
 Return the current clipper. This function may call UpdateClipper().
virtual iGraphics3DGetContext ()
 Get the iGraphics3d context of this view.
virtual iCustomMatrixCameraGetCustomMatrixCamera ()
 Get the current custom matrix camera.
virtual iEngineGetEngine ()
 Get the engine handle.
virtual int GetHeight () const
 Get the view height, in pixels.
virtual CS::Utility::MeshFilterGetMeshFilter ()
 Get the mesh filter used to restrict the meshes that are visible in this view.
virtual iPerspectiveCameraGetPerspectiveCamera ()
 Get the current perspective camera.
virtual int GetWidth () const
 Get the view width, in pixels.
virtual csVector3 InvProject (const csVector2 &p, float z) const
 Calculate an inverse projection corrected point for this view, that is the inverse projection of a 2D point expressed in screen space into the 3D camera space.
virtual csVector2 NormalizedToScreen (const csVector2 &pos)
 Transform a normalized screen space coordinate (-1 to 1) to real pixels in this viewport.
virtual csVector2 Project (const csVector3 &v) const
 Calculate a projection corrected point for this view, that is the projection of a 3D point expressed in camera space into the 2D screen space.
virtual void RestrictClipperToScreen ()
 Clip the polygon clipper to the screen boundaries.
virtual csVector2 ScreenToNormalized (const csVector2 &pos)
 Transform a screen space coordinate in pixels to a normalized screen coordinate (-1 to 1).
virtual void SetAutoResize (bool state)
 Enable or disable automatic resizing.
virtual void SetBackgroundColor (csColor4 *color)
 Set the background color of this view.
virtual void SetBackgroundTexture (iTextureHandle *texture, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th, uint8 alpha, bool tiled)
 Set the background texture of this view.
virtual void SetCamera (iCamera *c)
 Set the current camera.
virtual void SetContext (iGraphics3D *ig3d)
 Set the iGraphics3d context of this view.
virtual void SetCustomMatrixCamera (iCustomMatrixCamera *c)
 Set the current camera as a custom matrix camera.
virtual void SetEngine (iEngine *e)
 Set the engine handle.
virtual void SetHeight (int h)
 Set the view height, in pixels.
virtual void SetPerspectiveCamera (iPerspectiveCamera *c)
 Set the current camera as a perspective camera.
virtual void SetRectangle (int x, int y, int w, int h, bool restrictToScreen=true)
 Set the clipper as a clipping rectangle.
virtual void SetWidth (int w)
 Set the view width, in pixels.
virtual void UpdateClipper ()
 Update the Clipper. This is called automatically by GetClipper().
virtual ~csView ()
 Destructor.

Detailed Description

Default implementation of a iView.

Definition at line 42 of file csview.h.


Constructor & Destructor Documentation

csView::csView ( iEngine iEngine,
iGraphics3D ig3d 
)

Constructor.

virtual csView::~csView (  )  [virtual]

Destructor.


Member Function Documentation

virtual void csView::AddViewVertex ( int  x,
int  y 
) [virtual]

Add a vertex to the clipping polygon (non-rectangular clipping).

If the current clipper was a rectangle, then it will be deleted.

Parameters:
x The X coordinate of the vertex, in pixels.
y The Y coordinate of the vertex, in pixels.

Implements iView.

virtual void csView::ClearView (  )  [virtual]

Clear the clipper in order to start building a new polygon-based clipper.

Implements iView.

virtual void csView::Draw ( iMeshWrapper mesh = 0  )  [virtual]

Render the scene as seen from the camera.

Parameters:
mesh This parameter was previously used to restrict the rendering of the view to a single mesh, but it is not used anymore. You should use GetMeshFilter() instead.

Implements iView.

virtual void csView::DrawBackground ( iGraphics3D g3d  )  [virtual]

Draw the background of this view.

This is usually the responsability of the iRenderManager to call this method, hence you shouldn't need to call it manually.

Parameters:
g3d The 3D canvas where to render the background.

Implements iView.

virtual const csColor4* csView::GetBackgroundColor (  )  const [virtual]

Get the background color of this view.

This will be displayed before any other graphics when this view is rendered.

Implements iView.

virtual iTextureHandle* csView::GetBackgroundTexture ( int &  sx,
int &  sy,
int &  sw,
int &  sh,
int &  tx,
int &  ty,
int &  tw,
int &  th,
uint8 &  alpha,
bool &  tiled 
) const [virtual]

Get the background texture of this view.

This will be displayed before any other graphics when this view is rendered (but just after the background color).

Parameters:
sx The X coordinate of the left of the texture on screen.
sy The Y coordinate of the top of the texture on screen.
sw The width of the texture on screen.
sh The height of the texture on screen.
tx The X coordinate of the left of the displayed texture area.
ty The Y coordinate of the top of the displayed texture area.
tw The width of the displayed texture area.
th The height of the displayed texture area.
alpha The transparency of the texture.
tiled Whether the texture should be displayed once or repeated in order to cover the whole screen.
Returns:
The background texture.

Implements iView.

virtual iCamera* csView::GetCamera (  )  [virtual]

Get the current camera.

Implements iView.

virtual iClipper2D* csView::GetClipper (  )  [virtual]

Return the current clipper. This function may call UpdateClipper().

Implements iView.

virtual iGraphics3D* csView::GetContext (  )  [virtual]

Get the iGraphics3d context of this view.

Implements iView.

virtual iCustomMatrixCamera* csView::GetCustomMatrixCamera (  )  [virtual]

Get the current custom matrix camera.

Can return nullptr if the current camera is not a custom matrix camera.

Implements iView.

virtual iEngine* csView::GetEngine (  )  [virtual]

Get the engine handle.

Implements iView.

virtual int csView::GetHeight (  )  const [inline, virtual]

Get the view height, in pixels.

Implements iView.

Definition at line 131 of file csview.h.

virtual CS::Utility::MeshFilter& csView::GetMeshFilter (  )  [inline, virtual]

Get the mesh filter used to restrict the meshes that are visible in this view.

Implements iView.

Definition at line 121 of file csview.h.

virtual iPerspectiveCamera* csView::GetPerspectiveCamera (  )  [virtual]

Get the current perspective camera.

Can return nullptr if the current camera is not a perspective camera.

Implements iView.

virtual int csView::GetWidth (  )  const [inline, virtual]

Get the view width, in pixels.

Implements iView.

Definition at line 126 of file csview.h.

virtual csVector3 csView::InvProject ( const csVector2 p,
float  z 
) const [virtual]

Calculate an inverse projection corrected point for this view, that is the inverse projection of a 2D point expressed in screen space into the 3D camera space.

Parameters:
p The 2D point on the screen, in pixels.
z The Z component of the projection point, that is the distance between the camera and the plane where the point is projected.
Returns:
The 3D projection point, in camera space coordinates.
See also:
Project() iCamera::InvProject()

Implements iView.

virtual csVector2 csView::NormalizedToScreen ( const csVector2 pos  )  [inline, virtual]

Transform a normalized screen space coordinate (-1 to 1) to real pixels in this viewport.

Remarks:
Unlike csEngineTools::NormalizedToScreen(), this method works in view space, not in screen space. That is, the view coordinates are vertically mirrored in comparison to screen space, i.e. y=0 is at the bottom of the viewport, and y=GetHeight() at the top.

Implements iView.

Definition at line 146 of file csview.h.

virtual csVector2 csView::Project ( const csVector3 v  )  const [virtual]

Calculate a projection corrected point for this view, that is the projection of a 3D point expressed in camera space into the 2D screen space.

Parameters:
v The 3D point to be projected, in camera space coordinates.
Returns:
The 2D projection into the screen, in pixels.
See also:
InvProject() iCamera::Project()

Implements iView.

virtual void csView::RestrictClipperToScreen (  )  [virtual]

Clip the polygon clipper to the screen boundaries.

Implements iView.

virtual csVector2 csView::ScreenToNormalized ( const csVector2 pos  )  [inline, virtual]

Transform a screen space coordinate in pixels to a normalized screen coordinate (-1 to 1).

Remarks:
Unlike csEngineTools::NormalizedToScreen(), this method works in view space, not in screen space. That is, the view coordinates are vertically mirrored in comparison to screen space, i.e. y=0 is at the bottom of the viewport, and y=GetHeight() at the top.

Implements iView.

Definition at line 154 of file csview.h.

virtual void csView::SetAutoResize ( bool  state  )  [inline, virtual]

Enable or disable automatic resizing.

When this is true (default) then the view will detect automatically when the canvas size changes and adapt the view and camera automatically (i.e. it will change the view rectangle, the clipper coordinates and the camera aspect ratio). If you don't want that then you can disable this.

Implements iView.

Definition at line 114 of file csview.h.

virtual void csView::SetBackgroundColor ( csColor4 color  )  [virtual]

Set the background color of this view.

This will be displayed before any other graphics when this view is rendered.

If it is set to nullptr, then no background color will be displayed and the 2D canvas won't be cleared before the view is rendered. This can be used e.g. in order to superpose the rendering of several views.

The default is a black, non transparent, background color.

Implements iView.

virtual void csView::SetBackgroundTexture ( iTextureHandle texture,
int  sx,
int  sy,
int  sw,
int  sh,
int  tx,
int  ty,
int  tw,
int  th,
uint8  alpha,
bool  tiled 
) [virtual]

Set the background texture of this view.

This will be displayed before any other graphics when this view is rendered (but just after the background color).

Remarks:
Unlike the other methods of iView that uses flipped vertical coordinates, this method uses the same logic as iGraphics2D::DrawPixmap(), that is, y=0 is at the top of the screen while y=GetHeight() is at the bottom.
Parameters:
texture The background texture.
sx The X coordinate of the left of the texture on screen.
sy The Y coordinate of the top of the texture on screen.
sw The width of the texture on screen.
sh The height of the texture on screen.
tx The X coordinate of the left of the displayed texture area.
ty The Y coordinate of the top of the displayed texture area.
tw The width of the displayed texture area.
th The height of the displayed texture area.
alpha The transparency of the texture.
tiled Whether the texture should be displayed once or repeated in order to cover the whole screen.

Implements iView.

virtual void csView::SetCamera ( iCamera c  )  [virtual]

Set the current camera.

Implements iView.

virtual void csView::SetContext ( iGraphics3D ig3d  )  [virtual]

Set the iGraphics3d context of this view.

Implements iView.

virtual void csView::SetCustomMatrixCamera ( iCustomMatrixCamera c  )  [virtual]

Set the current camera as a custom matrix camera.

Implements iView.

virtual void csView::SetEngine ( iEngine e  )  [virtual]

Set the engine handle.

Implements iView.

virtual void csView::SetHeight ( int  h  )  [inline, virtual]

Set the view height, in pixels.

Implements iView.

Definition at line 141 of file csview.h.

virtual void csView::SetPerspectiveCamera ( iPerspectiveCamera c  )  [virtual]

Set the current camera as a perspective camera.

Implements iView.

virtual void csView::SetRectangle ( int  x,
int  y,
int  w,
int  h,
bool  restrictToScreen = true 
) [virtual]

Set the clipper as a clipping rectangle.

Parameters:
x The left position of the rectangle, in pixels.
y The bottom position of the rectangle, in pixels.
w The width of the rectangle, in pixels.
h The height of the rectangle, in pixels.
restrictToScreen Restrict the rectangle to not be bigger than the screen size.

Implements iView.

virtual void csView::SetWidth ( int  w  )  [inline, virtual]

Set the view width, in pixels.

Implements iView.

Definition at line 136 of file csview.h.

virtual void csView::UpdateClipper (  )  [virtual]

Update the Clipper. This is called automatically by GetClipper().

Implements iView.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1