diff --git a/src/tracks/graph.cpp b/src/tracks/graph.cpp index 5ef0876dc..b53db294f 100644 --- a/src/tracks/graph.cpp +++ b/src/tracks/graph.cpp @@ -120,7 +120,7 @@ void Graph::cleanupDebugMesh() /** Creates the actual mesh that is used by createDebugMesh() or makeMiniMap() */ void Graph::createMesh(bool show_invisible, bool enable_transparency, - const video::SColor *track_color) + const video::SColor *track_color, bool invert_x_z) { #ifndef SERVER_ONLY // The debug track will not be lighted or culled. @@ -172,6 +172,18 @@ void Graph::createMesh(bool show_invisible, bool enable_transparency, differentNodeColor(count, &this_color); // Transfer the 4 points of the current quad to the list of vertices m_all_nodes[count]->getVertices(new_v+4*i, this_color); + if (invert_x_z) + { + auto* vptr = new_v + 4 * i; + vptr[0].Pos.X = -vptr[0].Pos.X; + vptr[0].Pos.Z = -vptr[0].Pos.Z; + vptr[1].Pos.X = -vptr[1].Pos.X; + vptr[1].Pos.Z = -vptr[1].Pos.Z; + vptr[2].Pos.X = -vptr[2].Pos.X; + vptr[2].Pos.Z = -vptr[2].Pos.Z; + vptr[3].Pos.X = -vptr[3].Pos.X; + vptr[3].Pos.Z = -vptr[3].Pos.Z; + } // Set up the indices for the triangles // (note, afaik with opengl we could use quads directly, but the code @@ -244,7 +256,7 @@ void Graph::createMesh(bool show_invisible, bool enable_transparency, /** Creates the actual mesh that is used by createDebugMesh() or makeMiniMap() */ void Graph::createMeshSP(bool show_invisible, bool enable_transparency, - const video::SColor *track_color) + const video::SColor *track_color, bool invert_x_z) { #ifndef SERVER_ONLY @@ -294,6 +306,18 @@ void Graph::createMeshSP(bool show_invisible, bool enable_transparency, differentNodeColor(count, &this_color); // Transfer the 4 points of the current quad to the list of vertices m_all_nodes[count]->getSPMVertices(vertices.data() + (4 * i), this_color); + if (invert_x_z) + { + auto* vptr = vertices.data() + (4 * i); + vptr[0].m_position.X = -vptr[0].m_position.X; + vptr[0].m_position.Z = -vptr[0].m_position.Z; + vptr[1].m_position.X = -vptr[1].m_position.X; + vptr[1].m_position.Z = -vptr[1].m_position.Z; + vptr[2].m_position.X = -vptr[2].m_position.X; + vptr[2].m_position.Z = -vptr[2].m_position.Z; + vptr[3].m_position.X = -vptr[3].m_position.X; + vptr[3].m_position.Z = -vptr[3].m_position.Z; + } // Set up the indices for the triangles indices[6 * i] = 4 * i + 2; // First triangle: vertex 0, 1, 2 @@ -366,7 +390,8 @@ void Graph::createMeshSP(bool show_invisible, bool enable_transparency, */ RenderTarget* Graph::makeMiniMap(const core::dimension2du &dimension, const std::string &name, - const video::SColor &fill_color) + const video::SColor &fill_color, + bool invert_x_z) { // Skip minimap when profiling if (ProfileWorld::isNoGraphics()) return NULL; @@ -384,14 +409,14 @@ RenderTarget* Graph::makeMiniMap(const core::dimension2du &dimension, if (CVS->isGLSL()) { createMeshSP(/*show_invisible part of the track*/ false, - /*enable_transparency*/ false, - /*track_color*/ &fill_color); + /*enable_transparency*/ false, /*track_color*/&fill_color, + invert_x_z); } else { createMesh(/*show_invisible part of the track*/ false, - /*enable_transparency*/ false, - /*track_color*/ &fill_color); + /*enable_transparency*/ false, /*track_color*/&fill_color, + invert_x_z); } #endif diff --git a/src/tracks/graph.hpp b/src/tracks/graph.hpp index b1079354a..b19a7de8c 100644 --- a/src/tracks/graph.hpp +++ b/src/tracks/graph.hpp @@ -93,11 +93,13 @@ private: // ------------------------------------------------------------------------ void createMesh(bool show_invisible=true, bool enable_transparency=false, - const video::SColor *track_color=NULL); + const video::SColor *track_color=NULL, + bool invert_x_z = false); // ------------------------------------------------------------------------ void createMeshSP(bool show_invisible=true, bool enable_transparency=false, - const video::SColor *track_color=NULL); + const video::SColor *track_color=NULL, + bool invert_x_z = false); // ------------------------------------------------------------------------ void cleanupDebugMesh(); // ------------------------------------------------------------------------ @@ -143,7 +145,8 @@ public: // ------------------------------------------------------------------------ RenderTarget* makeMiniMap(const core::dimension2du &dimension, const std::string &name, - const video::SColor &fill_color); + const video::SColor &fill_color, + bool invert_x_z); // ------------------------------------------------------------------------ void mapPoint2MiniMap(const Vec3 &xyz, Vec3 *out) const; // ------------------------------------------------------------------------ diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 82bf23c50..4310abee5 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -105,6 +105,7 @@ Track::Track(const std::string &filename) m_magic_number = 0x17AC3802; #endif + m_minimap_invert_x_z = false; m_materials_loaded = false; m_filename = filename; m_root = @@ -709,6 +710,21 @@ void Track::startMusic() const */ void Track::loadArenaGraph(const XMLNode &node) { + // Determine if rotate minimap is needed for soccer mode (for blue team) + // Only need to test local player + if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) + { + for (unsigned i = 0; i < race_manager->getNumberOfKarts(); i++) + { + if (race_manager->getKartType(i) != RaceManager::KT_PLAYER) + continue; + if (race_manager->getKartInfo(i).getSoccerTeam() == + SOCCER_TEAM_BLUE) + m_minimap_invert_x_z = true; + break; + } + } + ArenaGraph* graph = new ArenaGraph(m_root+"navmesh.xml", &node); Graph::setGraph(graph); @@ -786,7 +802,15 @@ void Track::loadDriveGraph(unsigned int mode_id, const bool reverse) void Track::mapPoint2MiniMap(const Vec3 &xyz, Vec3 *draw_at) const { - Graph::get()->mapPoint2MiniMap(xyz, draw_at); + if (m_minimap_invert_x_z) + { + Vec3 invert = xyz; + invert.setX(-xyz.x()); + invert.setZ(-xyz.z()); + Graph::get()->mapPoint2MiniMap(invert, draw_at); + } + else + Graph::get()->mapPoint2MiniMap(xyz, draw_at); draw_at->setX(draw_at->getX() * m_minimap_x_scale); draw_at->setY(draw_at->getY() * m_minimap_y_scale); } @@ -1115,7 +1139,9 @@ void Track::loadMinimap() m_mini_map_size = World::getWorld()->getRaceGUI()->getMiniMapSize(); //Use twice the size of the rendered minimap to reduce significantly aliasing - m_render_target = Graph::get()->makeMiniMap(m_mini_map_size*2, "minimap::" + m_ident, video::SColor(127, 255, 255, 255)); + m_render_target = Graph::get()->makeMiniMap(m_mini_map_size * 2, + "minimap::" + m_ident, video::SColor(127, 255, 255, 255), + m_minimap_invert_x_z); if (!m_render_target) return; core::dimension2du mini_map_texture_size = m_render_target->getTextureSize(); diff --git a/src/tracks/track.hpp b/src/tracks/track.hpp index e4547d592..d91f4ef55 100644 --- a/src/tracks/track.hpp +++ b/src/tracks/track.hpp @@ -365,6 +365,8 @@ private: float m_displacement_speed; int m_physical_object_uid; + bool m_minimap_invert_x_z; + /** The levels for color correction * m_color_inlevel(black, gamma, white) * m_color_outlevel(black, white)*/