2014-10-14 13:11:37 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Colobot: Gold Edition source code
|
2023-08-06 21:15:48 +00:00
|
|
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
2015-08-22 14:40:02 +00:00
|
|
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
2014-10-14 13:11:37 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see http://gnu.org/licenses
|
|
|
|
*/
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-08-11 16:39:16 +00:00
|
|
|
/**
|
|
|
|
* \file graphics/engine/engine.h
|
2012-09-19 21:50:28 +00:00
|
|
|
* \brief Main graphics engine - CEngine class
|
2012-08-11 16:39:16 +00:00
|
|
|
*/
|
2012-06-22 14:31:55 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2013-02-16 21:37:43 +00:00
|
|
|
#include "common/singleton.h"
|
2018-04-19 21:17:28 +00:00
|
|
|
#include "common/system/system.h"
|
2012-09-19 21:50:28 +00:00
|
|
|
|
2012-07-26 20:26:19 +00:00
|
|
|
#include "graphics/core/color.h"
|
|
|
|
#include "graphics/core/texture.h"
|
2022-02-03 17:40:58 +00:00
|
|
|
#include "graphics/core/renderers.h"
|
2012-07-26 20:26:19 +00:00
|
|
|
#include "graphics/core/vertex.h"
|
2012-09-19 21:50:28 +00:00
|
|
|
|
2016-03-17 03:31:16 +00:00
|
|
|
#include "math/sphere.h"
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2021-12-23 22:08:56 +00:00
|
|
|
#include <glm/glm.hpp>
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-06-30 23:37:30 +00:00
|
|
|
#include <string>
|
2012-07-22 20:05:12 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
2012-08-12 08:45:04 +00:00
|
|
|
#include <set>
|
2015-06-20 17:27:43 +00:00
|
|
|
#include <memory>
|
2015-07-11 17:48:37 +00:00
|
|
|
#include <unordered_map>
|
2012-06-30 23:37:30 +00:00
|
|
|
|
|
|
|
|
2012-06-22 14:31:55 +00:00
|
|
|
class CApplication;
|
2012-08-10 21:31:42 +00:00
|
|
|
class CSoundInterface;
|
2012-09-29 22:23:26 +00:00
|
|
|
class CImage;
|
2015-08-07 06:31:34 +00:00
|
|
|
class CSystemUtils;
|
2015-07-11 17:48:37 +00:00
|
|
|
struct Event;
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2023-11-18 12:40:25 +00:00
|
|
|
class CObject;
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2012-09-19 21:50:28 +00:00
|
|
|
// Graphics module namespace
|
2015-08-02 09:40:47 +00:00
|
|
|
namespace Gfx
|
|
|
|
{
|
2012-06-24 13:41:56 +00:00
|
|
|
|
|
|
|
class CDevice;
|
2022-05-02 18:59:44 +00:00
|
|
|
class CUIRenderer;
|
|
|
|
class CObjectRenderer;
|
2015-07-09 16:45:02 +00:00
|
|
|
class COldModelManager;
|
2012-07-26 19:35:04 +00:00
|
|
|
class CLightManager;
|
2012-06-22 14:31:55 +00:00
|
|
|
class CText;
|
2012-06-24 13:41:56 +00:00
|
|
|
class CParticle;
|
2012-06-22 14:31:55 +00:00
|
|
|
class CWater;
|
|
|
|
class CCloud;
|
2012-06-24 13:41:56 +00:00
|
|
|
class CLightning;
|
2012-06-22 14:31:55 +00:00
|
|
|
class CPlanet;
|
|
|
|
class CTerrain;
|
2015-06-22 19:58:58 +00:00
|
|
|
class CPyroManager;
|
2015-07-11 17:48:37 +00:00
|
|
|
class CModelMesh;
|
2021-08-08 12:32:14 +00:00
|
|
|
class CVertexBuffer;
|
2022-02-26 01:39:13 +00:00
|
|
|
struct EngineBaseObjDataTier;
|
|
|
|
struct EngineBaseObject;
|
|
|
|
struct EngineTriangle;
|
|
|
|
struct Material;
|
2015-07-11 17:48:37 +00:00
|
|
|
struct ModelShadowSpot;
|
|
|
|
struct ModelTriangle;
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2022-02-26 01:39:13 +00:00
|
|
|
enum class TransparencyMode : unsigned char;
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \enum EngineTriangleType
|
|
|
|
* \brief Type of triangles drawn for engine objects
|
|
|
|
*/
|
2022-02-26 18:44:49 +00:00
|
|
|
enum class EngineTriangleType : unsigned char
|
2012-07-22 20:05:12 +00:00
|
|
|
{
|
|
|
|
//! Triangles
|
2022-01-18 18:29:36 +00:00
|
|
|
TRIANGLES = 1,
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Surfaces
|
2022-01-18 18:29:36 +00:00
|
|
|
SURFACE = 2
|
2012-07-22 20:05:12 +00:00
|
|
|
};
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
/**
|
|
|
|
\enum EngineObjectType
|
|
|
|
\brief Class of graphics engine object */
|
2022-02-26 18:44:49 +00:00
|
|
|
enum EngineObjectType : unsigned char
|
2012-06-22 14:31:55 +00:00
|
|
|
{
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Object doesn't exist
|
2012-07-22 20:05:12 +00:00
|
|
|
ENG_OBJTYPE_NULL = 0,
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Terrain
|
2012-07-22 20:05:12 +00:00
|
|
|
ENG_OBJTYPE_TERRAIN = 1,
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Fixed object
|
2012-07-22 20:05:12 +00:00
|
|
|
ENG_OBJTYPE_FIX = 2,
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Moving object
|
2013-04-27 15:50:30 +00:00
|
|
|
ENG_OBJTYPE_VEHICLE = 3,
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Part of a moving object
|
2012-07-22 20:05:12 +00:00
|
|
|
ENG_OBJTYPE_DESCENDANT = 4,
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Fixed object type quartz
|
2012-07-22 20:05:12 +00:00
|
|
|
ENG_OBJTYPE_QUARTZ = 5,
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Fixed object type metal
|
2012-07-22 20:05:12 +00:00
|
|
|
ENG_OBJTYPE_METAL = 6
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \struct EngineObject
|
|
|
|
* \brief Object drawn by the graphics engine
|
|
|
|
*/
|
2012-07-22 20:05:12 +00:00
|
|
|
struct EngineObject
|
|
|
|
{
|
2012-08-12 17:28:22 +00:00
|
|
|
//! If true, object is valid in objects vector
|
2015-08-05 17:49:25 +00:00
|
|
|
bool used = false;
|
2012-12-26 19:58:02 +00:00
|
|
|
//! Rank of associated base engine object
|
2015-08-05 17:49:25 +00:00
|
|
|
int baseObjRank = -1;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! If true, the object is drawn
|
2015-08-05 17:49:25 +00:00
|
|
|
bool visible = false;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! If true, object is behind the 2D interface
|
2015-08-05 17:49:25 +00:00
|
|
|
bool drawWorld = false;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Type of object
|
2015-08-05 17:49:25 +00:00
|
|
|
EngineObjectType type = ENG_OBJTYPE_NULL;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Transformation matrix
|
2022-07-09 10:23:50 +00:00
|
|
|
glm::mat4 transform = {};
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Distance to object from eye point
|
2015-08-05 17:49:25 +00:00
|
|
|
float distance = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Rank of the associated shadow
|
2015-08-05 17:49:25 +00:00
|
|
|
int shadowRank = -1;
|
2023-11-18 12:40:25 +00:00
|
|
|
//! Associated game object, if any. Null for terrain.
|
|
|
|
CObject* gameObject = nullptr;
|
2012-07-22 20:05:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \struct EngineShadowType
|
|
|
|
* \brief Type of shadow drawn by the graphics engine
|
|
|
|
*/
|
2022-02-26 02:53:39 +00:00
|
|
|
enum class EngineShadowType : unsigned char
|
2012-07-22 20:05:12 +00:00
|
|
|
{
|
|
|
|
//! Normal shadow
|
2022-01-18 18:42:19 +00:00
|
|
|
NORMAL = 0,
|
2012-07-22 20:05:12 +00:00
|
|
|
//! TODO: ?
|
2022-01-18 18:42:19 +00:00
|
|
|
WORM = 1
|
2012-07-22 20:05:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \struct EngineShadow
|
|
|
|
* \brief Shadow drawn by the graphics engine
|
|
|
|
*/
|
2012-07-22 20:05:12 +00:00
|
|
|
struct EngineShadow
|
|
|
|
{
|
2012-08-12 17:28:22 +00:00
|
|
|
//! If true, shadow is valid
|
2015-08-05 17:49:25 +00:00
|
|
|
bool used = false;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! If true, shadow is invisible (object being carried for example)
|
2015-08-05 17:49:25 +00:00
|
|
|
bool hide = false;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Rank of the associated object
|
2015-08-05 17:49:25 +00:00
|
|
|
int objRank = -1;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Type of shadow
|
2022-01-18 18:42:19 +00:00
|
|
|
EngineShadowType type = EngineShadowType::NORMAL;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Position of the shadow
|
2021-12-28 22:01:30 +00:00
|
|
|
glm::vec3 pos{ 0, 0, 0 };
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Normal to the terrain
|
2021-12-28 22:01:30 +00:00
|
|
|
glm::vec3 normal{ 0, 0, 0 };
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Angle of the shadow
|
2015-08-05 17:49:25 +00:00
|
|
|
float angle = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Radius of the shadow
|
2015-08-05 17:49:25 +00:00
|
|
|
float radius = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Intensity of the shadow
|
2015-08-05 17:49:25 +00:00
|
|
|
float intensity = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Height from the ground
|
2015-08-05 17:49:25 +00:00
|
|
|
float height = 0.0f;
|
2012-06-22 14:31:55 +00:00
|
|
|
};
|
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \struct EngineGroundSpot
|
|
|
|
* \brief A spot (large shadow) drawn on the ground by the graphics engine
|
|
|
|
*/
|
2012-07-22 20:05:12 +00:00
|
|
|
struct EngineGroundSpot
|
2012-06-22 14:31:55 +00:00
|
|
|
{
|
2012-08-12 17:28:22 +00:00
|
|
|
//! If true, ground spot is valid
|
2015-08-05 17:49:25 +00:00
|
|
|
bool used = false;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Color of the shadow
|
2022-07-09 10:23:50 +00:00
|
|
|
Color color = {};
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Min altitude
|
2015-08-05 17:49:25 +00:00
|
|
|
float min = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Max altitude
|
2015-08-05 17:49:25 +00:00
|
|
|
float max = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Transition area
|
2015-08-05 17:49:25 +00:00
|
|
|
float smooth = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Position for the shadow
|
2022-07-09 10:23:50 +00:00
|
|
|
glm::vec3 pos = { 0, 0, 0 };
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Radius of the shadow
|
2015-08-05 17:49:25 +00:00
|
|
|
float radius = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Position of the shadow drawn
|
2022-07-09 10:23:50 +00:00
|
|
|
glm::vec3 drawPos = { 0, 0, 0 };
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Radius of the shadow drawn
|
2015-08-05 17:49:25 +00:00
|
|
|
float drawRadius = 0.0f;
|
2012-06-22 14:31:55 +00:00
|
|
|
};
|
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \enum EngineGroundMarkPhase
|
|
|
|
* \brief Phase of life of an EngineGroundMark
|
|
|
|
*/
|
2022-02-26 18:44:49 +00:00
|
|
|
enum EngineGroundMarkPhase : unsigned char
|
2012-06-22 14:31:55 +00:00
|
|
|
{
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Null phase
|
|
|
|
ENG_GR_MARK_PHASE_NULL = 0,
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Increase
|
|
|
|
ENG_GR_MARK_PHASE_INC = 1,
|
|
|
|
//! Fixed
|
|
|
|
ENG_GR_MARK_PHASE_FIX = 2,
|
|
|
|
//! Decrease
|
2012-08-10 21:31:42 +00:00
|
|
|
ENG_GR_MARK_PHASE_DEC = 3
|
2012-06-22 14:31:55 +00:00
|
|
|
};
|
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \struct EngineGroundMark
|
|
|
|
* \brief A mark on ground drawn by the graphics engine
|
|
|
|
*/
|
2012-07-22 20:05:12 +00:00
|
|
|
struct EngineGroundMark
|
2012-06-22 14:31:55 +00:00
|
|
|
{
|
2012-07-22 20:05:12 +00:00
|
|
|
//! If true, draw mark
|
2015-08-05 17:49:25 +00:00
|
|
|
bool draw = false;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Phase of life
|
2022-07-09 10:23:50 +00:00
|
|
|
EngineGroundMarkPhase phase = ENG_GR_MARK_PHASE_NULL;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Times for 3 life phases
|
2015-08-15 22:06:27 +00:00
|
|
|
float delay[3] = {};
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Fixed time
|
2015-08-05 17:49:25 +00:00
|
|
|
float fix = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Position for marks
|
2021-12-28 22:01:30 +00:00
|
|
|
glm::vec3 pos{ 0, 0, 0 };
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Radius of marks
|
2015-08-05 17:49:25 +00:00
|
|
|
float radius = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Color intensity
|
2015-08-05 17:49:25 +00:00
|
|
|
float intensity = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Draw position for marks
|
2021-12-28 22:01:30 +00:00
|
|
|
glm::vec3 drawPos{ 0, 0, 0 };
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Radius for marks
|
2015-08-05 17:49:25 +00:00
|
|
|
float drawRadius = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Draw intensity for marks
|
2015-08-05 17:49:25 +00:00
|
|
|
float drawIntensity = 0.0f;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! X dimension of table
|
2015-08-05 17:49:25 +00:00
|
|
|
int dx = 0;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Y dimension of table
|
2015-08-05 17:49:25 +00:00
|
|
|
int dy = 0;
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Pointer to the table
|
2015-08-05 17:49:25 +00:00
|
|
|
char* table = nullptr;
|
2012-06-22 14:31:55 +00:00
|
|
|
};
|
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \enum EngineTextureMapping
|
|
|
|
* \brief Type of texture mapping
|
2012-07-22 20:05:12 +00:00
|
|
|
*/
|
2022-02-26 18:44:49 +00:00
|
|
|
enum class EngineTextureMapping : unsigned char
|
2012-06-22 14:31:55 +00:00
|
|
|
{
|
2022-01-18 19:14:07 +00:00
|
|
|
X = 1,
|
|
|
|
Y = 2,
|
|
|
|
Z = 3,
|
|
|
|
ONE_X = 4,
|
|
|
|
ONE_Y = 5,
|
|
|
|
ONE_Z = 6
|
2012-06-22 14:31:55 +00:00
|
|
|
};
|
|
|
|
|
2012-07-23 19:41:27 +00:00
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
/**
|
2012-09-19 21:50:28 +00:00
|
|
|
* \enum EngineMouseType
|
|
|
|
* \brief Type of mouse cursor displayed in-game
|
|
|
|
*/
|
2022-02-26 18:44:49 +00:00
|
|
|
enum EngineMouseType : unsigned char
|
2012-06-22 14:31:55 +00:00
|
|
|
{
|
2012-07-22 20:05:12 +00:00
|
|
|
//! Normal cursor (arrow)
|
|
|
|
ENG_MOUSE_NORM = 0,
|
|
|
|
//! Busy
|
|
|
|
ENG_MOUSE_WAIT = 1,
|
|
|
|
//! Edit (I-beam)
|
|
|
|
ENG_MOUSE_EDIT = 2,
|
|
|
|
//! Hand
|
|
|
|
ENG_MOUSE_HAND = 3,
|
|
|
|
//! Small cross
|
|
|
|
ENG_MOUSE_CROSS = 4,
|
|
|
|
//! TODO: ?
|
|
|
|
ENG_MOUSE_SHOW = 5,
|
|
|
|
//! Crossed out sign
|
|
|
|
ENG_MOUSE_NO = 6,
|
|
|
|
//! Resize
|
|
|
|
ENG_MOUSE_MOVE = 7,
|
|
|
|
//! Resize horizontally
|
|
|
|
ENG_MOUSE_MOVEH = 8,
|
|
|
|
//! Resize vertically
|
|
|
|
ENG_MOUSE_MOVEV = 9,
|
|
|
|
//! Resize diagonally bottom-left to top-right
|
|
|
|
ENG_MOUSE_MOVED = 10,
|
|
|
|
//! Resize diagonally top-left to bottom-right
|
|
|
|
ENG_MOUSE_MOVEI = 11,
|
|
|
|
//! Scroll to the left
|
|
|
|
ENG_MOUSE_SCROLLL = 12,
|
|
|
|
//! Scroll to the right
|
|
|
|
ENG_MOUSE_SCROLLR = 13,
|
|
|
|
//! Scroll up
|
|
|
|
ENG_MOUSE_SCROLLU = 14,
|
|
|
|
//! Scroll down
|
|
|
|
ENG_MOUSE_SCROLLD = 15,
|
|
|
|
//! Larger crosshair
|
|
|
|
ENG_MOUSE_TARGET = 16,
|
|
|
|
|
|
|
|
//! Number of items in enum
|
|
|
|
ENG_MOUSE_COUNT
|
2012-06-22 14:31:55 +00:00
|
|
|
};
|
|
|
|
|
2012-07-23 19:41:27 +00:00
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
/**
|
2012-08-12 22:14:42 +00:00
|
|
|
* \class CEngine
|
|
|
|
* \brief 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.
|
|
|
|
*
|
2012-09-27 18:43:20 +00:00
|
|
|
* \section Scene 3D Scene
|
2012-08-12 22:14:42 +00:00
|
|
|
*
|
|
|
|
* 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)
|
|
|
|
*
|
2012-09-27 18:43:20 +00:00
|
|
|
* \section Interface 2D Interface
|
2012-08-12 22:14:42 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2012-09-27 18:43:20 +00:00
|
|
|
* \section Objects Engine Objects
|
2012-08-12 22:14:42 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2012-12-27 13:18:16 +00:00
|
|
|
*
|
|
|
|
* Object's geometric data is stored as a separate object -- base engine object. Each object
|
2012-12-28 12:23:49 +00:00
|
|
|
* 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.
|
2012-12-27 13:18:16 +00:00
|
|
|
*
|
|
|
|
* Base engine object data is stored in a 4-tier tree which splits the data describing triangles.
|
2012-08-12 22:14:42 +00:00
|
|
|
*
|
|
|
|
* The 4 tiers contain the following information:
|
2012-12-27 13:18:16 +00:00
|
|
|
* - level 1 (EngineBaseObject) - geometric statistics
|
|
|
|
* - level 2 (EngineBaseObjTexTier) - two textures (names and structs) applied to triangles,
|
2015-07-09 16:45:02 +00:00
|
|
|
* - level 3 (EngineBaseObjDataTier) - type of object*, material, render state and the actual vertex data
|
2012-08-12 22:14:42 +00:00
|
|
|
*
|
2012-12-27 13:18:16 +00:00
|
|
|
* *NOTE: type of object in this context means only the internal type in 3D engine. It is not related
|
2012-08-12 22:14:42 +00:00
|
|
|
* to CObject types.
|
|
|
|
*
|
2012-12-27 13:18:16 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2012-08-12 22:14:42 +00:00
|
|
|
* Such tiered structure complicates loops over all object data, but saves a lot of memory and
|
2012-12-27 13:18:16 +00:00
|
|
|
* optimizes the rendering process.
|
2012-08-12 22:14:42 +00:00
|
|
|
*
|
|
|
|
* \section Shadows Shadows
|
|
|
|
*
|
|
|
|
* Each engine object can be associated with a shadow (EngineShadow). Like objects, shadows are
|
|
|
|
* identified by their rank obtained upon creation.
|
|
|
|
*
|
2012-12-27 13:18:16 +00:00
|
|
|
* Shadows are drawn as circular spots on the ground, except for shadows for worms, which have
|
|
|
|
* special mode for them.
|
2012-08-12 22:14:42 +00:00
|
|
|
*
|
|
|
|
* \section Textures 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
|
2012-09-19 21:50:28 +00:00
|
|
|
* at object creation time, and then referenced to as Texture structs, or even as unsigned int ID's
|
2012-08-12 22:14:42 +00:00
|
|
|
* 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.
|
2012-07-22 20:05:12 +00:00
|
|
|
*/
|
2013-02-16 21:37:43 +00:00
|
|
|
class CEngine : public CSingleton<CEngine>
|
2012-06-22 14:31:55 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-08-07 06:31:34 +00:00
|
|
|
CEngine(CApplication* app, CSystemUtils* systemUtils);
|
2012-06-26 20:23:05 +00:00
|
|
|
~CEngine();
|
|
|
|
|
2012-07-29 13:09:53 +00:00
|
|
|
//! Sets the device to be used
|
2012-09-19 21:50:28 +00:00
|
|
|
void SetDevice(CDevice* device);
|
2012-07-29 13:09:53 +00:00
|
|
|
//! Returns the current device
|
2013-02-16 21:37:43 +00:00
|
|
|
CDevice* GetDevice();
|
2022-05-02 18:59:44 +00:00
|
|
|
//! Returns the UI renderer
|
|
|
|
CUIRenderer* GetUIRenderer();
|
|
|
|
//! Returns the object renderer
|
|
|
|
CObjectRenderer* GetObjectRenderer();
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Returns the text rendering engine
|
|
|
|
CText* GetText();
|
2015-07-09 16:45:02 +00:00
|
|
|
COldModelManager* GetModelManager();
|
2015-06-22 19:58:58 +00:00
|
|
|
CPyroManager* GetPyroManager();
|
2013-02-16 21:37:43 +00:00
|
|
|
//! Returns the light manager
|
|
|
|
CLightManager* GetLightManager();
|
|
|
|
//! Returns the particle manager
|
|
|
|
CParticle* GetParticle();
|
|
|
|
//! Returns the terrain manager
|
|
|
|
CTerrain* GetTerrain();
|
|
|
|
//! Returns the water manager
|
|
|
|
CWater* GetWater();
|
|
|
|
//! Returns the lighting manager
|
|
|
|
CLightning* GetLightning();
|
|
|
|
//! Returns the planet manager
|
|
|
|
CPlanet* GetPlanet();
|
|
|
|
//! Returns the fog manager
|
|
|
|
CCloud* GetCloud();
|
|
|
|
|
|
|
|
//! Sets the terrain object
|
|
|
|
void SetTerrain(CTerrain* terrain);
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
|
2012-08-03 21:23:13 +00:00
|
|
|
//! Performs the initialization; must be called after device was set
|
|
|
|
bool Create();
|
|
|
|
//! Frees all resources before exit
|
|
|
|
void Destroy();
|
2012-07-01 20:59:22 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Called once per frame, the call is the entry point for rendering
|
|
|
|
void Render();
|
|
|
|
|
2012-07-01 20:59:22 +00:00
|
|
|
|
2012-07-29 13:09:53 +00:00
|
|
|
//! Processes incoming event
|
2012-08-10 21:31:42 +00:00
|
|
|
bool ProcessEvent(const Event& event);
|
2012-07-01 20:59:22 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Called once per frame, the call is the entry point for animating the scene
|
2012-09-12 21:43:04 +00:00
|
|
|
void FrameUpdate();
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-03 21:23:13 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Writes a screenshot containing the current frame
|
2015-08-06 10:59:09 +00:00
|
|
|
void WriteScreenShot(const std::string& fileName);
|
2012-08-03 21:23:13 +00:00
|
|
|
|
2013-05-12 12:55:41 +00:00
|
|
|
|
2015-10-01 16:55:41 +00:00
|
|
|
//@{
|
|
|
|
//! Management of animation pause mode
|
|
|
|
void SetPause(bool pause);
|
|
|
|
bool GetPause();
|
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of displaying statistic information
|
|
|
|
void SetShowStats(bool show);
|
|
|
|
bool GetShowStats();
|
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Enables/disables rendering
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetRenderEnable(bool enable);
|
2015-08-09 13:20:35 +00:00
|
|
|
|
2015-09-04 17:16:21 +00:00
|
|
|
void SetRenderInterface(bool enable);
|
|
|
|
bool GetRenderInterface();
|
|
|
|
|
2015-08-07 13:59:05 +00:00
|
|
|
//! Management of "screenshot mode" (disables interface particle rendering)
|
|
|
|
//@{
|
|
|
|
void SetScreenshotMode(bool screenshotMode);
|
|
|
|
bool GetScreenshotMode();
|
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Returns current size of viewport window
|
2021-12-23 22:08:56 +00:00
|
|
|
glm::ivec2 GetWindowSize();
|
2012-08-10 21:31:42 +00:00
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//@{
|
|
|
|
//! 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 */
|
2021-12-24 19:25:38 +00:00
|
|
|
glm::vec2 WindowToInterfaceCoords(const glm::ivec2& pos);
|
|
|
|
glm::ivec2 InterfaceToWindowCoords(const glm::vec2& pos);
|
2012-08-11 15:17:04 +00:00
|
|
|
//@}
|
2012-08-10 21:31:42 +00:00
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//@{
|
|
|
|
//! Conversion functions between window and interface sizes
|
|
|
|
/** Unlike coordinate conversions, this is only scale conversion, not translation and scale. */
|
2021-12-24 19:25:38 +00:00
|
|
|
glm::vec2 WindowToInterfaceSize(const glm::ivec2& size);
|
|
|
|
glm::ivec2 InterfaceToWindowSize(const glm::vec2& size);
|
2012-08-11 15:17:04 +00:00
|
|
|
//@}
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Increments the triangle counter for the current frame
|
2015-10-03 20:05:14 +00:00
|
|
|
void AddStatisticTriangle(int count);
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Returns the number of triangles in current frame
|
2012-07-01 20:59:22 +00:00
|
|
|
int GetStatisticTriangle();
|
2015-07-11 17:48:37 +00:00
|
|
|
|
2014-01-11 16:51:13 +00:00
|
|
|
//! Sets the coordinates to display in stats window
|
2021-12-28 22:01:30 +00:00
|
|
|
void SetStatisticPos(glm::vec3 pos);
|
2015-07-11 17:48:37 +00:00
|
|
|
|
2014-10-29 16:53:46 +00:00
|
|
|
//! Sets text to display as mission timer
|
|
|
|
void SetTimerDisplay(const std::string& text);
|
2012-06-26 20:23:05 +00:00
|
|
|
|
|
|
|
|
2015-07-11 17:48:37 +00:00
|
|
|
/* *************** New mesh interface *************** */
|
|
|
|
//! Add new instance of static mesh
|
|
|
|
/**
|
|
|
|
* Static meshes never change their geometry or texture mapping,
|
|
|
|
* so specific instances can share mesh data.
|
|
|
|
*
|
|
|
|
* @param mesh mesh data
|
|
|
|
* @param key key unique per object class
|
|
|
|
* @return mesh instance handle
|
|
|
|
*/
|
2023-11-18 12:40:25 +00:00
|
|
|
int AddStaticMesh(const std::string& key, const Gfx::CModelMesh* mesh, const glm::mat4& worldMatrix, CObject *gameObject);
|
2015-07-11 17:48:37 +00:00
|
|
|
|
|
|
|
//! Removes given static mesh
|
|
|
|
void DeleteStaticMesh(int meshHandle);
|
|
|
|
|
|
|
|
//! Adds a shadow spot to mesh
|
|
|
|
void AddStaticMeshShadowSpot(int meshHandle, const Gfx::ModelShadowSpot& shadowSpot);
|
|
|
|
|
|
|
|
//! Returns static mesh world matrix
|
2022-01-05 18:12:35 +00:00
|
|
|
const glm::mat4& GetStaticMeshWorldMatrix(int meshHandle);
|
2015-07-11 17:48:37 +00:00
|
|
|
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
/* *************** Object management *************** */
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-12-26 19:58:02 +00:00
|
|
|
// Base objects
|
|
|
|
|
|
|
|
//! Creates a base object and returns its rank
|
|
|
|
int CreateBaseObject();
|
|
|
|
//! Deletes a base object
|
|
|
|
void DeleteBaseObject(int baseObjRank);
|
|
|
|
//! Deletes all base objects
|
|
|
|
void DeleteAllBaseObjects();
|
|
|
|
|
|
|
|
//! Copies geometry between two base objects
|
|
|
|
void CopyBaseObject(int sourceBaseObjRank, int destBaseObjRank);
|
|
|
|
|
|
|
|
//! Adds triangles to given object with the specified params
|
2022-02-12 23:03:46 +00:00
|
|
|
void AddBaseObjTriangles(int baseObjRank, const std::vector<Gfx::ModelTriangle>& triangles);
|
2012-12-26 19:58:02 +00:00
|
|
|
|
2022-02-12 23:03:46 +00:00
|
|
|
void AddBaseObjTriangles(int baseObjRank, const std::vector<Vertex3D>& vertices,
|
|
|
|
const Material& material, EngineTriangleType type);
|
2012-12-26 19:58:02 +00:00
|
|
|
|
|
|
|
// Objects
|
|
|
|
|
2013-06-17 09:48:57 +00:00
|
|
|
//! Print debug info about an object
|
2015-10-03 20:05:14 +00:00
|
|
|
void DebugObject(int objRank);
|
2013-06-17 09:48:57 +00:00
|
|
|
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Creates a new object and returns its rank
|
2023-11-18 12:40:25 +00:00
|
|
|
int CreateObject(CObject *gameObject);
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Deletes all objects, shadows and ground spots
|
2012-12-26 19:58:02 +00:00
|
|
|
void DeleteAllObjects();
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Deletes the given object
|
2012-12-26 19:58:02 +00:00
|
|
|
void DeleteObject(int objRank);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
|
|
|
//@{
|
2012-12-26 19:58:02 +00:00
|
|
|
//! Management of the base object rank for engine object
|
|
|
|
void SetObjectBaseRank(int objRank, int baseObjRank);
|
|
|
|
int GetObjectBaseRank(int objRank);
|
2012-08-12 17:28:22 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
2012-12-26 19:58:02 +00:00
|
|
|
//! Management of engine object type
|
|
|
|
void SetObjectType(int objRank, EngineObjectType type);
|
|
|
|
EngineObjectType GetObjectType(int objRank);
|
2012-08-12 17:28:22 +00:00
|
|
|
//@}
|
|
|
|
|
2012-12-14 20:30:35 +00:00
|
|
|
//@{
|
2012-12-26 19:58:02 +00:00
|
|
|
//! Management of object transform
|
2022-01-05 18:12:35 +00:00
|
|
|
void SetObjectTransform(int objRank, const glm::mat4& transform);
|
|
|
|
void GetObjectTransform(int objRank, glm::mat4& transform);
|
2012-12-14 20:30:35 +00:00
|
|
|
//@}
|
|
|
|
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Sets drawWorld for given object
|
2012-12-26 19:58:02 +00:00
|
|
|
void SetObjectDrawWorld(int objRank, bool draw);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
2023-11-18 13:01:02 +00:00
|
|
|
//! Check if object is transparent to prevent blocking the camera view
|
|
|
|
bool IsGhostObject(int objRank);
|
2023-11-18 13:53:58 +00:00
|
|
|
//! Check if object draws in front of the user interface
|
|
|
|
bool IsDrawFrontObject(int objRank);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
|
|
|
//! Returns the bounding box for an object
|
2021-12-28 22:01:30 +00:00
|
|
|
void GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
|
|
|
//! Returns the total number of triangles of given object
|
|
|
|
int GetObjectTotalTriangles(int objRank);
|
|
|
|
|
|
|
|
//! Returns a partial list of triangles for given object
|
2015-07-09 16:45:02 +00:00
|
|
|
int GetPartialTriangles(int objRank, float percent, int maxCount,
|
2012-09-19 21:50:28 +00:00
|
|
|
std::vector<EngineTriangle>& triangles);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
|
|
|
//! Changes the 2nd texure for given object
|
2012-12-26 19:58:02 +00:00
|
|
|
void ChangeSecondTexture(int objRank, const std::string& tex2Name);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
2022-02-12 23:03:46 +00:00
|
|
|
void SetUVTransform(int objRank, const std::string& tag, const glm::vec2& offset, const glm::vec2& scale);
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-09-03 17:21:37 +00:00
|
|
|
//! Detects the target object that is selected with the mouse
|
|
|
|
/** Returns the rank of the object or -1. */
|
2021-12-28 22:01:30 +00:00
|
|
|
int DetectObject(const glm::vec2& mouse, glm::vec3& targetPos, bool terrain = false);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
|
|
|
//! Creates a shadow for the given object
|
2015-08-14 11:37:40 +00:00
|
|
|
void CreateShadowSpot(int objRank);
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Deletes the shadow for given object
|
2015-08-14 11:37:40 +00:00
|
|
|
void DeleteShadowSpot(int objRank);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
//! Management of different shadow params
|
2015-08-14 11:37:40 +00:00
|
|
|
void SetObjectShadowSpotHide(int objRank, bool hide);
|
|
|
|
void SetObjectShadowSpotType(int objRank, EngineShadowType type);
|
2021-12-28 22:01:30 +00:00
|
|
|
void SetObjectShadowSpotPos(int objRank, const glm::vec3& pos);
|
2015-08-14 11:37:40 +00:00
|
|
|
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);
|
2012-08-12 17:28:22 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Lists the ranks of objects and subobjects selected
|
|
|
|
void SetHighlightRank(int* rankList);
|
|
|
|
//! Returns the highlighted rectangle
|
2021-12-24 19:25:38 +00:00
|
|
|
bool GetHighlight(glm::vec2& p1, glm::vec2& p2);
|
2012-08-10 21:31:42 +00:00
|
|
|
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Deletes all ground spots
|
2012-12-26 19:58:02 +00:00
|
|
|
void DeleteAllGroundSpots();
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Creates a new ground spot and returns its rank
|
|
|
|
int CreateGroundSpot();
|
|
|
|
//! Deletes the given ground spot
|
|
|
|
void DeleteGroundSpot(int rank);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
//! Management of different ground spot params
|
2021-12-28 22:01:30 +00:00
|
|
|
void SetObjectGroundSpotPos(int rank, const glm::vec3& pos);
|
2012-12-26 19:58:02 +00:00
|
|
|
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);
|
2012-08-12 17:28:22 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Creates the ground mark with the given params
|
2021-12-28 22:01:30 +00:00
|
|
|
void CreateGroundMark(glm::vec3 pos, float radius,
|
2012-07-22 20:05:12 +00:00
|
|
|
float delay1, float delay2, float delay3,
|
|
|
|
int dx, int dy, char* table);
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Deletes the ground mark
|
|
|
|
void DeleteGroundMark(int rank);
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Updates the state after creating objects
|
2012-06-26 20:23:05 +00:00
|
|
|
void Update();
|
|
|
|
|
2012-07-22 20:05:12 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
/* *************** Mode setting *************** */
|
|
|
|
|
|
|
|
//! Specifies the location and direction of view
|
2022-02-26 00:16:36 +00:00
|
|
|
void SetViewParams(const glm::vec3 &eyePt, const glm::vec3 &lookatPt, const glm::vec3 &upVec);
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2017-06-04 11:10:50 +00:00
|
|
|
//! Updates the textures used for drawing ground spot
|
2022-02-26 00:16:36 +00:00
|
|
|
void UpdateGroundSpotTextures();
|
2017-06-04 11:10:50 +00:00
|
|
|
|
2012-08-12 08:45:04 +00:00
|
|
|
//! Loads texture, creating it if not already present
|
2012-09-29 21:37:38 +00:00
|
|
|
Texture LoadTexture(const std::string& name);
|
2012-09-29 22:23:26 +00:00
|
|
|
//! Loads texture from existing image
|
|
|
|
Texture LoadTexture(const std::string& name, CImage* image);
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Loads texture, creating it with given params if not already present
|
2012-09-29 21:37:38 +00:00
|
|
|
Texture LoadTexture(const std::string& name, const TextureCreateParams& params);
|
2012-08-12 08:45:04 +00:00
|
|
|
//! Loads all necessary textures
|
2012-07-22 20:05:12 +00:00
|
|
|
bool LoadAllTextures();
|
2012-08-12 08:45:04 +00:00
|
|
|
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Deletes the given texture, unloading it and removing from cache
|
2015-10-03 20:05:14 +00:00
|
|
|
void DeleteTexture(const std::string& texName);
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Deletes the given texture, unloading it and removing from cache
|
2012-09-19 21:50:28 +00:00
|
|
|
void DeleteTexture(const Texture& tex);
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2016-03-25 16:06:01 +00:00
|
|
|
//! Creates or updates the given texture with given image data
|
|
|
|
void CreateOrUpdateTexture(const std::string& texName, CImage* img);
|
|
|
|
|
2013-05-26 12:50:23 +00:00
|
|
|
//! Empties the texture cache
|
|
|
|
void FlushTextureCache();
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Defines of the distance field of vision
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetTerrainVision(float vision);
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
2017-08-05 07:45:08 +00:00
|
|
|
//! Management of camera vertical field-of-view angle.
|
|
|
|
/** This is specified in radians.
|
|
|
|
Horizontal FoV is calculated based on vertical FoV and aspect ratio.
|
2012-08-10 21:31:42 +00:00
|
|
|
0.75 = normal
|
|
|
|
1.50 = wide-angle */
|
|
|
|
void SetFocus(float focus);
|
2017-08-05 07:45:08 +00:00
|
|
|
//! Deprecated alias for GetVFovAngle
|
2012-08-10 21:31:42 +00:00
|
|
|
float GetFocus();
|
2017-08-05 07:45:08 +00:00
|
|
|
float GetVFovAngle();
|
|
|
|
float GetHFovAngle();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
|
|
|
|
2021-12-14 20:54:19 +00:00
|
|
|
void SetTriplanarMode(bool enabled);
|
|
|
|
bool GetTriplanarMode();
|
|
|
|
|
|
|
|
void SetTriplanarScale(float scale);
|
|
|
|
float GetTriplanarScale();
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of the global mode of contamination
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetDirty(bool mode);
|
2012-07-01 20:59:22 +00:00
|
|
|
bool GetDirty();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
//! Management of the global mode of horizontal fog patches
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetFog(bool mode);
|
2012-07-01 20:59:22 +00:00
|
|
|
bool GetFog();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
//! Management of the global mode of secondary texturing
|
2014-11-10 19:46:39 +00:00
|
|
|
void SetSecondTexture(const std::string& texNum);
|
|
|
|
const std::string& GetSecondTexture();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of view mode
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetRankView(int rank);
|
2012-07-01 20:59:22 +00:00
|
|
|
int GetRankView();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Whether to draw the world
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetDrawWorld(bool draw);
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Whether to draw the world on the interface
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetDrawFront(bool draw);
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Ambient color management
|
2012-09-19 21:50:28 +00:00
|
|
|
void SetAmbientColor(const Color& color, int rank = 0);
|
2012-09-29 21:37:38 +00:00
|
|
|
Color GetAmbientColor(int rank = 0);
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Color management under water
|
2012-09-19 21:50:28 +00:00
|
|
|
void SetWaterAddColor(const Color& color);
|
2012-09-29 21:37:38 +00:00
|
|
|
Color GetWaterAddColor();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of the fog color
|
2012-09-19 21:50:28 +00:00
|
|
|
void SetFogColor(const Color& color, int rank = 0);
|
2012-09-29 21:37:38 +00:00
|
|
|
Color GetFogColor(int rank = 0);
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of the depth of field.
|
|
|
|
/** Beyond this distance, nothing is visible.
|
|
|
|
Shortly (according SetFogStart), one enters the fog. */
|
2012-07-22 20:05:12 +00:00
|
|
|
void SetDeepView(float length, int rank = 0, bool ref=false);
|
|
|
|
float GetDeepView(int rank = 0);
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
|
|
|
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! 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). */
|
2012-07-22 20:05:12 +00:00
|
|
|
void SetFogStart(float start, int rank = 0);
|
|
|
|
float GetFogStart(int rank = 0);
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of the background image to use
|
2012-09-19 21:50:28 +00:00
|
|
|
void SetBackground(const std::string& name, Color up = Color(), Color down = Color(),
|
|
|
|
Color cloudUp = Color(), Color cloudDown = Color(),
|
2015-07-11 10:57:02 +00:00
|
|
|
bool full = false, bool scale = false);
|
2012-09-19 21:50:28 +00:00
|
|
|
void GetBackground(std::string& name, Color& up, Color& down,
|
|
|
|
Color& cloudUp, Color& cloudDown,
|
2015-07-11 10:57:02 +00:00
|
|
|
bool& full, bool& scale);
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
|
|
|
|
2012-08-12 08:45:04 +00:00
|
|
|
//! Specifies the name of foreground texture
|
|
|
|
void SetForegroundName(const std::string& name);
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Specifies whether to draw the foreground
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetOverFront(bool front);
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Sets the foreground overlay color
|
2022-02-26 01:39:13 +00:00
|
|
|
void SetOverColor(const Color& color, TransparencyMode mode);
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of the particle density
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2012-07-22 20:05:12 +00:00
|
|
|
void SetParticleDensity(float value);
|
|
|
|
float GetParticleDensity();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//! Adapts particle factor according to particle density
|
2012-07-22 20:05:12 +00:00
|
|
|
float ParticleAdapt(float factor);
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of the distance of clipping.
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetClippingDistance(float value);
|
2012-07-01 20:59:22 +00:00
|
|
|
float GetClippingDistance();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2015-05-06 15:55:10 +00:00
|
|
|
//@{
|
|
|
|
//! Management the texture filter mode
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2022-05-08 16:23:37 +00:00
|
|
|
void SetTextureFilterMode(TextureFilter value);
|
|
|
|
TextureFilter GetTextureFilterMode();
|
2015-05-06 15:55:10 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
//! Management the mipmap level for textures
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2015-05-06 15:55:10 +00:00
|
|
|
void SetTextureMipmapLevel(int value);
|
|
|
|
int GetTextureMipmapLevel();
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
//! Management the anisotropy level for textures
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2015-05-06 15:55:10 +00:00
|
|
|
void SetTextureAnisotropyLevel(int value);
|
|
|
|
int GetTextureAnisotropyLevel();
|
|
|
|
//@}
|
|
|
|
|
2015-05-11 13:21:17 +00:00
|
|
|
//@{
|
|
|
|
//! Management of shadow mapping
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: These are user configuration settings
|
2015-08-06 11:47:42 +00:00
|
|
|
bool IsShadowMappingSupported();
|
2015-05-11 13:21:17 +00:00
|
|
|
void SetShadowMapping(bool value);
|
|
|
|
bool GetShadowMapping();
|
2015-07-20 16:42:09 +00:00
|
|
|
void SetShadowMappingOffscreen(bool value);
|
|
|
|
bool GetShadowMappingOffscreen();
|
|
|
|
void SetShadowMappingOffscreenResolution(int resolution);
|
|
|
|
int GetShadowMappingOffscreenResolution();
|
2015-08-06 11:47:42 +00:00
|
|
|
bool IsShadowMappingQualitySupported();
|
2015-07-20 16:42:09 +00:00
|
|
|
void SetShadowMappingQuality(bool value);
|
|
|
|
bool GetShadowMappingQuality();
|
2016-03-10 09:50:54 +00:00
|
|
|
void SetTerrainShadows(bool value);
|
|
|
|
bool GetTerrainShadows();
|
2015-05-11 13:21:17 +00:00
|
|
|
//@}
|
|
|
|
|
2018-07-05 17:43:56 +00:00
|
|
|
//@{
|
|
|
|
//! Management of vertical synchronization
|
|
|
|
// NOTE: This is an user configuration setting
|
|
|
|
void SetVSync(int value);
|
|
|
|
int GetVSync();
|
|
|
|
//@}
|
|
|
|
|
2015-05-27 20:12:02 +00:00
|
|
|
//@{
|
2015-06-15 16:41:31 +00:00
|
|
|
//! Management of shadow color
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is a setting configurable only in INI file
|
2015-05-27 20:12:02 +00:00
|
|
|
void SetShadowColor(float value);
|
2015-07-18 22:07:59 +00:00
|
|
|
float GetShadowColor();
|
2015-05-27 20:12:02 +00:00
|
|
|
//@}
|
|
|
|
|
2015-06-15 16:41:31 +00:00
|
|
|
//@{
|
|
|
|
//! Management of shadow range
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is a setting configurable only in INI file
|
2015-06-15 16:41:31 +00:00
|
|
|
void SetShadowRange(float value);
|
2015-07-18 22:07:59 +00:00
|
|
|
float GetShadowRange();
|
2015-06-15 16:41:31 +00:00
|
|
|
//@}
|
|
|
|
|
2015-06-21 22:56:47 +00:00
|
|
|
//@{
|
|
|
|
//! Management of shadow range
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2015-06-21 22:56:47 +00:00
|
|
|
void SetMultiSample(int value);
|
2015-07-18 22:07:59 +00:00
|
|
|
int GetMultiSample();
|
2015-06-21 22:56:47 +00:00
|
|
|
//@}
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management the mode of background
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetBackForce(bool present);
|
2012-07-01 20:59:22 +00:00
|
|
|
bool GetBackForce();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Managing the mode of dynamic lights.
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetLightMode(bool present);
|
2012-07-01 20:59:22 +00:00
|
|
|
bool GetLightMode();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of the indentation mode while editing (CEdit)
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
|
|
|
// TODO: Move to CSettings
|
2012-06-29 22:12:04 +00:00
|
|
|
void SetEditIndentMode(bool autoIndent);
|
2012-07-01 20:59:22 +00:00
|
|
|
bool GetEditIndentMode();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of tab indent when editing (CEdit)
|
2015-08-14 11:04:05 +00:00
|
|
|
// NOTE: This is an user configuration setting
|
|
|
|
// TODO: Move to CSettings
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetEditIndentValue(int value);
|
2012-07-01 20:59:22 +00:00
|
|
|
int GetEditIndentValue();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of precision of robot tracks
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetTracePrecision(float factor);
|
2012-07-01 20:59:22 +00:00
|
|
|
float GetTracePrecision();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//@{
|
|
|
|
//! Management of mouse cursor type
|
2012-09-20 18:37:37 +00:00
|
|
|
void SetMouseType(EngineMouseType type);
|
2012-09-19 21:50:28 +00:00
|
|
|
EngineMouseType GetMouseType();
|
2012-08-10 21:31:42 +00:00
|
|
|
//@}
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2016-05-21 12:27:35 +00:00
|
|
|
//@{
|
|
|
|
//! Management of pause blur
|
2016-07-09 10:13:51 +00:00
|
|
|
void SetPauseBlurEnabled(bool enable);
|
|
|
|
bool GetPauseBlurEnabled();
|
2016-05-21 12:27:35 +00:00
|
|
|
//@}
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Returns the view matrix
|
2022-01-05 18:12:35 +00:00
|
|
|
const glm::mat4& GetMatView();
|
2017-01-02 17:43:19 +00:00
|
|
|
//! Returns the projection matrix
|
2022-01-05 18:12:35 +00:00
|
|
|
const glm::mat4& GetMatProj();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Returns the camera center point
|
2021-12-28 22:01:30 +00:00
|
|
|
TEST_VIRTUAL glm::vec3 GetEyePt();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Returns the camera target point
|
2021-12-28 22:01:30 +00:00
|
|
|
TEST_VIRTUAL glm::vec3 GetLookatPt();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Returns the horizontal direction angle of view
|
|
|
|
float GetEyeDirH();
|
|
|
|
//! Returns the vertical direction angle of view
|
|
|
|
float GetEyeDirV();
|
|
|
|
//! Indicates whether a point is visible
|
2021-12-28 22:01:30 +00:00
|
|
|
bool IsVisiblePoint(const glm::vec3& pos);
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2022-07-09 10:23:50 +00:00
|
|
|
//! Returns object material color
|
|
|
|
Color GetObjectColor(int object, const std::string& name);
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Updates the scene after a change of parameters
|
|
|
|
void ApplyChange();
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2022-01-05 18:12:35 +00:00
|
|
|
void RenderDebugSphere(const Math::Sphere&, const glm::mat4& transform = glm::mat4(1.0f), const Color & = Color{0.0f, 0.0f, 1.0f, 1.0f});
|
|
|
|
void RenderDebugBox(const glm::vec3& mins, const glm::vec3& maxs, const glm::mat4& transform = glm::mat4(1.0f), const Color & = Color{0.0f, 0.0f, 1.0f, 1.0f});
|
2016-03-17 03:31:16 +00:00
|
|
|
|
2016-03-28 11:51:39 +00:00
|
|
|
void SetDebugLights(bool debugLights);
|
|
|
|
bool GetDebugLights();
|
|
|
|
void DebugDumpLights();
|
|
|
|
|
2016-03-28 15:57:41 +00:00
|
|
|
void SetDebugResources(bool debugResources);
|
|
|
|
bool GetDebugResources();
|
|
|
|
|
2016-03-28 18:25:07 +00:00
|
|
|
void SetDebugGoto(bool debugGoto);
|
|
|
|
bool GetDebugGoto();
|
2022-02-04 00:00:18 +00:00
|
|
|
void AddDebugGotoLine(std::vector<Gfx::Vertex3D> line);
|
2016-03-28 19:42:25 +00:00
|
|
|
void SetDebugGotoBitmap(std::unique_ptr<CImage> debugImage);
|
2016-03-28 18:25:07 +00:00
|
|
|
|
2016-04-06 10:21:41 +00:00
|
|
|
void SetWindowCoordinates();
|
|
|
|
void SetInterfaceCoordinates();
|
|
|
|
|
2016-05-21 12:27:35 +00:00
|
|
|
void EnablePauseBlur();
|
|
|
|
void DisablePauseBlur();
|
|
|
|
|
2021-06-16 00:33:15 +00:00
|
|
|
|
2018-08-02 05:38:32 +00:00
|
|
|
//! Reloads all textures
|
|
|
|
/** This additionally sends EVENT_RELOAD_TEXTURES to reload all textures not maintained by CEngine **/
|
|
|
|
void ReloadAllTextures();
|
|
|
|
|
2022-01-19 22:13:50 +00:00
|
|
|
int ComputeSphereVisibility(const glm::mat4& m, const glm::vec3& center, float radius);
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
protected:
|
2016-03-26 17:55:39 +00:00
|
|
|
//! Resets some states and flushes textures after device was changed (e.g. resoulution changed)
|
|
|
|
/** Instead of calling this directly, send EVENT_RESOLUTION_CHANGED event **/
|
|
|
|
void ResetAfterVideoConfigChanged();
|
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Prepares the interface for 3D scene
|
|
|
|
void Draw3DScene();
|
2016-06-19 09:45:56 +00:00
|
|
|
//! Capture the 3D scene for pause blur
|
|
|
|
void Capture3DScene();
|
2016-06-19 10:23:54 +00:00
|
|
|
//! Draw the 3D scene capured for pause blur
|
|
|
|
void DrawCaptured3DScene();
|
2015-05-11 13:21:17 +00:00
|
|
|
//! Renders shadow map
|
|
|
|
void RenderShadowMap();
|
2015-06-22 21:42:01 +00:00
|
|
|
//! Enables or disables MSAA
|
|
|
|
void UseMSAA(bool enable);
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Draws the user interface over the scene
|
|
|
|
void DrawInterface();
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2015-08-14 11:36:23 +00:00
|
|
|
//! Draws old-style shadow spots
|
|
|
|
void DrawShadowSpots();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Draws the gradient background
|
2012-06-26 20:23:05 +00:00
|
|
|
void DrawBackground();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Draws the gradient background
|
2012-09-19 21:50:28 +00:00
|
|
|
void DrawBackgroundGradient(const Color& up, const Color& down);
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Draws the image background
|
2012-06-26 20:23:05 +00:00
|
|
|
void DrawBackgroundImage();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Draws all the planets
|
2012-06-26 20:23:05 +00:00
|
|
|
void DrawPlanet();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Draws the image foreground
|
|
|
|
void DrawForegroundImage();
|
|
|
|
//! Draws the foreground color
|
2012-06-26 20:23:05 +00:00
|
|
|
void DrawOverColor();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Draws the rectangle of the object highlighted
|
|
|
|
void DrawHighlight();
|
|
|
|
//! Draws the mouse cursor
|
2012-06-26 20:23:05 +00:00
|
|
|
void DrawMouse();
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Draw part of mouse cursor sprite
|
2022-02-03 17:40:58 +00:00
|
|
|
void DrawMouseSprite(const glm::ivec2& pos, const glm::ivec2& size, int icon, TransparencyMode mode);
|
2012-09-20 18:37:37 +00:00
|
|
|
//! Draw statistic texts
|
|
|
|
void DrawStats();
|
2014-10-29 16:53:46 +00:00
|
|
|
//! Draw mission timer
|
|
|
|
void DrawTimer();
|
2018-04-29 22:37:41 +00:00
|
|
|
void RenderPendingDebugDraws();
|
2012-07-22 20:05:12 +00:00
|
|
|
|
2022-02-12 23:03:46 +00:00
|
|
|
//! Creates a new tier
|
|
|
|
EngineBaseObjDataTier& AddLevel(EngineBaseObject& p3, EngineTriangleType type, const Material& material);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
|
|
|
//! Create texture and add it to cache
|
2013-05-26 12:50:23 +00:00
|
|
|
Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr);
|
2012-08-12 17:28:22 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Tests whether the given object is visible
|
2022-01-05 18:12:35 +00:00
|
|
|
bool IsVisible(const glm::mat4& matrix, int objRank);
|
2021-09-19 18:08:31 +00:00
|
|
|
|
2021-12-28 22:01:30 +00:00
|
|
|
bool InPlane(glm::vec3 normal, float originPlane, glm::vec3 center, float radius);
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Detects whether an object is affected by the mouse
|
2021-12-24 19:25:38 +00:00
|
|
|
bool DetectBBox(int objRank, const glm::vec2& mouse);
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Compute and return the 2D box on screen of any object
|
2021-12-24 19:25:38 +00:00
|
|
|
bool GetBBox2D(int objRank, glm::vec2& min, glm::vec2& max);
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Detects whether the mouse is in a triangle.
|
2021-12-28 22:01:30 +00:00
|
|
|
bool DetectTriangle(const glm::vec2& mouse, Vertex3D* triangle, int objRank, float& dist, glm::vec3& pos);
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Transforms a 3D point (x, y, z) in 2D space (x, y, -) of the window
|
|
|
|
/** The coordinated p2D.z gives the distance. */
|
2021-12-28 22:01:30 +00:00
|
|
|
bool TransformPoint(glm::vec3& p2D, int objRank, glm::vec3 p3D);
|
2012-08-10 21:31:42 +00:00
|
|
|
|
|
|
|
//! Calculates the distances between the viewpoint and the origin of different objects
|
2012-07-22 20:05:12 +00:00
|
|
|
void ComputeDistance();
|
2012-08-10 21:31:42 +00:00
|
|
|
|
2012-08-12 17:28:22 +00:00
|
|
|
//! Updates geometric parameters of objects (bounding box and radius)
|
2012-07-22 20:05:12 +00:00
|
|
|
void UpdateGeometry();
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-12-26 19:58:02 +00:00
|
|
|
//! Updates a given static buffer
|
|
|
|
void UpdateStaticBuffer(EngineBaseObjDataTier& p4);
|
|
|
|
|
2012-12-14 20:30:35 +00:00
|
|
|
//! Updates static buffers of changed objects
|
2012-12-26 19:58:02 +00:00
|
|
|
void UpdateStaticBuffers();
|
2012-12-14 20:30:35 +00:00
|
|
|
|
2015-08-04 18:30:31 +00:00
|
|
|
struct WriteScreenShotData
|
|
|
|
{
|
|
|
|
std::unique_ptr<CImage> img;
|
|
|
|
std::string fileName;
|
|
|
|
};
|
|
|
|
static void WriteScreenShotThread(std::unique_ptr<WriteScreenShotData> data);
|
2015-08-03 19:40:30 +00:00
|
|
|
|
2012-06-22 14:31:55 +00:00
|
|
|
protected:
|
2012-09-20 18:37:37 +00:00
|
|
|
CApplication* m_app;
|
2015-08-07 06:31:34 +00:00
|
|
|
CSystemUtils* m_systemUtils;
|
2012-09-20 18:37:37 +00:00
|
|
|
CSoundInterface* m_sound;
|
|
|
|
CDevice* m_device;
|
|
|
|
CTerrain* m_terrain;
|
2015-08-12 19:07:16 +00:00
|
|
|
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;
|
2015-06-22 19:58:58 +00:00
|
|
|
std::unique_ptr<CPyroManager> m_pyroManager;
|
2012-06-30 23:37:30 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Last encountered error
|
2012-06-30 23:37:30 +00:00
|
|
|
std::string m_error;
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2021-09-11 11:26:38 +00:00
|
|
|
TimeUtils::TimeStamp m_lastFrameTime;
|
|
|
|
TimeUtils::TimeStamp m_currentFrameTime;
|
2012-09-20 18:37:37 +00:00
|
|
|
int m_fpsCounter;
|
|
|
|
float m_fps;
|
|
|
|
|
2012-07-29 13:09:53 +00:00
|
|
|
//! Whether to show stats (FPS, etc)
|
|
|
|
bool m_showStats;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Rendering enabled?
|
|
|
|
bool m_render;
|
2015-09-04 17:16:21 +00:00
|
|
|
//! Render / hide the UI?
|
|
|
|
bool m_renderInterface;
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2015-08-07 13:59:05 +00:00
|
|
|
//! Screenshot mode?
|
|
|
|
bool m_screenshotMode;
|
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Projection matrix for 3D scene
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_matProj;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! View matrix for 3D scene
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_matView;
|
2017-08-05 07:45:08 +00:00
|
|
|
//! Camera vertical field-of-view angle for 3D scene. A.k.a. m_vfov
|
2012-06-26 20:23:05 +00:00
|
|
|
float m_focus;
|
2017-08-05 07:45:08 +00:00
|
|
|
//! Horizontal field-of-view angle, calculated from vertical FOV and aspect ratio
|
|
|
|
float m_hfov;
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2015-05-11 13:21:17 +00:00
|
|
|
//! Projection matrix for rendering shadow maps
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_shadowProjMat;
|
2015-05-11 13:21:17 +00:00
|
|
|
//! View matrix for rendering shadow maps
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_shadowViewMat;
|
2015-05-11 13:21:17 +00:00
|
|
|
//! Texture matrix for rendering shadow maps
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_shadowTextureMat;
|
2015-05-11 13:21:17 +00:00
|
|
|
//! Texture bias for sampling shadow maps
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_shadowBias;
|
2015-05-11 13:21:17 +00:00
|
|
|
|
2018-07-05 17:43:56 +00:00
|
|
|
//! Vertical synchronization controll
|
|
|
|
int m_vsync;
|
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//! World matrix for 2D interface
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_matWorldInterface;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Projection matrix for 2D interface
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_matProjInterface;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! View matrix for 2D interface
|
2022-01-05 18:12:35 +00:00
|
|
|
glm::mat4 m_matViewInterface;
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-10 21:31:42 +00:00
|
|
|
//! Current size of viewport window
|
2021-12-23 22:08:56 +00:00
|
|
|
glm::ivec2 m_size;
|
2012-07-22 20:05:12 +00:00
|
|
|
|
2012-12-26 19:58:02 +00:00
|
|
|
//! Base objects (also level 1 tier list)
|
|
|
|
std::vector<EngineBaseObject> m_baseObjects;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Object parameters
|
2012-09-19 21:50:28 +00:00
|
|
|
std::vector<EngineObject> m_objects;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Shadow list
|
2015-08-14 11:37:40 +00:00
|
|
|
std::vector<EngineShadow> m_shadowSpots;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Ground spot list
|
2012-09-19 21:50:28 +00:00
|
|
|
std::vector<EngineGroundSpot> m_groundSpots;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Ground mark
|
2012-09-19 21:50:28 +00:00
|
|
|
EngineGroundMark m_groundMark;
|
2022-04-06 23:11:23 +00:00
|
|
|
//! Team colors
|
|
|
|
std::map<int, Color> m_teamColors;
|
2012-07-22 20:05:12 +00:00
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Location of camera
|
2021-12-28 22:01:30 +00:00
|
|
|
glm::vec3 m_eyePt{ 0, 0, 0 };
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Camera target
|
2021-12-28 22:01:30 +00:00
|
|
|
glm::vec3 m_lookatPt{ 0, 0, 0 };
|
2012-06-26 20:23:05 +00:00
|
|
|
float m_eyeDirH;
|
|
|
|
float m_eyeDirV;
|
|
|
|
int m_rankView;
|
2012-09-20 18:37:37 +00:00
|
|
|
Color m_ambientColor[2];
|
|
|
|
Color m_backColor[2];
|
|
|
|
Color m_fogColor[2];
|
2012-06-26 20:23:05 +00:00
|
|
|
float m_deepView[2];
|
|
|
|
float m_fogStart[2];
|
2012-09-20 18:37:37 +00:00
|
|
|
Color m_waterAddColor;
|
2012-06-26 20:23:05 +00:00
|
|
|
int m_statisticTriangle;
|
2021-12-28 22:01:30 +00:00
|
|
|
glm::vec3 m_statisticPos{ 0, 0, 0 };
|
2012-06-26 20:23:05 +00:00
|
|
|
bool m_updateGeometry;
|
2012-12-26 19:58:02 +00:00
|
|
|
bool m_updateStaticBuffers;
|
2012-06-26 20:23:05 +00:00
|
|
|
bool m_firstGroundSpot;
|
2014-11-10 19:46:39 +00:00
|
|
|
std::string m_secondTex;
|
2012-08-12 17:28:22 +00:00
|
|
|
bool m_backgroundFull;
|
2015-07-11 10:57:02 +00:00
|
|
|
bool m_backgroundScale;
|
2012-07-22 20:05:12 +00:00
|
|
|
std::string m_backgroundName;
|
2012-09-20 18:37:37 +00:00
|
|
|
Texture m_backgroundTex;
|
|
|
|
Color m_backgroundColorUp;
|
|
|
|
Color m_backgroundColorDown;
|
|
|
|
Color m_backgroundCloudUp;
|
|
|
|
Color m_backgroundCloudDown;
|
2012-06-26 20:23:05 +00:00
|
|
|
bool m_overFront;
|
2012-09-20 18:37:37 +00:00
|
|
|
Color m_overColor;
|
2022-02-03 17:40:58 +00:00
|
|
|
TransparencyMode m_overMode;
|
2012-08-12 08:45:04 +00:00
|
|
|
std::string m_foregroundName;
|
2012-09-20 18:37:37 +00:00
|
|
|
Texture m_foregroundTex;
|
2012-06-26 20:23:05 +00:00
|
|
|
bool m_drawWorld;
|
|
|
|
bool m_drawFront;
|
2015-08-14 11:04:05 +00:00
|
|
|
float m_terrainVision;
|
|
|
|
bool m_backForce;
|
|
|
|
float m_tracePrecision;
|
2016-07-09 10:13:51 +00:00
|
|
|
bool m_pauseBlurEnabled;
|
2015-08-14 11:04:05 +00:00
|
|
|
|
2021-12-14 20:54:19 +00:00
|
|
|
bool m_triplanarMode;
|
|
|
|
float m_triplanarScale;
|
2015-08-14 11:04:05 +00:00
|
|
|
bool m_dirty;
|
|
|
|
bool m_fog;
|
2012-08-10 21:31:42 +00:00
|
|
|
float m_particleDensity;
|
2012-06-26 20:23:05 +00:00
|
|
|
float m_clippingDistance;
|
|
|
|
bool m_lightMode;
|
|
|
|
bool m_editIndentMode;
|
|
|
|
int m_editIndentValue;
|
|
|
|
|
2021-12-01 16:05:20 +00:00
|
|
|
struct ShadowParam
|
|
|
|
{
|
|
|
|
glm::mat4 transform;
|
|
|
|
glm::vec2 offset;
|
|
|
|
glm::vec2 scale;
|
|
|
|
float range;
|
|
|
|
};
|
|
|
|
|
|
|
|
int m_shadowRegions = 4;
|
|
|
|
ShadowParam m_shadowParams[4];
|
2015-05-11 13:21:17 +00:00
|
|
|
Texture m_shadowMap;
|
|
|
|
|
2018-05-01 19:27:49 +00:00
|
|
|
struct PendingDebugDraw
|
2018-04-29 22:37:41 +00:00
|
|
|
{
|
2022-02-04 00:00:18 +00:00
|
|
|
std::vector<Vertex3D> vertices;
|
2018-04-29 22:37:41 +00:00
|
|
|
std::vector<int> counts;
|
2018-05-07 18:28:31 +00:00
|
|
|
}
|
|
|
|
m_pendingDebugDraws;
|
2018-04-29 22:37:41 +00:00
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Ranks of highlighted objects
|
2012-08-10 21:31:42 +00:00
|
|
|
int m_highlightRank[100];
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Highlight visible?
|
2012-08-10 21:31:42 +00:00
|
|
|
bool m_highlight;
|
2012-08-12 08:45:04 +00:00
|
|
|
//! Time counter for highlight animation
|
|
|
|
float m_highlightTime;
|
2012-08-11 15:17:04 +00:00
|
|
|
//@{
|
|
|
|
//! Highlight rectangle points
|
2021-12-24 19:25:38 +00:00
|
|
|
glm::vec2 m_highlightP1;
|
|
|
|
glm::vec2 m_highlightP2;
|
2012-08-11 15:17:04 +00:00
|
|
|
//@}
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Default texture create params
|
2012-09-19 21:50:28 +00:00
|
|
|
TextureCreateParams m_defaultTexParams;
|
2012-09-29 08:40:11 +00:00
|
|
|
//! Create params for terrain textures
|
|
|
|
TextureCreateParams m_terrainTexParams;
|
2015-05-06 15:55:10 +00:00
|
|
|
//! Requested texture mipmap level
|
|
|
|
int m_textureMipmapLevel;
|
|
|
|
//! Requested texture anisotropy level
|
|
|
|
int m_textureAnisotropy;
|
2015-05-11 13:21:17 +00:00
|
|
|
//! true if shadow mapping enabled
|
|
|
|
bool m_shadowMapping;
|
2015-05-12 11:09:31 +00:00
|
|
|
//! true enables offscreen shadow rendering
|
|
|
|
bool m_offscreenShadowRendering;
|
2015-07-20 16:42:09 +00:00
|
|
|
//! Offscreen shadow rendering resolution
|
|
|
|
int m_offscreenShadowRenderingResolution;
|
2015-05-14 13:31:57 +00:00
|
|
|
//! true enables higher quality shadows
|
|
|
|
bool m_qualityShadows;
|
2016-03-10 09:50:54 +00:00
|
|
|
//! true enables casting shadows by terrain
|
|
|
|
bool m_terrainShadows;
|
2015-05-27 20:12:02 +00:00
|
|
|
//! Shadow color
|
|
|
|
float m_shadowColor;
|
2015-06-15 16:41:31 +00:00
|
|
|
//! Shadow range
|
|
|
|
float m_shadowRange;
|
2015-06-21 22:56:47 +00:00
|
|
|
//! Number of samples for multisample rendering
|
|
|
|
int m_multisample;
|
2012-07-22 20:05:12 +00:00
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Map of loaded textures (by name)
|
2012-09-19 21:50:28 +00:00
|
|
|
std::map<std::string, Texture> m_texNameMap;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Reverse map of loaded textures (by texture)
|
2012-09-19 21:50:28 +00:00
|
|
|
std::map<Texture, std::string> m_revTexNameMap;
|
2012-08-12 08:45:04 +00:00
|
|
|
//! Blacklist map of textures
|
|
|
|
/** Textures on this list were not successful in first loading,
|
|
|
|
* so are disabled for subsequent load calls. */
|
|
|
|
std::set<std::string> m_texBlacklist;
|
2012-07-22 20:05:12 +00:00
|
|
|
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Texture with mouse cursors
|
2012-09-19 21:50:28 +00:00
|
|
|
Texture m_miceTexture;
|
2012-08-11 15:17:04 +00:00
|
|
|
//! Type of mouse cursor
|
2012-09-19 21:50:28 +00:00
|
|
|
EngineMouseType m_mouseType;
|
2012-08-11 15:17:04 +00:00
|
|
|
|
2012-09-27 21:18:12 +00:00
|
|
|
//! True when drawing 2D UI
|
|
|
|
bool m_interfaceMode;
|
2013-06-17 16:06:39 +00:00
|
|
|
|
|
|
|
bool m_debugLights;
|
|
|
|
bool m_debugDumpLights;
|
2016-03-20 18:17:15 +00:00
|
|
|
bool m_debugCrashSpheres = false;
|
2016-03-28 15:57:41 +00:00
|
|
|
bool m_debugResources = false;
|
2016-03-28 18:25:07 +00:00
|
|
|
bool m_debugGoto = false;
|
2015-06-22 19:58:58 +00:00
|
|
|
|
2014-10-29 16:53:46 +00:00
|
|
|
std::string m_timerText;
|
2015-07-11 17:48:37 +00:00
|
|
|
|
|
|
|
std::unordered_map<std::string, int> m_staticMeshBaseObjects;
|
2015-10-01 16:55:41 +00:00
|
|
|
|
2022-02-04 00:00:18 +00:00
|
|
|
std::vector<std::vector<Vertex3D>> m_displayGoto;
|
2016-03-28 19:42:25 +00:00
|
|
|
std::unique_ptr<CImage> m_displayGotoImage;
|
2016-03-17 03:31:16 +00:00
|
|
|
|
2015-10-01 16:55:41 +00:00
|
|
|
//! Pause the animation updates
|
|
|
|
bool m_pause = false;
|
2016-05-21 12:27:35 +00:00
|
|
|
|
|
|
|
//! true means that current 3D scene was captured and is not to be rendered again
|
|
|
|
bool m_worldCaptured = false;
|
|
|
|
//! true means that currently rendered world is to be captured
|
|
|
|
bool m_captureWorld = false;
|
|
|
|
//! Texture with captured 3D world
|
|
|
|
Texture m_capturedWorldTexture;
|
2012-06-24 13:41:56 +00:00
|
|
|
};
|
2012-06-22 14:31:55 +00:00
|
|
|
|
2012-09-19 21:50:28 +00:00
|
|
|
|
|
|
|
} // namespace Gfx
|