VisPro  1.0
Project of Visualisierung 2
main.h
Go to the documentation of this file.
1 #pragma once
2 
7 // TCL integration
8 #include <tk.h>
9 #include "MyTkMain.h"
10 
11 // Standard
12 #include <iostream>
13 #include <fstream>
14 #include <sstream>
15 #include <stdio.h>
16 #include <stdlib.h>
17 
18 // OpenGL extensions
19 #include "glew.h"
20 #include "glfw3.h"
21 #include <GL/gl.h>
22 #include "glm.hpp"
23 #include "gtc/type_ptr.hpp"
24 #include "gtc/matrix_transform.hpp"
25 #include <memory>
26 
27 #include "UserInput.h"
28 #include "Texture.h"
29 #include "Geometry.h"
30 #include "SceneObject.h"
31 #include "PointLight.h"
32 #include "Light.h"
33 #include "../Scene/Camera.h"
34 #include "../Shader/Shader.h"
35 #include "../Shader/BlinnPhongShader.h"
36 #include "../Shader/NormalShader.h"
37 #include "../Shader/TextureShader.h"
38 #include "SceneImporter.h"
39 #include "SceneObjectManager.h"
40 #include "CutawaySurface.h"
41 #include "Quad.h"
42 
43 #include "StringHelpers.hpp"
44 #include <opencv2\opencv.hpp>
45 #include <opencv2\imgproc\imgproc.hpp>
46 #include <opencv2\highgui\highgui.hpp>
47 #include <opencv2\features2d\features2d.hpp>
48 #include <opencv2\nonfree\features2d.hpp>
49 #include <opencv2\highgui\highgui.hpp>
50 #include <opencv2\nonfree\nonfree.hpp>
51 
52 #include <Windows.h>
53 #include <opencv2\highgui\highgui_c.h>
54 #include "ZBufferView.h"
55 #include "RGBBufferView.h"
56 #include "TextureView.h"
57 #include "FrameBufferObjectView.h"
58 
59 
60 // Default screen parameters
61 int width = 1024;
62 int height = 800;
63 int refreshrate = 60;
64 bool fullscreen = false;
65 
66 // Geometries
67 SceneObjectManager obj_manager;
68 std::vector<std::shared_ptr<Energy>> e_items;
69 std::vector<std::shared_ptr<Environment>> environment;
70 
71 // Camera
72 Camera* camera;
73 float speed = 15.0f;
74 float look_speed = 0.001f;
75 float near_plane = 0.1f;
76 float far_plane = 180.0f;
77 float ratio = width / height;
78 float fov = glm::radians(70.0f);
79 
80 // Distance transform
81 CutawaySurface *cutaway = nullptr;
82 float drill_angle = 40.0f; // glm::radians();
83 float doCutaway = 1.0f;
84 
85 // Control
86 UserInput user_input;
87 
88 // Number of culled faces
89 int drawnFaces = 0;
90 
91 GLFWwindow* m_window = nullptr;
92 
93 std::string m_environmentDaeFile = "";
94 std::string m_itemDaeFile = "";
95 
96 ZBufferView *zBufferView = nullptr;
97 RGBBufferView *rgbBufferView = nullptr;
98 
99 TextureView *tex1View = nullptr;
100 TextureView *tex2View = nullptr;
101 
102 FrameBufferObjectView *fbo101View = nullptr;
103 FrameBufferObjectView *fbo202View = nullptr;
104 
105 FrameBufferObjectView *fbo101View_II = nullptr;
106 FrameBufferObjectView *fbo202View_II = nullptr;
107 
108 
109 // =============================================================================================
110 // TCL - Integration
111 // =============================================================================================
112 
113 bool startSim = false;
114 
115 // TCL components for GUI
116 Tcl_Interp *interp = nullptr;
117 static Tk_ArgvInfo argTable[] = { { "", TK_ARGV_END } };
118 
122 void UpdateNearPlane(float nearPlane);
123 
127 void UpdateFarPlane(float farPlane);
128 
132 void UpdateDrillAngle(float drillAngle);
133 
137 void UpdateEnvironment(const std::string &environmentDaeFile);
138 
142 void UpdateItem(const std::string &itemDaeFile);
143 
150 int SetEnvironmentCmd(ClientData clientData, Tcl_Interp *interp,
151  int argc, CONST84 char *argv[]);
152 
159 int SetItemCmd(ClientData clientData, Tcl_Interp *interp,
160  int argc, CONST84 char *argv[]);
161 
168 int StartSimCmd(ClientData clientData, Tcl_Interp *interp,
169  int argc, CONST84 char *argv[]);
170 
177 int SetNearPlaneCmd(ClientData clientData, Tcl_Interp *interp,
178  int argc, CONST84 char *argv[]);
179 
186 int SetFarPlaneCmd(ClientData clientData, Tcl_Interp *interp,
187  int argc, CONST84 char *argv[]);
188 
195 int SetDrillAngleCmd(ClientData clientData, Tcl_Interp *interp,
196  int argc, CONST84 char *argv[]);
197 
204 int SetDoCutawayCmd(ClientData clientData, Tcl_Interp *interp,
205  int argc, CONST84 char *argv[]);
206 
213 int GetNearPlaneCmd(ClientData clientData, Tcl_Interp *interp,
214  int argc, CONST84 char *argv[]);
215 
222 int GetFarPlaneCmd(ClientData clientData, Tcl_Interp *interp,
223  int argc, CONST84 char *argv[]);
224 
231 int GetDrillAngleCmd(ClientData clientData, Tcl_Interp *interp,
232  int argc, CONST84 char *argv[]);
233 
240 int GetDoCutawayCmd(ClientData clientData, Tcl_Interp *interp,
241  int argc, CONST84 char *argv[]);
242 
248 int Tk_AppInit(Tcl_Interp *interp);
249 
256 int InitTcl(int argc_in, char *argv_in[]);
257 
260 void TearDownTcl();
261 
266 int EvalTclFile(char *fileName);
267 
268 // =============================================================================================
269 // End TCL - Integration
270 // =============================================================================================
271 
272 // =============================================================================================
273 // main application
274 // =============================================================================================
275 
281 int main(int argc, char** argv);
282 
287 void init(GLFWwindow* window);
288 
294 void update(GLFWwindow* window, float deltaTime);
295 
299 void createDepthImage();
300 
305 
309 void draw();
310 
313 void cleanup();
314 
317 void initScreenParameters();
318 
319 // =============================================================================================
320 // End main application
321 // =============================================================================================
322 
int SetEnvironmentCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:155
Texture class file.
void UpdateNearPlane(float nearPlane)
Definition: main.cpp:102
void UpdateEnvironment(const std::string &environmentDaeFile)
Definition: main.cpp:143
scene object manager class file.
Quad class file.
void UpdateFarPlane(float farPlane)
Definition: main.cpp:116
Cutaway surface class file.
void createDepthImage()
Definition: main.cpp:682
Definition: ZBufferView.h:32
Geometry class file.
void draw()
Definition: main.cpp:709
void cleanup()
Definition: main.cpp:726
void TearDownTcl()
Definition: main.cpp:372
int SetFarPlaneCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:203
Definition: Camera.h:6
Definition: RGBBufferView.h:33
void init(GLFWwindow *window)
Definition: main.cpp:585
void update(GLFWwindow *window, float deltaTime)
Definition: main.cpp:669
void UpdateItem(const std::string &itemDaeFile)
Definition: main.cpp:149
Tcl/Tk integration file. On Windows, this file needs to be compiled twice, once with TK_ASCII_MAIN de...
int SetDoCutawayCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:223
int SetNearPlaneCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:193
int GetFarPlaneCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:245
int SetItemCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:170
Texture view class file.
Definition: UserInput.h:13
frame buffer object view class file.
void calculateCutawaySurface()
Definition: main.cpp:688
Definition: TextureView.h:11
User input class file.
int InitTcl(int argc_in, char *argv_in[])
Definition: main.cpp:327
Definition: CutawaySurface.h:14
Definition: SceneObjectManager.h:15
void initScreenParameters()
Definition: main.cpp:731
int GetDrillAngleCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:254
int StartSimCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:185
Scene importer class file.
int main(int argc, char **argv)
Definition: main.cpp:386
int SetDrillAngleCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:213
void UpdateDrillAngle(float drillAngle)
Definition: main.cpp:130
Z buffer view base class file.
int Tk_AppInit(Tcl_Interp *interp)
Definition: main.cpp:272
Definition: FrameBufferObjectView.h:11
int GetDoCutawayCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:263
RGB buffer view class file.
int EvalTclFile(char *fileName)
Definition: main.cpp:377
int GetNearPlaneCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
Definition: main.cpp:236