-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.cpp
More file actions
83 lines (66 loc) · 2.16 KB
/
main.cpp
File metadata and controls
83 lines (66 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//============================================================================
// Name : main.cpp
// Author : Christian Thurow
// Description : BRDF Calculation for Rapid Prototyping Project at TU-Berlin
//============================================================================
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include "cv.h"
#include "highgui.h"
#include "brdfdata.h"
#include <gl\GL.h> //do we really need that or just glut?
#include "glut.h"
#include "glutcallbacks.h"
void Render(CBRDFdata* data, int argc, char** argv);
using namespace std;
CBRDFdata m_brdf;
int m_width = 800;
int m_height = 600;
// main function
int main(int argc, char** argv)
{
//data structure for brdf
m_brdf = CBRDFdata();
cout << "loading data.." << endl;
//read in 3d model + calc surface normals
m_brdf.LoadModel("img\\timber.obj");
m_brdf.m_model = 1; //0: Phong, 1: Blinn-Phong
//read in 16 images
//assuming images are named 1.jpg to 16.jpg
m_brdf.LoadImages();
m_brdf.LoadDarkImage();
m_brdf.SubtractAmbientLight(); //not really important, but correct
//optional output
//m_brdf.PrintNormalisedImages();
//read in geometry and camera infos
m_brdf.LoadCameraParameters("img\\timber.cal");
//initialise led positions
m_brdf.InitLEDs();
//render model
cout << "begin rendering" << endl;
Render(&m_brdf, argc, argv);
//cvWaitKey(0);
return 0;
}
void Render(CBRDFdata* data, int argc, char** argv)
{
//render model in opengl
//let user interactively choose whether to show BRDF-correct lighting
// ->on key press, activate a shader that takes into account the brdf values of each surface
//show ground plane with origin
//show model, in correct relation to origin
//show camera position
//let user rotate and translate around
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE);
glutInitWindowPosition(1000, 100);
glutInitWindowSize(m_width, m_height);
glutInit(&argc, argv);
glutCreateWindow("Scanned Mesh");
// register GLUT callbacks (see glutcallbacks.c)
RegisterCallbacks();
// initialize OpenGL (see glutcallbacks.c)
Init();
// start GLUT event loop
glutMainLoop();
}