-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_MIP2.cpp
More file actions
284 lines (284 loc) · 8.85 KB
/
Copy pathmain_MIP2.cpp
File metadata and controls
284 lines (284 loc) · 8.85 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
//#include <glad/glad.h>
//#include <GLFW/glfw3.h>
//
//#include <glm/glm.hpp>
//#include <glm/gtc/matrix_transform.hpp>
//#include <glm/gtc/type_ptr.hpp>
//#include "imGui/imgui.h"
//#include "imGui/imgui_impl_glfw.h"
//#include "imGui/imgui_impl_opengl3.h"
//#include "shader_m.h"
//#include "camera.h"
//#include "model_animation.h"
//#include "utils.h"
//#include <assimp/scene.h>
//#include <assimp/postprocess.h>
//#include <assimp/Importer.hpp>
//#include <unordered_map>
//#include <cstdlib>
////#define STB_IMAGE_IMPLEMENTATION
////#include "stb_image.h"
//#include <iostream>
//
//void framebuffer_size_callback(GLFWwindow* window, int width, int height);
//void processInput(GLFWwindow* window);
//void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
//void mouse_callback(GLFWwindow* window, double xpos, double ypos);
//
//
//// settings
//const unsigned int SCR_WIDTH = 1200;
//const unsigned int SCR_HEIGHT = 900;
//bool firstMouse = true;
//
//
//
//
//// timing
//float deltaTime = 0.0f;
//float lastFrame = (float)glfwGetTime();
//// lighting
//glm::vec3 lightPos(1.0f, -0.35f, 2.0f);
////transformation components
//float rotate_step = 0.0f;
//float translat_step = 0.05f;
//float translat_step2 = 0.0f;
//float run_speed = 1.0f;
//float current_speed = 0.0f;
//float current_rotate_speed = 0.0f;
//float rotate_speed = 200.0f;
//float camera_zoomin = 75.0f;
//float dx = 0.0f;
//float dz = 0.0f;
//float dy = 0.0f;
//float x_position = 0.35f;
//float y_position = -0.35f;
//float z_position = 2.0f;
//
//float cameraHeight = 0.3f;
//float selfRotation = 0.0f;
//
//// camera
////Camera camera1(true, rotate_step, x_position, y_position, z_position, glm::vec3(0.0f, 0.0f, 0.0f));
//Camera camera(glm::vec3(0.0f, 0.0f, 100.0f));
//float lastX = SCR_WIDTH / 2.0f;
//float lastY = SCR_HEIGHT / 2.0f;
//
//
//
//int main()
//{
// // glfw: initialize and configure
// // ------------------------------
// glfwInit();
// glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
// glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
// glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
//
//
// // glfw window creation
// // --------------------
// GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Assignment 4", NULL, NULL);
// if (window == NULL)
// {
// std::cout << "Failed to create GLFW window" << std::endl;
// glfwTerminate();
// return -1;
// }
// glfwMakeContextCurrent(window);
// glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
//
//
// // tell GLFW to capture our mouse
// glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
//
// // glad: load all OpenGL function pointers
// // ---------------------------------------
// if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
// {
// std::cout << "Failed to initialize GLAD" << std::endl;
// return -1;
// }
//
// // tell stb_image.h to flip loaded texture's on the y-axis (before loading model).
// stbi_set_flip_vertically_on_load(true);
//
// // configure global opengl state
// // -----------------------------
// glEnable(GL_DEPTH_TEST);
// // Set OpenGL options
// glEnable(GL_CULL_FACE);
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//
// // load models
// // -----------
// Model ourModel("assets/models/resources/ground.fbx");
//
// //load Shader
// Shader lightingShader("assets/shaders/rendering/mip/effect.vs", "assets/shaders/rendering/mip/effect.fs");
// lightingShader.use();
//
//
// IMGUI_CHECKVERSION();
// ImGui::CreateContext();
// ImGuiIO& io = ImGui::GetIO(); (void)io;
// const char* glsl_version = "#version 330";
// ImGui_ImplGlfw_InitForOpenGL(window, true);
// ImGui_ImplOpenGL3_Init(glsl_version);
// ImGui::StyleColorsDark();
// // render loop
// // -----------
// while (!glfwWindowShouldClose(window))
// {
// ImGui_ImplOpenGL3_NewFrame();
// ImGui_ImplGlfw_NewFrame();
// ImGui::NewFrame();
//
//
// float elapsedTime = (float)glfwGetTime();
// deltaTime = elapsedTime - lastFrame;
// float dAngle = elapsedTime * 0.002;
// lastFrame = elapsedTime;
// processInput(window);
// rotate_step += current_rotate_speed * deltaTime;
// float distance = current_speed * deltaTime;
//
// dx = -(float)(distance * glm::sin(glm::radians(rotate_step)));
// dz = (float)(distance * glm::cos(glm::radians(rotate_step)));
// x_position += dx;
// z_position += dz;
// y_position += dy;
// selfRotation += deltaTime * 70.0f;
//
// //camera1.changePosition(rotate_step, x_position, y_position, z_position);
// // Our state
// bool show_demo_window = true;
// bool show_another_window = false;
// ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
// {
// static float f = 0.0f;
// static int counter = 0;
//
// ImGui::Begin("Parameters");
// ImGui::SliderFloat("X", &x_position, 0.0f, 500.0f);
// ImGui::SliderFloat("Y", &y_position, -500.0f, 500.0f);
// ImGui::SliderFloat("Z", &z_position, 0.0f, 1000.0f);
// ImGui::SliderFloat3("Light Position", &lightPos.x, 0.0f, 1000.0f);
//
//
// ImGui::End();
// }
// // render
// // ------
// glClearColor(0.05f, 0.05f, 0.05f, 1.0f);
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glViewport(0, 0, 1200, 900);
// lightingShader.use();
// lightingShader.setVec3("lightPos", lightPos);
// lightingShader.setVec3("viewPos", camera.Position);
//
//
// //projection view and model matrix
// glm::mat4 projectionMatrix = glm::perspective(camera_zoomin, (float)SCR_WIDTH / SCR_HEIGHT, 0.01f, 1500.0f);
// glm::mat4 viewMatrix = camera.GetViewMatrix();
// glm::mat4 viewProjectionMatrix = projectionMatrix * viewMatrix;
// lightingShader.setMat4("projection", projectionMatrix);
// lightingShader.setMat4("view", viewMatrix);
//
//
// //model1
// glm::mat4 model2 = glm::mat4(1.0f);
// model2 = glm::translate(model2, glm::vec3(0.0f, -20.0f, 0.0f));
// //model2 = glm::scale(model2, glm::vec3(2.1f, 2.1f, 2.1f));
// model2 = glm::rotate(model2, 90.0f, glm::vec3(1, 0, 0));
// lightingShader.setMat4("model", model2);
//
// ourModel.Draw(lightingShader);
//
//
//
// ImGui::Render();
// ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
//
// // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
// // -------------------------------------------------------------------------------
// glfwSwapBuffers(window);
// glfwPollEvents();
// }
// ImGui_ImplOpenGL3_Shutdown();
// ImGui_ImplGlfw_Shutdown();
// ImGui::DestroyContext();
// // glfw: terminate, clearing all previously allocated GLFW resources.
// // ------------------------------------------------------------------
//
// glfwTerminate();
// return 0;
//}
//
//// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
//// ---------------------------------------------------------------------------------------------------------
//void processInput(GLFWwindow* window)
//{
// if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
// glfwSetWindowShouldClose(window, true);
//
// if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) {
// current_speed = -run_speed;
// }
// else if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) {
// current_speed = run_speed;
// }
// else
// {
// current_speed = 0.0f;
// }
// if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) {
// current_rotate_speed = -rotate_speed;
// translat_step2 -= 0.003f;
// }
// else if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) {
// translat_step2 += 0.003f;
// current_rotate_speed = rotate_speed;
// }
// else
// {
// current_rotate_speed = 0.0f;
// }
//
//}
//
//
//// glfw: whenever the window size changed (by OS or user resize) this callback function executes
//// ---------------------------------------------------------------------------------------------
//void framebuffer_size_callback(GLFWwindow* window, int width, int height)
//{
// // make sure the viewport matches the new window dimensions; note that width and
// // height will be significantly larger than specified on retina displays.
// glViewport(0, 0, width, height);
//}
//
//// glfw: whenever the mouse scroll wheel scrolls, this callback is called
//// ----------------------------------------------------------------------
//void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
//{
// camera.ProcessMouseScroll(yoffset);
//}
//void mouse_callback(GLFWwindow* window, double xpos, double ypos)
//{
// if (firstMouse)
// {
// lastX = xpos;
// lastY = ypos;
// firstMouse = false;
// }
//
// float xoffset = xpos - lastX;
// float yoffset = lastY - ypos; // reversed since y-coordinates go from bottom to top
//
// lastX = xpos;
// lastY = ypos;
//
// camera.ProcessMouseMovement(xoffset, yoffset);
//}