19#ifndef HEADER_IRR_DRIVER_HPP
20#define HEADER_IRR_DRIVER_HPP
30#include "graphics/abstract_renderer.hpp"
31#include "graphics/gl_headers.hpp"
32#include "graphics/wind.hpp"
33#include "io/file_manager.hpp"
34#include "utils/aligned_array.hpp"
35#include "utils/no_copy.hpp"
36#include "utils/ptr_vector.hpp"
37#include "utils/vec3.hpp"
43#include <dimension2d.h>
44#include <position2d.h>
47#include <IEventReceiver.h>
52 class SPDynamicDrawCall;
58 namespace scene {
class ISceneManager;
class IMesh;
class IAnimatedMeshSceneNode;
class IAnimatedMesh;
59 class IMeshSceneNode;
class IParticleSystemSceneNode;
class ICameraSceneNode;
class ILightSceneNode;
60 class CLensFlareSceneNode; }
61 namespace gui {
class IGUIEnvironment;
class IGUIFont; }
62 namespace video {
struct IRenderTarget;
class ITexture;
class IVideoDriver;
68enum TypeRTT :
unsigned int;
75namespace GE {
class GERenderInfo; }
104 core::dimension2du m_actual_screen_size;
107 core::array<video::IRenderTarget>
m_mrt;
110 core::matrix4
m_ViewMatrix, m_InvViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix;
121 enum {RES_CHANGE_NONE, RES_CHANGE_YES, RES_CHANGE_CANCEL,
133 VideoMode(
int w,
int h) {m_width=w; m_height=h; }
134 int getWidth()
const {
return m_width; }
135 int getHeight()
const {
return m_height; }
139 scene::ISceneNode * node;
143 video::SColorf getAmbientLight()
const;
148 int m_screen_orientation;
149 std::vector<VideoMode> m_modes;
151 void setupViewports();
163 bool m_request_screenshot;
168 bool m_boundingboxesviz;
170 bool m_render_nw_debug;
176 unsigned m_last_light_bucket_distance;
177 unsigned m_skinning_joint;
180 core::vector3df m_sun_direction;
181 video::SColorf m_suncolor;
184 std::vector<LightNode *> m_lights;
186 std::vector<BloomData> m_forcedbloom;
188 std::vector<scene::ISceneNode *> m_background;
193 irr::ELOG_LEVEL m_logger_level;
196 std::vector<irr::scene::IAnimatedMeshSceneNode*> m_debug_meshes;
207 void setMaxTextureSize();
208 void unsetMaxTextureSize();
209 void getOpenGLData(std::string *vendor, std::string *renderer,
210 std::string *version);
212 void increaseObjectCount();
213 core::array<video::IRenderTarget> &getMainSetup();
215 core::recti getSplitscreenWindow(
int WindowNum);
218 scene::IMesh *
getMesh(
const std::string &name);
221 bool OnEvent(
const irr::SEvent &event);
223 bool force_SH_computation =
true);
225 const std::string &filename);
226 video::ITexture *
getTexture(
const std::string &filename);
229 scene::IMesh *
createQuadMesh(
const video::SMaterial *material=NULL,
230 bool create_one_quad=
false);
232 const double w,
const double h);
233 scene::ISceneNode *
addWaterNode(scene::IMesh *mesh, scene::IMesh **welded,
235 float wave_speed,
float wave_length);
236 scene::IMeshSceneNode*
addOctTree(scene::IMesh *mesh);
237 scene::ISceneNode*
addSphere(
float radius,
238 const video::SColor &color=video::SColor(128, 255, 255, 255));
239 scene::ISceneNode*
addMesh(scene::IMesh *mesh,
240 const std::string& debug_name,
241 scene::ISceneNode *parent = NULL,
242 std::shared_ptr<GE::GERenderInfo> render_info =
nullptr);
244 scene::ICameraSceneNode* cam,
245 scene::ISceneNode *parent = NULL);
246 scene::ISceneNode *
addBillboard(
const core::dimension2d< f32 > size,
247 const std::string& tex_name,
248 scene::ISceneNode* parent=NULL);
249 scene::IParticleSystemSceneNode
251 scene::ISceneNode *
addSkyBox(
const std::vector<video::ITexture*> &texture_names,
252 const std::vector<video::ITexture*> &spherical_harmonics_textures);
253 void suppressSkyBox();
257 scene::IAnimatedMeshSceneNode
259 const std::string& debug_name,
260 scene::ISceneNode* parent = NULL,
261 std::shared_ptr<GE::GERenderInfo> render_info =
nullptr);
262 scene::ICameraSceneNode
266 void removeCamera(
Camera *camera);
267 void update(
float dt,
bool loading=
false);
277 void setLastLightBucketDistance(
unsigned d) { m_last_light_bucket_distance = d; }
278 void setSkinningJoint(
unsigned d) { m_skinning_joint = d; }
280 core::position2di getMouseLocation();
283 void requestScreenshot();
284 class GPUTimer &getGPUTimer(
unsigned);
285 const char* getGPUQueryPhaseName(
unsigned);
288 std::unique_ptr<RenderTarget> createRenderTarget(
const irr::core::dimension2du &dimension,
289 const std::string &name);
327 inline core::vector3df getWind() {
return m_wind->getWind();}
333 const core::vector3df& getSunDirection()
const {
return m_sun_direction; };
335 void setSunDirection(
const core::vector3df &SunPos)
337 m_sun_direction = SunPos;
340 video::SColorf getSunColor()
const {
return m_suncolor; }
342 void setSunColor(
const video::SColorf &col)
347 GLuint getRenderTargetTexture(TypeRTT which);
348 GLuint getDepthStencilTexture();
350 void resetDebugModes();
352 void toggleSSAOViz() { m_ssaoviz = !m_ssaoviz; }
354 bool getSSAOViz() {
return m_ssaoviz; }
356 void toggleShadowViz() { m_shadowviz = !m_shadowviz; }
358 bool getShadowViz() {
return m_shadowviz; }
360 void toggleBoundingBoxesViz() { m_boundingboxesviz = !m_boundingboxesviz; }
362 void toggleRenderNetworkDebug() { m_render_nw_debug = !m_render_nw_debug; }
364 bool getRenderNetworkDebug()
const {
return m_render_nw_debug; }
366 void renderNetworkDebug();
368 bool getBoundingBoxesViz() {
return m_boundingboxesviz; }
372 void addSceneComplexity(
int complexity)
377 bool isRecording()
const {
return m_recording; }
379 void setRecording(
bool val);
381 std::vector<LightNode *> getLights() {
return m_lights; }
383 void addGlowingNode(scene::ISceneNode *n,
float r = 1.0f,
float g = 1.0f,
389 void clearGlowingNodes() {
m_renderer->clearGlowingNodes(); }
391 void addForcedBloomNode(scene::ISceneNode *n,
float power = 1)
397 m_forcedbloom.push_back(dat);
400 void clearForcedBloom() { m_forcedbloom.clear(); }
402 const std::vector<BloomData> &getForcedBloom()
const
404 return m_forcedbloom;
407 void clearBackgroundNodes() { m_background.clear(); }
409 void addBackgroundNode(scene::ISceneNode *
const n)
411 m_background.push_back(n);
414 scene::ISceneNode *addLight(
const core::vector3df &pos,
float energy,
415 float radius,
float r,
float g,
float b,
417 scene::ISceneNode* parent = NULL);
424 void cleanSunInterposer();
425 void createSunInterposer();
427 void setViewMatrix(core::matrix4 matrix)
429 m_ViewMatrix = matrix; matrix.getInverse(m_InvViewMatrix);
432 const core::matrix4 &getViewMatrix()
const {
return m_ViewMatrix; }
434 const core::matrix4 &getInvViewMatrix()
const {
return m_InvViewMatrix; }
436 void setProjMatrix(core::matrix4 matrix)
438 m_ProjMatrix = matrix; matrix.getInverse(m_InvProjMatrix);
441 const core::matrix4 &getProjMatrix()
const {
return m_ProjMatrix; }
443 const core::matrix4 &getInvProjMatrix()
const {
return m_InvProjMatrix; }
445 void genProjViewMatrix()
448 m_InvProjViewMatrix = m_ProjViewMatrix;
449 m_InvProjViewMatrix.makeInverse();
452 const core::matrix4 &getProjViewMatrix()
const {
return m_ProjViewMatrix; }
454 const core::matrix4 &getInvProjViewMatrix()
const
456 return m_InvProjViewMatrix;
459 const core::vector2df &getCurrentScreenSize()
const
464 const core::dimension2du getActualScreenSize()
const
466 return m_actual_screen_size;
469 float getSSAORadius()
const
471 return m_ssao_radius;
475 void setSSAORadius(
float v)
481 float getSSAOK()
const
487 void setSSAOK(
float v)
493 float getSSAOSigma()
const
499 void setSSAOSigma(
float v)
504 std::vector<scene::IAnimatedMeshSceneNode*> getDebugMeshes()
506 return m_debug_meshes;
509 void clearDebugMesh() { m_debug_meshes.clear(); }
512 void addDebugMesh(scene::IAnimatedMeshSceneNode *node)
514 m_debug_meshes.push_back(node);
519 void onUnloadWorld();
521 void updateSplitAndLightcoordRangeFromComputeShaders(
size_t width,
524 void uploadLightingData();
527 u32 getDefaultFramebuffer()
const;
529 void handleWindowResize();
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Virtual base class for the renderer.
Definition: abstract_renderer.hpp:60
This is the base class for all cameras.
Definition: camera.hpp:49
AssetType
The various asset types (and directories) STK might request.
Definition: file_manager.hpp:63
Definition: frame_buffer.hpp:33
Definition: glwrap.hpp:56
A simple class to store video resolutions.
Definition: irr_driver.hpp:128
class that creates the irrLicht device and offers higher-level ways to manage the 3D scene
Definition: irr_driver.hpp:86
AbstractRenderer * m_renderer
Renderer.
Definition: irr_driver.hpp:99
void reset()
Called before a race is started, after all cameras are set up.
Definition: irr_driver.cpp:259
void updateConfigIfRelevant()
If the position of the window should be remembered, store it in the config file.
Definition: irr_driver.cpp:296
int m_scene_complexity
Store if the scene is complex (based on polycount, etc)
Definition: irr_driver.hpp:157
Wind * m_wind
Wind.
Definition: irr_driver.hpp:102
bool OnEvent(const irr::SEvent &event)
This is not really used to process events, it's only used to shut down irrLicht's chatty logging unti...
Definition: irr_driver.cpp:2339
scene::ISceneNode * addWaterNode(scene::IMesh *mesh, scene::IMesh **welded, float wave_height, float wave_speed, float wave_length)
Converts the mesh into a water scene node.
Definition: irr_driver.cpp:1326
const irr::video::SColor & getClearColor() const
Returns the color to clear the back buffer.
Definition: irr_driver.hpp:293
scene::IMesh * createTexturedQuadMesh(const video::SMaterial *material, const double w, const double h)
Creates a quad mesh buffer with a given width and height (z coordinate is 0).
Definition: irr_driver.cpp:1559
IrrDriver()
The constructor creates the irrlicht device.
Definition: irr_driver.cpp:173
scene::IParticleSystemSceneNode * addParticleNode(bool default_emitter=true)
Adds a particle scene node.
Definition: irr_driver.cpp:1417
core::array< video::IRenderTarget > m_mrt
The main MRT setup.
Definition: irr_driver.hpp:107
void setClearbackBufferColor(irr::video::SColor color)
Sets the color to use when clearing the back buffer.
Definition: irr_driver.hpp:296
void removeTexture(video::ITexture *t)
Removes a texture from irrlicht's texture cache.
Definition: irr_driver.cpp:1638
bool moveWindow(int x, int y)
Moves the STK main window to coordinates (x,y)
Definition: irr_driver.cpp:1008
scene::ISceneNode * addBillboard(const core::dimension2d< f32 > size, const std::string &tex_name, scene::ISceneNode *parent=NULL)
Adds a billboard node to scene.
Definition: irr_driver.cpp:1481
unsigned int getRealTime()
Returns the current real time, which might not be 0 at start of the application.
Definition: irr_driver.cpp:2510
void removeMeshFromCache(scene::IMesh *mesh)
Removes a mesh from the mesh cache, freeing the memory.
Definition: irr_driver.cpp:1629
irr::video::SColor m_clear_color
Background colour to reset a buffer.
Definition: irr_driver.hpp:173
void setAllMaterialFlags(scene::IMesh *mesh) const
Sets the material flags in this mesh depending on the settings in material_manager.
Definition: irr_driver.cpp:1294
core::matrix4 m_ViewMatrix
Matrixes used in several places stored here to avoid recomputation.
Definition: irr_driver.hpp:110
scene::IMesh * getMesh(const std::string &name)
Loads a non-animated mesh and returns a pointer to it.
Definition: irr_driver.cpp:1277
gui::IGUIEnvironment * m_gui_env
Irrlicht gui environment.
Definition: irr_driver.hpp:93
scene::IAnimatedMesh * getAnimatedMesh(const std::string &name)
Loads an animated mesh and returns a pointer to it.
Definition: irr_driver.cpp:1233
gui::IGUIFont * m_race_font
Irrlicht race font.
Definition: irr_driver.hpp:97
void giveBoost(unsigned int cam_index)
Use motion blur for a short time.
Definition: irr_driver.hpp:325
const core::dimension2d< u32 > & getFrameSize() const
Returns the frame size.
Definition: irr_driver.cpp:2504
void update(float dt, bool loading=false)
Update, called once per frame.
Definition: irr_driver.cpp:2129
scene::IMeshSceneNode * addOctTree(scene::IMesh *mesh)
Adds a mesh that will be optimised using an oct tree.
Definition: irr_driver.cpp:1362
video::IVideoDriver * m_video_driver
Irrlicht video driver.
Definition: irr_driver.hpp:95
video::IVideoDriver * getVideoDriver() const
Returns the irrlicht video driver.
Definition: irr_driver.hpp:312
scene::ISceneNode * addSphere(float radius, const video::SColor &color=video::SColor(128, 255, 255, 255))
Adds a sphere with a given radius and color.
Definition: irr_driver.cpp:1372
scene::ISceneManager * m_scene_manager
Irrlicht scene manager.
Definition: irr_driver.hpp:91
void displayFPS()
Displays the FPS on the screen.
Definition: irr_driver.cpp:1862
~IrrDriver()
Destructor - removes the irrlicht device.
Definition: irr_driver.cpp:225
video::ITexture * getTexture(FileManager::AssetType type, const std::string &filename)
Loads a texture from a file and returns the texture object.
Definition: irr_driver.cpp:1740
void createListOfVideoModes()
Gets a list of supported video modes from the irrlicht device.
Definition: irr_driver.cpp:360
const std::vector< VideoMode > & getVideoModes() const
Returns a list of all video modes supports by the graphics card.
Definition: irr_driver.hpp:303
void grabAllTextures(const scene::IMesh *mesh)
Appends a pointer to each texture used in this mesh to the vector.
Definition: irr_driver.cpp:1761
void cancelResChange()
Call this to roll back to the previous resolution if a resolution switch attempt goes bad.
Definition: irr_driver.cpp:1188
void doScreenShot()
Requess a screenshot from irrlicht, and save it in a file.
Definition: irr_driver.cpp:2024
void initDevice()
This creates the actualy OpenGL device.
Definition: irr_driver.cpp:391
void changeResolution(const int w, const int h, const bool fullscreen)
Call to change resolution.
Definition: irr_driver.cpp:1023
void displayStoryModeTimer()
Displays the timer for Story Mode on the screen.
Definition: irr_driver.cpp:1982
void applyResolutionSettings(bool recreate_device)
Internal method that applies the resolution in user settings.
Definition: irr_driver.cpp:1048
const SHCoefficients * getSHCoefficients()
Returns a pointer to the spherical harmonics coefficients.
Definition: irr_driver.hpp:331
enum IrrDriver::@6 m_resolution_changing
Flag to indicate if a resolution change is pending (which will be acted upon in the next update).
IrrlichtDevice * getDevice() const
Returns the irrlicht device.
Definition: irr_driver.hpp:309
scene::ISceneNode * addSkyBox(const std::vector< video::ITexture * > &texture_names, const std::vector< video::ITexture * > &spherical_harmonics_textures)
Adds a skybox using.
Definition: irr_driver.cpp:1694
void setAmbientLight(const video::SColorf &light, bool force_SH_computation=true)
Sets the ambient light.
Definition: irr_driver.cpp:1840
void dropAllTextures(const scene::IMesh *mesh)
Appends a pointer to each texture used in this mesh to the vector.
Definition: irr_driver.cpp:1790
scene::IMesh * createQuadMesh(const video::SMaterial *material=NULL, bool create_one_quad=false)
Creates a quad mesh with a given material.
Definition: irr_driver.cpp:1516
void removeCameraSceneNode(scene::ICameraSceneNode *camera)
Removes a camera.
Definition: irr_driver.cpp:1725
gui::IGUIEnvironment * getGUI() const
Returns the gui environment, used to add widgets to a screen.
Definition: irr_driver.hpp:318
void printRenderStats()
Prints statistics about rendering, e.g.
Definition: irr_driver.cpp:1212
scene::ICameraSceneNode * addCameraSceneNode()
Adds a camera to the scene.
Definition: irr_driver.cpp:1713
scene::ISceneManager * getSceneManager() const
Returns the irrlicht scene manager.
Definition: irr_driver.hpp:315
bool m_pointer_shown
Whether the mouse cursor is currently shown.
Definition: irr_driver.hpp:154
scene::IAnimatedMeshSceneNode * addAnimatedMesh(scene::IAnimatedMesh *mesh, const std::string &debug_name, scene::ISceneNode *parent=NULL, std::shared_ptr< GE::GERenderInfo > render_info=nullptr)
Adds an animated mesh to the scene.
Definition: irr_driver.cpp:1649
scene::ISceneNode * addMesh(scene::IMesh *mesh, const std::string &debug_name, scene::ISceneNode *parent=NULL, std::shared_ptr< GE::GERenderInfo > render_info=nullptr)
Adds a static mesh to scene.
Definition: irr_driver.cpp:1427
void removeNode(scene::ISceneNode *node)
Removes a scene node from the scene.
Definition: irr_driver.cpp:1620
IrrlichtDevice * m_device
The irrlicht device.
Definition: irr_driver.hpp:89
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
manages smoke particle effects
Definition: per_camera_node.hpp:46
Definition: render_target.hpp:42
Definition: sp_dynamic_draw_call.hpp:42
Definition: irr_driver.hpp:138
Definition: spherical_harmonics.hpp:33