Make RecastDemo colors more meaningful (#254)

Implement a SampleDebugDraw which will color area types meaningfully, for example
color water as blue, grass as green and so on.
This commit is contained in:
Domenico Albani
2017-02-02 20:27:43 +01:00
committed by Jakob Botsch Nielsen
parent 16a7a30ada
commit 03eb2f92f3
13 changed files with 121 additions and 96 deletions

View File

@@ -215,8 +215,6 @@ void Sample_SoloMesh::handleRender()
if (!m_geom || !m_geom->getMesh())
return;
DebugDrawGL dd;
glEnable(GL_FOG);
glDepthMask(GL_TRUE);
@@ -225,10 +223,10 @@ void Sample_SoloMesh::handleRender()
if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
{
// Draw mesh
duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
duDebugDrawTriMeshSlope(&m_dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
m_agentMaxSlope, texScale);
m_geom->drawOffMeshConnections(&dd);
m_geom->drawOffMeshConnections(&m_dd);
}
glDisable(GL_FOG);
@@ -237,10 +235,10 @@ void Sample_SoloMesh::handleRender()
// Draw bounds
const float* bmin = m_geom->getNavMeshBoundsMin();
const float* bmax = m_geom->getNavMeshBoundsMax();
duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
dd.begin(DU_DRAW_POINTS, 5.0f);
dd.vertex(bmin[0],bmin[1],bmin[2],duRGBA(255,255,255,128));
dd.end();
duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
m_dd.begin(DU_DRAW_POINTS, 5.0f);
m_dd.vertex(bmin[0],bmin[1],bmin[2],duRGBA(255,255,255,128));
m_dd.end();
if (m_navMesh && m_navQuery &&
(m_drawMode == DRAWMODE_NAVMESH ||
@@ -250,76 +248,76 @@ void Sample_SoloMesh::handleRender()
m_drawMode == DRAWMODE_NAVMESH_INVIS))
{
if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
duDebugDrawNavMeshBVTree(&m_dd, *m_navMesh);
if (m_drawMode == DRAWMODE_NAVMESH_NODES)
duDebugDrawNavMeshNodes(&dd, *m_navQuery);
duDebugDrawNavMeshPolysWithFlags(&dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
duDebugDrawNavMeshNodes(&m_dd, *m_navQuery);
duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
}
glDepthMask(GL_TRUE);
if (m_chf && m_drawMode == DRAWMODE_COMPACT)
duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
duDebugDrawCompactHeightfieldSolid(&m_dd, *m_chf);
if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
duDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
duDebugDrawCompactHeightfieldDistance(&m_dd, *m_chf);
if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
if (m_solid && m_drawMode == DRAWMODE_VOXELS)
{
glEnable(GL_FOG);
duDebugDrawHeightfieldSolid(&dd, *m_solid);
duDebugDrawHeightfieldSolid(&m_dd, *m_solid);
glDisable(GL_FOG);
}
if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
{
glEnable(GL_FOG);
duDebugDrawHeightfieldWalkable(&dd, *m_solid);
duDebugDrawHeightfieldWalkable(&m_dd, *m_solid);
glDisable(GL_FOG);
}
if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
{
glDepthMask(GL_FALSE);
duDebugDrawRawContours(&dd, *m_cset);
duDebugDrawRawContours(&m_dd, *m_cset);
glDepthMask(GL_TRUE);
}
if (m_cset && m_drawMode == DRAWMODE_BOTH_CONTOURS)
{
glDepthMask(GL_FALSE);
duDebugDrawRawContours(&dd, *m_cset, 0.5f);
duDebugDrawContours(&dd, *m_cset);
duDebugDrawRawContours(&m_dd, *m_cset, 0.5f);
duDebugDrawContours(&m_dd, *m_cset);
glDepthMask(GL_TRUE);
}
if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
{
glDepthMask(GL_FALSE);
duDebugDrawContours(&dd, *m_cset);
duDebugDrawContours(&m_dd, *m_cset);
glDepthMask(GL_TRUE);
}
if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
{
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
glDepthMask(GL_FALSE);
duDebugDrawRegionConnections(&dd, *m_cset);
duDebugDrawRegionConnections(&m_dd, *m_cset);
glDepthMask(GL_TRUE);
}
if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
{
glDepthMask(GL_FALSE);
duDebugDrawPolyMesh(&dd, *m_pmesh);
duDebugDrawPolyMesh(&m_dd, *m_pmesh);
glDepthMask(GL_TRUE);
}
if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
{
glDepthMask(GL_FALSE);
duDebugDrawPolyMeshDetail(&dd, *m_dmesh);
duDebugDrawPolyMeshDetail(&m_dd, *m_dmesh);
glDepthMask(GL_TRUE);
}
m_geom->drawConvexVolumes(&dd);
m_geom->drawConvexVolumes(&m_dd);
if (m_tool)
m_tool->handleRender();