updated version with bugs fixed
This commit is contained in:
parent
c80e50570b
commit
eca61c1656
|
@ -5,6 +5,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <vcg/complex/trimesh/update/bounding.h>
|
||||||
|
|
||||||
|
|
||||||
class TextUtility
|
class TextUtility
|
||||||
|
@ -189,11 +190,16 @@ typedef typename SaveMeshType::CoordType CoordType;
|
||||||
idtf.write(3,"}");
|
idtf.write(3,"}");
|
||||||
|
|
||||||
idtf.write(3,"MODEL_POSITION_LIST {");
|
idtf.write(3,"MODEL_POSITION_LIST {");
|
||||||
|
|
||||||
|
vcg::tri::UpdateBounding<SaveMeshType>::Box(m);
|
||||||
|
SaveMeshType::ScalarType diag = m.bbox.Diag();
|
||||||
|
SaveMeshType::CoordType center = m.bbox.Center();
|
||||||
for(ConstVertexIterator vit = m.vert.begin();vit != m.vert.end();++vit)
|
for(ConstVertexIterator vit = m.vert.begin();vit != m.vert.end();++vit)
|
||||||
{
|
{
|
||||||
idtf.write(4,TextUtility::nmbToStr(vit->P().X()) + " " +
|
SaveMeshType::CoordType tmp = (vit->P() - center)/diag;
|
||||||
TextUtility::nmbToStr(vit->P().Y()) + " " +
|
idtf.write(4,TextUtility::nmbToStr(tmp.X()) + " " +
|
||||||
TextUtility::nmbToStr(vit->P().Z()));
|
TextUtility::nmbToStr(tmp.Z()) + " " +
|
||||||
|
TextUtility::nmbToStr(tmp.Y()));
|
||||||
}
|
}
|
||||||
idtf.write(3,"}");
|
idtf.write(3,"}");
|
||||||
|
|
||||||
|
@ -203,8 +209,8 @@ typedef typename SaveMeshType::CoordType CoordType;
|
||||||
for(unsigned int ii = 0;ii < 3;++ii)
|
for(unsigned int ii = 0;ii < 3;++ii)
|
||||||
{
|
{
|
||||||
idtf.write(4,TextUtility::nmbToStr(fitn->N().X()) + " " +
|
idtf.write(4,TextUtility::nmbToStr(fitn->N().X()) + " " +
|
||||||
TextUtility::nmbToStr(fitn->N().Y()) + " " +
|
TextUtility::nmbToStr(fitn->N().Z()) + " " +
|
||||||
TextUtility::nmbToStr(fitn->N().Z()));
|
TextUtility::nmbToStr(fitn->N().Y()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
idtf.write(3,"}");
|
idtf.write(3,"}");
|
||||||
|
|
|
@ -8,10 +8,60 @@
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#include "export_idtf.h"
|
#include "export_idtf.h"
|
||||||
|
#include<vcg/space/point3.h>
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri {
|
namespace tri {
|
||||||
namespace io {
|
namespace io {
|
||||||
|
namespace u3dparametersclasses
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Movie15Parameters
|
||||||
|
{
|
||||||
|
Movie15Parameters()
|
||||||
|
{
|
||||||
|
_campar = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//WARNING: in movie15 y-axis and z-axis have been inverted!!!
|
||||||
|
class CameraParameters
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CameraParameters()
|
||||||
|
:_cam_fov_angle(0.0f),_cam_roll_angle(0.0f),_obj_to_cam_dir(vcg::Point3f(0.0f,0.0f,0.0f)),_obj_to_cam_dist(0.0),_obj_pos(vcg::Point3f(0.0f,0.0f,0.0f))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
template<typename SaveMeshType>
|
template<typename SaveMeshType>
|
||||||
class ExporterU3D
|
class ExporterU3D
|
||||||
|
@ -36,50 +86,9 @@ public:
|
||||||
else return dae_error_msg[error];
|
else return dae_error_msg[error];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Movie15Parameters
|
|
||||||
{
|
|
||||||
Movie15Parameters()
|
|
||||||
{
|
|
||||||
_campar = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//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:
|
private:
|
||||||
|
|
||||||
struct IDTFConverterParameters
|
static int InvokeConverter(const u3dparametersclasses::IDTFConverterParameters& par)
|
||||||
{
|
|
||||||
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;
|
QProcess p;
|
||||||
QString convstring = par._converter_loc;
|
QString convstring = par._converter_loc;
|
||||||
|
@ -91,38 +100,60 @@ private:
|
||||||
return (int) t;
|
return (int) t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveLatex(SaveMeshType& m,const QString& file,const Movie15Parameters& mov_par)
|
static void SaveLatex(SaveMeshType& m,const QString& file,const u3dparametersclasses::Movie15Parameters& mov_par)
|
||||||
{
|
{
|
||||||
|
|
||||||
Output_File latex(file.toStdString() + ".tex");
|
Output_File latex(file.toStdString() + ".tex");
|
||||||
QString u3df = file + ".u3d";
|
QString u3df = file + ".u3d";
|
||||||
|
QStringList file_trim;
|
||||||
|
if (u3df.contains("/"))
|
||||||
|
file_trim = u3df.split("/");
|
||||||
|
else
|
||||||
|
if (u3df.contains("\\"))
|
||||||
|
file_trim = u3df.split("/");
|
||||||
|
std::string u3d_final = file_trim.at(file_trim.size() - 1).toStdString();
|
||||||
latex.write(0,"\\begin{document}");
|
latex.write(0,"\\begin{document}");
|
||||||
latex.write(0,"\\includemovie[");
|
latex.write(0,"\\includemovie[");
|
||||||
latex.write(1,"poster,");
|
latex.write(1,"poster,");
|
||||||
latex.write(1,"toolbar, %same as `controls\'");
|
latex.write(1,"toolbar, %same as `controls\'");
|
||||||
latex.write(1,"label=" + file.toStdString() + ",");
|
latex.write(1,"label=" + u3d_final + ",");
|
||||||
latex.write(1,"text=(" + u3df.toStdString() + "),");
|
latex.write(1,"text=(" + u3d_final + "),");
|
||||||
std::string cam_string;
|
std::string cam_string;
|
||||||
typename Movie15Parameters::CameraParameters* cam = mov_par._campar;
|
u3dparametersclasses::Movie15Parameters::CameraParameters* cam = mov_par._campar;
|
||||||
cam_string = cam_string + "3Daac=" + TextUtility::nmbToStr(cam->_cam_fov_angle) +
|
if (cam != NULL)
|
||||||
", 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()) +
|
cam_string = cam_string + "3Daac=" + TextUtility::nmbToStr(cam->_cam_fov_angle) +
|
||||||
", 3Droo=" + TextUtility::nmbToStr(cam->_obj_to_cam_dist) +
|
", 3Droll=" + TextUtility::nmbToStr(cam->_cam_roll_angle) +
|
||||||
", 3Dcoo=" + TextUtility::nmbToStr(cam->_obj_pos.X()) + " " + TextUtility::nmbToStr(cam->_obj_pos.Y()) + " " + TextUtility::nmbToStr(cam->_obj_pos.Z()) + ",";
|
", 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()) +
|
||||||
latex.write(1,cam_string);
|
", 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}{" + u3d_final + "}");
|
||||||
latex.write(0,"\\end{document}");
|
latex.write(0,"\\end{document}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static int Save(SaveMeshType& m,const char* output_file,const char* conv_loc,const Movie15Parameters& mov_par,const int mask)
|
static int Save(SaveMeshType& m,const char* output_file,const char* conv_loc,const u3dparametersclasses::Movie15Parameters& mov_par,const int mask)
|
||||||
{
|
{
|
||||||
QString curr = QDir::currentPath();
|
QString curr = QDir::currentPath();
|
||||||
|
QString out(output_file);
|
||||||
|
QStringList out_trim;
|
||||||
|
if (out.contains("/"))
|
||||||
|
out_trim = out.split("/");
|
||||||
|
else
|
||||||
|
if (out.contains("\\"))
|
||||||
|
out_trim = out.split("/");
|
||||||
|
|
||||||
QString tmp(QDir::tempPath());
|
QString tmp(QDir::tempPath());
|
||||||
tmp = tmp + "/" + output_file + ".idtf";
|
tmp = tmp + "/" + out_trim.at(out_trim.size() - 1) + ".idtf";
|
||||||
|
|
||||||
vcg::tri::io::ExporterIDTF<SaveMeshType>::Save(m,qPrintable(tmp),mask);
|
vcg::tri::io::ExporterIDTF<SaveMeshType>::Save(m,qPrintable(tmp),mask);
|
||||||
IDTFConverterParameters idtfpar(QString(conv_loc),tmp,QString(output_file));
|
QString conv_loc_st(conv_loc);
|
||||||
|
QString output_file_st(output_file);
|
||||||
|
u3dparametersclasses::IDTFConverterParameters idtfpar(conv_loc_st,tmp,output_file_st);
|
||||||
int res = InvokeConverter(idtfpar);
|
int res = InvokeConverter(idtfpar);
|
||||||
QDir::setCurrent(curr);
|
QDir::setCurrent(curr);
|
||||||
QString lat (output_file);
|
QString lat (output_file);
|
||||||
|
@ -130,7 +161,11 @@ public:
|
||||||
SaveLatex(m,l[0],mov_par);
|
SaveLatex(m,l[0],mov_par);
|
||||||
QDir dir(QDir::tempPath());
|
QDir dir(QDir::tempPath());
|
||||||
dir.remove(tmp);
|
dir.remove(tmp);
|
||||||
return res;
|
|
||||||
|
if (res)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetExportMaskCapability()
|
static int GetExportMaskCapability()
|
||||||
|
|
Loading…
Reference in New Issue