Example #1
0
void Sample::handleRender()
{
	if (!m_geom)
		return;
	
	DebugDrawGL dd;
		
	// Draw mesh
	duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
					   m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0, 1.0f);
	// Draw bounds
	const float* bmin = m_geom->getMeshBoundsMin();
	const float* bmax = m_geom->getMeshBoundsMax();
	duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
}
Example #2
0
void Visualization::renderScene()
{
	if (m_scene)
    {
        DebugDrawGL dd;
        
        // Draw mesh
        duDebugDrawTriMesh(&dd, m_scene->getMesh()->getVerts(), m_scene->getMesh()->getVertCount(),
                           m_scene->getMesh()->getTris(), m_scene->getMesh()->getNormals(), m_scene->getMesh()->getTriCount(), 0, 1.0f);
        // Draw bounds
        const float* bmin = m_scene->getMeshBoundsMin();
        const float* bmax = m_scene->getMeshBoundsMax();
        duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
    }
}
Example #3
0
void Sample::handleRender()
{
	if (!m_geom)
		return;
	
	DebugDrawGL dd;
		
	// Draw mesh
	duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
					   m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0, 1.0f);
	// Draw bounds
	const dtCoordinates bmin( m_geom->getMeshBoundsMin() );
	const dtCoordinates bmax( m_geom->getMeshBoundsMax() );
	duDebugDrawBoxWire(&dd, bmin.X(),bmin.Y(),bmin.Z(), bmax.X(),bmax.Y(),bmax.Z(), duRGBA(255,255,255,128), 1.0f);
}
void Sample_TileMesh::handleRender()
{
	if (!m_geom || !m_geom->getMesh())
		return;
	
	DebugDrawGL dd;

	// Draw mesh
	if (m_drawMode == DRAWMODE_MESH)
	{
		// Draw mesh
		duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
								m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
								m_agentMaxSlope);
		m_geom->drawOffMeshConnections(&dd);
	}
	else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
	{
		// Draw mesh
		duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
						   m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0);
		m_geom->drawOffMeshConnections(&dd);
	}
	
/*	duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
					   m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0);
	m_geom->drawOffMeshConnections(&dd);*/
	
	glDepthMask(GL_FALSE);
	
	// Draw bounds
	const float* bmin = m_geom->getMeshBoundsMin();
	const float* bmax = m_geom->getMeshBoundsMax();
	duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
	
	// Tiling grid.
	int gw = 0, gh = 0;
	rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh);
	const int tw = (gw + (int)m_tileSize-1) / (int)m_tileSize;
	const int th = (gh + (int)m_tileSize-1) / (int)m_tileSize;
	const float s = m_tileSize*m_cellSize;
	duDebugDrawGridXZ(&dd, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f);
	
	// Draw active tile
	duDebugDrawBoxWire(&dd, m_tileBmin[0],m_tileBmin[1],m_tileBmin[2], m_tileBmax[0],m_tileBmax[1],m_tileBmax[2], m_tileCol, 2.0f);
	
/*	if (m_navMesh)
	{
		duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
		if (m_drawPortals)
			duDebugDrawNavMeshPortals(&dd, *m_navMesh);
	}*/
	
	if (m_navMesh && m_navQuery &&
		(m_drawMode == DRAWMODE_NAVMESH ||
		 m_drawMode == DRAWMODE_NAVMESH_TRANS ||
		 m_drawMode == DRAWMODE_NAVMESH_BVTREE ||
		 m_drawMode == DRAWMODE_NAVMESH_NODES ||
		 m_drawMode == DRAWMODE_NAVMESH_PORTALS ||
		 m_drawMode == DRAWMODE_NAVMESH_INVIS))
	{
		if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
			duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
		if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
			duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
		if (m_drawMode == DRAWMODE_NAVMESH_PORTALS)
			duDebugDrawNavMeshPortals(&dd, *m_navMesh);
		if (m_drawMode == DRAWMODE_NAVMESH_NODES)
			duDebugDrawNavMeshNodes(&dd, *m_navQuery);
	}
	
	
	glDepthMask(GL_TRUE);
	
	if (m_chf && m_drawMode == DRAWMODE_COMPACT)
		duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
	
	if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
		duDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
	if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
		duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
	if (m_solid && m_drawMode == DRAWMODE_VOXELS)
	{
		glEnable(GL_FOG);
		duDebugDrawHeightfieldSolid(&dd, *m_solid);
		glDisable(GL_FOG);
	}
	if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
	{
		glEnable(GL_FOG);
		duDebugDrawHeightfieldWalkable(&dd, *m_solid);
		glDisable(GL_FOG);
	}
	if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawRawContours(&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);
		glDepthMask(GL_TRUE);
	}
	if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawContours(&dd, *m_cset);
		glDepthMask(GL_TRUE);
	}
	if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
	{
		duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
		
		glDepthMask(GL_FALSE);
		duDebugDrawRegionConnections(&dd, *m_cset);
		glDepthMask(GL_TRUE);
	}
	if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawPolyMesh(&dd, *m_pmesh);
		glDepthMask(GL_TRUE);
	}
	if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawPolyMeshDetail(&dd, *m_dmesh);
		glDepthMask(GL_TRUE);
	}
	
	m_geom->drawConvexVolumes(&dd);
	
	if (m_tool)
		m_tool->handleRender();
	
	glDepthMask(GL_TRUE);
}
void Sample_SoloMeshSimple::handleRender()
{
    if (!m_geom || !m_geom->getMesh())
        return;

    DebugDrawGL dd;

    glEnable(GL_FOG);
    glDepthMask(GL_TRUE);

    if (m_drawMode == DRAWMODE_MESH)
    {
        // Draw mesh
        duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
                                m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
                                m_agentMaxSlope);
        m_geom->drawOffMeshConnections(&dd);
    }
    else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
    {
        // Draw mesh
        duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
                           m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0);
        m_geom->drawOffMeshConnections(&dd);
    }

    glDisable(GL_FOG);
    glDepthMask(GL_FALSE);

    // Draw bounds
    const float* bmin = m_geom->getMeshBoundsMin();
    const float* bmax = m_geom->getMeshBoundsMax();
    duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);

    if (m_navMesh && m_navQuery &&
        (m_drawMode == DRAWMODE_NAVMESH ||
        m_drawMode == DRAWMODE_NAVMESH_TRANS ||
        m_drawMode == DRAWMODE_NAVMESH_BVTREE ||
         m_drawMode == DRAWMODE_NAVMESH_NODES ||
        m_drawMode == DRAWMODE_NAVMESH_INVIS))
    {
        if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
            duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
        if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
            duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
        if (m_drawMode == DRAWMODE_NAVMESH_NODES)
            duDebugDrawNavMeshNodes(&dd, *m_navQuery);
    }

    glDepthMask(GL_TRUE);

    if (m_chf && m_drawMode == DRAWMODE_COMPACT)
        duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);

    if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
        duDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
    if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
        duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
    if (m_solid && m_drawMode == DRAWMODE_VOXELS)
    {
        glEnable(GL_FOG);
        duDebugDrawHeightfieldSolid(&dd, *m_solid);
        glDisable(GL_FOG);
    }
    if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
    {
        glEnable(GL_FOG);
        duDebugDrawHeightfieldWalkable(&dd, *m_solid);
        glDisable(GL_FOG);
    }
    if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawRawContours(&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);
        glDepthMask(GL_TRUE);
    }
    if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawContours(&dd, *m_cset);
        glDepthMask(GL_TRUE);
    }
    if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
    {
        duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);

        glDepthMask(GL_FALSE);
        duDebugDrawRegionConnections(&dd, *m_cset);
        glDepthMask(GL_TRUE);
    }
    if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawPolyMesh(&dd, *m_pmesh);
        glDepthMask(GL_TRUE);
    }
    if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawPolyMeshDetail(&dd, *m_dmesh);
        glDepthMask(GL_TRUE);
    }

    m_geom->drawConvexVolumes(&dd);

    if (m_tool)
        m_tool->handleRender();

    glDepthMask(GL_TRUE);
}
void Sample_Debug::handleRender()
{
	if (!m_geom || !m_geom->getMesh())
		return;
	
	DebugDrawGL dd;
	
	glEnable(GL_FOG);
	glDepthMask(GL_TRUE);
	
	if (m_drawMode == DRAWMODE_MESH)
	{
		// Draw mesh
		duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
								m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
								m_agentMaxSlope);
		m_geom->drawOffMeshConnections(&dd);
	}
	else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
	{
		// Draw mesh
		duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
						   m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0);
		m_geom->drawOffMeshConnections(&dd);
	}
	
	glDisable(GL_FOG);
	glDepthMask(GL_FALSE);
	
	// Draw bounds
	const float* bmin = m_geom->getMeshBoundsMin();
	const float* bmax = m_geom->getMeshBoundsMax();
	duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
	
	// Tiling grid.
	int gw = 0, gh = 0;
	rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh);
	const int tw = (gw + (int)m_tileSize-1) / (int)m_tileSize;
	const int th = (gh + (int)m_tileSize-1) / (int)m_tileSize;
	duDebugDrawGridXZ(&dd, bmin[0],bmin[1],bmin[2], tw,th, m_tileSize, duRGBA(0,0,0,64), 1.0f);
	
	if (m_navMesh &&
		(m_drawMode == DRAWMODE_NAVMESH ||
		 m_drawMode == DRAWMODE_NAVMESH_TRANS ||
		 m_drawMode == DRAWMODE_NAVMESH_BVTREE ||
		 m_drawMode == DRAWMODE_NAVMESH_INVIS))
	{
		if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
			duDebugDrawNavMesh(&dd, *m_navMesh, m_navMeshDrawFlags);
		if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
			duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
	}
	
	glDepthMask(GL_TRUE);
	
    if (m_drawMode == DRAWMODE_COMPACT)
		for (int i = 0; i < m_chfCount; ++i)
            if(i == m_tile)
			duDebugDrawCompactHeightfieldSolid(&dd, m_chf[i]);

	if (m_drawMode == DRAWMODE_COMPACT_DISTANCE)
		for (int i = 0; i < m_chfCount; ++i)
            if(i == m_tile)
			duDebugDrawCompactHeightfieldDistance(&dd, m_chf[i]);

	if (m_drawMode == DRAWMODE_COMPACT_REGIONS)
		for (int i = 0; i < m_chfCount; ++i)
            if(i == m_tile)
			duDebugDrawCompactHeightfieldRegions(&dd, m_chf[i]);
	
	if (m_drawMode == DRAWMODE_VOXELS)
	{
		glEnable(GL_FOG);
		for (int i = 0; i < m_hfCount; ++i)
            if(i == m_tile)
			duDebugDrawHeightfieldSolid(&dd, m_hf[i]);
		glDisable(GL_FOG);
	}

	if (m_drawMode == DRAWMODE_VOXELS_WALKABLE)
	{
		glEnable(GL_FOG);
		for (int i = 0; i < m_hfCount; ++i)
            if(i == m_tile)
			duDebugDrawHeightfieldWalkable(&dd, m_hf[i]);
		glDisable(GL_FOG);
	}

	if (m_drawMode == DRAWMODE_RAW_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		for (int i = 0; i < m_csetCount; ++i)
            if(i == m_tile)
			duDebugDrawRawContours(&dd, m_cset[i]);
		glDepthMask(GL_TRUE);
	}

	if (m_drawMode == DRAWMODE_BOTH_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		for (int i = 0; i < m_csetCount; ++i)
            if(i == m_tile)
		{
			duDebugDrawRawContours(&dd, m_cset[i], 0.5f);
			duDebugDrawContours(&dd, m_cset[i]);
		}
		glDepthMask(GL_TRUE);
	}

	if (m_drawMode == DRAWMODE_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		for (int i = 0; i < m_csetCount; ++i)
            if(i == m_tile)
			duDebugDrawContours(&dd, m_cset[i]);
		glDepthMask(GL_TRUE);
	}

	if (m_drawMode == DRAWMODE_REGION_CONNECTIONS)
	{
		for (int i = 0; i < m_chfCount; ++i)
            if(i == m_tile)
			duDebugDrawCompactHeightfieldRegions(&dd, m_chf[i]);
		
		glDepthMask(GL_FALSE);
		for (int i = 0; i < m_csetCount; ++i)
            if(i == m_tile)
			duDebugDrawRegionConnections(&dd, m_cset[i]);
		glDepthMask(GL_TRUE);
	}

	if (/*m_pmesh &&*/ m_drawMode == DRAWMODE_POLYMESH)
	{
		glDepthMask(GL_FALSE);
        for(int i = 0; i < m_pmeshCount; ++i)
            if(i == m_tile)
		    duDebugDrawPolyMesh(&dd, m_pmesh[i]);
		glDepthMask(GL_TRUE);
	}
	if (/*m_dmesh &&*/ m_drawMode == DRAWMODE_POLYMESH_DETAIL)
	{
		glDepthMask(GL_FALSE);
        for(int i = 0; i < m_dmeshCount; ++i)
            if(i == m_tile)
		    duDebugDrawPolyMeshDetail(&dd, m_dmesh[i]);
		glDepthMask(GL_TRUE);
	}
	
	m_geom->drawConvexVolumes(&dd);

	if (m_tool)
		m_tool->handleRender();

	glDepthMask(GL_TRUE);
}