Made lap line consistently red (code to get a checkered lap line
is still in but commented out - it looks quite for in the shorter tracks imho). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7678 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a87e19ad9b
commit
e78d2d8887
@ -259,7 +259,9 @@ void QuadGraph::setDefaultStartPositions(AlignedArray<btTransform>
|
||||
/** Creates a mesh for this graph. The mesh is not added to a scene node and
|
||||
* is stored in m_mesh.
|
||||
*/
|
||||
void QuadGraph::createMesh(bool show_invisible, bool draw_lap_line)
|
||||
void QuadGraph::createMesh(bool show_invisible,
|
||||
const video::SColor *track_color,
|
||||
const video::SColor *lap_color)
|
||||
{
|
||||
// The debug track will not be lighted or culled.
|
||||
video::SMaterial m;
|
||||
@ -284,6 +286,9 @@ void QuadGraph::createMesh(bool show_invisible, bool draw_lap_line)
|
||||
irr::u16 *ind = new irr::u16[6*n];
|
||||
video::SColor c(255, 255, 0, 0);
|
||||
|
||||
if(track_color)
|
||||
c = *track_color;
|
||||
|
||||
// Now add all quads
|
||||
int i=0;
|
||||
for(unsigned int count=0; count<m_all_nodes.size(); count++)
|
||||
@ -292,8 +297,11 @@ void QuadGraph::createMesh(bool show_invisible, bool draw_lap_line)
|
||||
if(!show_invisible && m_all_nodes[count]->getQuad().isInvisible())
|
||||
continue;
|
||||
// Swap the colours from red to blue and back
|
||||
c.setRed (i%2 ? 255 : 0);
|
||||
c.setBlue(i%2 ? 0 : 255);
|
||||
if(!track_color)
|
||||
{
|
||||
c.setRed (i%2 ? 255 : 0);
|
||||
c.setBlue(i%2 ? 0 : 255);
|
||||
}
|
||||
// Transfer the 4 points of the current quad to the list of vertices
|
||||
m_all_nodes[count]->getQuad().getVertices(new_v+4*i, c);
|
||||
|
||||
@ -311,18 +319,20 @@ void QuadGraph::createMesh(bool show_invisible, bool draw_lap_line)
|
||||
|
||||
m_mesh_buffer->append(new_v, n*4, ind, n*6);
|
||||
|
||||
if(draw_lap_line)
|
||||
if(lap_color)
|
||||
{
|
||||
video::S3DVertex lap_v[4];
|
||||
irr::u16 lap_ind[6];
|
||||
video::SColor c(128, 128, 128, 128);
|
||||
m_all_nodes[0]->getQuad().getVertices(lap_v, c);
|
||||
video::SColor c(128, 255, 0, 0);
|
||||
m_all_nodes[0]->getQuad().getVertices(lap_v, *lap_color);
|
||||
|
||||
// Now scale the length (distance between vertix 0 and 3
|
||||
// and between 1 and 2) to be 'length':
|
||||
Vec3 bb_min, bb_max;
|
||||
m_all_quads->getBoundingBox(&bb_min, &bb_max);
|
||||
const float length=(bb_max.getZ()-bb_min.getZ())/20.0f;
|
||||
// Length of the lap line about 3% of the 'height'
|
||||
// of the track.
|
||||
const float length=(bb_max.getZ()-bb_min.getZ())*0.03;
|
||||
|
||||
core::vector3df dl = lap_v[3].Pos-lap_v[0].Pos;
|
||||
float ll2 = dl.getLengthSQ();
|
||||
@ -337,13 +347,19 @@ void QuadGraph::createMesh(bool show_invisible, bool draw_lap_line)
|
||||
lap_v[2].Pos = lap_v[1].Pos+core::vector3df(0, 0, 1);
|
||||
else
|
||||
lap_v[2].Pos = lap_v[1].Pos+dr*length/sqrt(lr2);
|
||||
lap_v[3].Pos.Y += 1.0f;
|
||||
lap_ind[0] = 0;
|
||||
lap_ind[1] = 1;
|
||||
lap_ind[2] = 2;
|
||||
lap_ind[3] = 0;
|
||||
lap_ind[4] = 3;
|
||||
lap_ind[5] = 2;
|
||||
lap_ind[4] = 2;
|
||||
lap_ind[5] = 3;
|
||||
// Set it a bit higher to avoid issued with z fighting,
|
||||
// i.e. part of the lap line might not be visible.
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
lap_v[i].Pos.Y += 0.1f;
|
||||
#ifndef USE_TEXTURED_LINE
|
||||
m_mesh_buffer->append(lap_v, 4, lap_ind, 6);
|
||||
#else
|
||||
lap_v[0].TCoords = core::vector2df(0,0);
|
||||
lap_v[1].TCoords = core::vector2df(3,0);
|
||||
lap_v[2].TCoords = core::vector2df(3,1);
|
||||
@ -352,6 +368,7 @@ lap_v[3].Pos.Y += 1.0f;
|
||||
video::SMaterial &m = m_mesh_buffer->getMaterial();
|
||||
video::ITexture *t = irr_driver->getTexture("chess.png");
|
||||
m.setTexture(0, t);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Instead of setting the bounding boxes, we could just disable culling,
|
||||
@ -602,16 +619,11 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2du &dimension,
|
||||
const video::SColor &fill_color)
|
||||
{
|
||||
IrrDriver::RTTProvider rttProvider(dimension, name);
|
||||
video::SColor red(128, 255, 0, 0);
|
||||
createMesh(/*show_invisible part of the track*/ false,
|
||||
/*createLapLine*/ true );
|
||||
/*track_color*/ &fill_color,
|
||||
/*lap line color*/ &red );
|
||||
video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices();
|
||||
// The last 4 vertices are for the lap counting line, which
|
||||
// is textured, so don't change the colour there.
|
||||
for(unsigned int i=0; i<m_mesh_buffer->getVertexCount()-4; i++)
|
||||
{
|
||||
v[i].Color = fill_color;
|
||||
}
|
||||
|
||||
|
||||
m_node = irr_driver->addMesh(m_mesh); // add Debug Mesh
|
||||
#ifdef DEBUG
|
||||
|
@ -62,7 +62,9 @@ private:
|
||||
|
||||
void setDefaultSuccessors();
|
||||
void load (const std::string &filename);
|
||||
void createMesh(bool show_invisible=true, bool draw_lap_line=false);
|
||||
void createMesh(bool show_invisible=true,
|
||||
const video::SColor *track_color=NULL,
|
||||
const video::SColor *lap_color=NULL);
|
||||
int getPredecessor(unsigned int target_node) const;
|
||||
public:
|
||||
static const int UNKNOWN_SECTOR;
|
||||
|
Loading…
Reference in New Issue
Block a user