|
@@ -37,8 +37,8 @@
|
|
#define FILE_AUDIO_MTL "models/audio/audio.mtl"
|
|
#define FILE_AUDIO_MTL "models/audio/audio.mtl"
|
|
#define FILE_VIDEO_OBJ "models/camera/camera.obj"
|
|
#define FILE_VIDEO_OBJ "models/camera/camera.obj"
|
|
#define FILE_VIDEO_MTL "models/camera/camera.mtl"
|
|
#define FILE_VIDEO_MTL "models/camera/camera.mtl"
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
Generator::Generator(General& g, std::vector<Area>& a,std::vector<Resource>& r,
|
|
Generator::Generator(General& g, std::vector<Area>& a,std::vector<Resource>& r,
|
|
std::vector<Stage>& s, GWindow* ui)
|
|
std::vector<Stage>& s, GWindow* ui)
|
|
{
|
|
{
|
|
@@ -93,6 +93,19 @@ void Generator::error(const std::string& l, int level)
|
|
else if(level==LOG_ERROR) {p="Erreur: "; m_nErrors++;}
|
|
else if(level==LOG_ERROR) {p="Erreur: "; m_nErrors++;}
|
|
else {p="Erreur Critique: "; m_nCriticalErrors++; }
|
|
else {p="Erreur Critique: "; m_nCriticalErrors++; }
|
|
m_errors.push_back (p+l);
|
|
m_errors.push_back (p+l);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void Generator::generateMap()
|
|
|
|
+{
|
|
|
|
+ std::string map = m_gen.getMap ();
|
|
|
|
+ if(map!="")
|
|
|
|
+ {
|
|
|
|
+ log("Génération du la map: '"+map+"' vers '" +OS::concatPath(m_pathRaw, strtolower (m_gen.m_name+"_map"))+"'");
|
|
|
|
+ OS::copy(map, OS::concatPath(m_pathRaw, "map") );
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ log("Pas de carte a ajouter");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void Generator::generate()
|
|
void Generator::generate()
|
|
@@ -100,6 +113,7 @@ void Generator::generate()
|
|
Json::Value o = m_ui->getJson (true);
|
|
Json::Value o = m_ui->getJson (true);
|
|
std::cout << "gen: "<< OS::concatPath(m_pathRaw, strtolower (m_gen.m_name)) << std::endl;
|
|
std::cout << "gen: "<< OS::concatPath(m_pathRaw, strtolower (m_gen.m_name)) << std::endl;
|
|
std::ofstream rout(OS::concatPath(m_pathRaw, strtolower (m_gen.m_name)));
|
|
std::ofstream rout(OS::concatPath(m_pathRaw, strtolower (m_gen.m_name)));
|
|
|
|
+ generateMap();
|
|
for(int i=0; i<m_resources.size(); i++)
|
|
for(int i=0; i<m_resources.size(); i++)
|
|
{
|
|
{
|
|
|
|
|
|
@@ -124,7 +138,7 @@ Resource* Generator::findResource(const std::string& name)
|
|
return &m_resources[i];
|
|
return &m_resources[i];
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Stage* Generator::findStage(int i)
|
|
Stage* Generator::findStage(int i)
|
|
{
|
|
{
|
|
for(int i=0; i<m_stages.size(); i++)
|
|
for(int i=0; i<m_stages.size(); i++)
|
|
@@ -246,7 +260,6 @@ void Generator::generateResourceImage(Resource& r)
|
|
o.generate ();
|
|
o.generate ();
|
|
log("\tGénération du fichier ressource: '"+OS::concatPath(m_pathRaw, strtolower (r.getName()))+"_res'");
|
|
log("\tGénération du fichier ressource: '"+OS::concatPath(m_pathRaw, strtolower (r.getName()))+"_res'");
|
|
std::ofstream rout(OS::concatPath(m_pathRaw, strtolower (r.getName()))+"_res");
|
|
std::ofstream rout(OS::concatPath(m_pathRaw, strtolower (r.getName()))+"_res");
|
|
- copyObj(FILE_VIDEO_OBJ, m_pathRaw, r.getName());
|
|
|
|
rout << r.getJson(true);
|
|
rout << r.getJson(true);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -261,25 +274,24 @@ void Generator::generateResourceAudio(Resource& r)
|
|
copyObj(FILE_AUDIO_OBJ, m_pathRaw, r.getName());
|
|
copyObj(FILE_AUDIO_OBJ, m_pathRaw, r.getName());
|
|
rout << r.getJson(true);
|
|
rout << r.getJson(true);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
void Generator::generateResourceVideo(Resource& r)
|
|
void Generator::generateResourceVideo(Resource& r)
|
|
{
|
|
{
|
|
OS::Path o(r.getFile());
|
|
OS::Path o(r.getFile());
|
|
log("\tCopie du fichier video '"+r.getFile()+"' vers '"+OS::concatPath(m_pathRaw, r.getName()+"_video")+"'");
|
|
log("\tCopie du fichier video '"+r.getFile()+"' vers '"+OS::concatPath(m_pathRaw, r.getName()+"_video")+"'");
|
|
std::ofstream rout(OS::concatPath(m_pathRaw, strtolower (r.getName()))+"_res");
|
|
std::ofstream rout(OS::concatPath(m_pathRaw, strtolower (r.getName()))+"_res");
|
|
log("\tGénération du fichier ressource: '"+OS::concatPath(m_pathRaw, strtolower (r.getName()))+"_res'");
|
|
log("\tGénération du fichier ressource: '"+OS::concatPath(m_pathRaw, strtolower (r.getName()))+"_res'");
|
|
|
|
+ copyObj(FILE_VIDEO_OBJ, m_pathRaw, r.getName());
|
|
OS::copy(r.getFile(), OS::concatPath(m_pathRaw, r.getName()+"_video") );
|
|
OS::copy(r.getFile(), OS::concatPath(m_pathRaw, r.getName()+"_video") );
|
|
rout << r.getJson(true);
|
|
rout << r.getJson(true);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
void Generator::generateResource(Resource& r)
|
|
void Generator::generateResource(Resource& r)
|
|
{
|
|
{
|
|
int n = stringtotype (r.getType());
|
|
int n = stringtotype (r.getType());
|
|
- //std::cout << TYPE_3D << " == " << n << std::endl;
|
|
|
|
- //std::cout << "3D" << " == " << r.getType() << std::endl;
|
|
|
|
switch(n)
|
|
switch(n)
|
|
{
|
|
{
|
|
case TYPE_3D:
|
|
case TYPE_3D:
|
|
@@ -304,7 +316,7 @@ std::string Generator::newFilename(const std::string& file)
|
|
return strtolower(p.m_name)+"_"+strtolower(p.m_ext);
|
|
return strtolower(p.m_name)+"_"+strtolower(p.m_ext);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
void Generator::copyObj(const std::string& obj, const std::string& dir, const std::string& name)
|
|
void Generator::copyObj(const std::string& obj, const std::string& dir, const std::string& name)
|
|
{
|
|
{
|
|
std::string line;
|
|
std::string line;
|
|
@@ -340,7 +352,7 @@ void Generator::copyObj(const std::string& obj, const std::string& dir, const st
|
|
else
|
|
else
|
|
out << buf << std::endl;
|
|
out << buf << std::endl;
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
int Generator::getErrorsCount() { return m_nErrors; }
|
|
int Generator::getErrorsCount() { return m_nErrors; }
|
|
@@ -352,7 +364,7 @@ void Generator::copyMtl(const std::string& mtl, const std::string& dir)
|
|
std::string line;
|
|
std::string line;
|
|
OS::Path o(mtl);
|
|
OS::Path o(mtl);
|
|
std::ifstream in(mtl);
|
|
std::ifstream in(mtl);
|
|
- std::ofstream out(OS::concatPath(dir,strtolower (o.m_name)+"_mtl"));
|
|
|
|
|
|
+ std::ofstream out(OS::concatPath(dir,strtolower (o.m_name)+".mtl"));
|
|
//std::cout << "Mlt " << dir+"/"+strtolower (o.m_name)<< std::endl;
|
|
//std::cout << "Mlt " << dir+"/"+strtolower (o.m_name)<< std::endl;
|
|
log("\tCopie du fichier MTL '"+mtl+"' vers '"+OS::concatPath(dir,strtolower (o.m_name)+"_mtl'"));
|
|
log("\tCopie du fichier MTL '"+mtl+"' vers '"+OS::concatPath(dir,strtolower (o.m_name)+"_mtl'"));
|
|
while(std::getline(in, line))
|
|
while(std::getline(in, line))
|
|
@@ -365,7 +377,7 @@ void Generator::copyMtl(const std::string& mtl, const std::string& dir)
|
|
buf=line.substr(i);
|
|
buf=line.substr(i);
|
|
buf=buf;
|
|
buf=buf;
|
|
if( (start=buf.find("map_Kd") )!= std::string::npos )
|
|
if( (start=buf.find("map_Kd") )!= std::string::npos )
|
|
- {
|
|
|
|
|
|
+ {
|
|
std::string tmp="";
|
|
std::string tmp="";
|
|
std::string file="";
|
|
std::string file="";
|
|
|
|
|