mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-19 11:04:39 +00:00
correct a small bug
This commit is contained in:
parent
9c9442d825
commit
22bcffb2ca
@ -25,6 +25,9 @@
|
||||
History
|
||||
|
||||
$Log$
|
||||
Revision 1.2 2006/01/29 23:52:43 fmazzant
|
||||
correct a small bug
|
||||
|
||||
Revision 1.1 2006/01/26 18:39:19 fmazzant
|
||||
moved mask dialog exporter from mashio to meshlab
|
||||
|
||||
@ -69,19 +72,10 @@ void SaveMaskExporterDialog::InitDialog()
|
||||
connect(ui.NoneButton,SIGNAL(clicked()),this,SLOT(SlotSelectionNoneButton()));
|
||||
ui.renametextureButton->setDisabled(true);
|
||||
|
||||
//disabled
|
||||
//check globali disabilitati
|
||||
ui.check_iom_vertquality->setDisabled(true);
|
||||
ui.check_iom_facequality->setDisabled(true);
|
||||
|
||||
//all - none
|
||||
ui.AllButton->setChecked(true);
|
||||
//ui.NoneButton->setChecked(true);
|
||||
|
||||
//checked
|
||||
ui.check_iom_vertquality->setChecked(true);
|
||||
ui.check_iom_facequality->setChecked(true);
|
||||
|
||||
SetTextureName();
|
||||
SetMaskCapability();
|
||||
}
|
||||
@ -124,6 +118,9 @@ int SaveMaskExporterDialog::GetNewMask()
|
||||
void SaveMaskExporterDialog::SetMaskCapability()
|
||||
{
|
||||
//vert
|
||||
ui.check_iom_vertquality->setDisabled( ((capability & MeshModel::IOM_VERTQUALITY)==0) /*| ((m->mask & MeshModel::IOM_VERTQUALITY)==0)*/ );
|
||||
ui.check_iom_vertquality->setChecked( ((capability & MeshModel::IOM_VERTQUALITY)!=0) /*& ((m->mask & MeshModel::IOM_VERTQUALITY)!=0)*/);
|
||||
|
||||
ui.check_iom_vertflags->setDisabled( ((capability & MeshModel::IOM_VERTFLAGS)==0) /*| ((m->mask & MeshModel::IOM_VERTFLAGS)==0)*/ );
|
||||
ui.check_iom_vertflags->setChecked ( ((capability & MeshModel::IOM_VERTFLAGS)!=0) /*& ((m->mask & MeshModel::IOM_VERTFLAGS)!=0)*/ );
|
||||
|
||||
@ -137,6 +134,9 @@ void SaveMaskExporterDialog::SetMaskCapability()
|
||||
ui.check_iom_vertnormal->setChecked ( ((capability & MeshModel::IOM_VERTNORMAL)!=0) /*& ((m->mask & MeshModel::IOM_VERTNORMAL)!=0)*/ );
|
||||
|
||||
//face
|
||||
ui.check_iom_facequality->setDisabled( ((capability & MeshModel::IOM_FACEQUALITY)==0) /*| ((m->mask & MeshModel::IOM_FACEQUALITY)==0)*/);
|
||||
ui.check_iom_facequality->setChecked( ((capability & MeshModel::IOM_FACEQUALITY)!=0) /*& ((m->mask & MeshModel::IOM_FACEQUALITY)!=0)*/);
|
||||
|
||||
ui.check_iom_faceflags->setDisabled( ((capability & MeshModel::IOM_FACEFLAGS)==0) /*| ((m->mask & MeshModel::IOM_FACEFLAGS)==0) */);
|
||||
ui.check_iom_faceflags->setChecked ( ((capability & MeshModel::IOM_FACEFLAGS)!=0) /*& ((m->mask & MeshModel::IOM_FACEFLAGS)!=0) */);
|
||||
|
||||
@ -169,19 +169,16 @@ void SaveMaskExporterDialog::SetMaskCapability()
|
||||
void SaveMaskExporterDialog::SlotOkButton()
|
||||
{
|
||||
int newmask = 0;
|
||||
|
||||
newmask |= vcg::tri::io::Mask::IOM_VERTQUALITY;
|
||||
newmask |= vcg::tri::io::Mask::IOM_FACEQUALITY;
|
||||
|
||||
if( ui.check_iom_vertflags->isChecked() ) { newmask |= MeshModel::IOM_VERTFLAGS;}
|
||||
if( ui.check_iom_vertcolor->isChecked() ) { newmask |= MeshModel::IOM_VERTCOLOR;}
|
||||
//if( ui.check_iom_vertquality->isChecked() ) { newmask |= MeshModel::IOM_VERTQUALITY;}
|
||||
if( ui.check_iom_vertquality->isChecked() ) { newmask |= MeshModel::IOM_VERTQUALITY;}
|
||||
if( ui.check_iom_verttexcoord->isChecked() ) { newmask |= MeshModel::IOM_VERTTEXCOORD;}
|
||||
if( ui.check_iom_vertnormal->isChecked() ) { newmask |= MeshModel::IOM_VERTNORMAL;}
|
||||
|
||||
if( ui.check_iom_faceflags->isChecked() ) { newmask |= MeshModel::IOM_FACEFLAGS;}
|
||||
if( ui.check_iom_facecolor->isChecked() ) { newmask |= MeshModel::IOM_FACECOLOR;}
|
||||
//if( ui.check_iom_facequality->isChecked() ) { newmask |= MeshModel::IOM_FACEQUALITY;}
|
||||
if( ui.check_iom_facequality->isChecked() ) { newmask |= MeshModel::IOM_FACEQUALITY;}
|
||||
if( ui.check_iom_facenormal->isChecked() ) { newmask |= MeshModel::IOM_FACENORMAL;}
|
||||
|
||||
if( ui.check_iom_wedgcolor->isChecked() ) { newmask |= MeshModel::IOM_WEDGCOLOR;}
|
||||
@ -219,12 +216,14 @@ void SaveMaskExporterDialog::SlotSelectionTextureName()
|
||||
void SaveMaskExporterDialog::SlotSelectionAllButton()
|
||||
{
|
||||
//vert
|
||||
ui.check_iom_vertquality->setChecked(ui.check_iom_vertquality->isEnabled());
|
||||
ui.check_iom_vertflags->setChecked(ui.check_iom_vertflags->isEnabled());
|
||||
ui.check_iom_vertcolor->setChecked(ui.check_iom_vertcolor->isEnabled());
|
||||
ui.check_iom_verttexcoord->setChecked(ui.check_iom_verttexcoord->isEnabled());
|
||||
ui.check_iom_vertnormal->setChecked(ui.check_iom_vertnormal->isEnabled());
|
||||
|
||||
//face
|
||||
ui.check_iom_facequality->setChecked(ui.check_iom_facequality->isEnabled());
|
||||
ui.check_iom_faceflags->setChecked(ui.check_iom_faceflags->isEnabled());
|
||||
ui.check_iom_facenormal->setChecked(ui.check_iom_facenormal->isEnabled());
|
||||
ui.check_iom_facecolor->setChecked(ui.check_iom_facecolor->isEnabled());
|
||||
@ -238,18 +237,20 @@ void SaveMaskExporterDialog::SlotSelectionAllButton()
|
||||
void SaveMaskExporterDialog::SlotSelectionNoneButton()
|
||||
{
|
||||
//vert
|
||||
ui.check_iom_vertflags->setChecked((ui.check_iom_vertflags->isEnabled()& ui.check_iom_vertflags->isChecked()) && !ui.check_iom_vertflags->isChecked());
|
||||
ui.check_iom_vertcolor->setChecked((ui.check_iom_vertcolor->isEnabled() & ui.check_iom_vertcolor->isChecked())&& !ui.check_iom_vertcolor->isChecked());
|
||||
ui.check_iom_verttexcoord->setChecked((ui.check_iom_verttexcoord->isEnabled() & ui.check_iom_verttexcoord->isChecked())&& !ui.check_iom_verttexcoord->isChecked());
|
||||
ui.check_iom_vertnormal->setChecked((ui.check_iom_vertnormal->isEnabled() & ui.check_iom_vertnormal->isChecked())&& !ui.check_iom_vertnormal->isChecked());
|
||||
ui.check_iom_vertquality->setChecked(ui.check_iom_vertquality->isEnabled() & ui.check_iom_vertquality->isChecked());
|
||||
ui.check_iom_vertflags->setChecked(ui.check_iom_vertflags->isEnabled()& ui.check_iom_vertflags->isChecked());
|
||||
ui.check_iom_vertcolor->setChecked(ui.check_iom_vertcolor->isEnabled() & ui.check_iom_vertcolor->isChecked());
|
||||
ui.check_iom_verttexcoord->setChecked(ui.check_iom_verttexcoord->isEnabled() & ui.check_iom_verttexcoord->isChecked());
|
||||
ui.check_iom_vertnormal->setChecked(ui.check_iom_vertnormal->isEnabled() & ui.check_iom_vertnormal->isChecked());
|
||||
|
||||
//face
|
||||
ui.check_iom_faceflags->setChecked((ui.check_iom_faceflags->isEnabled() & ui.check_iom_faceflags->isChecked())&& !ui.check_iom_faceflags->isChecked());
|
||||
ui.check_iom_facenormal->setChecked((ui.check_iom_facenormal->isEnabled()& ui.check_iom_facenormal->isChecked())&& !ui.check_iom_facenormal->isChecked());
|
||||
ui.check_iom_facecolor->setChecked((ui.check_iom_facecolor->isEnabled()& ui.check_iom_facecolor->isChecked())&& !ui.check_iom_facecolor->isChecked());
|
||||
ui.check_iom_facequality->setChecked(ui.check_iom_facequality->isEnabled() & ui.check_iom_facequality->isChecked());
|
||||
ui.check_iom_faceflags->setChecked(ui.check_iom_faceflags->isEnabled() & ui.check_iom_faceflags->isChecked());
|
||||
ui.check_iom_facenormal->setChecked(ui.check_iom_facenormal->isEnabled()& ui.check_iom_facenormal->isChecked());
|
||||
ui.check_iom_facecolor->setChecked(ui.check_iom_facecolor->isEnabled()& ui.check_iom_facecolor->isChecked());
|
||||
|
||||
//wedg
|
||||
ui.check_iom_wedgcolor->setChecked((ui.check_iom_wedgcolor->isEnabled() & ui.check_iom_wedgcolor->isChecked())&& !ui.check_iom_wedgcolor->isChecked());
|
||||
ui.check_iom_wedgtexcoord->setChecked((ui.check_iom_wedgtexcoord->isEnabled() & ui.check_iom_wedgtexcoord->isChecked())&& !ui.check_iom_wedgtexcoord->isChecked());
|
||||
ui.check_iom_wedgnormal->setChecked((ui.check_iom_wedgnormal->isEnabled() & ui.check_iom_wedgnormal->isChecked())&& !ui.check_iom_wedgnormal->isChecked());
|
||||
ui.check_iom_wedgcolor->setChecked(ui.check_iom_wedgcolor->isEnabled() & ui.check_iom_wedgcolor->isChecked());
|
||||
ui.check_iom_wedgtexcoord->setChecked(ui.check_iom_wedgtexcoord->isEnabled() & ui.check_iom_wedgtexcoord->isChecked());
|
||||
ui.check_iom_wedgnormal->setChecked(ui.check_iom_wedgnormal->isEnabled() & ui.check_iom_wedgnormal->isChecked());
|
||||
}
|
||||
@ -25,6 +25,9 @@
|
||||
History
|
||||
|
||||
$Log$
|
||||
Revision 1.3 2006/01/29 23:52:43 fmazzant
|
||||
correct a small bug
|
||||
|
||||
Revision 1.2 2006/01/29 18:33:42 fmazzant
|
||||
added some comment to the code
|
||||
|
||||
@ -159,13 +162,11 @@ namespace io {
|
||||
//capability |= MeshModel::IOM_CAMERA;
|
||||
|
||||
//vert
|
||||
capability |= MeshModel::IOM_VERTQUALITY;
|
||||
//capability |= MeshModel::IOM_VERTTEXCOORD;
|
||||
|
||||
//face
|
||||
capability |= MeshModel::IOM_FACEFLAGS;
|
||||
capability |= MeshModel::IOM_FACECOLOR;
|
||||
capability |= MeshModel::IOM_FACEQUALITY;
|
||||
capability |= MeshModel::IOM_FACENORMAL;
|
||||
|
||||
//wedg
|
||||
@ -211,116 +212,111 @@ namespace io {
|
||||
|
||||
int v_index = 0;
|
||||
VertexIterator vi;
|
||||
if(mask & MeshModel::IOM_VERTQUALITY)
|
||||
//saves vert
|
||||
for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi) if( !(*vi).IsD() )
|
||||
{
|
||||
//saves vert
|
||||
for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi) if( !(*vi).IsD() )
|
||||
{
|
||||
Lib3dsPoint point;
|
||||
point.pos[0] = (*vi).P()[0];
|
||||
point.pos[1] = (*vi).P()[1];
|
||||
point.pos[2] = (*vi).P()[2];
|
||||
Lib3dsPoint point;
|
||||
point.pos[0] = (*vi).P()[0];
|
||||
point.pos[1] = (*vi).P()[1];
|
||||
point.pos[2] = (*vi).P()[2];
|
||||
|
||||
mesh->pointL[v_index] = point;
|
||||
mesh->pointL[v_index] = point;
|
||||
|
||||
if (cb !=NULL)
|
||||
(*cb)(100.0 * (float)++current/(float)max, "writing vertices ");
|
||||
else
|
||||
return E_ABORTED;
|
||||
v_index++;
|
||||
}
|
||||
if (cb !=NULL)
|
||||
(*cb)(100.0 * (float)++current/(float)max, "writing vertices ");
|
||||
else
|
||||
return E_ABORTED;
|
||||
v_index++;
|
||||
}
|
||||
|
||||
lib3ds_mesh_new_face_list (mesh, m.face.size());//set number of faces
|
||||
int f_index = 0;//face index
|
||||
int t_index = 0;//texture index
|
||||
FaceIterator fi;
|
||||
if(mask & MeshModel::IOM_FACEQUALITY)
|
||||
for(fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() )
|
||||
{
|
||||
for(fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() )
|
||||
Lib3dsFace face;
|
||||
face.points[0] = GetIndexVertex(m, (*fi).V(0));
|
||||
face.points[1] = GetIndexVertex(m, (*fi).V(1));
|
||||
face.points[2] = GetIndexVertex(m, (*fi).V(2));
|
||||
|
||||
//saves coord textures
|
||||
if(m.HasPerWedgeTexture() && mask & MeshModel::IOM_WEDGTEXCOORD )
|
||||
{
|
||||
Lib3dsFace face;
|
||||
face.points[0] = GetIndexVertex(m, (*fi).V(0));
|
||||
face.points[1] = GetIndexVertex(m, (*fi).V(1));
|
||||
face.points[2] = GetIndexVertex(m, (*fi).V(2));
|
||||
|
||||
//saves coord textures
|
||||
if(m.HasPerWedgeTexture() && mask & MeshModel::IOM_WEDGTEXCOORD )
|
||||
unsigned int MAX = 3;
|
||||
for(unsigned int k=0;k<MAX;k++)
|
||||
{
|
||||
unsigned int MAX = 3;
|
||||
for(unsigned int k=0;k<MAX;k++)
|
||||
{
|
||||
mesh->texelL[face.points[k]][0] = (*fi).WT(k).u();
|
||||
mesh->texelL[face.points[k]][1] = (*fi).WT(k).v();
|
||||
}
|
||||
mesh->texelL[face.points[k]][0] = (*fi).WT(k).u();
|
||||
mesh->texelL[face.points[k]][1] = (*fi).WT(k).v();
|
||||
}
|
||||
|
||||
if(mask & MeshModel::IOM_FACEFLAGS)
|
||||
face.flags = 0;
|
||||
|
||||
face.smoothing = 10;
|
||||
|
||||
if(mask & MeshModel::IOM_FACENORMAL)
|
||||
{
|
||||
face.normal[0] = (*fi).N()[0];
|
||||
face.normal[1] = (*fi).N()[1];
|
||||
face.normal[2] = (*fi).N()[2];
|
||||
}
|
||||
|
||||
int material_index = CreateNewMaterial(m, materials, 0, fi);
|
||||
if(material_index == materials.size())
|
||||
{
|
||||
Lib3dsMaterial *material = lib3ds_material_new();//creates a new material
|
||||
|
||||
std::string name = qnamematerial.arg(material_index-1).toStdString();
|
||||
strcpy(material->name,name.c_str());//copy new name of material
|
||||
|
||||
if(mask & MeshModel::IOM_FACECOLOR)
|
||||
{
|
||||
//ambient
|
||||
material->ambient[0] = materials[materials.size()-1].Ka[0];
|
||||
material->ambient[1] = materials[materials.size()-1].Ka[1];
|
||||
material->ambient[2] = materials[materials.size()-1].Ka[2];
|
||||
material->ambient[3] = materials[materials.size()-1].Tr;
|
||||
|
||||
//diffuse
|
||||
material->diffuse[0] = materials[materials.size()-1].Kd[0];
|
||||
material->diffuse[1] = materials[materials.size()-1].Kd[1];
|
||||
material->diffuse[2] = materials[materials.size()-1].Kd[2];
|
||||
material->diffuse[3] = materials[materials.size()-1].Tr;
|
||||
|
||||
//specular
|
||||
material->specular[0] = materials[materials.size()-1].Ks[0];
|
||||
material->specular[1] = materials[materials.size()-1].Ks[1];
|
||||
material->specular[2] = materials[materials.size()-1].Ks[2];
|
||||
material->specular[3] = materials[materials.size()-1].Tr;
|
||||
|
||||
//shininess
|
||||
material->shininess = materials[materials.size()-1].Ns;
|
||||
}
|
||||
|
||||
//texture
|
||||
if(mask & MeshModel::IOM_WEDGTEXCOORD)
|
||||
strcpy(material->texture1_map.name,materials[materials.size()-1].map_Kd.c_str());
|
||||
|
||||
lib3ds_file_insert_material(file,material);//inserts the material inside the file
|
||||
strcpy(face.material,name.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string name = qnamematerial.arg(material_index).toStdString();
|
||||
strcpy(face.material,name.c_str());//set name of material
|
||||
}
|
||||
|
||||
|
||||
mesh->faceL[f_index]=face;
|
||||
|
||||
if (cb !=NULL)
|
||||
(*cb)(100.0 * (float)++current/(float)max, "writing faces ");
|
||||
else
|
||||
return E_ABORTED;
|
||||
f_index++;
|
||||
|
||||
}
|
||||
|
||||
if(mask & MeshModel::IOM_FACEFLAGS)
|
||||
face.flags = 0;
|
||||
|
||||
face.smoothing = 10;
|
||||
|
||||
if(mask & MeshModel::IOM_FACENORMAL)
|
||||
{
|
||||
face.normal[0] = (*fi).N()[0];
|
||||
face.normal[1] = (*fi).N()[1];
|
||||
face.normal[2] = (*fi).N()[2];
|
||||
}
|
||||
|
||||
int material_index = CreateNewMaterial(m, materials, 0, fi);
|
||||
if(material_index == materials.size())
|
||||
{
|
||||
Lib3dsMaterial *material = lib3ds_material_new();//creates a new material
|
||||
|
||||
std::string name = qnamematerial.arg(material_index-1).toStdString();
|
||||
strcpy(material->name,name.c_str());//copy new name of material
|
||||
|
||||
if(mask & MeshModel::IOM_FACECOLOR)
|
||||
{
|
||||
//ambient
|
||||
material->ambient[0] = materials[materials.size()-1].Ka[0];
|
||||
material->ambient[1] = materials[materials.size()-1].Ka[1];
|
||||
material->ambient[2] = materials[materials.size()-1].Ka[2];
|
||||
material->ambient[3] = materials[materials.size()-1].Tr;
|
||||
|
||||
//diffuse
|
||||
material->diffuse[0] = materials[materials.size()-1].Kd[0];
|
||||
material->diffuse[1] = materials[materials.size()-1].Kd[1];
|
||||
material->diffuse[2] = materials[materials.size()-1].Kd[2];
|
||||
material->diffuse[3] = materials[materials.size()-1].Tr;
|
||||
|
||||
//specular
|
||||
material->specular[0] = materials[materials.size()-1].Ks[0];
|
||||
material->specular[1] = materials[materials.size()-1].Ks[1];
|
||||
material->specular[2] = materials[materials.size()-1].Ks[2];
|
||||
material->specular[3] = materials[materials.size()-1].Tr;
|
||||
|
||||
//shininess
|
||||
material->shininess = materials[materials.size()-1].Ns;
|
||||
}
|
||||
|
||||
//texture
|
||||
if(mask & MeshModel::IOM_WEDGTEXCOORD)
|
||||
strcpy(material->texture1_map.name,materials[materials.size()-1].map_Kd.c_str());
|
||||
|
||||
lib3ds_file_insert_material(file,material);//inserts the material inside the file
|
||||
strcpy(face.material,name.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string name = qnamematerial.arg(material_index).toStdString();
|
||||
strcpy(face.material,name.c_str());//set name of material
|
||||
}
|
||||
|
||||
|
||||
mesh->faceL[f_index]=face;
|
||||
|
||||
if (cb !=NULL)
|
||||
(*cb)(100.0 * (float)++current/(float)max, "writing faces ");
|
||||
else
|
||||
return E_ABORTED;
|
||||
f_index++;
|
||||
|
||||
}
|
||||
|
||||
lib3ds_file_insert_mesh(file, mesh);//inserts the Mesh into file
|
||||
|
||||
@ -25,6 +25,9 @@
|
||||
History
|
||||
|
||||
$Log$
|
||||
Revision 1.3 2006/01/29 23:52:43 fmazzant
|
||||
correct a small bug
|
||||
|
||||
Revision 1.2 2006/01/29 18:33:42 fmazzant
|
||||
added some comment to the code
|
||||
|
||||
@ -138,13 +141,10 @@ namespace io {
|
||||
int capability = 0;
|
||||
|
||||
//vert
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTQUALITY;
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTNORMAL;
|
||||
|
||||
//face
|
||||
capability |= vcg::tri::io::Mask::IOM_FACECOLOR;
|
||||
capability |= vcg::tri::io::Mask::IOM_FACEQUALITY;
|
||||
capability |= vcg::tri::io::Mask::IOM_FACECOLOR;
|
||||
|
||||
//wedg
|
||||
capability |= vcg::tri::io::Mask::IOM_WEDGTEXCOORD;
|
||||
@ -187,107 +187,101 @@ namespace io {
|
||||
//vertexs + normal
|
||||
VertexIterator vi;
|
||||
std::map<Point3f,int> NormalVertex;
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_VERTQUALITY)
|
||||
int numvert = 0;
|
||||
int value = 1;
|
||||
for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi) if( !(*vi).IsD() )
|
||||
{
|
||||
int numvert = 0;
|
||||
int value = 1;
|
||||
for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi) if( !(*vi).IsD() )
|
||||
//saves normal per vertex
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
|
||||
{
|
||||
//saves normal per vertex
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
|
||||
if(AddNewNormalVertex(NormalVertex,(*vi).N(),value))
|
||||
{
|
||||
if(AddNewNormalVertex(NormalVertex,(*vi).N(),value))
|
||||
{
|
||||
fprintf(fp,"vn %f %f %f\n",(*vi).N()[0],(*vi).N()[1],(*vi).N()[2]);
|
||||
value++;
|
||||
}
|
||||
fprintf(fp,"vn %f %f %f\n",(*vi).N()[0],(*vi).N()[1],(*vi).N()[2]);
|
||||
value++;
|
||||
}
|
||||
|
||||
//saves vertex
|
||||
fprintf(fp,"v %f %f %f\n",(*vi).P()[0],(*vi).P()[1],(*vi).P()[2]);
|
||||
|
||||
if (cb !=NULL)
|
||||
(*cb)(100.0 * (float)++current/(float)max, "writing vertices ");
|
||||
else
|
||||
{ fclose(fp); return E_ABORTED;}
|
||||
}
|
||||
fprintf(fp,"# %d vertices, %d vertices normals\n\n",m.vert.size(),NormalVertex.size());
|
||||
|
||||
//saves vertex
|
||||
fprintf(fp,"v %f %f %f\n",(*vi).P()[0],(*vi).P()[1],(*vi).P()[2]);
|
||||
|
||||
if (cb !=NULL)
|
||||
(*cb)(100.0 * (float)++current/(float)max, "writing vertices ");
|
||||
else
|
||||
{ fclose(fp); return E_ABORTED;}
|
||||
}
|
||||
fprintf(fp,"# %d vertices, %d vertices normals\n\n",m.vert.size(),NormalVertex.size());
|
||||
|
||||
//faces + texture coords
|
||||
FaceIterator fi;
|
||||
std::map<vcg::TCoord2<float>,int> CoordIndexTexture;
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_FACEQUALITY)
|
||||
unsigned int material_num = 0;
|
||||
int mem_index = 0; //var temporany
|
||||
/*int*/ value = 1;//tmp
|
||||
for(fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() )
|
||||
{
|
||||
unsigned int material_num = 0;
|
||||
int mem_index = 0; //var temporany
|
||||
int value = 1;//tmp
|
||||
for(fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() )
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_FACECOLOR)
|
||||
{
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_FACECOLOR)
|
||||
int index = CreateNewMaterial(m,materials,material_num,fi);
|
||||
|
||||
if(index == materials.size())//inserts a new element material
|
||||
{
|
||||
int index = CreateNewMaterial(m,materials,material_num,fi);
|
||||
|
||||
if(index == materials.size())//inserts a new element material
|
||||
{
|
||||
material_num++;
|
||||
fprintf(fp,"\nusemtl material_%d\n",materials[index-1].index);
|
||||
mem_index = index-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(index != mem_index)//inserts old name elemente material
|
||||
{
|
||||
fprintf(fp,"\nusemtl material_%d\n",materials[index].index);
|
||||
mem_index=index;
|
||||
}
|
||||
}
|
||||
material_num++;
|
||||
fprintf(fp,"\nusemtl material_%d\n",materials[index-1].index);
|
||||
mem_index = index-1;
|
||||
}
|
||||
|
||||
//saves texture coord
|
||||
unsigned int MAX = 3;
|
||||
for(unsigned int k=0;k<MAX;k++)
|
||||
{
|
||||
if(m.HasPerWedgeTexture() && oi.mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)
|
||||
{
|
||||
if(AddNewTextureCoord(CoordIndexTexture,(*fi).WT(k),value))
|
||||
{
|
||||
fprintf(fp,"vt %f %f\n",(*fi).WT(k).u(),(*fi).WT(k).v());
|
||||
value++;//ncreases the value number to be associated to the Texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(fp,"f ");
|
||||
for(unsigned int k=0;k<MAX;k++)
|
||||
{
|
||||
int v = -1;
|
||||
// +1 because Obj file format begins from index = 1 but not from index = 0.
|
||||
v = GetIndexVertex(m, (*fi).V(k)) + 1;//index of vertex per face
|
||||
|
||||
int vt = -1;
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)
|
||||
vt = GetIndexVertexTexture(CoordIndexTexture,(*fi).WT(k));//index of vertex texture per face
|
||||
|
||||
int vn = -1;
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
|
||||
vn = GetIndexVertexNormal(m, NormalVertex, v);//index of vertex normal per face.
|
||||
|
||||
//writes elements on file obj
|
||||
WriteFacesElement(fp,v,vt,vn);
|
||||
|
||||
if(k!=MAX-1)
|
||||
fprintf(fp," ");
|
||||
else
|
||||
fprintf(fp,"\n");
|
||||
}
|
||||
if (cb !=NULL)
|
||||
(*cb)(100.0 * (float)++current/(float)max, "writing faces ");
|
||||
else
|
||||
{ fclose(fp); return E_ABORTED;}
|
||||
}//for
|
||||
fprintf(fp,"# %d faces, %d coords texture\n\n",m.face.size(),CoordIndexTexture.size());
|
||||
}
|
||||
{
|
||||
if(index != mem_index)//inserts old name elemente material
|
||||
{
|
||||
fprintf(fp,"\nusemtl material_%d\n",materials[index].index);
|
||||
mem_index=index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//saves texture coord
|
||||
unsigned int MAX = 3;
|
||||
for(unsigned int k=0;k<MAX;k++)
|
||||
{
|
||||
if(m.HasPerWedgeTexture() && oi.mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)
|
||||
{
|
||||
if(AddNewTextureCoord(CoordIndexTexture,(*fi).WT(k),value))
|
||||
{
|
||||
fprintf(fp,"vt %f %f\n",(*fi).WT(k).u(),(*fi).WT(k).v());
|
||||
value++;//ncreases the value number to be associated to the Texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(fp,"f ");
|
||||
for(unsigned int k=0;k<MAX;k++)
|
||||
{
|
||||
int v = -1;
|
||||
// +1 because Obj file format begins from index = 1 but not from index = 0.
|
||||
v = GetIndexVertex(m, (*fi).V(k)) + 1;//index of vertex per face
|
||||
|
||||
int vt = -1;
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)
|
||||
vt = GetIndexVertexTexture(CoordIndexTexture,(*fi).WT(k));//index of vertex texture per face
|
||||
|
||||
int vn = -1;
|
||||
if(oi.mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
|
||||
vn = GetIndexVertexNormal(m, NormalVertex, v);//index of vertex normal per face.
|
||||
|
||||
//writes elements on file obj
|
||||
WriteFacesElement(fp,v,vt,vn);
|
||||
|
||||
if(k!=MAX-1)
|
||||
fprintf(fp," ");
|
||||
else
|
||||
fprintf(fp,"\n");
|
||||
}
|
||||
if (cb !=NULL)
|
||||
(*cb)(100.0 * (float)++current/(float)max, "writing faces ");
|
||||
else
|
||||
{ fclose(fp); return E_ABORTED;}
|
||||
}//for
|
||||
fprintf(fp,"# %d faces, %d coords texture\n\n",m.face.size(),CoordIndexTexture.size());
|
||||
|
||||
fprintf(fp,"# End of File");
|
||||
fclose(fp);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user