From 4543f6ab5eeba3877c0ac93e8e3a9dc753a35b77 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Thu, 15 Oct 2009 23:51:41 +0000 Subject: [PATCH] Ported the display of karts in the minimap to irr 1.6 (note that the speedometer display is also ported, but does not work atm due to limitations of irr 1.6 ... or incorrect usage ;) ). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4120 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/states_screens/race_gui.cpp | 85 ++++++++++++++++++++------------- src/states_screens/race_gui.hpp | 3 +- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 7d57b5a30..be0953547 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -114,15 +114,17 @@ void RaceGUI::createMarkerTexture() core::vector2df center((float)((m_marker_rendered_size>>1)+i*m_marker_rendered_size), (float)(m_marker_rendered_size>>1) ); int count = kp->getShape(); - core::array vertices; - createRegularPolygon(count, (float)radius, center,&vertices); + //core::array vertices; + video::S3DVertex *vertices = new video::S3DVertex[count+1]; + unsigned short int *index = new unsigned short int[count+1]; + video::SColor color = kp->getColor(); + createRegularPolygon(count, (float)radius, center, color, + vertices, index); - video::SColor color = kp->getColor(); - core::array colors; - colors.push_back(color); -#ifdef IRRLICHT_HAS_SUPERTUXKART_POLYGON - irr_driver->getVideoDriver()->draw2DPolygon(vertices, &colors); -#endif + irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, count, + index, count-2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN); + delete vertices; + delete index; } m_marker = rttProvider.renderToTexture(-1, /*is_2d_render*/true); @@ -138,16 +140,19 @@ void RaceGUI::createMarkerTexture() */ void RaceGUI::createRegularPolygon(unsigned int n, float radius, const core::vector2df ¢er, - core::array *v) + const video::SColor &color, + video::S3DVertex *v, unsigned short int *index) { float f = 2*M_PI/(float)n; for (unsigned int i=0; ipush_back(X); + v[i].Pos.X = X.X; + v[i].Pos.Y = X.Y; + v[i].Color = color; + index[i] = i; } - } // createRegularPolygon //----------------------------------------------------------------------------- @@ -435,36 +440,48 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y, #else core::dimension2di bar_size = bar_texture->getOriginalSize(); #endif - core::array tex_coords; // texture coordinates - core::array bar_vertices; // screen coordinates - - tex_coords.push_back(core::vector2di(bar_size.Width, bar_size.Height)); - bar_vertices.push_back(core::vector2df((float)meter_pos.LowerRightCorner.X, - (float)meter_pos.LowerRightCorner.Y)); - tex_coords.push_back(core::vector2di(0,bar_size.Height)); - bar_vertices.push_back(core::vector2df((float)meter_pos.UpperLeftCorner.X, - (float)meter_pos.LowerRightCorner.Y)); + video::S3DVertex vertices[4]; + vertices[0].TCoords = core::vector2df(1.0f, 1.0f); + vertices[0].Pos = core::vector3df((float)meter_pos.LowerRightCorner.X, + (float)meter_pos.LowerRightCorner.Y, + 0); + vertices[1].TCoords = core::vector2df(0, 1.0f); + vertices[1].Pos = core::vector3df((float)meter_pos.UpperLeftCorner.X, + (float)meter_pos.LowerRightCorner.Y, 0); + unsigned int count; if(speed_ratio<=0.5f) { - core::vector2di v0(0, bar_size.Height-(int)(2*(speed_ratio)*bar_size.Height)); - tex_coords.push_back(v0); - bar_vertices.push_back(core::vector2df((float)meter_pos.UpperLeftCorner.X, - (float)meter_pos.LowerRightCorner.Y-speed_ratio*2*meter_height)); + count = 3; + vertices[2].TCoords = core::vector2df(0, 1-2*speed_ratio); + vertices[2].Pos = core::vector3df((float)meter_pos.UpperLeftCorner.X, + (float)meter_pos.LowerRightCorner.Y-speed_ratio*2*meter_height, + 0); } else { - tex_coords.push_back(core::vector2di(0, 0)); - bar_vertices.push_back(core::vector2df((float)offset_x, - (float)(UserConfigParams::m_height-offset_y-meter_height))); - - core::vector2di v0((int)(2*(speed_ratio-0.5f)*bar_size.Width), 0); - tex_coords.push_back(v0); - bar_vertices.push_back(core::vector2df(offset_x+2*(speed_ratio-0.5f)*meter_width, - (float)(UserConfigParams::m_height-offset_y-meter_height))); + count = 4; + vertices[2].TCoords = core::vector2df(0,0); + vertices[2].Pos = core::vector3df((float)offset_x, + (float)(UserConfigParams::m_height-offset_y-meter_height), + 0); + vertices[3].TCoords = core::vector2df(2*speed_ratio-1.0f, 0); + vertices[3].Pos = core::vector3df(offset_x+2*(speed_ratio-0.5f)*meter_width, + (float)(UserConfigParams::m_height-offset_y-meter_height), + 0); } -#ifdef IRRLICHT_HAS_SUPERTUXKART_POLYGON - irr_driver->getVideoDriver()->draw2DPolygon(bar_vertices, NULL, bar_texture, true, &tex_coords); + short int index[4]; + for(unsigned int i=0; igetTexture()); + irr_driver->getVideoDriver()->setMaterial(m); +#ifdef DOES_NOT_WORK_ATM + irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, count, + index, count-2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN); #endif } // drawSpeed diff --git a/src/states_screens/race_gui.hpp b/src/states_screens/race_gui.hpp index 3d829bc65..8a9df48d8 100644 --- a/src/states_screens/race_gui.hpp +++ b/src/states_screens/race_gui.hpp @@ -136,7 +136,8 @@ private: void createMarkerTexture(); void createRegularPolygon(unsigned int n, float radius, const core::vector2df ¢er, - core::array *v); + const video::SColor &color, + video::S3DVertex *v, unsigned short int *index); /* Display informat on screen */ void drawStatusText ();