Commit c4365042 authored by Thomas's avatar Thomas

gestion obstacles mobiles et environnement dynamiques

parent 4333cf13
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 2.8)
project(SocialAgents)
# a decommenter si on veut voir ce qui se passe a la compilation
#set( CMAKE_VERBOSE_MAKEFILE 1 )
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../CGoGN)
SET(CMAKE_MODULE_PATH " ${CMAKE_MODULE_PATH} ${CGoGN_ROOT_DIR}/cmake_modules/")
find_package(OpenGL)
find_package(GLUT)
# FOR Qt4
FIND_PACKAGE(Qt4 REQUIRED)
SET(QT_USE_QTOPENGL TRUE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
# qq definition specifiques pour mac
IF(APPLE)
# attention a changer pour chercher la bonne version automatiquement
SET(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined -Wl,dynamic_lookup")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAC_OSX")
SET(CMAKE_OSX_ARCHITECTURES x86_64)
ENDIF(APPLE)
IF(WIN32)
SET(GLEW_LIBRARY glew32)
SET(DEVIL_LIBRARIES DevIL ILU ILUT)
SET(ZLIB_LIBRARIES zlib)
SET(LIBXML2_LIBRARIES xml2)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/dependencies/include/)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/dependencies/lib/)
ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
find_package(DevIL)
find_package(ZLIB)
find_package(LibXml2)
SET(GLEW_LIBRARY GLEW)
IF (IL_LIBRARIES)
SET(DEVIL_LIBRARIES ${IL_LIBRARIES} ${ILU_LIBRARIES} ${ILUT_LIBRARIES})
ELSE(IL_LIBRARIES)
SET(DEVIL_LIBRARIES ${IL_LIBRARY} ${ILU_LIBRARY} ${ILUT_LIBRARY})
ENDIF(IL_LIBRARIES)
ENDIF(WIN32)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
SET(COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream openctm assimp)
SET(CGoGN_LIBS_D topologyD algoD containerD utilsD)
SET(CGoGN_LIBS_R topology algo container utils)
SET(NUMERICAL_LIBS numerical lapack blas f2c)
include(${CGoGN_ROOT_DIR}/build/apps_cmake.txt)
add_subdirectory(Release)
add_subdirectory(Debug)
......@@ -38,6 +38,7 @@ add_executable( socialAgentsD
../src/viewer.cpp
../src/env_map.cpp
../src/agent.cpp
../src/moving_obstacle.cpp
../src/simulator.cpp
../src/gl2ps.c
${socialAgents_moc}
......
......@@ -34,6 +34,7 @@ add_executable( socialAgents
../src/viewer.cpp
../src/env_map.cpp
../src/agent.cpp
../src/moving_obstacle.cpp
../src/simulator.cpp
../src/gl2ps.c
${socialAgents_moc}
......
......@@ -6,7 +6,7 @@
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<desc>Produced by GNUPLOT 4.4 patchlevel 2 </desc>
<desc>Produced by GNUPLOT 4.4 patchlevel 0 </desc>
<defs>
......@@ -30,174 +30,174 @@
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,367.5 L576.8,367.5 '></path>
<path d='M57.7,367.5 L580.6,367.5 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,367.5 L58.2,367.5 M576.8,367.5 L568.6,367.5 '></path>
<g transform="translate(42.3,371.6)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<path d='M57.7,367.5 L65.9,367.5 M580.6,367.5 L572.4,367.5 '></path>
<g transform="translate(50.0,371.6)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan> 0</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,317.2 L576.8,317.2 '></path>
<path d='M57.7,317.2 L580.6,317.2 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,317.2 L58.2,317.2 M576.8,317.2 L568.6,317.2 '></path>
<g transform="translate(42.3,321.3)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<path d='M57.7,317.2 L65.9,317.2 M580.6,317.2 L572.4,317.2 '></path>
<g transform="translate(50.0,321.3)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan> 20</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,266.9 L576.8,266.9 '></path>
<path d='M57.7,266.9 L580.6,266.9 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,266.9 L58.2,266.9 M576.8,266.9 L568.6,266.9 '></path>
<g transform="translate(42.3,271.0)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<path d='M57.7,266.9 L65.9,266.9 M580.6,266.9 L572.4,266.9 '></path>
<g transform="translate(50.0,271.0)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan> 40</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,216.6 L576.8,216.6 '></path>
<path d='M57.7,216.6 L580.6,216.6 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,216.6 L58.2,216.6 M576.8,216.6 L568.6,216.6 '></path>
<g transform="translate(42.3,220.7)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<path d='M57.7,216.6 L65.9,216.6 M580.6,216.6 L572.4,216.6 '></path>
<g transform="translate(50.0,220.7)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan> 60</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,166.3 L576.8,166.3 '></path>
<path d='M57.7,166.3 L580.6,166.3 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,166.3 L58.2,166.3 M576.8,166.3 L568.6,166.3 '></path>
<g transform="translate(42.3,170.4)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<path d='M57.7,166.3 L65.9,166.3 M580.6,166.3 L572.4,166.3 '></path>
<g transform="translate(50.0,170.4)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan> 80</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,116.1 L576.8,116.1 '></path>
<path d='M57.7,116.1 L580.6,116.1 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,116.1 L58.2,116.1 M576.8,116.1 L568.6,116.1 '></path>
<g transform="translate(42.3,120.2)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<path d='M57.7,116.1 L65.9,116.1 M580.6,116.1 L572.4,116.1 '></path>
<g transform="translate(50.0,120.2)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan> 100</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,65.8 L414.6,65.8 M569.1,65.8 L576.8,65.8 '></path>
<path d='M57.7,65.8 L418.4,65.8 M572.9,65.8 L580.6,65.8 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,65.8 L58.2,65.8 M576.8,65.8 L568.6,65.8 '></path>
<g transform="translate(42.3,69.9)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<path d='M57.7,65.8 L65.9,65.8 M580.6,65.8 L572.4,65.8 '></path>
<g transform="translate(50.0,69.9)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan> 120</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,15.5 L576.8,15.5 '></path>
<path d='M57.7,15.5 L580.6,15.5 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,15.5 L58.2,15.5 M576.8,15.5 L568.6,15.5 '></path>
<g transform="translate(42.3,19.6)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<path d='M57.7,15.5 L65.9,15.5 M580.6,15.5 L572.4,15.5 '></path>
<g transform="translate(50.0,19.6)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan> 140</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M181.7,367.2 L181.7,15.5 '></path>
<path d='M188.4,367.2 L188.4,15.5 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M181.7,367.2 L181.7,359.0 M181.7,15.5 L181.7,23.7 '></path>
<g transform="translate(181.7,387.7)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:middle">
<path d='M188.4,367.2 L188.4,359.0 M188.4,15.5 L188.4,23.7 '></path>
<g transform="translate(188.4,387.7)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:middle">
<text><tspan>Circle-250</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M313.4,367.2 L313.4,15.5 '></path>
<path d='M319.2,367.2 L319.2,15.5 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M313.4,367.2 L313.4,359.0 M313.4,15.5 L313.4,23.7 '></path>
<g transform="translate(313.4,387.7)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:middle">
<path d='M319.2,367.2 L319.2,359.0 M319.2,15.5 L319.2,23.7 '></path>
<g transform="translate(319.2,387.7)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:middle">
<text><tspan>Circle-500</tspan>
</text>
</g>
</g>
<g style="fill:none; color:gray; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M445.1,367.2 L445.1,89.3 M445.1,23.7 L445.1,15.5 '></path>
<path d='M449.9,367.2 L449.9,89.3 M449.9,23.7 L449.9,15.5 '></path>
</g>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M445.1,367.2 L445.1,359.0 M445.1,15.5 L445.1,23.7 '></path>
<g transform="translate(445.1,387.7)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:middle">
<path d='M449.9,367.2 L449.9,359.0 M449.9,15.5 L449.9,23.7 '></path>
<g transform="translate(449.9,387.7)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:middle">
<text><tspan>Circle-1000</tspan>
</text>
</g>
<path d='M50.0,15.5 L50.0,367.2 L576.8,367.2 L576.8,15.5 L50.0,15.5 Z '></path>
<path d='M57.7,15.5 L57.7,367.2 L580.6,367.2 L580.6,15.5 L57.7,15.5 Z '></path>
</g>
<a xlink:title="Plot #1">
<g style="fill:none; color:red; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<g transform="translate(514.7,36.0)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<g transform="translate(518.5,36.0)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan>Eux</tspan>
</text>
</g>
<g style = 'stroke:none; shape-rendering:crispEdges'>
<polygon fill = 'currentColor' points = '522.4,36.0 561.4,36.0 561.4,27.8 522.4,27.8 '/>
<polygon fill = 'currentColor' points = '149.9,367.2 169.7,367.2 169.7,345.5 149.9,345.5 '/>
<polygon fill = 'currentColor' points = '281.6,367.2 301.4,367.2 301.4,278.8 281.6,278.8 '/>
<polygon fill = 'currentColor' points = '413.3,367.2 433.1,367.2 433.1,54.2 413.3,54.2 '/>
<polygon fill = 'currentColor' points = '526.2,36.0 565.2,36.0 565.2,27.8 526.2,27.8 '/>
<polygon fill = 'currentColor' points = '156.8,367.2 176.5,367.2 176.5,345.5 156.8,345.5 '/>
<polygon fill = 'currentColor' points = '287.6,367.2 307.3,367.2 307.3,278.8 287.6,278.8 '/>
<polygon fill = 'currentColor' points = '418.3,367.2 438.0,367.2 438.0,54.2 418.3,54.2 '/>
</g>
</g>
</a>
<a xlink:title="Plot #2">
<g style="fill:none; color:green; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<g transform="translate(514.7,52.4)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<g transform="translate(518.5,52.4)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan>NousAdapt</tspan>
</text>
</g>
<g style = 'stroke:none; shape-rendering:crispEdges'>
<polygon fill = 'currentColor' points = '522.4,52.4 561.4,52.4 561.4,44.2 522.4,44.2 '/>
<polygon fill = 'currentColor' points = '171.8,367.2 191.7,367.2 191.7,360.7 171.8,360.7 '/>
<polygon fill = 'currentColor' points = '303.5,367.2 323.4,367.2 323.4,348.8 303.5,348.8 '/>
<polygon fill = 'currentColor' points = '435.2,367.2 455.1,367.2 455.1,300.6 435.2,300.6 '/>
<polygon fill = 'currentColor' points = '526.2,52.4 565.2,52.4 565.2,44.2 526.2,44.2 '/>
<polygon fill = 'currentColor' points = '178.6,367.2 198.3,367.2 198.3,360.7 178.6,360.7 '/>
<polygon fill = 'currentColor' points = '309.3,367.2 329.1,367.2 329.1,348.8 309.3,348.8 '/>
<polygon fill = 'currentColor' points = '440.1,367.2 459.8,367.2 459.8,300.6 440.1,300.6 '/>
</g>
</g>
</a>
<a xlink:title="Plot #3">
<g style="fill:none; color:blue; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<g transform="translate(514.7,68.8)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<g transform="translate(518.5,68.8)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan>NousStatic</tspan>
</text>
</g>
<g style = 'stroke:none; shape-rendering:crispEdges'>
<polygon fill = 'currentColor' points = '522.4,68.8 561.4,68.8 561.4,60.6 522.4,60.6 '/>
<polygon fill = 'currentColor' points = '193.8,367.2 213.6,367.2 213.6,361.1 193.8,361.1 '/>
<polygon fill = 'currentColor' points = '325.5,367.2 345.3,367.2 345.3,340.8 325.5,340.8 '/>
<polygon fill = 'currentColor' points = '457.2,367.2 477.0,367.2 477.0,247.7 457.2,247.7 '/>
<polygon fill = 'currentColor' points = '526.2,68.8 565.2,68.8 565.2,60.6 526.2,60.6 '/>
<polygon fill = 'currentColor' points = '200.4,367.2 220.1,367.2 220.1,361.1 200.4,361.1 '/>
<polygon fill = 'currentColor' points = '331.1,367.2 350.8,367.2 350.8,340.8 331.1,340.8 '/>
<polygon fill = 'currentColor' points = '461.9,367.2 481.6,367.2 481.6,247.7 461.9,247.7 '/>
</g>
</g>
</a>
<a xlink:title="Plot #4">
<g style="fill:none; color:cyan; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<g transform="translate(514.7,85.2)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<g transform="translate(518.5,85.2)" style="stroke:none; fill:black; font-family:arial; font-size:11.00pt; text-anchor:end">
<text><tspan>NousMaxSubdiv</tspan>
</text>
</g>
<g style = 'stroke:none; shape-rendering:crispEdges'>
<polygon fill = 'currentColor' points = '522.4,85.2 561.4,85.2 561.4,77.0 522.4,77.0 '/>
<polygon fill = 'currentColor' points = '215.7,367.2 235.6,367.2 235.6,361.4 215.7,361.4 '/>
<polygon fill = 'currentColor' points = '347.4,367.2 367.3,367.2 367.3,343.8 347.4,343.8 '/>
<polygon fill = 'currentColor' points = '479.1,367.2 499.0,367.2 499.0,301.3 479.1,301.3 '/>
<polygon fill = 'currentColor' points = '526.2,85.2 565.2,85.2 565.2,77.0 526.2,77.0 '/>
<polygon fill = 'currentColor' points = '222.2,367.2 241.9,367.2 241.9,361.4 222.2,361.4 '/>
<polygon fill = 'currentColor' points = '352.9,367.2 372.6,367.2 372.6,343.8 352.9,343.8 '/>
<polygon fill = 'currentColor' points = '483.6,367.2 503.4,367.2 503.4,301.3 483.6,301.3 '/>
</g>
</g>
</a>
<g style="fill:none; color:black; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
<path d='M50.0,15.5 L50.0,367.2 L576.8,367.2 L576.8,15.5 L50.0,15.5 Z '></path>
<path d='M57.7,15.5 L57.7,367.2 L580.6,367.2 L580.6,15.5 L57.7,15.5 Z '></path>
</g>
</svg>
This diff is collapsed.
This diff is collapsed.
......@@ -50,6 +50,10 @@ public:
CGoGN::Algo::MovingObjects::ParticleCell2D<PFP> part_;
std::vector<VEC3> goals_;
VEC3 finalGoal;
Dart finalDart;
unsigned int curGoal_;
static unsigned int maxNeighbors_;
......
......@@ -2,6 +2,7 @@
#define ENV_GENERATOR
#include "Container/fakeAttribute.h"
#include "env_map.h"
namespace CGoGN
{
......@@ -15,14 +16,26 @@ bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker&
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark);
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark);
template <typename PFP>
Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& buildingMark, float height);
template <typename PFP>
void generateBuilding(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, float height, unsigned int buildingType, CellMarker& obstacleMark, CellMarker& buildingMark);
bool animateCity(EnvMap* envMap);
//template <typename PFP>
//Dart generateBuilding(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, float height, unsigned int buildingType, CellMarker& obstacleMark, CellMarker& buildingMark);
//template <typename PFP>
//void generateCity(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize, unsigned int nbSquares);
template <typename PFP>
void generateCity(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize, unsigned int nbSquares);
Dart generateBuilding(EnvMap* envMap, Dart d, float height, unsigned int buildingType);
template <typename PFP>
void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares);
template <typename PFP>
void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize);
......@@ -30,7 +43,6 @@ void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMark
template <typename PFP>
void generatePathToUpperStair(typename PFP::MAP& map,typename PFP::TVEC3& position, Dart dLower,Dart dUpper);
template <typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position);
......
......@@ -44,6 +44,104 @@ Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, typenam
return prim;
}
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark)
{
Algo::Modelisation::Polyhedron<PFP> prim(map, position);
prim.grid_topo(cX, cY);
prim.embedGrid(sideLength * cX, sqrt(sideLength*sideLength*3.0f/4.0f) * cY);
Dart dY = prim.getDart(); //remind the first quad of the line
Dart dX = prim.getDart(); //goes through the line
bool odd=true; //odd line or not
for(unsigned int i=0;i<cX*cY; )
{
Dart dNext = map.phi1(map.phi2(map.phi1(dX)));
Dart toCut = dX;
if(odd)
{
toCut = map.phi1(toCut); //change the side of the split face
position[toCut][0]-= sideLength/2.0f; //move vertices for equilateral triangles
}
map.splitFace(toCut,map.phi1(map.phi1(toCut)));
++i;
if(i%cX==0 && i>0) //goes up and change side of split
{
Dart endSquare = map.newOrientedFace(3); //add triangle add end of lines to make a square
Dart dN;
if(odd)
{
dN = map.phi1(map.phi2(map.phi1(dX)));
map.sewFaces(dN,endSquare);
position[map.phi_1(endSquare)] = position[map.phi1(endSquare)];
position[map.phi_1(endSquare)][0]+= sideLength/2.0f;
}
else
{
dN = map.phi1(dX);
map.sewFaces(dN,endSquare);
position[map.phi_1(endSquare)] = position[endSquare];
}
if(odd)
dY = map.phi2(map.phi_1(map.phi2(map.phi1(dY))));
else
dY = map.phi2(map.phi1(map.phi2(map.phi_1(dY))));
dX = dY;
odd=!odd;
}
else
dX = dNext;
}
Dart boundary;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(map.phi2(d) == d)
{
Dart dA = map.alpha1(map.phi1(d));
if(map.phi2(dA)==dA && position[dA]==position[map.phi1(d)] && position[map.phi1(dA)]==position[d])
map.sewFaces(dA,d);
else
{
obstacleMark.mark(d);
boundary = d;
}
}
}
map.closeHole(boundary);
buildingMark.mark(map.phi2(boundary));
if(odd) //last top line if odd
{
for(unsigned int i=0;i<cX; ++i)
{
dX = map.phi1(dX);
position[dX][0]-= sideLength/2.0f;
}
}
//add hexagons
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(map.vertexDegree(d)==6)
// {
// map.deleteVertex(d);
// }
// }
return prim;
}
template <typename PFP>
Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& buildingMark, float height)
{
......@@ -59,79 +157,177 @@ Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, D
}
template <typename PFP>
void generateBuilding(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, float height, unsigned int buildingType, CellMarker& obstacleMark, CellMarker& buildingMark)
bool animateCity(EnvMap* envMap)
{
typename PFP::MAP& map = envMap->map;
typename PFP::TVEC3& position = envMap->position;
typename PFP::TAB_AGENTVECT& agents = envMap->agentvect;
typename PFP::TAB_AGENTVECT& agentNeighbors = envMap->neighborAgentvect;
CellMarker& obstacleMark = envMap->obstacleMark;
CellMarker& buildingMark = envMap->buildingMark;
std::vector<Dart>& newBuildings = envMap->newBuildings;
unsigned int state=rand()%10;
if(state<2)
{
//generate new building
bool found=false;
Dart d(rand()%map.getNbDarts());
if(!map.isDartValid(d))
map.next(d);
if(!buildingMark.isMarked(d) && agents[d].size() == 0 && agentNeighbors[d].size() == 0 && notDiagonalAdjacentToAnObstacle<PFP>(map,d,obstacleMark))
found=true;
if(found)
{
d = generateBuilding<PFP>(envMap, d, 2.0f, 0);
newBuildings.push_back(d);
return true;
}
}
else if(newBuildings.size()>0)
{
//take a newBuilding and make it higher
state = rand()%newBuildings.size();
Dart d = newBuildings[state];
//decide if we create a new floor, or just make it higher
unsigned int typeOfUpdate = rand()%10;
if(typeOfUpdate<9)
{
Dart dd=d;
do
{
position[dd][2] += 2.0f;
dd = map.phi1(dd);
} while(dd!=d);
if(position[dd][2]>((10+rand()%10)*10.0f))
newBuildings.erase(newBuildings.begin()+state);
}
else
{
typename PFP::VEC3 c = Algo::Geometry::faceCentroid<PFP>(map,d,position);
Dart dRoofSmall = Algo::Modelisation::extrudeFace<PFP>(map,position,d,0.0f);
Dart dd = dRoofSmall;
do
{
position[dd] = position[dd] + (c-position[dd])/3.0f;
dd = map.phi1(dd);
} while (dd!=dRoofSmall);
// Dart dRoof = Algo::Modelisation::extrudeFace<PFP>(map,position,dRoofSmall,2.0f);
Dart dRoof = extrudeFaceAndMark<PFP>(map,position,dRoofSmall,buildingMark,2.0f);
newBuildings.erase(newBuildings.begin()+state);
newBuildings.push_back(dRoof);
}
}
return false;
}
//template <typename PFP>
//Dart generateBuilding(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, float height, unsigned int buildingType, CellMarker& obstacleMark, CellMarker& buildingMark)
//template <typename PFP>
//void generateCity(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize, unsigned int nbSquares)
template <typename PFP>
Dart generateBuilding(EnvMap* envMap, Dart d, float height, unsigned int buildingType)
{
typename PFP::MAP& map = envMap->map;
typename PFP::TVEC3& position = envMap->position;
CellMarker& obstacleMark = envMap->obstacleMark;
CellMarker& buildingMark = envMap->buildingMark;
// mark the face as obstacle before extrusion
Dart dd = d;
buildingMark.mark(dd);
do
{
obstacleMark.mark(dd);
Dart next = map.phi1(dd);
Dart previous = map.phi_1(dd);
Obstacle* o = new Obstacle(position[dd], position[next], position[previous], position[map.phi1(next)]);
envMap->pushObstacleInCells(o, map.phi2(dd));
dd = map.phi1(dd);
} while(dd != d);
// Dart dRoof;
// dRoof = extrudeFaceAndMark<PFP>(map, position, d, buildingMark, height);
//
// switch(buildingType)
// {
// case 0 :
// {
// break;