75 lines
2 KiB
C++
75 lines
2 KiB
C++
#include "cube.h"
|
|
#include "sphere.h"
|
|
#include "write_obj.h"
|
|
#include "QuadViewer.h"
|
|
#include "set_texture_from_png.h"
|
|
#include <igl/readOBJ.h>
|
|
#include <Eigen/Core>
|
|
#include <vector>
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <limits>
|
|
#include <functional>
|
|
|
|
|
|
int main(int argc, char * argv[])
|
|
{
|
|
// parse command line arguments
|
|
std::string path_to_cube_png;
|
|
std::string path_to_earth_png;
|
|
if (argc == 3) {
|
|
std::string args0 = argv[1];
|
|
std::string args1 = argv[2];
|
|
// check if ends with .png
|
|
if (args0.size() > 4 && args0.substr(args0.size() - 3, 3) == "png") {
|
|
path_to_cube_png = args0;
|
|
}
|
|
if (args1.size() > 4 && args1.substr(args1.size() - 3, 3) == "png") {
|
|
path_to_earth_png = args1;
|
|
}
|
|
}
|
|
if (argc != 3 || path_to_cube_png.empty() || path_to_earth_png.empty()) {
|
|
printf(
|
|
"Error: received unexpected command line arguments. \n"
|
|
"Correct usage: \n"
|
|
" Linux: ./obj <path to rubiks-cube.png> <path to earth-square.png>\n"
|
|
" Windows: obj.exe <path to rubiks-cube.png> <path to earth-square.png> \n"
|
|
"For example: \n"
|
|
" Linux: ./obj ../data/rubiks-cube.png ../data/earth-square.png \n"
|
|
" Windows: obj.exe ../../../data/rubiks-cube.png ../../../data/earth-square.png \n"
|
|
);
|
|
return -1;
|
|
}
|
|
{
|
|
// Create mesh of a cube
|
|
Eigen::MatrixXd V,UV,NV;
|
|
Eigen::MatrixXi F,UF,NF;
|
|
cube(V,F,UV,UF,NV,NF);
|
|
write_obj("cube.obj",V,F,UV,UF,NV,NF);
|
|
printf("wrote to cube.obj \n");
|
|
igl::readOBJ("cube.obj",V,UV,NV,F,UF,NF);
|
|
{
|
|
QuadViewer v;
|
|
v.set_mesh(V,F,UV,UF,NV,NF);
|
|
set_texture_from_png(path_to_cube_png, v.viewer.data());
|
|
v.launch();
|
|
}
|
|
}
|
|
|
|
{
|
|
// Create mesh of a sphere
|
|
Eigen::MatrixXd V,UV,NV;
|
|
Eigen::MatrixXi F,UF,NF;
|
|
sphere(60,40,V,F,UV,UF,NV,NF);
|
|
write_obj("sphere.obj",V,F,UV,UF,NV,NF);
|
|
printf("wrote to sphere.obj \n");
|
|
igl::readOBJ("sphere.obj",V,UV,NV,F,UF,NF);
|
|
{
|
|
QuadViewer v;
|
|
v.set_mesh(V,F,UV,UF,NV,NF);
|
|
set_texture_from_png(path_to_earth_png, v.viewer.data());
|
|
v.launch();
|
|
}
|
|
}
|
|
|
|
}
|