Commit edc6c934 authored by David Cazier's avatar David Cazier
Browse files

Merge cgogn:~jund/CGoGN_Apps/SA2

Conflicts:
	svg/mapBuild.svg
parents 62edba1a 09ef01a3
......@@ -57,9 +57,15 @@ void generatePathToUpperStair(typename PFP::MAP& map, typename PFP::TVEC3& posit
template <typename PFP>
void generatePlanet(EnvMap& envMap) ;
template <typename PFP>
typename PFP::VEC3 parametrization(typename PFP::VEC3 p, float r, Geom::BoundingBox<typename PFP::VEC3> bb);
template <typename PFP>
void planetify(typename PFP::MAP& map, typename PFP::TVEC3& position, float r);
template <typename PFP>
void planetify(typename PFP::MAP& map, typename PFP::TVEC3& position, float r, Geom::BoundingBox<typename PFP::VEC3> bb);
/*******************************************************************************/
template <typename PFP>
......
......@@ -202,7 +202,11 @@ template <typename PFP>
Dart extrudeBuilding(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, unsigned int buildingType, float height)
{
Dart dRoof ;
VEC3 sky(0,0,1.0f);
// VEC3 sky(0,0,1.0f);
VEC3 v1(position[map.phi1(d)]-position[d]);
VEC3 v2(position[map.template phi<11>(d)]-position[d]);
VEC3 sky = (v1^v2);
sky.normalize();
dRoof = Algo::Modelisation::extrudeFace<PFP>(map, position, d, sky*height) ;
switch (buildingType)
......@@ -613,43 +617,44 @@ void generatePlanet(EnvMap& envMap)
prim.embedSphere((xRadius+yRadius)/2.0f) ;
}
template <typename PFP>
typename PFP::VEC3 parametrization(typename PFP::VEC3 p, float r, Geom::BoundingBox<typename PFP::VEC3> bb)
{
p[0] = 2.0f*M_PI*(p[0]-bb.min()[0])/bb.size(0);
p[1] = ((2.0f*M_PI*(p[1]-bb.min()[1])/bb.size(1))-M_PI)/2.0f;
return typename PFP::VEC3(2.0f*r*cos(p[0])*cos(p[1]),
2.0f*r*sin(p[0])*cos(p[1]),
2.0f*r*sin(p[1]));
}
template <typename PFP>
void planetify(typename PFP::MAP& map, typename PFP::TVEC3& position, float r)
{
Geom::BoundingBox<typename PFP::VEC3> bb ;
bb = Algo::Geometry::computeBoundingBox<PFP>(map, position) ;
VEC3 diff = bb.max() - bb.min();
float width = diff[0];
float height = diff[1];
float nR = std::max(width, height);
typedef typename PFP::VEC3 VEC3 ;
TraversorV<typename PFP::MAP> tv(map);
//apply inverted transformation to build a sphere from planar coordinates (not working)
for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
{
VEC3 p = position[d];
// p -= bb.min();
p -= bb.center();
// p /= (nR/2.0f);
p.normalize();
// position[d] = VEC3(
// 2.0f*p[0]/(1.0f+(p[0]*p[0])+(p[1]*p[1])),
// 2.0f*p[1]/(1.0f+(p[0]*p[0])+(p[1]*p[1])),
// (-1.0f+(p[0]*p[0])+(p[1]*p[1]))/(1.0f+(p[0]*p[0])+(p[1]*p[1]))
// );
//inverted Lambert azimuthal equal-area projection (not working)
position[d] = VEC3(
sqrt(1.0f-((p[0]*p[0])+(p[1]*p[1]))/4.0f*p[0]),
sqrt(1.0f-((p[0]*p[0])+(p[1]*p[1]))/4.0f*p[1]),
-1.0f+((p[0]*p[0])+(p[1]*p[1]))/2.0f);
position[d] = parametrization<PFP>(position[d], r, bb);
}
}
template <typename PFP>
void planetify(typename PFP::MAP& map, typename PFP::TVEC3& position, float r, Geom::BoundingBox<typename PFP::VEC3> bb)
{
TraversorV<typename PFP::MAP> tv(map);
for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
{
position[d] = parametrization<PFP>(position[d], r, bb);
}
}
template <typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position,
CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
......
......@@ -95,18 +95,32 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
std::string filename = "./svg/mapRoads.svg" ;
// std::string filename = "./svg/simpleCross.svg" ;
Algo::Import::importSVG<PFP>(map, filename, position, obstacleMark, buildingMark) ;
// CityGenerator::planetify<PFP>(map, position, 10.0f);
std::cout << "test" << std::endl;
mapScenary.addAttribute<float, FACE>("agents") ;
std::string filename2 = "./svg/mapBuild.svg" ;
Algo::Import::importSVG<PFP>(mapScenary, filename2, positionScenary, obstacleMarkS, buildingMarkS) ;
Geom::BoundingBox<typename PFP::VEC3> bb1, bb2 ;
bb1 = Algo::Geometry::computeBoundingBox<PFP>(map, position) ;
bb2 = Algo::Geometry::computeBoundingBox<PFP>(map, position) ;
bb1.addPoint(bb2.min());
bb1.addPoint(bb2.max());
// CityGenerator::planetify<PFP>(map, position, 10.0f, bb1);
// CityGenerator::planetify<PFP>(mapScenary, positionScenary, 10.0f, bb1);
std::vector<Dart> v;
TraversorF<PFP::MAP> tF(mapScenary);
for(Dart d = tF.begin() ; d != tF.end() ; d = tF.next())
{
v.push_back(d);
}
std::cout << "builds " << v.size() << std::endl;
for(std::vector<Dart>::iterator it = v.begin() ; it != v.end() ; it++)
{
Dart d = *it;
//test if convex
bool convex=true;
......@@ -161,16 +175,9 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
et.triangule();
//subdivision to create footpath
// SelectorCellUnmarked<EDGE> nb(obstacleMark);
SelectorDartNoBoundary<PFP::MAP> nb(map);
// SelectorTrue alldarts;
Algo::Modelisation::TwoNPlusOneSubdivision<PFP,PFP::TVEC3, VEC3>(map,position,nb);
markPedWay();
// Algo::BooleanOperator::mergeVertices<PFP>(map, position) ;
// map.closeMap() ;
// Algo::Modelisation::CatmullClarkSubdivision<PFP>(map, position) ;
// Algo::Modelisation::computeDual<PFP>(map) ;
// SelectorDartNoBoundary<PFP::MAP> nb(map);
// Algo::Modelisation::TwoNPlusOneSubdivision<PFP,PFP::TVEC3, VEC3>(map,position,nb);
// markPedWay();
}
break;
}
......
......@@ -897,8 +897,6 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
cameraLook[1] = tmp ;
}
//define the camera position
// if (draft) out << "#include \"sombrero2_lowres_POV_geom.inc\"" << std::endl ;
if (!draft)
{
out << "#include \"Sheriff_animated_POV_geom.inc\"" << std::endl ;
......@@ -919,7 +917,6 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
// out << "camera { location PosSpline(" << (sim.globalTime_ - 1000.0f) / 120.0f
// << ") look_at LookSpline(" << (sim.globalTime_ - 1000.0f) / 120.0f << ") " ;
// else
out << "camera { location <" << cameraPos[0] << "," << cameraPos[1] << "," << cameraPos[2]
<< "> look_at <" << cameraLook[0] << "," << cameraLook[1] << "," << cameraLook[2] << "> " ;
......
This diff is collapsed.
......@@ -36,14 +36,14 @@
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1680"
inkscape:window-height="994"
inkscape:window-height="1021"
id="namedview20587"
showgrid="false"
inkscape:zoom="1.8101934"
inkscape:cx="269.64834"
inkscape:cy="724.69223"
inkscape:window-x="1680"
inkscape:window-y="27"
inkscape:zoom="0.45254835"
inkscape:cx="444.14566"
inkscape:cy="746.80007"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:object-nodes="true"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="800"
height="800"
id="svg2"
version="1.1"
inkscape:version="0.48.1 r9760"
sodipodi:docname="planet.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="263.3871"
inkscape:cy="369.89214"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-page="true"
inkscape:window-width="1680"
inkscape:window-height="1021"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:object-nodes="true"
inkscape:snap-smooth-nodes="false"
inkscape:snap-global="true"
inkscape:object-paths="false" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-252.36218)">
<path
style="fill:none;stroke:#000000;stroke-width:30;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 0,721.42857 58.159369,3.8453 88.090631,28.83327 291.18662,-3.73465 229.70624,-214.65821"
id="path2987"
inkscape:connector-curvature="0"
transform="translate(0,252.36218)"
sodipodi:nodetypes="ccccc" />
<path
style="color:#000000;fill:none;stroke:#000000;stroke-width:40;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 58.159369,725.27387 30.794724,-45.986 291.651787,-8.85539 -2.71457,-269.60141 1.5856,-197.34046 L 700,264.28571"
id="path2989"
inkscape:connector-curvature="0"
transform="translate(0,252.36218)"
sodipodi:nodetypes="cccccc" />
<path
style="fill:none;stroke:#000000;stroke-width:40;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 0,402.63304 90.620126,-0.99867 287.271184,-0.8033 c 80.24707,-0.38299 337.63234,57.75207 337.63234,57.75207 L 800,396.23893 637.14286,348.81651"
id="path3780"
inkscape:connector-curvature="0"
transform="translate(0,252.36218)"
sodipodi:nodetypes="cccccc" />
<path
style="fill:none;stroke:#000000;stroke-width:30;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="M 88.954093,679.28787 0,491.86667 0,402.63304 0,301.57911 379.47691,203.49061"
id="path3779"
inkscape:connector-curvature="0"
transform="translate(0,252.36218)"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;stroke:#000000;stroke-width:60;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="m 140,465.71429 97.85714,97.85714"
id="path3781"
inkscape:connector-curvature="0"
transform="translate(0,252.36218)" />
</g>
</svg>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment