shot/camera io added

This commit is contained in:
ganovelli 2004-10-07 14:19:06 +00:00
parent 5d07b02cf6
commit 5e15dc4a97
2 changed files with 103 additions and 85 deletions

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.7 2004/07/15 10:54:48 ganovelli
std added
Revision 1.6 2004/05/28 14:11:13 ganovelli
changes to comply io_mask moving in vcg::ply namesp
@ -147,8 +150,8 @@ static bool Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &
//if(textures.size()>1 && (HasPerWedgeTexture() || HasPerVertexTexture())) multit = true;
}
//if( (pi.mask & PLYMask::PM_CAMERA) && camera.IsValid() )
/*{
if( (pi.mask & ply::PLYMask::PM_CAMERA) && m.shot.IsValid())
{
fprintf(fpout,
"element camera 1\n"
"property float view_px\n"
@ -175,7 +178,7 @@ static bool Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &
"property float k3\n"
"property float k4\n"
);
}*/
}
fprintf(fpout,
"element vertex %d\n"
@ -268,68 +271,68 @@ static bool Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &
fprintf(fpout, "end_header\n" );
// Salvataggio camera
//if( (pi.mask & ply::PLYMask::PM_CAMERA) && camera.IsValid() )
//{
//if(binary)
//{
// float t[17];
if( (pi.mask & ply::PLYMask::PM_CAMERA) && m.shot.IsValid() )
{
if(binary)
{
float t[17];
// t[ 0] = camera.view_p[0];
// t[ 1] = camera.view_p[1];
// t[ 2] = camera.view_p[2];
// t[ 3] = camera.x_axis[0];
// t[ 4] = camera.x_axis[1];
// t[ 5] = camera.x_axis[2];
// t[ 6] = camera.y_axis[0];
// t[ 7] = camera.y_axis[1];
// t[ 8] = camera.y_axis[2];
// t[ 9] = camera.z_axis[0];
// t[10] = camera.z_axis[1];
// t[11] = camera.z_axis[2];
// t[12] = camera.f;
// t[13] = camera.s[0];
// t[14] = camera.s[1];
// t[15] = camera.c[0];
// t[16] = camera.c[1];
// fwrite(t,sizeof(float),17,fpout);
t[ 0] = -m.shot.similarity.tra[0];
t[ 1] = -m.shot.similarity.tra[1];
t[ 2] = -m.shot.similarity.tra[2];
t[ 3] = m.shot.similarity.rot[0][0];
t[ 4] = m.shot.similarity.rot[0][1];
t[ 5] = m.shot.similarity.rot[0][2];
t[ 6] = m.shot.similarity.rot[1][0];
t[ 7] = m.shot.similarity.rot[1][1];
t[ 8] = m.shot.similarity.rot[1][2];
t[ 9] = m.shot.similarity.rot[2][0];
t[10] = m.shot.similarity.rot[2][1];
t[11] = m.shot.similarity.rot[2][2];
t[12] = m.shot.camera.f;
t[13] = m.shot.camera.s[0];
t[14] = m.shot.camera.s[1];
t[15] = m.shot.camera.c[0];
t[16] = m.shot.camera.c[1];
fwrite(t,sizeof(float),17,fpout);
// fwrite( camera.viewport,sizeof(int),2,fpout );
fwrite( &m.shot.camera.viewport[0],sizeof(int),2,fpout );
// t[ 0] = camera.k[0];
// t[ 1] = camera.k[1];
// t[ 2] = camera.k[2];
// t[ 3] = camera.k[3];
// fwrite(t,sizeof(float),4,fpout);
//}
//else
//{
// fprintf(fpout,"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d %d %g %g %g %g\n"
// ,camera.view_p[0]
// ,camera.view_p[1]
// ,camera.view_p[2]
// ,camera.x_axis[0]
// ,camera.x_axis[1]
// ,camera.x_axis[2]
// ,camera.y_axis[0]
// ,camera.y_axis[1]
// ,camera.y_axis[2]
// ,camera.z_axis[0]
// ,camera.z_axis[1]
// ,camera.z_axis[2]
// ,camera.f
// ,camera.s[0]
// ,camera.s[1]
// ,camera.c[0]
// ,camera.c[1]
// ,camera.viewport[0]
// ,camera.viewport[1]
// ,camera.k[0]
// ,camera.k[1]
// ,camera.k[2]
// ,camera.k[3]
// );
//}
//}
t[ 0] = m.shot.camera.k[0];
t[ 1] = m.shot.camera.k[1];
t[ 2] = m.shot.camera.k[2];
t[ 3] = m.shot.camera.k[3];
fwrite(t,sizeof(float),4,fpout);
}
else
{
fprintf(fpout,"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d %d %g %g %g %g\n"
,-m.shot.similarity.tra[0]
,-m.shot.similarity.tra[1]
,-m.shot.similarity.tra[2]
,m.shot.similarity.rot[0][0]
,m.shot.similarity.rot[0][1]
,m.shot.similarity.rot[0][2]
,m.shot.similarity.rot[1][0]
,m.shot.similarity.rot[1][1]
,m.shot.similarity.rot[1][2]
,m.shot.similarity.rot[2][0]
,m.shot.similarity.rot[2][1]
,m.shot.similarity.rot[2][2]
,m.shot.camera.f
,m.shot.camera.s[0]
,m.shot.camera.s[1]
,m.shot.camera.c[0]
,m.shot.camera.c[1]
,m.shot.camera.viewport[0]
,m.shot.camera.viewport[1]
,m.shot.camera.k[0]
,m.shot.camera.k[1]
,m.shot.camera.k[2]
,m.shot.camera.k[3]
);
}
}
int j;

View File

@ -24,6 +24,10 @@
History
$Log: not supported by cvs2svn $
Revision 1.8 2004/06/23 15:36:43 cignoni
Restructured management of error, now the standard open for any mesh type return the error code, the default success value is zero
Any import class has a method ErrorMsg that give a verbal description of an error code.
Revision 1.7 2004/06/11 17:09:41 ganovelli
inclusion of vector..minorchanges
@ -463,29 +467,40 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi )
return pi.status;
}
//camera.valid = true;
//camera.view_p[0] = ca.view_px;
//camera.view_p[1] = ca.view_py;
//camera.view_p[2] = ca.view_pz;
//camera.x_axis[0] = ca.x_axisx;
//camera.x_axis[1] = ca.x_axisy;
//camera.x_axis[2] = ca.x_axisz;
//camera.y_axis[0] = ca.y_axisx;
//camera.y_axis[1] = ca.y_axisy;
//camera.y_axis[2] = ca.y_axisz;
//camera.z_axis[0] = ca.z_axisx;
//camera.z_axis[1] = ca.z_axisy;
//camera.z_axis[2] = ca.z_axisz;
//camera.f = ca.focal;
//camera.s[0] = ca.scalex;
//camera.s[1] = ca.scaley;
//camera.c[0] = ca.centerx;
//camera.c[1] = ca.centery;
//camera.viewport[0] = ca.viewportx;
//camera.viewport[1] = ca.viewporty;
//camera.k[0] = ca.k1;
//camera.k[1] = ca.k2;
//camera.k[2] = ca.k3;
//camera.k[3] = ca.k4;
// extrinsic
// view point
m.shot.similarity.tra[0] = -ca.view_px;
m.shot.similarity.tra[1] = -ca.view_py;
m.shot.similarity.tra[2] = -ca.view_pz;
// axis (i.e. rotation).
m.shot.similarity.rot.SetIdentity();
m.shot.similarity.rot[0][0] = ca.x_axisx;
m.shot.similarity.rot[0][1] = ca.x_axisy;
m.shot.similarity.rot[0][2] = ca.x_axisz;
m.shot.similarity.rot[1][0] = ca.y_axisx;
m.shot.similarity.rot[1][1] = ca.y_axisy;
m.shot.similarity.rot[1][2] = ca.y_axisz;
m.shot.similarity.rot[2][0] = ca.z_axisx;
m.shot.similarity.rot[2][1] = ca.z_axisy;
m.shot.similarity.rot[2][2] = ca.z_axisz;
//intrinsic
m.shot.camera.f = ca.focal;
m.shot.camera.s[0] = ca.scalex;
m.shot.camera.s[1] = ca.scaley;
m.shot.camera.c[0] = ca.centerx;
m.shot.camera.c[1] = ca.centery;
m.shot.camera.viewport[0] = ca.viewportx;
m.shot.camera.viewport[1] = ca.viewporty;
m.shot.camera.k[0] = ca.k1;
m.shot.camera.k[1] = ca.k2;
m.shot.camera.k[2] = ca.k3;
m.shot.camera.k[3] = ca.k4;
}
}
else if( !strcmp( pf.ElemName(i),"vertex" ) )