|
|
@ -47,7 +47,7 @@
|
|
|
|
//#include <nel/ligo/zone_region.h>
|
|
|
|
//#include <nel/ligo/zone_region.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
//#include <set>
|
|
|
|
#include <list>
|
|
|
|
#include <map>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
@ -90,6 +90,7 @@ struct CPoint
|
|
|
|
CVector Pos; /* Position, height not necessarily specified (X="26218.738281" Y="-1092.078979" Z="0.000000") */
|
|
|
|
CVector Pos; /* Position, height not necessarily specified (X="26218.738281" Y="-1092.078979" Z="0.000000") */
|
|
|
|
float Angle; /* (2.827213) */
|
|
|
|
float Angle; /* (2.827213) */
|
|
|
|
float Scale; /* Scale (0.643217) */
|
|
|
|
float Scale; /* Scale (0.643217) */
|
|
|
|
|
|
|
|
std::string Shape;
|
|
|
|
|
|
|
|
|
|
|
|
bool Plant;
|
|
|
|
bool Plant;
|
|
|
|
std::string Form; /* (FY_S2_savantree_B) */
|
|
|
|
std::string Form; /* (FY_S2_savantree_B) */
|
|
|
@ -165,7 +166,7 @@ struct CPlant
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
std::map<std::string, CPlant> s_ShapeToForm;
|
|
|
|
std::map<std::string, CPlant> s_ShapeToForm;
|
|
|
|
std::set<CPoint> s_Instances;
|
|
|
|
std::list<CPoint> s_Instances;
|
|
|
|
|
|
|
|
|
|
|
|
bool loadLeveldesign()
|
|
|
|
bool loadLeveldesign()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -235,9 +236,9 @@ bool loadInstances()
|
|
|
|
instance.Pos = info.Pos;
|
|
|
|
instance.Pos = info.Pos;
|
|
|
|
instance.Angle = info.Rot.getAngle();
|
|
|
|
instance.Angle = info.Rot.getAngle();
|
|
|
|
instance.Scale = info.Scale.z;
|
|
|
|
instance.Scale = info.Scale.z;
|
|
|
|
string shape = toLowerAscii(info.Name);
|
|
|
|
instance.Shape = toLowerAscii(info.Name);
|
|
|
|
printf("%s\n", shape.c_str());
|
|
|
|
printf("%s\n", instance.Shape.c_str());
|
|
|
|
std::map<std::string, CPlant>::iterator formIt = s_ShapeToForm.find(shape);
|
|
|
|
std::map<std::string, CPlant>::iterator formIt = s_ShapeToForm.find(instance.Shape);
|
|
|
|
if (formIt != s_ShapeToForm.end())
|
|
|
|
if (formIt != s_ShapeToForm.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
instance.Form = formIt->second.Form;
|
|
|
|
instance.Form = formIt->second.Form;
|
|
|
@ -250,6 +251,81 @@ bool loadInstances()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
instance.Plant = false;
|
|
|
|
instance.Plant = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s_Instances.push_back(instance);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool eraseReference()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<std::string> igs;
|
|
|
|
|
|
|
|
CPath::getPathContent(s_ReferenceDir, true, false, true, igs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (std::vector<std::string>::iterator it(igs.begin()), end(igs.end()); it != end; ++it)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (CFile::getExtension(*it) != nlstr("ig"))
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
printf("%s\n", (*it).c_str());
|
|
|
|
|
|
|
|
CInstanceGroup ig;
|
|
|
|
|
|
|
|
CIFile inputStream;
|
|
|
|
|
|
|
|
if (!inputStream.open(*it))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("Unable to open %s\n", (*it).c_str());
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ig.serial(inputStream);
|
|
|
|
|
|
|
|
CVector gpos = ig.getGlobalPos();
|
|
|
|
|
|
|
|
if (gpos.x != 0.0f || gpos.y != 0.0f || gpos.z != 0.0f)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("Invalid global pos: %f, %f, %f", gpos.x, gpos.y, gpos.z);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
string zoneLwr = toLowerAscii(CFile::getFilenameWithoutExtension(*it));
|
|
|
|
|
|
|
|
for (ptrdiff_t i = 0; i < (ptrdiff_t)ig._InstancesInfos.size(); ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CInstanceGroup::CInstance &info = ig._InstancesInfos[i];
|
|
|
|
|
|
|
|
string shape = toLowerAscii(info.Name);
|
|
|
|
|
|
|
|
printf("%s\n", shape.c_str());
|
|
|
|
|
|
|
|
bool erased = false;
|
|
|
|
|
|
|
|
for (std::list<CPoint>::iterator it(s_Instances.begin()), end(s_Instances.end()); it != end; ++it)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const CPoint &instance = *it;
|
|
|
|
|
|
|
|
if (instance.Pos.x == info.Pos.x
|
|
|
|
|
|
|
|
&& instance.Pos.y == info.Pos.y
|
|
|
|
|
|
|
|
&& instance.Shape == shape)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf(" = Found and erased\n");
|
|
|
|
|
|
|
|
s_Instances.erase(it);
|
|
|
|
|
|
|
|
erased = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!erased)
|
|
|
|
|
|
|
|
printf(" = NOT FOUND!\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool eraseNonPlants()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (std::list<CPoint>::iterator it(s_Instances.begin()), end(s_Instances.end()); it != end;)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const CPoint &instance = *it;
|
|
|
|
|
|
|
|
if (!instance.Plant)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erase '%s' because it's not a plant!\n", instance.Shape.c_str());
|
|
|
|
|
|
|
|
std::list<CPoint>::iterator nextIt = it;
|
|
|
|
|
|
|
|
++nextIt;
|
|
|
|
|
|
|
|
s_Instances.erase(it);
|
|
|
|
|
|
|
|
it = nextIt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -262,7 +338,9 @@ bool unbuildFlora()
|
|
|
|
CPath::addSearchPath(s_LeveldesignDir, true, false);
|
|
|
|
CPath::addSearchPath(s_LeveldesignDir, true, false);
|
|
|
|
|
|
|
|
|
|
|
|
return loadLeveldesign()
|
|
|
|
return loadLeveldesign()
|
|
|
|
&& loadInstances();
|
|
|
|
&& loadInstances()
|
|
|
|
|
|
|
|
&& eraseReference()
|
|
|
|
|
|
|
|
&& eraseNonPlants();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool unbuildFlora(NLMISC::CCmdArgs &args)
|
|
|
|
bool unbuildFlora(NLMISC::CCmdArgs &args)
|
|
|
|