added movie15parameter class
This commit is contained in:
parent
01ca6ad3a0
commit
41872da199
|
@ -55,7 +55,23 @@ template<typename SaveMeshType>
|
||||||
class ExporterIDTF
|
class ExporterIDTF
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Save(SaveMeshType& m,const char* file,const int mask)
|
enum IDTFError
|
||||||
|
{
|
||||||
|
E_NOERROR // 0
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *ErrorMsg(int error)
|
||||||
|
{
|
||||||
|
static const char * dae_error_msg[] =
|
||||||
|
{
|
||||||
|
"No errors"
|
||||||
|
};
|
||||||
|
|
||||||
|
if(error>0 || error<0) return "Unknown error";
|
||||||
|
else return dae_error_msg[error];
|
||||||
|
};
|
||||||
|
|
||||||
|
static int Save(SaveMeshType& m,const char* file,const int mask)
|
||||||
{
|
{
|
||||||
Output_File idtf(file);
|
Output_File idtf(file);
|
||||||
idtf.write(0,"FILE_FORMAT \"IDTF\"");
|
idtf.write(0,"FILE_FORMAT \"IDTF\"");
|
||||||
|
@ -121,7 +137,7 @@ public:
|
||||||
idtf.write(4,"}");
|
idtf.write(4,"}");
|
||||||
idtf.write(3,"}");
|
idtf.write(3,"}");
|
||||||
idtf.write(3,"MESH_FACE_POSITION_LIST {");
|
idtf.write(3,"MESH_FACE_POSITION_LIST {");
|
||||||
for(typename SaveMeshType::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit)
|
for(SaveMeshType::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit)
|
||||||
{
|
{
|
||||||
idtf.write(4,TextUtility::nmbToStr(fit->V(0) - &(*m.vert.begin())) + " " +
|
idtf.write(4,TextUtility::nmbToStr(fit->V(0) - &(*m.vert.begin())) + " " +
|
||||||
TextUtility::nmbToStr(fit->V(1) - &(*m.vert.begin())) + " " +
|
TextUtility::nmbToStr(fit->V(1) - &(*m.vert.begin())) + " " +
|
||||||
|
@ -131,7 +147,7 @@ public:
|
||||||
|
|
||||||
idtf.write(3,"MESH_FACE_NORMAL_LIST {");
|
idtf.write(3,"MESH_FACE_NORMAL_LIST {");
|
||||||
unsigned int nn = 0;
|
unsigned int nn = 0;
|
||||||
for(typename SaveMeshType::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit)
|
for(SaveMeshType::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit)
|
||||||
{
|
{
|
||||||
idtf.write(4,TextUtility::nmbToStr(nn) + " " +
|
idtf.write(4,TextUtility::nmbToStr(nn) + " " +
|
||||||
TextUtility::nmbToStr(nn + 1) + " " +
|
TextUtility::nmbToStr(nn + 1) + " " +
|
||||||
|
@ -144,7 +160,7 @@ public:
|
||||||
{
|
{
|
||||||
idtf.write(3,"MESH_FACE_TEXTURE_COORD_LIST {");
|
idtf.write(3,"MESH_FACE_TEXTURE_COORD_LIST {");
|
||||||
unsigned int nn = 0;
|
unsigned int nn = 0;
|
||||||
for(typename SaveMeshType::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit)
|
for(SaveMeshType::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit)
|
||||||
{
|
{
|
||||||
idtf.write(4,"FACE " + TextUtility::nmbToStr(nn) + "{");
|
idtf.write(4,"FACE " + TextUtility::nmbToStr(nn) + "{");
|
||||||
idtf.write(5,"TEXTURE_LAYER 0 TEX_COORD: " + TextUtility::nmbToStr(nn) + " " +
|
idtf.write(5,"TEXTURE_LAYER 0 TEX_COORD: " + TextUtility::nmbToStr(nn) + " " +
|
||||||
|
@ -156,14 +172,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
idtf.write(3,"MESH_FACE_SHADING_LIST {");
|
idtf.write(3,"MESH_FACE_SHADING_LIST {");
|
||||||
for(typename SaveMeshType::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit)
|
for(SaveMeshType::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit)
|
||||||
{
|
{
|
||||||
idtf.write(4,TextUtility::nmbToStr(0));
|
idtf.write(4,TextUtility::nmbToStr(0));
|
||||||
}
|
}
|
||||||
idtf.write(3,"}");
|
idtf.write(3,"}");
|
||||||
|
|
||||||
idtf.write(3,"MODEL_POSITION_LIST {");
|
idtf.write(3,"MODEL_POSITION_LIST {");
|
||||||
for(typename SaveMeshType::ConstVertexIterator vit = m.vert.begin();vit != m.vert.end();++vit)
|
for(SaveMeshType::ConstVertexIterator vit = m.vert.begin();vit != m.vert.end();++vit)
|
||||||
{
|
{
|
||||||
idtf.write(4,TextUtility::nmbToStr(vit->P().X()) + " " +
|
idtf.write(4,TextUtility::nmbToStr(vit->P().X()) + " " +
|
||||||
TextUtility::nmbToStr(vit->P().Y()) + " " +
|
TextUtility::nmbToStr(vit->P().Y()) + " " +
|
||||||
|
@ -172,7 +188,7 @@ public:
|
||||||
idtf.write(3,"}");
|
idtf.write(3,"}");
|
||||||
|
|
||||||
idtf.write(3,"MODEL_NORMAL_LIST {");
|
idtf.write(3,"MODEL_NORMAL_LIST {");
|
||||||
for(typename SaveMeshType::FaceIterator fitn = m.face.begin();fitn != m.face.end();++fitn)
|
for(SaveMeshType::FaceIterator fitn = m.face.begin();fitn != m.face.end();++fitn)
|
||||||
{
|
{
|
||||||
for(unsigned int ii = 0;ii < 3;++ii)
|
for(unsigned int ii = 0;ii < 3;++ii)
|
||||||
{
|
{
|
||||||
|
@ -186,7 +202,7 @@ public:
|
||||||
if (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)
|
if (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)
|
||||||
{
|
{
|
||||||
idtf.write(3,"MODEL_TEXTURE_COORD_LIST {");
|
idtf.write(3,"MODEL_TEXTURE_COORD_LIST {");
|
||||||
for(typename SaveMeshType::FaceIterator fitn = m.face.begin();fitn != m.face.end();++fitn)
|
for(SaveMeshType::FaceIterator fitn = m.face.begin();fitn != m.face.end();++fitn)
|
||||||
{
|
{
|
||||||
for(unsigned int ii = 0;ii < 3;++ii)
|
for(unsigned int ii = 0;ii < 3;++ii)
|
||||||
{
|
{
|
||||||
|
@ -200,6 +216,7 @@ public:
|
||||||
idtf.write(2,"}");
|
idtf.write(2,"}");
|
||||||
idtf.write(1,"}");
|
idtf.write(1,"}");
|
||||||
idtf.write(0,"}");
|
idtf.write(0,"}");
|
||||||
|
return IDTFError::E_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetExportMaskCapability()
|
static int GetExportMaskCapability()
|
||||||
|
|
|
@ -16,19 +16,82 @@ namespace io {
|
||||||
template<typename SaveMeshType>
|
template<typename SaveMeshType>
|
||||||
class ExporterU3D
|
class ExporterU3D
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
static void InvokeConverter(const QString& converter_path,const QString& input_idtf,const QString& output_u3d)
|
public:
|
||||||
|
enum U3DError
|
||||||
{
|
{
|
||||||
QProcess p;
|
E_NOERROR, // 0
|
||||||
|
E_ABORTED_CONVERSION //1
|
||||||
|
};
|
||||||
|
|
||||||
p.start(converter_path + "IDTFConverter.exe -input " + input_idtf + " -output " + output_u3d);
|
static const char *ErrorMsg(int error)
|
||||||
//wait for two minutes
|
{
|
||||||
bool t = p.waitForFinished(120000);
|
static const char * dae_error_msg[] =
|
||||||
p.close();
|
{
|
||||||
|
"No errors",
|
||||||
|
"Conversion Process From Idtf intermediate file to U3D format aborted"
|
||||||
|
};
|
||||||
|
|
||||||
|
if(error>1 || error<0) return "Unknown error";
|
||||||
|
else return dae_error_msg[error];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Movie15Parameters
|
||||||
|
{
|
||||||
|
Movie15Parameters()
|
||||||
|
{
|
||||||
|
_campar = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveLatex(SaveMeshType& m,const QString& file)
|
//WARNING: in movie15 y-axis and z-axis have been inverted!!!
|
||||||
|
class CameraParameters
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CameraParameters(const float cam_fov_angle,const float cam_roll_angle,
|
||||||
|
const vcg::Point3f& obj_to_cam_dir,const float obj_to_cam_dist,
|
||||||
|
const vcg::Point3f& obj_pos = vcg::Point3f(0.0f,0.0f,0.0f))
|
||||||
|
:_cam_fov_angle(cam_fov_angle),_cam_roll_angle(cam_roll_angle),_obj_to_cam_dir(obj_to_cam_dir),_obj_to_cam_dist(obj_to_cam_dist),_obj_pos(obj_pos)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
float _cam_fov_angle;
|
||||||
|
float _cam_roll_angle;
|
||||||
|
vcg::Point3f _obj_to_cam_dir;
|
||||||
|
float _obj_to_cam_dist;
|
||||||
|
vcg::Point3f _obj_pos;
|
||||||
|
|
||||||
|
};
|
||||||
|
CameraParameters* _campar;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
struct IDTFConverterParameters
|
||||||
|
{
|
||||||
|
const QString& _converter_loc;
|
||||||
|
const QString& _input_file;
|
||||||
|
const QString& _output_file;
|
||||||
|
|
||||||
|
IDTFConverterParameters(const QString& converter_loc,const QString& input_file,const QString& output_file)
|
||||||
|
:_converter_loc(converter_loc),_input_file(input_file),_output_file(output_file)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int InvokeConverter(const IDTFConverterParameters& par)
|
||||||
|
{
|
||||||
|
QProcess p;
|
||||||
|
QString convstring = par._converter_loc;
|
||||||
|
convstring = convstring + " -input " + par._input_file + " -output " + par._output_file;
|
||||||
|
p.start(convstring);
|
||||||
|
//wait until the task has been completed
|
||||||
|
bool t = p.waitForFinished(-1);
|
||||||
|
p.close();
|
||||||
|
return (int) t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SaveLatex(SaveMeshType& m,const QString& file,const Movie15Parameters& mov_par)
|
||||||
{
|
{
|
||||||
Output_File latex(file.toStdString() + ".tex");
|
Output_File latex(file.toStdString() + ".tex");
|
||||||
QString u3df = file + ".u3d";
|
QString u3df = file + ".u3d";
|
||||||
|
@ -38,7 +101,14 @@ private:
|
||||||
latex.write(1,"toolbar, %same as `controls\'");
|
latex.write(1,"toolbar, %same as `controls\'");
|
||||||
latex.write(1,"label=" + file.toStdString() + ",");
|
latex.write(1,"label=" + file.toStdString() + ",");
|
||||||
latex.write(1,"text=(" + u3df.toStdString() + "),");
|
latex.write(1,"text=(" + u3df.toStdString() + "),");
|
||||||
latex.write(1,"3Daac=60, 3Dcoo=-3.382026195526123 -63.33322525024414 -3.2237343788146973, 3Droo=1.4597717633624103,");
|
std::string cam_string;
|
||||||
|
Movie15Parameters::CameraParameters* cam = mov_par._campar;
|
||||||
|
cam_string = cam_string + "3Daac=" + TextUtility::nmbToStr(cam->_cam_fov_angle) +
|
||||||
|
", 3Droll=" + TextUtility::nmbToStr(cam->_cam_roll_angle) +
|
||||||
|
", 3Dc2c=" + TextUtility::nmbToStr(cam->_obj_to_cam_dir.X()) + " " + TextUtility::nmbToStr(cam->_obj_to_cam_dir.Y()) + " " + TextUtility::nmbToStr(cam->_obj_to_cam_dir.Z()) +
|
||||||
|
", 3Droo=" + TextUtility::nmbToStr(cam->_obj_to_cam_dist) +
|
||||||
|
", 3Dcoo=" + TextUtility::nmbToStr(cam->_obj_pos.X()) + " " + TextUtility::nmbToStr(cam->_obj_pos.Y()) + " " + TextUtility::nmbToStr(cam->_obj_pos.Z()) + ",";
|
||||||
|
latex.write(1,cam_string);
|
||||||
latex.write(1,"3Dlights=File,");
|
latex.write(1,"3Dlights=File,");
|
||||||
latex.write(0,"]{\\linewidth}{\\linewidth}{" + u3df.toStdString() + "}");
|
latex.write(0,"]{\\linewidth}{\\linewidth}{" + u3df.toStdString() + "}");
|
||||||
latex.write(0,"\\end{document}");
|
latex.write(0,"\\end{document}");
|
||||||
|
@ -46,52 +116,30 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static int Save(SaveMeshType& m,const char* outputfile,const int mask,const char* converter_path)
|
static int Save(SaveMeshType& m,const char* output_file,const char* conv_loc,const Movie15Parameters& mov_par,const int mask)
|
||||||
{
|
{
|
||||||
QString curr = QDir::currentPath();
|
QString curr = QDir::currentPath();
|
||||||
QString tmp(QDir::tempPath());
|
QString tmp(QDir::tempPath());
|
||||||
QString pathout(outputfile);
|
tmp = tmp + "/" + output_file + ".idtf";
|
||||||
QStringList pathlist = pathout.split('/');
|
|
||||||
QString filename;
|
|
||||||
QString outputcom;
|
|
||||||
if (pathlist.size() != 0)
|
|
||||||
{
|
|
||||||
filename = pathlist.at(pathlist.size() - 1);
|
|
||||||
if (pathlist.size() > 1)
|
|
||||||
outputcom = pathout;
|
|
||||||
else
|
|
||||||
outputcom = curr + "/" + filename;
|
|
||||||
}
|
|
||||||
else return 1;
|
|
||||||
|
|
||||||
tmp = tmp + "/" + filename + ".idtf";
|
|
||||||
|
|
||||||
vcg::tri::io::ExporterIDTF<SaveMeshType>::Save(m,qPrintable(tmp),mask);
|
vcg::tri::io::ExporterIDTF<SaveMeshType>::Save(m,qPrintable(tmp),mask);
|
||||||
InvokeConverter(converter_path,qPrintable(tmp),qPrintable(outputcom));
|
IDTFConverterParameters idtfpar(QString(conv_loc),tmp,QString(output_file));
|
||||||
|
int res = InvokeConverter(idtfpar);
|
||||||
QDir::setCurrent(curr);
|
QDir::setCurrent(curr);
|
||||||
QString lat (outputfile);
|
QString lat (output_file);
|
||||||
QStringList l = lat.split(".");
|
QStringList l = lat.split(".");
|
||||||
SaveLatex(m,l[0]);
|
SaveLatex(m,l[0],mov_par);
|
||||||
QDir dir(QDir::tempPath());
|
QDir dir(QDir::tempPath());
|
||||||
dir.remove(tmp);
|
dir.remove(tmp);
|
||||||
return 0;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetExportMaskCapability()
|
static int GetExportMaskCapability()
|
||||||
{
|
{
|
||||||
int capability = 0;
|
int capability = 0;
|
||||||
|
|
||||||
//camera
|
|
||||||
//capability |= MeshModel::IOM_CAMERA;
|
|
||||||
|
|
||||||
//vert
|
//vert
|
||||||
capability |= MeshModel::IOM_VERTNORMAL;
|
capability |= MeshModel::IOM_VERTNORMAL;
|
||||||
capability |= MeshModel::IOM_VERTTEXCOORD;
|
|
||||||
//capability |= MeshModel::
|
|
||||||
////face
|
|
||||||
////capability |= MeshModel::IOM_FACEFLAGS;
|
|
||||||
////capability |= MeshModel::IOM_FACECOLOR;
|
|
||||||
//capability |= MeshModel::IOM_FACENORMAL;
|
|
||||||
|
|
||||||
////wedg
|
////wedg
|
||||||
capability |= MeshModel::IOM_WEDGTEXCOORD;
|
capability |= MeshModel::IOM_WEDGTEXCOORD;
|
||||||
|
@ -99,6 +147,7 @@ public:
|
||||||
|
|
||||||
return capability;
|
return capability;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue