From efe4f0baddf10124581e4fcb88d55a52838b06a1 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 9 Sep 2012 17:51:10 +0200 Subject: Refactoring in src/common - refactored CInstanceManager and some headers - removed old headers --- src/graphics/engine/lightning.h | 2 +- src/graphics/engine/pyro.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/lightning.h b/src/graphics/engine/lightning.h index e34eb3b..af389f2 100644 --- a/src/graphics/engine/lightning.h +++ b/src/graphics/engine/lightning.h @@ -22,7 +22,7 @@ #pragma once -#include "common/misc.h" +#include "common/event.h" #include "math/vector.h" diff --git a/src/graphics/engine/pyro.h b/src/graphics/engine/pyro.h index 5d2ca63..c0c0144 100644 --- a/src/graphics/engine/pyro.h +++ b/src/graphics/engine/pyro.h @@ -22,7 +22,8 @@ #pragma once -#include "common/misc.h" +#include "common/event.h" +#include "common/global.h" #include "graphics/engine/engine.h" #include "object/object.h" -- cgit v1.2.3-1-g7c22 From 479a67a731be5a5e8035ea7acce0344c7c605814 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Mon, 10 Sep 2012 23:29:38 +0200 Subject: Merge with changes from Zaba999 fork. --- src/graphics/engine/camera.cpp | 61 ------------------------------------------ 1 file changed, 61 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index f077fff..78ab808 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -28,67 +28,6 @@ #include "object/object.h" #include "physics/physics.h" - -// TODO temporary stubs for CObject and CPhysics - -void CObject::SetTransparency(float) -{ -} - -CObject* CObject::GetFret() -{ - return nullptr; -} - -CObject* CObject::GetPower() -{ - return nullptr; -} - -CObject* CObject::GetTruck() -{ - return nullptr; -} - -ObjectType CObject::GetType() -{ - return OBJECT_NULL; -} - -void CObject::SetGunGoalH(float) -{ -} - -void CObject::GetGlobalSphere(Math::Vector &pos, float &radius) -{ -} - -float CObject::GetAngleY(int) -{ - return 0.0f; -} - -Math::Vector CObject::GetPosition(int) -{ - return Math::Vector(); -} - -void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV, - Math::Vector &lookat, Math::Vector &upVec, - Gfx::CameraType type) -{ -} - -CPhysics* CObject::GetPhysics() -{ - return nullptr; -} - -bool CPhysics::GetLand() -{ - return false; -} - //! Changes the level of transparency of an object and objects transported (battery & cargo) void SetTransparency(CObject* obj, float value) { -- cgit v1.2.3-1-g7c22 From e57be247c2ddce796fd64e9f3c1b3bfa4759b74a Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Mon, 10 Sep 2012 23:39:22 +0200 Subject: commented new part in cmakelist and reverted stubs in camera.cpp. Will be commited later after implementation is finished in dev-object branch. --- src/graphics/engine/camera.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 78ab808..034c5ea 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -28,6 +28,67 @@ #include "object/object.h" #include "physics/physics.h" + +// TODO temporary stubs for CObject and CPhysics + +void CObject::SetTransparency(float) +{ +} + +CObject* CObject::GetFret() +{ + return nullptr; +} + +CObject* CObject::GetPower() +{ + return nullptr; +} + +CObject* CObject::GetTruck() +{ + return nullptr; +} + +ObjectType CObject::GetType() +{ + return OBJECT_NULL; +} + +void CObject::SetGunGoalH(float) +{ +} + +void CObject::GetGlobalSphere(Math::Vector &pos, float &radius) +{ +} + +float CObject::GetAngleY(int) +{ + return 0.0f; +} + +Math::Vector CObject::GetPosition(int) +{ + return Math::Vector(); +} + +void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV, + Math::Vector &lookat, Math::Vector &upVec, + Gfx::CameraType type) +{ +} + +CPhysics* CObject::GetPhysics() +{ + return nullptr; +} + +bool CPhysics::GetLand() +{ + return false; +} + //! Changes the level of transparency of an object and objects transported (battery & cargo) void SetTransparency(CObject* obj, float value) { @@ -1658,3 +1719,4 @@ Math::Vector Gfx::CCamera::ExcludeObject(Math::Vector eye, Math::Vector lookat, return eye;*/ } + -- cgit v1.2.3-1-g7c22 From 1bb1eb7b8790d52fea2296b06c1d46730946fc53 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Tue, 11 Sep 2012 23:11:34 +0200 Subject: half of task compile. --- src/graphics/engine/camera.cpp | 61 ------------------------------------------ 1 file changed, 61 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 034c5ea..c374ed0 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -28,67 +28,6 @@ #include "object/object.h" #include "physics/physics.h" - -// TODO temporary stubs for CObject and CPhysics - -void CObject::SetTransparency(float) -{ -} - -CObject* CObject::GetFret() -{ - return nullptr; -} - -CObject* CObject::GetPower() -{ - return nullptr; -} - -CObject* CObject::GetTruck() -{ - return nullptr; -} - -ObjectType CObject::GetType() -{ - return OBJECT_NULL; -} - -void CObject::SetGunGoalH(float) -{ -} - -void CObject::GetGlobalSphere(Math::Vector &pos, float &radius) -{ -} - -float CObject::GetAngleY(int) -{ - return 0.0f; -} - -Math::Vector CObject::GetPosition(int) -{ - return Math::Vector(); -} - -void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV, - Math::Vector &lookat, Math::Vector &upVec, - Gfx::CameraType type) -{ -} - -CPhysics* CObject::GetPhysics() -{ - return nullptr; -} - -bool CPhysics::GetLand() -{ - return false; -} - //! Changes the level of transparency of an object and objects transported (battery & cargo) void SetTransparency(CObject* obj, float value) { -- cgit v1.2.3-1-g7c22 From 34d7dcf3be24de04b2b9c64edb2666439b353a5b Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 12 Sep 2012 23:43:04 +0200 Subject: Simulation timestamps and input bindings - added new simulation time calculations in CApplication - added simulation frame updates - rewritten old input binding code and input state tracking --- src/graphics/engine/engine.cpp | 30 +++++------------------------- src/graphics/engine/engine.h | 9 +-------- 2 files changed, 6 insertions(+), 33 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 068687a..d368aa6 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -357,22 +357,22 @@ bool Gfx::CEngine::ProcessEvent(const Event &event) } } } - else if (event.type == EVENT_FRAME) - { - m_highlightTime += event.rTime; - } // By default, pass on all events return true; } -void Gfx::CEngine::FrameMove(float rTime) +void Gfx::CEngine::FrameUpdate() { + float rTime = m_app->GetRelTime(); + m_lightMan->UpdateProgression(rTime); m_particle->FrameParticle(rTime); ComputeDistance(); UpdateGeometry(); + m_highlightTime = m_app->GetAbsTime(); + if (m_groundMark.draw) { if (m_groundMark.phase == Gfx::ENG_GR_MARK_PHASE_INC) // growing? @@ -402,16 +402,6 @@ void Gfx::CEngine::FrameMove(float rTime) } } } - - if (m_sound == nullptr) - m_sound = static_cast( m_iMan->SearchInstance(CLASS_SOUND) ); - - m_sound->FrameMove(rTime); -} - -void Gfx::CEngine::StepSimulation(float rTime) -{ - m_app->StepSimulation(rTime); } bool Gfx::CEngine::WriteScreenShot(const std::string& fileName, int width, int height) @@ -2726,16 +2716,6 @@ int Gfx::CEngine::GetEditIndentValue() return m_editIndentValue; } -void Gfx::CEngine::SetSpeed(float speed) -{ - m_speed = speed; -} - -float Gfx::CEngine::GetSpeed() -{ - return m_speed; -} - void Gfx::CEngine::SetTracePrecision(float factor) { m_tracePrecision = factor; diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 705c83a..1ce93a3 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -664,9 +664,7 @@ public: bool ProcessEvent(const Event& event); //! Called once per frame, the call is the entry point for animating the scene - void FrameMove(float rTime); - //! Evolved throughout the game - void StepSimulation(float rTime); + void FrameUpdate(); //! Writes a screenshot containing the current frame @@ -1098,11 +1096,6 @@ public: int GetEditIndentValue(); //@} - //@{ - //! Management of game speed - void SetSpeed(float speed); - float GetSpeed(); - //@{ //! Management of precision of robot tracks void SetTracePrecision(float factor); -- cgit v1.2.3-1-g7c22 From 6a0d150539897ec65ccc161305db48de10ea35ba Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Sep 2012 10:38:08 +0200 Subject: Interface works - removed mock of CInterface and fixed event passing to CRobotMain - changed texture names from tga and bmp to png - UI now works but interaction is still broken --- src/graphics/engine/engine.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index d368aa6..af209bd 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -37,6 +37,7 @@ #include "graphics/engine/water.h" #include "math/geometry.h" #include "sound/sound.h" +#include "ui/interface.h" // Initial size of various vectors @@ -87,15 +88,6 @@ Gfx::EngineObjLevel4::EngineObjLevel4(bool used, Gfx::EngineTriangleType type, c vertices.reserve(LEVEL4_VERTEX_PREALLOCATE_COUNT); } - - -// TODO: temporary stub for CInterface -class CInterface -{ -public: - void Draw() {} -}; - Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app) { m_iMan = iMan; @@ -3124,7 +3116,7 @@ void Gfx::CEngine::DrawInterface() m_device->SetTransform(Gfx::TRANSFORM_WORLD, m_matWorldInterface); // Draw the entire interface - CInterface* interface = static_cast( m_iMan->SearchInstance(CLASS_INTERFACE) ); + Ui::CInterface* interface = static_cast( m_iMan->SearchInstance(CLASS_INTERFACE) ); if (interface != nullptr) interface->Draw(); @@ -3834,6 +3826,8 @@ void Gfx::CEngine::DrawMouseSprite(Math::Point pos, Math::Point size, int icon) Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), normal, Math::Point(u2, v1)) }; + m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, false); + m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false); m_device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); AddStatisticTriangle(2); } -- cgit v1.2.3-1-g7c22 From 2e21435f432191afa1b0f609daa8ca9d4cde1e93 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Sep 2012 20:00:25 +0200 Subject: Some memory leaks fixed --- src/graphics/engine/text.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 19ef57b..8fc8709 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -785,18 +785,20 @@ Gfx::CharTexture Gfx::CText::CreateCharTexture(Gfx::UTF8Char ch, Gfx::CachedFont data.surface = nullptr; - SDL_FreeSurface(textSurface); - SDL_FreeSurface(textureSurface); - if (! tex.Valid()) { m_error = "Texture create error"; return texture; } + else + { + texture.id = tex.id; + texture.texSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textureSurface->w, textureSurface->h)); + texture.charSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textSurface->w, textSurface->h)); + } - texture.id = tex.id; - texture.texSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textureSurface->w, textureSurface->h)); - texture.charSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textSurface->w, textSurface->h)); + SDL_FreeSurface(textSurface); + SDL_FreeSurface(textureSurface); return texture; } -- cgit v1.2.3-1-g7c22 From 844e11db4f394004258cdca8f8fd8bc95c41a985 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Mon, 17 Sep 2012 20:47:27 +0200 Subject: changes needeto to cimpile on windows. --- src/graphics/engine/camera.cpp | 4 ++-- src/graphics/engine/camera.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index c374ed0..80757c4 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -202,12 +202,12 @@ void Gfx::CCamera::Init(Math::Vector eye, Math::Vector lookat, float delay) } -void Gfx::CCamera::SetObject(CObject* object) +void Gfx::CCamera::SetControllingObject(CObject* object) { m_cameraObj = object; } -CObject* Gfx::CCamera::GetObject() +CObject* Gfx::CCamera::GetControllingObject() { return m_cameraObj; } diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h index 1a82f9f..f2022f7 100644 --- a/src/graphics/engine/camera.h +++ b/src/graphics/engine/camera.h @@ -136,8 +136,8 @@ class CCamera { void Init(Math::Vector eye, Math::Vector lookat, float delay); //! Sets the object controlling the camera - void SetObject(CObject* object); - CObject* GetObject(); + void SetControllingObject(CObject* object); + CObject* GetControllingObject(); //! Change the type of camera void SetType(Gfx::CameraType type); -- cgit v1.2.3-1-g7c22 From 4b67386a697c27186b6eb4809bea9547372dacd7 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 17 Sep 2012 23:41:53 +0200 Subject: Change of background image handling - removed old 4 quarter backgrounds - fixes in texture loading - other minor fixes --- src/graphics/engine/engine.cpp | 153 +++++++---------------------------------- src/graphics/engine/engine.h | 12 ++-- 2 files changed, 29 insertions(+), 136 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index af209bd..bd5f60f 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -139,7 +139,7 @@ Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app) m_backgroundCloudUp = Gfx::Color(); m_backgroundCloudDown = Gfx::Color(); m_backgroundFull = false; - m_backgroundQuarter = false; + m_backgroundScale = Math::Point(1.0f, 1.0f); m_overFront = true; m_overColor = Gfx::Color(); m_overMode = ENG_RSTATE_TCOLOR_BLACK; @@ -330,24 +330,6 @@ bool Gfx::CEngine::ProcessEvent(const Event &event) int index = static_cast(m_mouseType); m_mouseType = static_cast( (index + 1) % Gfx::ENG_MOUSE_COUNT ); } - else if (event.key.key == KEY(F3)) - { - bool bq = !m_backgroundQuarter; - SetBackground(bq ? "geneda.png" : "", Gfx::Color(), Gfx::Color(), Gfx::Color(), Gfx::Color(), true, bq); - } - else if (event.key.key == KEY(F4)) - { - m_skyMode = !m_skyMode; - if (! m_skyMode) - { - m_backgroundColorDown = Gfx::Color(0.2f, 0.2f, 0.2f); - m_backgroundColorUp = Gfx::Color(0.8f, 0.8f, 0.8f); - } - else - { - m_backgroundColorDown = m_backgroundColorUp = Gfx::Color(0.0f, 0.0f, 0.0f); - } - } } // By default, pass on all events @@ -2148,26 +2130,10 @@ bool Gfx::CEngine::LoadAllTextures() LoadTexture("effect02.png"); LoadTexture("map.png"); - if (m_backgroundQuarter) // image into 4 pieces? - { - if (! m_backgroundName.empty()) - { - for (int i = 0; i < 4; i++) - m_backgroundQuarterTexs[i] = LoadTexture(m_backgroundQuarterNames[i]); - } - else - { - for (int i = 0; i < 4; i++) - m_backgroundQuarterTexs[i].SetInvalid(); - } - } + if (! m_backgroundName.empty()) + m_backgroundTex = LoadTexture(m_backgroundName); else - { - if (! m_backgroundName.empty()) - m_backgroundFullTex = LoadTexture(m_backgroundName); - else - m_backgroundFullTex.SetInvalid(); - } + m_backgroundTex.SetInvalid(); if (! m_foregroundName.empty()) m_foregroundTex = LoadTexture(m_foregroundName); @@ -2446,29 +2412,14 @@ float Gfx::CEngine::GetFogStart(int rank) return m_fogStart[rank]; } -std::string QuarterName(const std::string& name, int quarter) -{ - size_t pos = name.find('.'); - if (pos == std::string::npos) - return name; - - return name.substr(0, pos) + std::string(1, static_cast('a' + quarter)) + name.substr(pos); -} - void Gfx::CEngine::SetBackground(const std::string& name, Gfx::Color up, Gfx::Color down, Gfx::Color cloudUp, Gfx::Color cloudDown, - bool full, bool quarter) + bool full, Math::Point scale) { - if (m_backgroundFullTex.Valid()) + if (m_backgroundTex.Valid()) { - DeleteTexture(m_backgroundFullTex); - m_backgroundFullTex.SetInvalid(); - } - - for (int i = 0; i < 4; i++) - { - DeleteTexture(m_backgroundQuarterTexs[i]); - m_backgroundQuarterTexs[i].SetInvalid(); + DeleteTexture(m_backgroundTex); + m_backgroundTex.SetInvalid(); } m_backgroundName = name; @@ -2477,28 +2428,15 @@ void Gfx::CEngine::SetBackground(const std::string& name, Gfx::Color up, Gfx::Co m_backgroundCloudUp = cloudUp; m_backgroundCloudDown = cloudDown; m_backgroundFull = full; - m_backgroundQuarter = quarter; + m_backgroundScale = scale; if (! m_backgroundName.empty()) - { - if (m_backgroundQuarter) - { - for (int i = 0; i < 4; i++) - { - m_backgroundQuarterNames[i] = QuarterName(name, i); - m_backgroundQuarterTexs[i] = LoadTexture(m_backgroundQuarterNames[i]); - } - } - else - { - m_backgroundFullTex = LoadTexture(m_backgroundName); - } - } + m_backgroundTex = LoadTexture(m_backgroundName); } void Gfx::CEngine::GetBackground(std::string& name, Gfx::Color& up, Gfx::Color& down, Gfx::Color& cloudUp, Gfx::Color& cloudDown, - bool &full, bool &quarter) + bool &full, Math::Point& scale) { name = m_backgroundName; up = m_backgroundColorUp; @@ -2506,7 +2444,7 @@ void Gfx::CEngine::GetBackground(std::string& name, Gfx::Color& up, Gfx::Color& cloudUp = m_backgroundCloudUp; cloudDown = m_backgroundCloudDown; full = m_backgroundFull; - quarter = m_backgroundQuarter; + scale = m_backgroundScale; } void Gfx::CEngine::SetForegroundName(const std::string& name) @@ -3477,10 +3415,16 @@ void Gfx::CEngine::DrawBackgroundGradient(const Gfx::Color& up, const Gfx::Color AddStatisticTriangle(2); } -// Status: PART_TESTED -void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, const Gfx::Texture &tex) +// Status: TESTED, VERIFIED +void Gfx::CEngine::DrawBackgroundImage() { - Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal + Math::Point p1, p2; + p1.x = 0.0f; + p1.y = 0.0f; + p2.x = 1.0f; + p2.y = 1.0f; + +Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal float u1, u2, v1, v2; if (m_backgroundFull) @@ -3489,14 +3433,6 @@ void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, co v1 = 0.0f; u2 = 1.0f; v2 = 1.0f; - - if (m_backgroundQuarter) - { - u1 += 0.5f/512.0f; - v1 += 0.5f/384.0f; - u2 -= 0.5f/512.0f; - v2 -= 0.5f/384.0f; - } } else { @@ -3513,7 +3449,10 @@ void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, co v2 = v1+h; } - SetTexture(tex); + u2 *= m_backgroundScale.x; + v2 *= m_backgroundScale.y; + + SetTexture(m_backgroundTex); SetState(Gfx::ENG_RSTATE_OPAQUE_TEXTURE | Gfx::ENG_RSTATE_WRAP); m_device->SetTransform(Gfx::TRANSFORM_VIEW, m_matViewInterface); @@ -3532,48 +3471,6 @@ void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, co AddStatisticTriangle(2); } -// Status: TESTED, VERIFIED -void Gfx::CEngine::DrawBackgroundImage() -{ - Math::Point p1, p2; - std::string name; - - if (m_backgroundQuarter) - { - p1.x = 0.0f; - p1.y = 0.5f; - p2.x = 0.5f; - p2.y = 1.0f; - DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[0]); - - p1.x = 0.5f; - p1.y = 0.5f; - p2.x = 1.0f; - p2.y = 1.0f; - DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[1]); - - p1.x = 0.0f; - p1.y = 0.0f; - p2.x = 0.5f; - p2.y = 0.5f; - DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[2]); - - p1.x = 0.5f; - p1.y = 0.0f; - p2.x = 1.0f; - p2.y = 0.5f; - DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[3]); - } - else - { - p1.x = 0.0f; - p1.y = 0.0f; - p2.x = 1.0f; - p2.y = 1.0f; - DrawBackgroundImageQuarter(p1, p2, m_backgroundFullTex); - } -} - void Gfx::CEngine::DrawPlanet() { if (! m_planet->PlanetExist()) return; diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 1ce93a3..01a1dee 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -991,10 +991,10 @@ public: //! Management of the background image to use void SetBackground(const std::string& name, Gfx::Color up = Gfx::Color(), Gfx::Color down = Gfx::Color(), Gfx::Color cloudUp = Gfx::Color(), Gfx::Color cloudDown = Gfx::Color(), - bool full = false, bool quarter = false); + bool full = false, Math::Point scale = Math::Point(1.0f, 1.0f)); void GetBackground(std::string& name, Gfx::Color& up, Gfx::Color& down, Gfx::Color& cloudUp, Gfx::Color& cloudDown, - bool& full, bool& quarter); + bool& full, Math::Point& scale); //@} //! Specifies the name of foreground texture @@ -1154,8 +1154,6 @@ protected: void DrawBackground(); //! Draws the gradient background void DrawBackgroundGradient(const Gfx::Color& up, const Gfx::Color& down); - //! Draws a portion of the image background - void DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, const Gfx::Texture &tex); //! Draws the image background void DrawBackgroundImage(); //! Draws all the planets @@ -1290,11 +1288,9 @@ protected: bool m_firstGroundSpot; int m_secondTexNum; bool m_backgroundFull; - bool m_backgroundQuarter; + Math::Point m_backgroundScale; std::string m_backgroundName; - std::string m_backgroundQuarterNames[4]; - Gfx::Texture m_backgroundFullTex; - Gfx::Texture m_backgroundQuarterTexs[4]; + Gfx::Texture m_backgroundTex; Gfx::Color m_backgroundColorUp; Gfx::Color m_backgroundColorDown; Gfx::Color m_backgroundCloudUp; -- cgit v1.2.3-1-g7c22 From a397922e8d53c6f7ff469d38e5139fd003c705b5 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Tue, 18 Sep 2012 00:01:00 +0200 Subject: warnings fight in progress. --- src/graphics/engine/particle.cpp | 2 +- src/graphics/engine/particle.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp index 37a3975..c177deb 100644 --- a/src/graphics/engine/particle.cpp +++ b/src/graphics/engine/particle.cpp @@ -200,7 +200,7 @@ void Gfx::CParticle::DrawParticle(int sheet) // TODO! } -bool Gfx::CParticle::WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur) +bool Gfx::CParticle::WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur) { GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n"); // TODO! diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h index c53aea5..f78e242 100644 --- a/src/graphics/engine/particle.h +++ b/src/graphics/engine/particle.h @@ -306,7 +306,7 @@ public: void FrameParticle(float rTime); void DrawParticle(int sheet); - bool WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur); + bool WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur); protected: void DeleteRank(int rank); -- cgit v1.2.3-1-g7c22 From 10c9d92cd2581448d76548efb20957a7a1c24478 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 19 Sep 2012 21:23:42 +0200 Subject: Mouse wheel events, motion vectors - added mouse wheel events - added motion vectors to CRobotMain - other minor changes in event.h --- src/graphics/engine/camera.cpp | 34 ++++++++++++++++------------------ src/graphics/engine/camera.h | 2 +- 2 files changed, 17 insertions(+), 19 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 80757c4..cd7e307 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -1002,11 +1002,9 @@ bool Gfx::CCamera::EventProcess(const Event &event) EventMouseMove(event); break; - // TODO: mouse wheel event - /*case EVENT_KEY_DOWN: - if ( event.param == VK_WHEELUP ) EventMouseWheel(+1); - if ( event.param == VK_WHEELDOWN ) EventMouseWheel(-1); - break;*/ + case EVENT_MOUSE_WHEEL: + EventMouseWheel(event.mouseWheel.dir); + break; default: break; @@ -1020,17 +1018,17 @@ bool Gfx::CCamera::EventMouseMove(const Event &event) return true; } -void Gfx::CCamera::EventMouseWheel(int dir) +void Gfx::CCamera::EventMouseWheel(WheelDirection dir) { if (m_type == Gfx::CAM_TYPE_BACK) { - if (dir > 0) + if (dir == WHEEL_UP) { m_backDist -= 8.0f; if (m_backDist < m_backMin) m_backDist = m_backMin; } - if (dir < 0) + else if (dir == WHEEL_DOWN) { m_backDist += 8.0f; if (m_backDist > 200.0f) @@ -1041,13 +1039,13 @@ void Gfx::CCamera::EventMouseWheel(int dir) if ( m_type == Gfx::CAM_TYPE_FIX || m_type == Gfx::CAM_TYPE_PLANE ) { - if (dir > 0) + if (dir == WHEEL_UP) { m_fixDist -= 8.0f; if (m_fixDist < 10.0f) m_fixDist = 10.0f; } - if (dir < 0) + else if (dir == WHEEL_DOWN) { m_fixDist += 8.0f; if (m_fixDist > 200.0f) @@ -1057,13 +1055,13 @@ void Gfx::CCamera::EventMouseWheel(int dir) if ( m_type == Gfx::CAM_TYPE_VISIT ) { - if (dir > 0) + if (dir == WHEEL_UP) { m_visitDist -= 8.0f; if (m_visitDist < 20.0f) m_visitDist = 20.0f; } - if (dir < 0) + else if (dir == WHEEL_DOWN) { m_visitDist += 8.0f; if (m_visitDist > 200.0f) @@ -1184,19 +1182,19 @@ bool Gfx::CCamera::EventFrameFree(const Event &event) m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDirV * event.rTime * factor * m_speed); // Up/Down - m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, event.axeY * event.rTime * factor * m_speed); + m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, event.motionInput.y * event.rTime * factor * m_speed); // Left/Right if ( event.keyState & KS_CONTROL ) { - if ( event.axeX < 0.0f ) - m_eyePt = Math::LookatPoint(m_eyePt, m_directionH + Math::PI / 2.0f, m_directionV, -event.axeX * event.rTime * factor * m_speed); - if ( event.axeX > 0.0f ) - m_eyePt = Math::LookatPoint(m_eyePt, m_directionH - Math::PI / 2.0f, m_directionV, event.axeX * event.rTime * factor * m_speed); + if ( event.motionInput.x < 0.0f ) + m_eyePt = Math::LookatPoint(m_eyePt, m_directionH + Math::PI / 2.0f, m_directionV, -event.motionInput.x * event.rTime * factor * m_speed); + if ( event.motionInput.x > 0.0f ) + m_eyePt = Math::LookatPoint(m_eyePt, m_directionH - Math::PI / 2.0f, m_directionV, event.motionInput.x * event.rTime * factor * m_speed); } else { - m_directionH -= event.axeX * event.rTime * 0.7f * m_speed; + m_directionH -= event.motionInput.x * event.rTime * 0.7f * m_speed; } // PageUp/PageDown diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h index f2022f7..7a7350f 100644 --- a/src/graphics/engine/camera.h +++ b/src/graphics/engine/camera.h @@ -208,7 +208,7 @@ protected: //! Changes the camera according to the mouse moved bool EventMouseMove(const Event &event); //! Mouse wheel operation - void EventMouseWheel(int dir); + void EventMouseWheel(WheelDirection dir); //! Changes the camera according to the time elapsed bool EventFrame(const Event &event); //! Moves the point of view -- cgit v1.2.3-1-g7c22