App::cViewer class

This class represents all the camera and viewport configuration used to render a scene.

This includes the FOV, projection matrix, view matrix (i.e. camera orientation and position), as well as the color and depth buffers where the scene will be rendered into. It also has the "renderType" variable, a specific thing to Spore, which is used in shader selection.

Public types

struct Camera
enum class Projection: int { NA = 0, Perspective = 1, Parallel = 2, PerspectiveInfinite = 3 }

Public functions

auto Initialize(bool isParallelProjection = false) -> bool
auto Dispose() -> void
auto ClearScene(int8_t flags) -> bool
Clears one or more surfaces such as the render target, the depth buffer or the stencil buffer.
auto BeginUpdate() -> bool
Call before rendering, loads all the viewer data into the renderer system; must be paired with a EndUpdate() call.
auto EndUpdate() -> bool
Call after finished rendering, has to be paired with a BeginUpdate() call.
auto SetBackgroundColor(const Math::ColorRGBA& color) -> void
Sets the background color that is shown in the background of the scene.
auto GetNearPlane() const -> float
auto GetFarPlane() const -> float
auto SetNearPlane(float nearPlane) -> void
auto SetFarPlane(float farPlane) -> void
auto SetAspectRatio(float aspectRatio) -> void
auto SetPerspectiveProjection(float fovDegrees) -> void
auto SetParallelProjection(float viewWindowX, float viewWindowY) -> void
auto SetViewport(const IntRectangle& viewport) -> void
auto SetViewWindow(const Vector2& window) -> void
auto SetViewOffset(const Vector2& offset) -> void
auto SetCameraMaterialLODs(const Vector4& values) -> void
auto GetCameraMaterialLODs() const -> Vector4
auto SetRenderType(int renderType, bool = 0) -> void
auto SetTargetRaster(RenderWare::Raster* raster) -> void
Sets the target raster where the scene will be painted.
auto SetTargetZBuffer(RenderWare::Raster* raster) -> void
Sets the target raster where the scene depth buffer will be painted.
auto SetCameraTransform(const Transform& transform) -> void
Sets the camera position and direction.
auto GetViewTransform() const -> Transform
auto GetCameraToMouse(Vector3& cameraPosition, Vector3& direction) const -> bool
Just calls GetCameraToPoint() for the current mouse coordinates.
auto GetCameraToPoint(float x, float y, Vector3& cameraPosition, Vector3& direction) const -> bool
auto GetCamera() -> Camera*
auto GetViewport() const -> D3DVIEWPORT9

Public variables

Matrix4 viewTransform
Matrix4 field_40
Matrix4 field_80
Matrix4 field_C0
Matrix4 field_100
ColorRGBA backgroundColor
int renderType
bool field_154
int field_158
float cameraMaterialLODs
bool field_16C
Camera* pCamera

Function documentation

bool App::cViewer::ClearScene(int8_t flags)

Clears one or more surfaces such as the render target, the depth buffer or the stencil buffer.

Parameters
flags A combination of flags in the D3DCLEAR enum.
Returns true If the operation was carried out successfully.

This calls the IDirect3DDevice9::Clear() method using this Viewer background color. It will also call IDirect3DDevice9::SetViewport() if the current viewport is not that from the viewer.

void App::cViewer::SetBackgroundColor(const Math::ColorRGBA& color)

Sets the background color that is shown in the background of the scene.

Parameters
color

More exactly, this is the color used to clear the scene.

void App::cViewer::SetTargetRaster(RenderWare::Raster* raster)

Sets the target raster where the scene will be painted.

Parameters
raster

void App::cViewer::SetTargetZBuffer(RenderWare::Raster* raster)

Sets the target raster where the scene depth buffer will be painted.

Parameters
raster

void App::cViewer::SetCameraTransform(const Transform& transform)

Sets the camera position and direction.

Parameters
transform The transform applied to the camera.

bool App::cViewer::GetCameraToMouse(Vector3& cameraPosition, Vector3& direction) const

Just calls GetCameraToPoint() for the current mouse coordinates.

Parameters
cameraPosition [Output]
direction [Output]

bool App::cViewer::GetCameraToPoint(float x, float y, Vector3& cameraPosition, Vector3& direction) const

Parameters
x
y
cameraPosition [Output]
direction [Output]