Loading...
Searching...
No Matches
Gfx::CEngine Class Reference

The graphics engine. More...

`#include <src/graphics/engine/engine.h>`

Inheritance diagram for Gfx::CEngine:
[legend]

## Classes

struct | WriteScreenShotData
struct | PendingDebugDraw

## Public Member Functions

| CEngine (CApplication *app, CSystemUtils *systemUtils)
void | SetDevice (CDevice *device)
| Sets the device to be used.
CDevice * | GetDevice ()
| Returns the current device.
CText * | GetText ()
| Returns the text rendering engine.
COldModelManager * | GetModelManager ()
CPyroManager * | GetPyroManager ()
CLightManager * | GetLightManager ()
| Returns the light manager.
CParticle * | GetParticle ()
| Returns the particle manager.
CTerrain * | GetTerrain ()
| Returns the terrain manager.
CWater * | GetWater ()
| Returns the water manager.
CLightning * | GetLightning ()
| Returns the lighting manager.
CPlanet * | GetPlanet ()
| Returns the planet manager.
CCloud * | GetCloud ()
| Returns the fog manager.
void | SetTerrain (CTerrain *terrain)
| Sets the terrain object.
bool | Create ()
| Performs the initialization; must be called after device was set.
void | Destroy ()
| Frees all resources before exit.
void | Render ()
| Called once per frame, the call is the entry point for rendering.
bool | ProcessEvent (const Event &event)
| Processes incoming event.
void | FrameUpdate ()
| Called once per frame, the call is the entry point for animating the scene.
void | WriteScreenShot (const std::string &fileName)
| Writes a screenshot containing the current frame.
void | SetPause (bool pause)
| Management of animation pause mode.
bool | GetPause ()
void | SetShowStats (bool show)
| Management of displaying statistic information.
bool | GetShowStats ()
void | SetRenderEnable (bool enable)
| Enables/disables rendering.
void | SetRenderInterface (bool enable)
bool | GetRenderInterface ()
void | SetScreenshotMode (bool screenshotMode)
| Management of "screenshot mode" (disables interface particle rendering).
bool | GetScreenshotMode ()
Math::IntPoint | GetWindowSize ()
| Returns current size of viewport window.
Math::Point | WindowToInterfaceCoords (Math::IntPoint pos)
| Conversion functions between window and interface coordinates.
Math::IntPoint | InterfaceToWindowCoords (Math::Point pos)
Math::Point | WindowToInterfaceSize (Math::IntPoint size)
| Conversion functions between window and interface sizes.
Math::IntPoint | InterfaceToWindowSize (Math::Point size)
void | AddStatisticTriangle (int count)
| Increments the triangle counter for the current frame.
int | GetStatisticTriangle ()
| Returns the number of triangles in current frame.
void | SetStatisticPos (Math::Vector pos)
| Sets the coordinates to display in stats window.
void | SetTimerDisplay (const std::string &text)
| Sets text to display as mission timer.
int | AddStaticMesh (const std::string &key, const Gfx::CModelMesh *mesh, const Math::Matrix &worldMatrix)
| Add new instance of static mesh.
void | DeleteStaticMesh (int meshHandle)
| Removes given static mesh.
void | AddStaticMeshShadowSpot (int meshHandle, const Gfx::ModelShadowSpot &shadowSpot)
| Adds a shadow spot to mesh.
const Math::Matrix & | GetStaticMeshWorldMatrix (int meshHandle)
| Returns static mesh world matrix.
void | SetStaticMeshTransparency (int meshHandle, float value)
| Sets transparency for static mesh.
int | CreateBaseObject ()
| Creates a base object and returns its rank.
void | DeleteBaseObject (int baseObjRank)
| Deletes a base object.
void | DeleteAllBaseObjects ()
| Deletes all base objects.
void | CopyBaseObject (int sourceBaseObjRank, int destBaseObjRank)
| Copies geometry between two base objects.
void | AddBaseObjTriangles (int baseObjRank, const std::vector< Gfx::ModelTriangle > &triangles)
| Adds triangles to given object with the specified params.
void | AddBaseObjQuick (int baseObjRank, const EngineBaseObjDataTier &buffer, std::string tex1Name, std::string tex2Name, bool globalUpdate)
| Adds a tier 4 engine object directly.
void | DebugObject (int objRank)
| Print debug info about an object.
int | CreateObject ()
| Creates a new object and returns its rank.
void | DeleteAllObjects ()
| Deletes all objects, shadows and ground spots.
void | DeleteObject (int objRank)
| Deletes the given object.
void | SetObjectBaseRank (int objRank, int baseObjRank)
| Management of the base object rank for engine object.
int | GetObjectBaseRank (int objRank)
void | SetObjectType (int objRank, EngineObjectType type)
| Management of engine object type.
EngineObjectType | GetObjectType (int objRank)
void | SetObjectTransform (int objRank, const Math::Matrix &transform)
| Management of object transform.
void | GetObjectTransform (int objRank, Math::Matrix &transform)
void | SetObjectDrawWorld (int objRank, bool draw)
| Sets drawWorld for given object.
void | SetObjectDrawFront (int objRank, bool draw)
| Sets drawFront for given object.
void | SetObjectTransparency (int objRank, float value)
| Sets the transparency level for given object.
void | GetObjectBBox (int objRank, Math::Vector &min, Math::Vector &max)
| Returns the bounding box for an object.
int | GetObjectTotalTriangles (int objRank)
| Returns the total number of triangles of given object.
EngineBaseObjDataTier * | FindTriangles (int objRank, const Material &material, int state, std::string tex1Name, std::string tex2Name)
| Returns the first found tier 4 engine object for the given params or nullptr if not found.
int | GetPartialTriangles (int objRank, float percent, int maxCount, std::vector< EngineTriangle > &triangles)
| Returns a partial list of triangles for given object.
void | ChangeSecondTexture (int objRank, const std::string &tex2Name)
| Changes the 2nd texure for given object.
void | ChangeTextureMapping (int objRank, const Material &mat, int state, const std::string &tex1Name, const std::string &tex2Name, EngineTextureMapping mode, float au, float bu, float av, float bv)
| Changes (recalculates) texture mapping for given object.
void | TrackTextureMapping (int objRank, const Material &mat, int state, const std::string &tex1Name, const std::string &tex2Name, EngineTextureMapping mode, float pos, float factor, float tl, float ts, float tt)
| Changes texture mapping for robot tracks.
int | DetectObject (Math::Point mouse, Math::Vector &targetPos, bool terrain=false)
| Detects the target object that is selected with the mouse.
void | CreateShadowSpot (int objRank)
| Creates a shadow for the given object.
void | DeleteShadowSpot (int objRank)
| Deletes the shadow for given object.
void | SetObjectShadowSpotHide (int objRank, bool hide)
| Management of different shadow params.
void | SetObjectShadowSpotType (int objRank, EngineShadowType EngineShadowType type)
void | SetObjectShadowSpotPos (int objRank, const Math::Vector &pos)
void | SetObjectShadowSpotAngle (int objRank, float angle)
void | SetObjectShadowSpotRadius (int objRank, float radius)
void | SetObjectShadowSpotIntensity (int objRank, float intensity)
void | SetObjectShadowSpotHeight (int objRank, float height)
void | UpdateObjectShadowSpotNormal (int objRank)
void | SetHighlightRank (int *rankList)
| Lists the ranks of objects and subobjects selected.
bool | GetHighlight (Math::Point &p1, Math::Point &p2)
| Returns the highlighted rectangle.
void | DeleteAllGroundSpots ()
| Deletes all ground spots.
int | CreateGroundSpot ()
| Creates a new ground spot and returns its rank.
void | DeleteGroundSpot (int rank)
| Deletes the given ground spot.
void | SetObjectGroundSpotPos (int rank, const Math::Vector &pos)
| Management of different ground spot params.
void | SetObjectGroundSpotRadius (int rank, float radius)
void | SetObjectGroundSpotColor (int rank, const Color &color)
void | SetObjectGroundSpotMinMax (int rank, float min, float max)
void | SetObjectGroundSpotSmooth (int rank, float smooth)
void | CreateGroundMark (Math::Vector pos, float radius, float delay1, float delay2, float delay3, int dx, int dy, char *table)
| Creates the ground mark with the given params.
void | DeleteGroundMark (int rank)
| Deletes the ground mark.
void | Update ()
| Updates the state after creating objects.
void | SetState (int state, const Color &color=Color(1.0f, 1.0f, 1.0f, 1.0f))
| Sets the current rendering state.
void | SetMaterial (const Material &mat)
| Sets the current material.
void | SetViewParams (const Math::Vector &eyePt, const Math::Vector &lookatPt, const Math::Vector &upVec)
| Specifies the location and direction of view.
void | UpdateGroundSpotTextures ()
| Updates the textures used for drawing ground spot.
Texture | LoadTexture (const std::string &name)
| Loads texture, creating it if not already present.
Texture | LoadTexture (const std::string &name, CImage *image)
| Loads texture from existing image.
Texture | LoadTexture (const std::string &name, const TextureCreateParams &params)
| Loads texture, creating it with given params if not already present.
bool | LoadAllTextures ()
| Loads all necessary textures.
bool | ChangeTextureColor (const std::string &texName, const std::string &srcName, Color colorRef1, Color colorNew1, Color colorRef2, Color colorNew2, float tolerance1, float tolerance2, Math::Point ts, Math::Point ti, Math::Point *exclude=nullptr, float shift=0.0f, bool hsv=false)
| Changes colors in a texture.
bool | ChangeTextureColor (const std::string &texName, Color colorRef1, Color colorNew1, Color colorRef2, Color colorNew2, float tolerance1, float tolerance2, Math::Point ts, Math::Point ti, Math::Point *exclude=nullptr, float shift=0.0f, bool hsv=false)
bool | SetTexture (const std::string &name, int stage=0)
| Sets texture for given stage; if not present in cache, the texture is loaded.
void | SetTexture (const Texture &tex, int stage=0)
| Sets texture for given stage.
void | DeleteTexture (const std::string &texName)
| Deletes the given texture, unloading it and removing from cache.
void | DeleteTexture (const Texture &tex)
| Deletes the given texture, unloading it and removing from cache.
void | CreateOrUpdateTexture (const std::string &texName, CImage *img)
| Creates or updates the given texture with given image data.
void | FlushTextureCache ()
| Empties the texture cache.
void | SetTerrainVision (float vision)
| Defines of the distance field of vision.
void | SetFocus (float focus)
| Management of camera vertical field-of-view angle.
float | GetFocus ()
| Deprecated alias for GetVFovAngle.
float | GetVFovAngle ()
float | GetHFovAngle ()
void | SetDirty (bool mode)
| Management of the global mode of contamination.
bool | GetDirty ()
void | SetFog (bool mode)
| Management of the global mode of horizontal fog patches.
bool | GetFog ()
void | SetSecondTexture (const std::string &texNum)
| Management of the global mode of secondary texturing.
const std::string & | GetSecondTexture ()
void | SetRankView (int rank)
| Management of view mode.
int | GetRankView ()
void | SetDrawWorld (bool draw)
| Whether to draw the world.
void | SetDrawFront (bool draw)
| Whether to draw the world on the interface.
void | SetAmbientColor (const Color &color, int rank=0)
| Ambient color management.
Color | GetAmbientColor (int rank=0)
void | SetWaterAddColor (const Color &color)
| Color management under water.
Color | GetWaterAddColor ()
void | SetFogColor (const Color &color, int rank=0)
| Management of the fog color.
Color | GetFogColor (int rank=0)
void | SetDeepView (float length, int rank=0, bool ref=false)
| Management of the depth of field.
float | GetDeepView (int rank=0)
void | SetFogStart (float start, int rank=0)
| Management the start of fog.
float | GetFogStart (int rank=0)
void | SetBackground (const std::string &name, Color up=Color(), Color down=Color(), Color cloudUp=Color(), Color cloudDown=Color(), bool full=false, bool scale=false)
| Management of the background image to use.
void | GetBackground (std::string &name, Color &up, Color &down, Color &cloudUp, Color &cloudDown, bool &full, bool &scale)
void | SetForegroundName (const std::string &name)
| Specifies the name of foreground texture.
void | SetOverFront (bool front)
| Specifies whether to draw the foreground.
void | SetOverColor (const Color &color=Color(), int mode=ENG_RSTATE_TCOLOR_BLACK)
| Sets the foreground overlay color.
void | SetParticleDensity (float value)
| Management of the particle density.
float | GetParticleDensity ()
float | ParticleAdapt (float factor)
| Adapts particle factor according to particle density.
void | SetClippingDistance (float value)
| Management of the distance of clipping.
float | GetClippingDistance ()
void | SetTextureFilterMode (TexFilter value)
| Management the texture filter mode.
TexFilter | GetTextureFilterMode ()
void | SetTextureMipmapLevel (int value)
| Management the mipmap level for textures.
int | GetTextureMipmapLevel ()
void | SetTextureAnisotropyLevel (int value)
| Management the anisotropy level for textures.
int | GetTextureAnisotropyLevel ()
bool | IsShadowMappingSupported ()
| Management of shadow mapping.
void | SetShadowMapping (bool value)
bool | GetShadowMapping ()
void | SetShadowMappingOffscreen (bool value)
bool | GetShadowMappingOffscreen ()
void | SetShadowMappingOffscreenResolution (int resolution)
int | GetShadowMappingOffscreenResolution ()
bool | IsShadowMappingQualitySupported ()
void | SetShadowMappingQuality (bool value)
bool | GetShadowMappingQuality ()
void | SetTerrainShadows (bool value)
bool | GetTerrainShadows ()
void | SetVSync (int value)
| Management of vertical synchronization.
int | GetVSync ()
void | SetShadowColor (float value)
| Management of shadow color.
float | GetShadowColor ()
void | SetShadowRange (float value)
| Management of shadow range.
float | GetShadowRange ()
void | SetMultiSample (int value)
| Management of shadow range.
int | GetMultiSample ()
void | SetBackForce (bool present)
| Management the mode of background.
bool | GetBackForce ()
void | SetLightMode (bool present)
| Managing the mode of dynamic lights.
bool | GetLightMode ()
void | SetEditIndentMode (bool autoIndent)
| Management of the indentation mode while editing (CEdit).
bool | GetEditIndentMode ()
void | SetEditIndentValue (int value)
| Management of tab indent when editing (CEdit).
int | GetEditIndentValue ()
void | SetTracePrecision (float factor)
| Management of precision of robot tracks.
float | GetTracePrecision ()
void | SetMouseType (EngineMouseType type)
| Management of mouse cursor type.
EngineMouseType | GetMouseType ()
void | SetPauseBlurEnabled (bool enable)
| Management of pause blur.
bool | GetPauseBlurEnabled ()
const Math::Matrix & | GetMatView ()
| Returns the view matrix.
const Math::Matrix & | GetMatProj ()
| Returns the projection matrix.
TEST_VIRTUAL Math::Vector | GetEyePt ()
| Returns the camera center point.
TEST_VIRTUAL Math::Vector | GetLookatPt ()
| Returns the camera target point.
float | GetEyeDirH ()
| Returns the horizontal direction angle of view.
float | GetEyeDirV ()
| Returns the vertical direction angle of view.
bool | IsVisiblePoint (const Math::Vector &pos)
| Indicates whether a point is visible.
void | UpdateMatProj ()
| Resets the projection matrix after changes.
void | ApplyChange ()
| Updates the scene after a change of parameters.
void | RenderDebugSphere (const Math::Sphere &, const Math::Matrix &transform=Math::Matrix{}, const Color &=Color{0.0f, 0.0f, 1.0f, 1.0f})
void | RenderDebugBox (const Math::Vector &mins, const Math::Vector &maxs, const Math::Matrix &transform=Math::Matrix{}, const Color &=Color{0.0f, 0.0f, 1.0f, 1.0f})
void | SetDebugLights (bool debugLights)
bool | GetDebugLights ()
void | DebugDumpLights ()
void | SetDebugResources (bool debugResources)
bool | GetDebugResources ()
void | SetDebugGoto (bool debugGoto)
bool | GetDebugGoto ()
void | AddDebugGotoLine (std::vector< Gfx::VertexCol > line)
void | SetDebugGotoBitmap (std::unique_ptr< CImage > debugImage)
void | SetWindowCoordinates ()
void | SetInterfaceCoordinates ()
void | EnablePauseBlur ()
void | DisablePauseBlur ()
void | ReloadAllTextures ()
| Reloads all textures.

## Protected Member Functions

void | ResetAfterVideoConfigChanged ()
| Resets some states and flushes textures after device was changed (e.g. resoulution changed).
void | Draw3DScene ()
| Prepares the interface for 3D scene.
void | Capture3DScene ()
| Capture the 3D scene for pause blur.
void | DrawCaptured3DScene ()
| Draw the 3D scene capured for pause blur.
void | RenderShadowMap ()
| Renders shadow map.
void | UseShadowMapping (bool enable)
| Enables or disables shadow mapping.
void | UseMSAA (bool enable)
| Enables or disables MSAA.
void | DrawObject (const EngineBaseObjDataTier &p4)
| Draw 3D object.
void | DrawInterface ()
| Draws the user interface over the scene.
void | DrawShadowSpots ()
| Draws old-style shadow spots.
void | DrawBackground ()
| Draws the gradient background.
void | DrawBackgroundGradient (const Color &up, const Color &down)
| Draws the gradient background.
void | DrawBackgroundImage ()
| Draws the image background.
void | DrawPlanet ()
| Draws all the planets.
void | DrawForegroundImage ()
| Draws the image foreground.
void | DrawOverColor ()
| Draws the foreground color.
void | DrawHighlight ()
| Draws the rectangle of the object highlighted.
void | DrawMouse ()
| Draws the mouse cursor.
void | DrawMouseSprite (Math::IntPoint pos, Math::IntPoint size, int icon)
| Draw part of mouse cursor sprite.
void | DrawStats ()
| Draw statistic texts.
void | DrawTimer ()
| Draw mission timer.
void | RenderPendingDebugDraws ()
EngineBaseObjTexTier & | AddLevel2 (EngineBaseObject &p1, const std::string &tex1Name, const std::string &tex2Name)
| Creates a new tier 2 object (texture).
EngineBaseObjDataTier & | AddLevel3 (EngineBaseObjTexTier &p3, EngineTriangleType type, const Material &material, int state)
| Creates a new tier 3 object (data).
Texture | CreateTexture (const std::string &texName, const TextureCreateParams &params, CImage *image=nullptr)
| Create texture and add it to cache.
bool | IsVisible (int objRank)
| Tests whether the given object is visible.
bool | DetectBBox (int objRank, Math::Point mouse)
| Detects whether an object is affected by the mouse.
bool | GetBBox2D (int objRank, Math::Point &min, Math::Point &max)
| Compute and return the 2D box on screen of any object.
bool | DetectTriangle (Math::Point mouse, VertexTex2 *triangle, int objRank, float &dist, Math::Vector &pos)
| Detects whether the mouse is in a triangle.
bool | TransformPoint (Math::Vector &p2D, int objRank, Math::Vector p3D)
| Transforms a 3D point (x, y, z) in 2D space (x, y, -) of the window.
void | ComputeDistance ()
| Calculates the distances between the viewpoint and the origin of different objects.
void | UpdateGeometry ()
| Updates geometric parameters of objects (bounding box and radius).
void | UpdateStaticBuffer (EngineBaseObjDataTier &p4)
| Updates a given static buffer.
void | UpdateStaticBuffers ()
| Updates static buffers of changed objects.
void | AddBaseObjTriangles (int baseObjRank, const std::vector< VertexTex2 > &vertices, const Material &material, int state, std::string tex1Name, std::string tex2Name)
int | GetEngineState (const ModelTriangle &triangle)

## Static Protected Member Functions

static void | WriteScreenShotThread (std::unique_ptr< WriteScreenShotData > data)

## Protected Attributes

CApplication * | m_app
CSystemUtils * | m_systemUtils
CSoundInterface * | m_sound
CDevice * | m_device
CTerrain * | m_terrain
std::unique_ptr< COldModelManager > | m_modelManager
std::unique_ptr< CText > | m_text
std::unique_ptr< CLightManager > | m_lightMan
std::unique_ptr< CParticle > | m_particle
std::unique_ptr< CWater > | m_water
std::unique_ptr< CCloud > | m_cloud
std::unique_ptr< CLightning > | m_lightning
std::unique_ptr< CPlanet > | m_planet
std::unique_ptr< CPyroManager > | m_pyroManager
std::string | m_error
| Last encountered error.
TimeUtils::TimeStamp | m_lastFrameTime
TimeUtils::TimeStamp | m_currentFrameTime
int | m_fpsCounter
float | m_fps
bool | m_showStats
| Whether to show stats (FPS, etc).
bool | m_render
| Rendering enabled?
bool | m_renderInterface
| Render / hide the UI?
bool | m_screenshotMode
| Screenshot mode?
Math::Matrix | m_matProj
| Projection matrix for 3D scene.
Math::Matrix | m_matView
| View matrix for 3D scene.
float | m_focus
| Camera vertical field-of-view angle for 3D scene. A.k.a. m_vfov.
float | m_hfov
| Horizontal field-of-view angle, calculated from vertical FOV and aspect ratio.
Math::Matrix | m_shadowProjMat
| Projection matrix for rendering shadow maps.
Math::Matrix | m_shadowViewMat
| View matrix for rendering shadow maps.
Math::Matrix | m_shadowTextureMat
| Texture matrix for rendering shadow maps.
Math::Matrix | m_shadowBias
| Texture bias for sampling shadow maps.
int | m_vsync
| Vertical synchronization controll.
Math::Matrix | m_matWorldInterface
| World matrix for 2D interface.
Math::Matrix | m_matProjInterface
| Projection matrix for 2D interface.
Math::Matrix | m_matViewInterface
| View matrix for 2D interface.
Math::IntPoint | m_size
| Current size of viewport window.
std::vector< EngineBaseObject > | m_baseObjects
| Base objects (also level 1 tier list).
std::vector< EngineObject > | m_objects
| Object parameters.
std::vector< EngineShadow > | m_shadowSpots
| Shadow list.
std::vector< EngineGroundSpot > | m_groundSpots
| Ground spot list.
EngineGroundMark | m_groundMark
| Ground mark.
Math::Vector | m_eyePt
| Location of camera.
Math::Vector | m_lookatPt
| Camera target.
float | m_eyeDirH
float | m_eyeDirV
int | m_rankView
Color | m_ambientColor [2]
Color | m_backColor [2]
Color | m_fogColor [2]
float | m_deepView [2]
float | m_fogStart [2]
Color | m_waterAddColor
int | m_statisticTriangle
Math::Vector | m_statisticPos
bool | m_updateGeometry
bool | m_updateStaticBuffers
bool | m_firstGroundSpot
std::string | m_secondTex
bool | m_backgroundFull
bool | m_backgroundScale
std::string | m_backgroundName
Texture | m_backgroundTex
Color | m_backgroundColorUp
Color | m_backgroundColorDown
Color | m_backgroundCloudUp
Color | m_backgroundCloudDown
bool | m_overFront
Color | m_overColor
int | m_overMode
std::string | m_foregroundName
Texture | m_foregroundTex
bool | m_drawWorld
bool | m_drawFront
float | m_terrainVision
bool | m_backForce
float | m_tracePrecision
bool | m_pauseBlurEnabled
bool | m_dirty
bool | m_fog
float | m_particleDensity
float | m_clippingDistance
bool | m_lightMode
bool | m_editIndentMode
int | m_editIndentValue
Texture | m_shadowMap
struct Gfx::CEngine::PendingDebugDraw | m_pendingDebugDraws
int | m_highlightRank [100]
| Ranks of highlighted objects.
bool | m_highlight
| Highlight visible?
float | m_highlightTime
| Time counter for highlight animation.
Math::Point | m_highlightP1
| Highlight rectangle points.
Math::Point | m_highlightP2
TextureCreateParams | m_defaultTexParams
| Default texture create params.
TextureCreateParams | m_terrainTexParams
| Create params for terrain textures.
int | m_textureMipmapLevel
| Requested texture mipmap level.
int | m_textureAnisotropy
| Requested texture anisotropy level.
bool | m_shadowMapping
| true if shadow mapping enabled
bool | m_offscreenShadowRendering
| true enables offscreen shadow rendering
int | m_offscreenShadowRenderingResolution
| Offscreen shadow rendering resolution.
bool | m_qualityShadows
| true enables higher quality shadows
bool | m_terrainShadows
| true enables casting shadows by terrain
float | m_shadowColor
| Shadow color.
float | m_shadowRange
| Shadow range.
int | m_multisample
| Number of samples for multisample rendering.
std::map< std::string, Texture > | m_texNameMap
| Map of loaded textures (by name).
std::map< Texture, std::string > | m_revTexNameMap
| Reverse map of loaded textures (by texture).
std::set< std::string > | m_texBlacklist
| Blacklist map of textures.
Texture | m_miceTexture
| Texture with mouse cursors.
EngineMouseType | m_mouseType
| Type of mouse cursor.
int | m_lastState
| Last engine render state (-1 at the beginning of frame).
Color | m_lastColor
| Last color set with render state.
std::string | m_lastTexture [2]
| Last texture names for 2 used texture stages.
Material | m_lastMaterial
| Last material.
bool | m_interfaceMode
| True when drawing 2D UI.
bool | m_debugLights
bool | m_debugDumpLights
bool | m_debugCrashSpheres = false
bool | m_debugResources = false
bool | m_debugGoto = false
std::string | m_timerText
std::unordered_map< std::string, int > | m_staticMeshBaseObjects
std::vector< std::vector< VertexCol > > | m_displayGoto
std::unique_ptr< CImage > | m_displayGotoImage
bool | m_pause = false
| Pause the animation updates.
bool | m_worldCaptured = false
| true means that current 3D scene was captured and is not to be rendered again
bool | m_captureWorld = false
| true means that currently rendered world is to be captured
Texture | m_capturedWorldTexture
| Texture with captured 3D world.

## Additional Inherited Members

Static Public Member Functions inherited from CSingleton< CEngine >
static CEngine & | GetInstance ()
static CEngine * | GetInstancePointer ()
static bool | IsCreated ()
Static Protected Attributes inherited from CSingleton< CEngine >
static CEngine * | m_instance

## Detailed Description

The graphics engine.

This is the main class for graphics engine. It is responsible for drawing the 3D scene, setting various render states, and facilitating the drawing of 2D interface.

It uses a lower-level CDevice object which is implementation-independent core engine.

# 3D Scene

The 3D scene is drawn with view coordinates set from camera position in 3D space and a perspective projection matrix. The world matrix depends on the object drawn. The coordinate system is left-handed: X axis is to the right, Y axis to the top and Z axis is into the screen (Z = 0 is the sceen surface).

In general, the 3D scene is composed of the following things:

- sky background (gradient or texture image)
- planets orbiting in the sky (drawn by CPlanet)
- terrain - ground of the game level (part of engine objects)
- main scene objects - robots, buildings, etc. (engine objects)
- water/lava (drawn by CWater)
- cloud layer (drawn by CCloud)
- fire, lightning and particle effects (CPyro, CLightning and CParticle)
- foreground image overlaid onto the scene at the end - for example, aiming crosshairs
- 2D interface controls available in-game
- mouse cursor
- animated highlight box of the selected object(s)

# 2D Interface

The 2D interface is drawn in fixed XY coordinates, independent from window size. Lower-left corner of the screen is (0,0) and upper-right corner is (1,1). Matrices for world, view and projection are therefore fixed and never change.

The class tracks the change of window coordinates and conversion functions between the window and interface coordinates are provided.

Interface drawing is delegated to CInterface class and particular controls are instances of CControl class. The source code for these classes is in src/ui directory.

# Engine Objects

The 3D scene is composed of objects which are basically collections of triangles forming a surface or simply independent triangles in space.

Objects are uniquely identified by object rank obtained at object creation. Creating an object equals to allocating space for EngineObject structure which holds object parameters.

Object's geometric data is stored as a separate object – base engine object. Each object must reference a valid base engine object or an empty base engine object (with rank = -1). This many-to-one association allows to share same geometric data (e.g. from same model) across objects.

Base engine object data is stored in a 4-tier tree which splits the data describing triangles.

The 4 tiers contain the following information:

- level 1 (EngineBaseObject) - geometric statistics
- level 2 (EngineBaseObjTexTier) - two textures (names and structs) applied to triangles,
- level 3 (EngineBaseObjDataTier) - type of object*, material, render state and the actual vertex data

*NOTE: type of object in this context means only the internal type in 3D engine. It is not related to CObject types.

Last tier containing vertex data contains also an ID of static buffer holding the data. The static buffer is created and updated with new data as needed.

Such tiered structure complicates loops over all object data, but saves a lot of memory and optimizes the rendering process.

# Shadows

Each engine object can be associated with a shadow (EngineShadow). Like objects, shadows are identified by their rank obtained upon creation.

Shadows are drawn as circular spots on the ground, except for shadows for worms, which have special mode for them.

# Render States

Almost every primitive drawn on screen is drawn in state set through EngineRenderState enum. In some functions, custom modes are still set, using CDevice's SetRenderState. However, it will be subject to removal in the future. Generally, setting render states should be minimized to avoid unnecessary overhead.

Some states are clearly the result of legacy drawing and texturing methods. For example, TTEXTURE states should really be removed and the textures changed to ones with alpha channel. In the future, the whole modesetting code will probably be refactored to something more maintainable.

# Textures

Textures are loaded from a texture subdir in data directory. In the old code, textures were identified by file name and loaded using some D3D util code. With new code and OpenGL backend, this approach is not efficient - name comparison, etc. takes a lot of time. In the future, textures should be loaded once at object creation time, and then referenced to as Texture structs, or even as unsigned int ID's which is what OpenGL actually wants. The old method is kept for now, with mapping between texture names and texture structs but it will also be subject to refactoring in the future.

## Member Function Documentation

## SetDevice()

void Gfx::CEngine::SetDevice | ( | CDevice * | device | ) |

Sets the device to be used.

## GetDevice()

CDevice * Gfx::CEngine::GetDevice | ( |  | ) |

Returns the current device.

## GetText()

CText * Gfx::CEngine::GetText | ( |  | ) |

Returns the text rendering engine.

## GetLightManager()

CLightManager * Gfx::CEngine::GetLightManager | ( |  | ) |

Returns the light manager.

## GetParticle()

CParticle * Gfx::CEngine::GetParticle | ( |  | ) |

Returns the particle manager.

## GetTerrain()

CTerrain * Gfx::CEngine::GetTerrain | ( |  | ) |

Returns the terrain manager.

## GetWater()

CWater * Gfx::CEngine::GetWater | ( |  | ) |

Returns the water manager.

## GetLightning()

CLightning * Gfx::CEngine::GetLightning | ( |  | ) |

Returns the lighting manager.

## GetPlanet()

CPlanet * Gfx::CEngine::GetPlanet | ( |  | ) |

Returns the planet manager.

## GetCloud()

CCloud * Gfx::CEngine::GetCloud | ( |  | ) |

Returns the fog manager.

## SetTerrain()

void Gfx::CEngine::SetTerrain | ( | CTerrain * | terrain | ) |

Sets the terrain object.

## Create()

bool Gfx::CEngine::Create | ( |  | ) |

Performs the initialization; must be called after device was set.

## Destroy()

void Gfx::CEngine::Destroy | ( |  | ) |

Frees all resources before exit.

## Render()

void Gfx::CEngine::Render | ( |  | ) |

Called once per frame, the call is the entry point for rendering.

This function sets up render states, clears the viewport, and renders the scene.

## ProcessEvent()

bool Gfx::CEngine::ProcessEvent | ( | const Event & | event | ) |

Processes incoming event.

## FrameUpdate()

void Gfx::CEngine::FrameUpdate | ( |  | ) |

Called once per frame, the call is the entry point for animating the scene.

## WriteScreenShot()

void Gfx::CEngine::WriteScreenShot | ( | const std::string & | fileName | ) |

Writes a screenshot containing the current frame.

## SetPause()

void Gfx::CEngine::SetPause | ( | bool | pause | ) |

Management of animation pause mode.

## SetShowStats()

void Gfx::CEngine::SetShowStats | ( | bool | show | ) |

Management of displaying statistic information.

## SetRenderEnable()

void Gfx::CEngine::SetRenderEnable | ( | bool | enable | ) |

Enables/disables rendering.

## SetScreenshotMode()

void Gfx::CEngine::SetScreenshotMode | ( | bool | screenshotMode | ) |

Management of "screenshot mode" (disables interface particle rendering).

## GetWindowSize()

Math::IntPoint Gfx::CEngine::GetWindowSize | ( |  | ) |

Returns current size of viewport window.

## WindowToInterfaceCoords()

Math::Point Gfx::CEngine::WindowToInterfaceCoords | ( | Math::IntPoint | pos | ) |

Conversion functions between window and interface coordinates.

Window coordinates are from top-left (0,0) to bottom-right (w,h) - size of window Interface cords are from bottom-left (0,0) to top-right (1,1) - and do not depend on window size

## WindowToInterfaceSize()

Math::Point Gfx::CEngine::WindowToInterfaceSize | ( | Math::IntPoint | size | ) |

Conversion functions between window and interface sizes.

Unlike coordinate conversions, this is only scale conversion, not translation and scale.

## AddStatisticTriangle()

void Gfx::CEngine::AddStatisticTriangle | ( | int | count | ) |

Increments the triangle counter for the current frame.

## GetStatisticTriangle()

int Gfx::CEngine::GetStatisticTriangle | ( |  | ) |

Returns the number of triangles in current frame.

## SetStatisticPos()

void Gfx::CEngine::SetStatisticPos | ( | Math::Vector | pos | ) |

Sets the coordinates to display in stats window.

## SetTimerDisplay()

void Gfx::CEngine::SetTimerDisplay | ( | const std::string & | text | ) |

Sets text to display as mission timer.

## AddStaticMesh()

int Gfx::CEngine::AddStaticMesh | ( | const std::string & | key,
|  | const Gfx::CModelMesh * | mesh,
|  | const Math::Matrix & | worldMatrix )

Add new instance of static mesh.

Static meshes never change their geometry or texture mapping, so specific instances can share mesh data.

Parameters

  mesh | mesh data
  key | key unique per object class

Returns
  mesh instance handle

## DeleteStaticMesh()

void Gfx::CEngine::DeleteStaticMesh | ( | int | meshHandle | ) |

Removes given static mesh.

## AddStaticMeshShadowSpot()

void Gfx::CEngine::AddStaticMeshShadowSpot | ( | int | meshHandle,
|  | const Gfx::ModelShadowSpot & | shadowSpot )

Adds a shadow spot to mesh.

## GetStaticMeshWorldMatrix()

const Math::Matrix & Gfx::CEngine::GetStaticMeshWorldMatrix | ( | int | meshHandle | ) |

Returns static mesh world matrix.

## SetStaticMeshTransparency()

void Gfx::CEngine::SetStaticMeshTransparency | ( | int | meshHandle,
|  | float | value )

Sets transparency for static mesh.

## CreateBaseObject()

int Gfx::CEngine::CreateBaseObject | ( |  | ) |

Creates a base object and returns its rank.

## DeleteBaseObject()

void Gfx::CEngine::DeleteBaseObject | ( | int | baseObjRank | ) |

Deletes a base object.

## DeleteAllBaseObjects()

void Gfx::CEngine::DeleteAllBaseObjects | ( |  | ) |

Deletes all base objects.

## CopyBaseObject()

void Gfx::CEngine::CopyBaseObject | ( | int | sourceBaseObjRank,
|  | int | destBaseObjRank )

Copies geometry between two base objects.

## AddBaseObjTriangles()

void Gfx::CEngine::AddBaseObjTriangles | ( | int | baseObjRank,
|  | const std::vector< Gfx::ModelTriangle > & | triangles )

Adds triangles to given object with the specified params.

## AddBaseObjQuick()

void Gfx::CEngine::AddBaseObjQuick | ( | int | baseObjRank,
|  | const EngineBaseObjDataTier & | buffer,
|  | std::string | tex1Name,
|  | std::string | tex2Name,
|  | bool | globalUpdate )

Adds a tier 4 engine object directly.

## DebugObject()

void Gfx::CEngine::DebugObject | ( | int | objRank | ) |

Print debug info about an object.

## CreateObject()

int Gfx::CEngine::CreateObject | ( |  | ) |

Creates a new object and returns its rank.

## DeleteAllObjects()

void Gfx::CEngine::DeleteAllObjects | ( |  | ) |

Deletes all objects, shadows and ground spots.

## DeleteObject()

void Gfx::CEngine::DeleteObject | ( | int | objRank | ) |

Deletes the given object.

## SetObjectBaseRank()

void Gfx::CEngine::SetObjectBaseRank | ( | int | objRank,
|  | int | baseObjRank )

Management of the base object rank for engine object.

## SetObjectType()

void Gfx::CEngine::SetObjectType | ( | int | objRank,
|  | EngineObjectType | type )

Management of engine object type.

## SetObjectTransform()

void Gfx::CEngine::SetObjectTransform | ( | int | objRank,
|  | const Math::Matrix & | transform )

Management of object transform.

## SetObjectDrawWorld()

void Gfx::CEngine::SetObjectDrawWorld | ( | int | objRank,
|  | bool | draw )

Sets drawWorld for given object.

## SetObjectDrawFront()

void Gfx::CEngine::SetObjectDrawFront | ( | int | objRank,
|  | bool | draw )

Sets drawFront for given object.

## SetObjectTransparency()

void Gfx::CEngine::SetObjectTransparency | ( | int | objRank,
|  | float | value )

Sets the transparency level for given object.

## GetObjectBBox()

void Gfx::CEngine::GetObjectBBox | ( | int | objRank,
|  | Math::Vector & | min,
|  | Math::Vector & | max )

Returns the bounding box for an object.

## GetObjectTotalTriangles()

int Gfx::CEngine::GetObjectTotalTriangles | ( | int | objRank | ) |

Returns the total number of triangles of given object.

## FindTriangles()

EngineBaseObjDataTier * Gfx::CEngine::FindTriangles | ( | int | objRank,
|  | const Material & | material,
|  | int | state,
|  | std::string | tex1Name,
|  | std::string | tex2Name )

Returns the first found tier 4 engine object for the given params or nullptr if not found.

## GetPartialTriangles()

int Gfx::CEngine::GetPartialTriangles | ( | int | objRank,
|  | float | percent,
|  | int | maxCount,
|  | std::vector< EngineTriangle > & | triangles )

Returns a partial list of triangles for given object.

## ChangeSecondTexture()

void Gfx::CEngine::ChangeSecondTexture | ( | int | objRank,
|  | const std::string & | tex2Name )

Changes the 2nd texure for given object.

## ChangeTextureMapping()

void Gfx::CEngine::ChangeTextureMapping | ( | int | objRank,
|  | const Material & | mat,
|  | int | state,
|  | const std::string & | tex1Name,
|  | const std::string & | tex2Name,
|  | EngineTextureMapping | mode,
|  | float | au,
|  | float | bu,
|  | float | av,
|  | float | bv )

Changes (recalculates) texture mapping for given object.

## TrackTextureMapping()

void Gfx::CEngine::TrackTextureMapping | ( | int | objRank,
|  | const Material & | mat,
|  | int | state,
|  | const std::string & | tex1Name,
|  | const std::string & | tex2Name,
|  | EngineTextureMapping | mode,
|  | float | pos,
|  | float | factor,
|  | float | tl,
|  | float | ts,
|  | float | tt )

Changes texture mapping for robot tracks.

## DetectObject()

int Gfx::CEngine::DetectObject | ( | Math::Point | mouse,
|  | Math::Vector & | targetPos,
|  | bool | terrain = false )

Detects the target object that is selected with the mouse.

Returns the rank of the object or -1.

## CreateShadowSpot()

void Gfx::CEngine::CreateShadowSpot | ( | int | objRank | ) |

Creates a shadow for the given object.

## DeleteShadowSpot()

void Gfx::CEngine::DeleteShadowSpot | ( | int | objRank | ) |

Deletes the shadow for given object.

## SetObjectShadowSpotHide()

void Gfx::CEngine::SetObjectShadowSpotHide | ( | int | objRank,
|  | bool | hide )

Management of different shadow params.

## SetHighlightRank()

void Gfx::CEngine::SetHighlightRank | ( | int * | rankList | ) |

Lists the ranks of objects and subobjects selected.

## GetHighlight()

bool Gfx::CEngine::GetHighlight | ( | Math::Point & | p1,
|  | Math::Point & | p2 )

Returns the highlighted rectangle.

## DeleteAllGroundSpots()

void Gfx::CEngine::DeleteAllGroundSpots | ( |  | ) |

Deletes all ground spots.

## CreateGroundSpot()

int Gfx::CEngine::CreateGroundSpot | ( |  | ) |

Creates a new ground spot and returns its rank.

## DeleteGroundSpot()

void Gfx::CEngine::DeleteGroundSpot | ( | int | rank | ) |

Deletes the given ground spot.

## SetObjectGroundSpotPos()

void Gfx::CEngine::SetObjectGroundSpotPos | ( | int | rank,
|  | const Math::Vector & | pos )

Management of different ground spot params.

## CreateGroundMark()

void Gfx::CEngine::CreateGroundMark | ( | Math::Vector | pos,
|  | float | radius,
|  | float | delay1,
|  | float | delay2,
|  | float | delay3,
|  | int | dx,
|  | int | dy,
|  | char * | table )

Creates the ground mark with the given params.

## DeleteGroundMark()

void Gfx::CEngine::DeleteGroundMark | ( | int | rank | ) |

Deletes the ground mark.

## Update()

void Gfx::CEngine::Update | ( |  | ) |

Updates the state after creating objects.

## SetState()

void Gfx::CEngine::SetState | ( | int | state,
|  | const Color & | color = Color(1.0f, 1.0f, 1.0f, 1.0f) )

Sets the current rendering state.

## SetMaterial()

void Gfx::CEngine::SetMaterial | ( | const Material & | mat | ) |

Sets the current material.

## SetViewParams()

void Gfx::CEngine::SetViewParams | ( | const Math::Vector & | eyePt,
|  | const Math::Vector & | lookatPt,
|  | const Math::Vector & | upVec )

Specifies the location and direction of view.

## UpdateGroundSpotTextures()

void Gfx::CEngine::UpdateGroundSpotTextures | ( |  | ) |

Updates the textures used for drawing ground spot.

## LoadTexture() [1/3]

Texture Gfx::CEngine::LoadTexture | ( | const std::string & | name | ) |

Loads texture, creating it if not already present.

## LoadTexture() [2/3]

Texture Gfx::CEngine::LoadTexture | ( | const std::string & | name,
|  | CImage * | image )

Loads texture from existing image.

## LoadTexture() [3/3]

Texture Gfx::CEngine::LoadTexture | ( | const std::string & | name,
|  | const TextureCreateParams & | params )

Loads texture, creating it with given params if not already present.

## LoadAllTextures()

bool Gfx::CEngine::LoadAllTextures | ( |  | ) |

Loads all necessary textures.

## ChangeTextureColor()

bool Gfx::CEngine::ChangeTextureColor | ( | const std::string & | texName,
|  | const std::string & | srcName,
|  | Color | colorRef1,
|  | Color | colorNew1,
|  | Color | colorRef2,
|  | Color | colorNew2,
|  | float | tolerance1,
|  | float | tolerance2,
|  | Math::Point | ts,
|  | Math::Point | ti,
|  | Math::Point * | exclude = nullptr,
|  | float | shift = 0.0f,
|  | bool | hsv = false )

Changes colors in a texture.

## SetTexture() [1/2]

bool Gfx::CEngine::SetTexture | ( | const std::string & | name,
|  | int | stage = 0 )

Sets texture for given stage; if not present in cache, the texture is loaded.

If loading fails, returns false.

## SetTexture() [2/2]

void Gfx::CEngine::SetTexture | ( | const Texture & | tex,
|  | int | stage = 0 )

Sets texture for given stage.

## DeleteTexture() [1/2]

void Gfx::CEngine::DeleteTexture | ( | const std::string & | texName | ) |

Deletes the given texture, unloading it and removing from cache.

## DeleteTexture() [2/2]

void Gfx::CEngine::DeleteTexture | ( | const Texture & | tex | ) |

Deletes the given texture, unloading it and removing from cache.

## CreateOrUpdateTexture()

void Gfx::CEngine::CreateOrUpdateTexture | ( | const std::string & | texName,
|  | CImage * | img )

Creates or updates the given texture with given image data.

## FlushTextureCache()

void Gfx::CEngine::FlushTextureCache | ( |  | ) |

Empties the texture cache.

## SetTerrainVision()

void Gfx::CEngine::SetTerrainVision | ( | float | vision | ) |

Defines of the distance field of vision.

## SetFocus()

void Gfx::CEngine::SetFocus | ( | float | focus | ) |

Management of camera vertical field-of-view angle.

This is specified in radians. Horizontal FoV is calculated based on vertical FoV and aspect ratio. 0.75 = normal 1.50 = wide-angle

## GetFocus()

float Gfx::CEngine::GetFocus | ( |  | ) |

Deprecated alias for GetVFovAngle.

## SetDirty()

void Gfx::CEngine::SetDirty | ( | bool | mode | ) |

Management of the global mode of contamination.

## SetFog()

void Gfx::CEngine::SetFog | ( | bool | mode | ) |

Management of the global mode of horizontal fog patches.

## SetSecondTexture()

void Gfx::CEngine::SetSecondTexture | ( | const std::string & | texNum | ) |

Management of the global mode of secondary texturing.

## SetRankView()

void Gfx::CEngine::SetRankView | ( | int | rank | ) |

Management of view mode.

## SetDrawWorld()

void Gfx::CEngine::SetDrawWorld | ( | bool | draw | ) |

Whether to draw the world.

## SetDrawFront()

void Gfx::CEngine::SetDrawFront | ( | bool | draw | ) |

Whether to draw the world on the interface.

## SetAmbientColor()

void Gfx::CEngine::SetAmbientColor | ( | const Color & | color,
|  | int | rank = 0 )

Ambient color management.

## SetWaterAddColor()

void Gfx::CEngine::SetWaterAddColor | ( | const Color & | color | ) |

Color management under water.

## SetFogColor()

void Gfx::CEngine::SetFogColor | ( | const Color & | color,
|  | int | rank = 0 )

Management of the fog color.

## SetDeepView()

void Gfx::CEngine::SetDeepView | ( | float | length,
|  | int | rank = 0,
|  | bool | ref = false )

Management of the depth of field.

Beyond this distance, nothing is visible. Shortly (according SetFogStart), one enters the fog.

## SetFogStart()

void Gfx::CEngine::SetFogStart | ( | float | start,
|  | int | rank = 0 )

Management the start of fog.

With 0.0, the fog from the point of view (fog max). With 1.0, the fog from the depth of field (no fog).

## SetBackground()

void Gfx::CEngine::SetBackground | ( | const std::string & | name,
|  | Color | up = Color(),
|  | Color | down = Color(),
|  | Color | cloudUp = Color(),
|  | Color | cloudDown = Color(),
|  | bool | full = false,
|  | bool | scale = false )

Management of the background image to use.

## SetForegroundName()

void Gfx::CEngine::SetForegroundName | ( | const std::string & | name | ) |

Specifies the name of foreground texture.

## SetOverFront()

void Gfx::CEngine::SetOverFront | ( | bool | front | ) |

Specifies whether to draw the foreground.

## SetOverColor()

void Gfx::CEngine::SetOverColor | ( | const Color & | color = Color(),
|  | int | mode = ENG_RSTATE_TCOLOR_BLACK )

Sets the foreground overlay color.

## SetParticleDensity()

void Gfx::CEngine::SetParticleDensity | ( | float | value | ) |

Management of the particle density.

## ParticleAdapt()

float Gfx::CEngine::ParticleAdapt | ( | float | factor | ) |

Adapts particle factor according to particle density.

## SetClippingDistance()

void Gfx::CEngine::SetClippingDistance | ( | float | value | ) |

Management of the distance of clipping.

## SetTextureFilterMode()

void Gfx::CEngine::SetTextureFilterMode | ( | TexFilter | value | ) |

Management the texture filter mode.

## SetTextureMipmapLevel()

void Gfx::CEngine::SetTextureMipmapLevel | ( | int | value | ) |

Management the mipmap level for textures.

## SetTextureAnisotropyLevel()

void Gfx::CEngine::SetTextureAnisotropyLevel | ( | int | value | ) |

Management the anisotropy level for textures.

## IsShadowMappingSupported()

bool Gfx::CEngine::IsShadowMappingSupported | ( |  | ) |

Management of shadow mapping.

## SetVSync()

void Gfx::CEngine::SetVSync | ( | int | value | ) |

Management of vertical synchronization.

## SetShadowColor()

void Gfx::CEngine::SetShadowColor | ( | float | value | ) |

Management of shadow color.

## SetShadowRange()

void Gfx::CEngine::SetShadowRange | ( | float | value | ) |

Management of shadow range.

## SetMultiSample()

void Gfx::CEngine::SetMultiSample | ( | int | value | ) |

Management of shadow range.

## SetBackForce()

void Gfx::CEngine::SetBackForce | ( | bool | present | ) |

Management the mode of background.

## SetLightMode()

void Gfx::CEngine::SetLightMode | ( | bool | present | ) |

Managing the mode of dynamic lights.

## SetEditIndentMode()

void Gfx::CEngine::SetEditIndentMode | ( | bool | autoIndent | ) |

Management of the indentation mode while editing (CEdit).

## SetEditIndentValue()

void Gfx::CEngine::SetEditIndentValue | ( | int | value | ) |

Management of tab indent when editing (CEdit).

## SetTracePrecision()

void Gfx::CEngine::SetTracePrecision | ( | float | factor | ) |

Management of precision of robot tracks.

## SetMouseType()

void Gfx::CEngine::SetMouseType | ( | EngineMouseType | type | ) |

Management of mouse cursor type.

## SetPauseBlurEnabled()

void Gfx::CEngine::SetPauseBlurEnabled | ( | bool | enable | ) |

Management of pause blur.

## GetMatView()

const Math::Matrix & Gfx::CEngine::GetMatView | ( |  | ) |

Returns the view matrix.

## GetMatProj()

const Math::Matrix & Gfx::CEngine::GetMatProj | ( |  | ) |

Returns the projection matrix.

## GetEyePt()

Math::Vector Gfx::CEngine::GetEyePt | ( |  | ) |

Returns the camera center point.

## GetLookatPt()

Math::Vector Gfx::CEngine::GetLookatPt | ( |  | ) |

Returns the camera target point.

## GetEyeDirH()

float Gfx::CEngine::GetEyeDirH | ( |  | ) |

Returns the horizontal direction angle of view.

## GetEyeDirV()

float Gfx::CEngine::GetEyeDirV | ( |  | ) |

Returns the vertical direction angle of view.

## IsVisiblePoint()

bool Gfx::CEngine::IsVisiblePoint | ( | const Math::Vector & | pos | ) |

Indicates whether a point is visible.

## UpdateMatProj()

void Gfx::CEngine::UpdateMatProj | ( |  | ) |

Resets the projection matrix after changes.

## ApplyChange()

void Gfx::CEngine::ApplyChange | ( |  | ) |

Updates the scene after a change of parameters.

## ReloadAllTextures()

void Gfx::CEngine::ReloadAllTextures | ( |  | ) |

Reloads all textures.

This additionally sends EVENT_RELOAD_TEXTURES to reload all textures not maintained by CEngine

## ResetAfterVideoConfigChanged()

void Gfx::CEngine::ResetAfterVideoConfigChanged | ( |  | ) |

protected

Resets some states and flushes textures after device was changed (e.g. resoulution changed).

Instead of calling this directly, send EVENT_RESOLUTION_CHANGED event

## Draw3DScene()

void Gfx::CEngine::Draw3DScene | ( |  | ) |

protected

Prepares the interface for 3D scene.

## Capture3DScene()

void Gfx::CEngine::Capture3DScene | ( |  | ) |

protected

Capture the 3D scene for pause blur.

## DrawCaptured3DScene()

void Gfx::CEngine::DrawCaptured3DScene | ( |  | ) |

protected

Draw the 3D scene capured for pause blur.

## RenderShadowMap()

void Gfx::CEngine::RenderShadowMap | ( |  | ) |

protected

Renders shadow map.

## UseShadowMapping()

void Gfx::CEngine::UseShadowMapping | ( | bool | enable | ) |

protected

Enables or disables shadow mapping.

## UseMSAA()

void Gfx::CEngine::UseMSAA | ( | bool | enable | ) |

protected

Enables or disables MSAA.

## DrawObject()

void Gfx::CEngine::DrawObject | ( | const EngineBaseObjDataTier & | p4 | ) |

protected

Draw 3D object.

## DrawInterface()

void Gfx::CEngine::DrawInterface | ( |  | ) |

protected

Draws the user interface over the scene.

## DrawShadowSpots()

void Gfx::CEngine::DrawShadowSpots | ( |  | ) |

protected

Draws old-style shadow spots.

## DrawBackground()

void Gfx::CEngine::DrawBackground | ( |  | ) |

protected

Draws the gradient background.

## DrawBackgroundGradient()

void Gfx::CEngine::DrawBackgroundGradient | ( | const Color & | up,
|  | const Color & | down )

protected

Draws the gradient background.

## DrawBackgroundImage()

void Gfx::CEngine::DrawBackgroundImage | ( |  | ) |

protected

Draws the image background.

## DrawPlanet()

void Gfx::CEngine::DrawPlanet | ( |  | ) |

protected

Draws all the planets.

## DrawForegroundImage()

void Gfx::CEngine::DrawForegroundImage | ( |  | ) |

protected

Draws the image foreground.

## DrawOverColor()

void Gfx::CEngine::DrawOverColor | ( |  | ) |

protected

Draws the foreground color.

## DrawHighlight()

void Gfx::CEngine::DrawHighlight | ( |  | ) |

protected

Draws the rectangle of the object highlighted.

## DrawMouse()

void Gfx::CEngine::DrawMouse | ( |  | ) |

protected

Draws the mouse cursor.

## DrawMouseSprite()

void Gfx::CEngine::DrawMouseSprite | ( | Math::IntPoint | pos,
|  | Math::IntPoint | size,
|  | int | icon )

protected

Draw part of mouse cursor sprite.

## DrawStats()

void Gfx::CEngine::DrawStats | ( |  | ) |

protected

Draw statistic texts.

## DrawTimer()

void Gfx::CEngine::DrawTimer | ( |  | ) |

protected

Draw mission timer.

## AddLevel2()

EngineBaseObjTexTier & Gfx::CEngine::AddLevel2 | ( | EngineBaseObject & | p1,
|  | const std::string & | tex1Name,
|  | const std::string & | tex2Name )

protected

Creates a new tier 2 object (texture).

## AddLevel3()

EngineBaseObjDataTier & Gfx::CEngine::AddLevel3 | ( | EngineBaseObjTexTier & | p3,
|  | EngineTriangleType | type,
|  | const Material & | material,
|  | int | state )

protected

Creates a new tier 3 object (data).

## CreateTexture()

Texture Gfx::CEngine::CreateTexture | ( | const std::string & | texName,
|  | const TextureCreateParams & | params,
|  | CImage * | image = nullptr )

protected

Create texture and add it to cache.

## IsVisible()

bool Gfx::CEngine::IsVisible | ( | int | objRank | ) |

protected

Tests whether the given object is visible.

Use only after world transform already set.

## DetectBBox()

bool Gfx::CEngine::DetectBBox | ( | int | objRank,
|  | Math::Point | mouse )

protected

Detects whether an object is affected by the mouse.

## GetBBox2D()

bool Gfx::CEngine::GetBBox2D | ( | int | objRank,
|  | Math::Point & | min,
|  | Math::Point & | max )

protected

Compute and return the 2D box on screen of any object.

## DetectTriangle()

bool Gfx::CEngine::DetectTriangle | ( | Math::Point | mouse,
|  | VertexTex2 * | triangle,
|  | int | objRank,
|  | float & | dist,
|  | Math::Vector & | pos )

protected

Detects whether the mouse is in a triangle.

## TransformPoint()

bool Gfx::CEngine::TransformPoint | ( | Math::Vector & | p2D,
|  | int | objRank,
|  | Math::Vector | p3D )

protected

Transforms a 3D point (x, y, z) in 2D space (x, y, -) of the window.

The coordinated p2D.z gives the distance.

## ComputeDistance()

void Gfx::CEngine::ComputeDistance | ( |  | ) |

protected

Calculates the distances between the viewpoint and the origin of different objects.

## UpdateGeometry()

void Gfx::CEngine::UpdateGeometry | ( |  | ) |

protected

Updates geometric parameters of objects (bounding box and radius).

## UpdateStaticBuffer()

void Gfx::CEngine::UpdateStaticBuffer | ( | EngineBaseObjDataTier & | p4 | ) |

protected

Updates a given static buffer.

## UpdateStaticBuffers()

void Gfx::CEngine::UpdateStaticBuffers | ( |  | ) |

protected

Updates static buffers of changed objects.

## Member Data Documentation

## m_error

std::string Gfx::CEngine::m_error

protected

Last encountered error.

## m_showStats

bool Gfx::CEngine::m_showStats

protected

Whether to show stats (FPS, etc).

## m_render

bool Gfx::CEngine::m_render

protected

Rendering enabled?

## m_renderInterface

bool Gfx::CEngine::m_renderInterface

protected

Render / hide the UI?

## m_screenshotMode

bool Gfx::CEngine::m_screenshotMode

protected

Screenshot mode?

## m_matProj

Math::Matrix Gfx::CEngine::m_matProj

protected

Projection matrix for 3D scene.

## m_matView

Math::Matrix Gfx::CEngine::m_matView

protected

View matrix for 3D scene.

## m_focus

float Gfx::CEngine::m_focus

protected

Camera vertical field-of-view angle for 3D scene. A.k.a. m_vfov.

## m_hfov

float Gfx::CEngine::m_hfov

protected

Horizontal field-of-view angle, calculated from vertical FOV and aspect ratio.

## m_shadowProjMat

Math::Matrix Gfx::CEngine::m_shadowProjMat

protected

Projection matrix for rendering shadow maps.

## m_shadowViewMat

Math::Matrix Gfx::CEngine::m_shadowViewMat

protected

View matrix for rendering shadow maps.

## m_shadowTextureMat

Math::Matrix Gfx::CEngine::m_shadowTextureMat

protected

Texture matrix for rendering shadow maps.

## m_shadowBias

Math::Matrix Gfx::CEngine::m_shadowBias

protected

Texture bias for sampling shadow maps.

## m_vsync

int Gfx::CEngine::m_vsync

protected

Vertical synchronization controll.

## m_matWorldInterface

Math::Matrix Gfx::CEngine::m_matWorldInterface

protected

World matrix for 2D interface.

## m_matProjInterface

Math::Matrix Gfx::CEngine::m_matProjInterface

protected

Projection matrix for 2D interface.

## m_matViewInterface

Math::Matrix Gfx::CEngine::m_matViewInterface

protected

View matrix for 2D interface.

## m_size

Math::IntPoint Gfx::CEngine::m_size

protected

Current size of viewport window.

## m_baseObjects

std::vector<EngineBaseObject> Gfx::CEngine::m_baseObjects

protected

Base objects (also level 1 tier list).

## m_objects

std::vector<EngineObject> Gfx::CEngine::m_objects

protected

Object parameters.

## m_shadowSpots

std::vector<EngineShadow> Gfx::CEngine::m_shadowSpots

protected

Shadow list.

## m_groundSpots

std::vector<EngineGroundSpot> Gfx::CEngine::m_groundSpots

protected

Ground spot list.

## m_groundMark

EngineGroundMark Gfx::CEngine::m_groundMark

protected

Ground mark.

## m_eyePt

Math::Vector Gfx::CEngine::m_eyePt

protected

Location of camera.

## m_lookatPt

Math::Vector Gfx::CEngine::m_lookatPt

protected

Camera target.

## m_highlightRank

int Gfx::CEngine::m_highlightRank[100]

protected

Ranks of highlighted objects.

## m_highlight

bool Gfx::CEngine::m_highlight

protected

Highlight visible?

## m_highlightTime

float Gfx::CEngine::m_highlightTime

protected

Time counter for highlight animation.

## m_highlightP1

Math::Point Gfx::CEngine::m_highlightP1

protected

Highlight rectangle points.

## m_defaultTexParams

TextureCreateParams Gfx::CEngine::m_defaultTexParams

protected

Default texture create params.

## m_terrainTexParams

TextureCreateParams Gfx::CEngine::m_terrainTexParams

protected

Create params for terrain textures.

## m_textureMipmapLevel

int Gfx::CEngine::m_textureMipmapLevel

protected

Requested texture mipmap level.

## m_textureAnisotropy

int Gfx::CEngine::m_textureAnisotropy

protected

Requested texture anisotropy level.

## m_shadowMapping

bool Gfx::CEngine::m_shadowMapping

protected

true if shadow mapping enabled

## m_offscreenShadowRendering

bool Gfx::CEngine::m_offscreenShadowRendering

protected

true enables offscreen shadow rendering

## m_offscreenShadowRenderingResolution

int Gfx::CEngine::m_offscreenShadowRenderingResolution

protected

Offscreen shadow rendering resolution.

## m_qualityShadows

bool Gfx::CEngine::m_qualityShadows

protected

true enables higher quality shadows

## m_terrainShadows

bool Gfx::CEngine::m_terrainShadows

protected

true enables casting shadows by terrain

## m_shadowColor

float Gfx::CEngine::m_shadowColor

protected

Shadow color.

## m_shadowRange

float Gfx::CEngine::m_shadowRange

protected

Shadow range.

## m_multisample

int Gfx::CEngine::m_multisample

protected

Number of samples for multisample rendering.

## m_texNameMap

std::map<std::string, Texture> Gfx::CEngine::m_texNameMap

protected

Map of loaded textures (by name).

## m_revTexNameMap

std::map<Texture, std::string> Gfx::CEngine::m_revTexNameMap

protected

Reverse map of loaded textures (by texture).

## m_texBlacklist

std::set<std::string> Gfx::CEngine::m_texBlacklist

protected

Blacklist map of textures.

Textures on this list were not successful in first loading, so are disabled for subsequent load calls.

## m_miceTexture

Texture Gfx::CEngine::m_miceTexture

protected

Texture with mouse cursors.

## m_mouseType

EngineMouseType Gfx::CEngine::m_mouseType

protected

Type of mouse cursor.

## m_lastState

int Gfx::CEngine::m_lastState

protected

Last engine render state (-1 at the beginning of frame).

## m_lastColor

Color Gfx::CEngine::m_lastColor

protected

Last color set with render state.

## m_lastTexture

std::string Gfx::CEngine::m_lastTexture[2]

protected

Last texture names for 2 used texture stages.

## m_lastMaterial

Material Gfx::CEngine::m_lastMaterial

protected

Last material.

## m_interfaceMode

bool Gfx::CEngine::m_interfaceMode

protected

True when drawing 2D UI.

## m_pause

bool Gfx::CEngine::m_pause = false

protected

Pause the animation updates.

## m_worldCaptured

bool Gfx::CEngine::m_worldCaptured = false

protected

true means that current 3D scene was captured and is not to be rendered again

## m_captureWorld

bool Gfx::CEngine::m_captureWorld = false

protected

true means that currently rendered world is to be captured

## m_capturedWorldTexture

Texture Gfx::CEngine::m_capturedWorldTexture

protected

Texture with captured 3D world.

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

- src/graphics/engine/engine.h
- src/graphics/engine/engine.cpp