Example for TriangleMesh object, writes a wrl with an image using textured quad ,TriangleMesh
#include <Utils/TriangleMesh.hh>
#include <Utils/ThreeDOut.hh>
#include <Base/Image/ImageIO.hh>
#include <Filter/Rescale.hh>
#include <Base/Common/FileHandling.hh>
#include <Image/Camera.hh>
#include <sstream>
#include <Base/Math/Random.hh>
#include <iostream>
using namespace std;
using namespace BIAS;
#define TILE_WIDTH 129
#define TILE_HEIGHT 129
void usage(char* name)
{
cout<<"usage:\n";
cout<<name<<" <depthmap> <texture> [projection] \n";
cout<<endl<<endl;
}
int main(int argc, char* argv[])
{
if(argc<3) {
usage(argv[0]);
return -1;
}
if(ImageIO::Load(argv[2], texture)!=0) {
cout<<"texture could not be loaded!\n";
usage(argv[0]);
return -1;
}
if(ImageIO::Load(argv[1], depthMap)!=0) {
cout<<"depth map could not be loaded!\n";
usage(argv[0]);
if (string(argv[1])==string("UNITSPHERE")) {
}
else return -1;
}
bool loaded = false;
if (argc>3)
if (P.
Load(argv[2])==0) loaded =
true;
if (!loaded) {
} else {
cout<<"Projection could not be loaded from file or meta data!\n";
usage(argv[0]);
return -1;
}
}
cout<<"meshing..."; cout.flush();
double minCornerAngle = 3.0*M_PI/180.0;
double maxViewingAngle = 91.0 * M_PI / 180.0;
if(argc>4) {
minCornerAngle = atof(argv[4])*M_PI/180.0;
}
cout<<"minCornerAngle = "<<minCornerAngle<<endl;
double hws = 20;
double hws2 = hws + 2;
for (unsigned int q=0; q<30; q++) {
for (unsigned int i=0; i<4; i++) {
p[i] = p1;
switch (i) {
case 0: p[i][0] -= hws; p[i][1] -= hws; break;
case 1: p[i][0] += hws; p[i][1] -= hws; break;
case 2: p[i][0] -= hws; p[i][1] += hws; break;
case 3: p[i][0] += hws; p[i][1] += hws; break;
}
X[i] =
}
mesh.GenerateTexturedQuad(Pmat, texture, X[0], X[1], X[2], X[3]);
}
string vrmlfilename = "Quad.wrl";
cout<<"Writing VRML to "<<vrmlfilename<<flush<<endl;
cout<<"finished\n";
return 0;
}