diff --git a/source/renderer/TerrainOverlay.cpp b/source/renderer/TerrainOverlay.cpp index 95d60a194b..fcf77a44d8 100644 --- a/source/renderer/TerrainOverlay.cpp +++ b/source/renderer/TerrainOverlay.cpp @@ -2,6 +2,7 @@ #include "TerrainOverlay.h" +#include "ps/Overlay.h" #include "ps/Game.h" #include "ps/World.h" #include "graphics/Terrain.h" @@ -76,7 +77,7 @@ TerrainOverlay::~TerrainOverlay() - +#if 0 //initial test to draw out entity boundaries //it shows how to retrieve object boundary postions for triangulation //NOTE: it's a test to see how to retrieve bounadry locations for static objects on the terrain. @@ -164,7 +165,7 @@ void TerrainOverlay::RenderEntityEdges() //---------------------- } - +#endif void TerrainOverlay::RenderOverlays() diff --git a/source/renderer/TerrainOverlay.h b/source/renderer/TerrainOverlay.h index 3540498a9c..2d0d3c507f 100644 --- a/source/renderer/TerrainOverlay.h +++ b/source/renderer/TerrainOverlay.h @@ -10,24 +10,7 @@ #ifndef INCLUDED_TERRAINOVERLAY #define INCLUDED_TERRAINOVERLAY -//Kai: added for rendering triangulate Terrain Overlay - - -#include "ps/Overlay.h" // for CColor -#include -#include "ps/Vector2D.h" -#include "graphics/Terrain.h" - - -//Kai: added for line drawing -#include "simulation/Entity.h" -#include "simulation/EntityManager.h" -#include "simulation/BoundingObjects.h" -#include "dcdt/se/se_dcdt.h" -#include "lib/ogl.h" - - - +class CColor; class CTerrain; /** @@ -116,11 +99,12 @@ public: /// Draw all TerrainOverlay objects that exist. static void RenderOverlays(); +#if 0 /** * Kai: added function to draw out line segments for triangulation */ static void RenderEntityEdges(); - +#endif private: @@ -140,238 +124,6 @@ private: }; -class TriangulationTerrainOverlay : public TerrainOverlay -{ - - SrArray constr; - SrArray unconstr; - - //std::vector path; - - SrPolygon CurPath; -public: - - - void RenderCurrentPath() - { - glColor3f(1,1,1); - - for(int i=0; i< CurPath.size()-1; i++) - { - std::vector results; - g_EntityManager.GetExtant(results); - CEntity* tempHandle = results[0]; - - glBegin(GL_LINE_LOOP); - - float x1 = CurPath[i].x; - float y1 = CurPath[i].y; - float x2 = CurPath[i+1].x; - float y2 = CurPath[i+1].y; - glVertex3f(x1,tempHandle->GetAnchorLevel(x1,y1) + 0.2f,y1); - glVertex3f(x2,tempHandle->GetAnchorLevel(x2,y2) + 0.2f,y2); - glEnd(); - - - } - } - - - // - //Kai: added function to draw out constrained line segments in triangulation - // - void RenderConstrainedEdges() - { - - std::vector results; - g_EntityManager.GetExtant(results); - CEntity* tempHandle = results[0]; - - glColor3f( 1, 1, 1 ); - - - for(int i=0; iGetAnchorLevel( x1, y1 ) + 0.2f, y1 ); - glVertex3f( x2, tempHandle->GetAnchorLevel( x2, y2 ) + 0.2f, y2 ); - glEnd(); - - } - - - } - - - // - // Kai: added function to draw out unconstrained line segments in triangulation - // - void RenderUnconstrainedEdges() - { - std::vector results; - g_EntityManager.GetExtant(results); - CEntity* tempHandle = results[0]; - - - glColor3f( 0, 1, 0 ); - - for(int i=0; iGetAnchorLevel( x1, y1 ) + 0.2f, y1 ); - glVertex3f( x2, tempHandle->GetAnchorLevel( x2, y2 ) + 0.2f, y2 ); - glEnd(); - - } - - } - - void setCurrentPath(SrPolygon _CurPath) - { - CurPath = _CurPath; - - } - - - - - - void setConstrainedEdges(SrArray _constr) - { - constr = _constr; - - } - - void setUnconstrainedEdges(SrArray _unconstr) - { - unconstr = _unconstr; - - } - - void Render() - { - - } - - - TriangulationTerrainOverlay() - { - - } - - virtual void GetTileExtents( - ssize_t& min_i_inclusive, ssize_t& min_j_inclusive, - ssize_t& max_i_inclusive, ssize_t& max_j_inclusive) - { - min_i_inclusive = 1; - min_j_inclusive = 1; - max_i_inclusive = 2; - max_j_inclusive = 2; - } - - virtual void ProcessTile(ssize_t UNUSED(i), ssize_t UNUSED(j)) - { - - RenderConstrainedEdges(); - RenderUnconstrainedEdges(); - RenderCurrentPath(); - - } - - - - -}; - - - - - - - - - - -class PathFindingTerrainOverlay : public TerrainOverlay -{ -public: - char random[1021]; - std::vector aPath; - - void setPath(std::vector _aPath) - { - aPath =_aPath; - - for(size_t k = 0 ; k< aPath.size();k++) - { - aPath[k] = WorldspaceToTilespace( aPath[k] ); - } - - } - - CVector2D WorldspaceToTilespace( const CVector2D &ws ) - { - return CVector2D(floor(ws.x/CELL_SIZE), floor(ws.y/CELL_SIZE)); - } - - bool inPath(ssize_t i, ssize_t j) - { - for(size_t k = 0 ; k aPath; + + void setPath(std::vector _aPath) + { + aPath =_aPath; + + for(size_t k = 0 ; k< aPath.size();k++) + { + aPath[k] = WorldspaceToTilespace( aPath[k] ); + } + } + + CVector2D WorldspaceToTilespace( const CVector2D &ws ) + { + return CVector2D(floor(ws.x/CELL_SIZE), floor(ws.y/CELL_SIZE)); + } + + bool inPath(ssize_t i, ssize_t j) + { + for(size_t k = 0 ; ksetPath(mPath); } Cleanup(); diff --git a/source/simulation/AStarEngine.h b/source/simulation/AStarEngine.h index 5da9840096..60cdfdcf9b 100644 --- a/source/simulation/AStarEngine.h +++ b/source/simulation/AStarEngine.h @@ -61,6 +61,8 @@ public: typedef unsigned char AStarNodeFlag; +class PathFindingTerrainOverlay; + class CAStarEngine { public: @@ -77,7 +79,7 @@ public: void SetSearchLimit( int limit ); //Kai:added tile overlay for pathfinding - PathFindingTerrainOverlay pathfindingOverlay; + PathFindingTerrainOverlay* pathfindingOverlay; SrPolygon pol; diff --git a/source/simulation/PathfindEngine.cpp b/source/simulation/PathfindEngine.cpp index 229b64e04e..f1f1979a5a 100644 --- a/source/simulation/PathfindEngine.cpp +++ b/source/simulation/PathfindEngine.cpp @@ -18,6 +18,139 @@ #define EPSILON 0.00001f +class TriangulationTerrainOverlay : public TerrainOverlay +{ + SrArray constr; + SrArray unconstr; + + //std::vector path; + + SrPolygon CurPath; +public: + + void RenderCurrentPath() + { + glColor3f(1,1,1); + + for(int i=0; i< CurPath.size()-1; i++) + { + std::vector results; + g_EntityManager.GetExtant(results); + CEntity* tempHandle = results[0]; + + glBegin(GL_LINE_LOOP); + + float x1 = CurPath[i].x; + float y1 = CurPath[i].y; + float x2 = CurPath[i+1].x; + float y2 = CurPath[i+1].y; + glVertex3f(x1,tempHandle->GetAnchorLevel(x1,y1) + 0.2f,y1); + glVertex3f(x2,tempHandle->GetAnchorLevel(x2,y2) + 0.2f,y2); + glEnd(); + } + } + + // + //Kai: added function to draw out constrained line segments in triangulation + // + void RenderConstrainedEdges() + { + std::vector results; + g_EntityManager.GetExtant(results); + CEntity* tempHandle = results[0]; + + glColor3f( 1, 1, 1 ); + + for(int i=0; iGetAnchorLevel( x1, y1 ) + 0.2f, y1 ); + glVertex3f( x2, tempHandle->GetAnchorLevel( x2, y2 ) + 0.2f, y2 ); + glEnd(); + } + } + + // + // Kai: added function to draw out unconstrained line segments in triangulation + // + void RenderUnconstrainedEdges() + { + std::vector results; + g_EntityManager.GetExtant(results); + CEntity* tempHandle = results[0]; + + glColor3f( 0, 1, 0 ); + + for(int i=0; iGetAnchorLevel( x1, y1 ) + 0.2f, y1 ); + glVertex3f( x2, tempHandle->GetAnchorLevel( x2, y2 ) + 0.2f, y2 ); + glEnd(); + } + } + + void setCurrentPath(SrPolygon _CurPath) + { + CurPath = _CurPath; + } + + void setConstrainedEdges(SrArray _constr) + { + constr = _constr; + } + + void setUnconstrainedEdges(SrArray _unconstr) + { + unconstr = _unconstr; + } + + void Render() + { + } + + + TriangulationTerrainOverlay() + { + } + + virtual void GetTileExtents( + ssize_t& min_i_inclusive, ssize_t& min_j_inclusive, + ssize_t& max_i_inclusive, ssize_t& max_j_inclusive) + { + min_i_inclusive = 1; + min_j_inclusive = 1; + max_i_inclusive = 2; + max_j_inclusive = 2; + } + + virtual void ProcessTile(ssize_t UNUSED(i), ssize_t UNUSED(j)) + { + + RenderConstrainedEdges(); + RenderUnconstrainedEdges(); + RenderCurrentPath(); + } +}; + CPathfindEngine::CPathfindEngine() : triangulationOverlay(0), OABBBOUNDREDUCTION(0.8f), diff --git a/source/simulation/PathfindEngine.h b/source/simulation/PathfindEngine.h index 3dfd21688c..8a34f2af3f 100644 --- a/source/simulation/PathfindEngine.h +++ b/source/simulation/PathfindEngine.h @@ -17,6 +17,7 @@ #include "TRAStarEngine.h" +class TriangulationTerrainOverlay; #define g_Pathfinder CPathfindEngine::GetSingleton() diff --git a/source/sound/SoundGroup.h b/source/sound/SoundGroup.h index 2f26ef35c7..616ecf6600 100644 --- a/source/sound/SoundGroup.h +++ b/source/sound/SoundGroup.h @@ -14,7 +14,7 @@ Example usage: (SEE SOUNDGROUPMGR.H) Example SoundGroup.xml - + 1.0 0 diff --git a/source/tools/atlas/GameInterface/Brushes.cpp b/source/tools/atlas/GameInterface/Brushes.cpp index 5e1d799045..c2a43fc5ed 100644 --- a/source/tools/atlas/GameInterface/Brushes.cpp +++ b/source/tools/atlas/GameInterface/Brushes.cpp @@ -2,6 +2,7 @@ #include "Brushes.h" +#include "ps/Overlay.h" #include "ps/Game.h" #include "ps/World.h" #include "graphics/Terrain.h"