// Include standard headers
#include <stdio.h>
#include <stdlib.h>
// Include GLEW
#include <GL/glew.h>
// Include GLFW
#include <glfw3.h>
GLFWwindow* window;
// Include GLM
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/norm.hpp>
using namespace glm;
#include <common/shader.hpp>
#include <common/texture.hpp>
#include <common/controls.hpp>
GLfloat *makeCIrcleVertexData(GLfloat x, GLfloat y, GLfloat z, GLfloat radius,
GLint numberOfSides); // 원만드는 함수
GLfloat* MakeCylinder(GLfloat *buffer1, GLfloat *buffer2, GLint num);
// 원기둥 만드는 함수 - 실패 -
int main(void)
{
// Initialise GLFW
if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW\n");
getchar();
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
window = glfwCreateWindow(1024, 768, "Project 76", NULL, NULL);
if (window == NULL) {
fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU,
they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
getchar();
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Initialize GLEW
glewExperimental = true; // Needed for core profile
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
getchar();
glfwTerminate();
return -1;
}
// Ensure we can capture the escape key being pressed below
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
// Set the mouse at the center of the screen 키보드 마우스 사용을 위한 부분.
glfwPollEvents();
glfwSetCursorPos(window, 1024 / 2, 768 / 2); // 커서 위치
// Dark blue background
glClearColor(0.0f, 0.0f, 0.4f, 0.0f); // 배경색 다크블루 안건드림
// Enable depth test
glEnable(GL_DEPTH_TEST);
// Accept fragment if it closer to the camera than the former one
glDepthFunc(GL_LESS);
// Cull triangles which normal is not towards the camera
glEnable(GL_CULL_FACE);
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
// 기타 설정은 건드리지 않음
// Create and compile our GLSL program from the shaders
GLuint programID = LoadShaders("TransformVertexShader.vertexshader",
"ColorFragmentShader.fragmentshader");
GLuint programID2 = LoadShaders("TransformVertexShader2.vertexshader",
"TextureFragmentShader.fragmentshader");
// 두번째 쉐이더로 텍스쳐 사용 용도로 불러온다.
// Get a handle for our "MVP" uniform
GLuint MatrixID = glGetUniformLocation(programID, "MVP");
GLuint MatrixID2 = glGetUniformLocation(programID2, "MVP"); // 마찬가지로 텍스쳐 사용을 위함
GLuint Texture = loadBMP_custom("texture001.bmp"); // 미리 텍스쳐를 불러와 가지고 있다.
GLuint Texture2 = loadBMP_custom("texture002.bmp");
// 셰이더에 업로드하기 위한 핸들러
GLuint TextureID = glGetUniformLocation(programID2, "myTextureSampler");
static const GLfloat g_vertex_buffer_data[] = {
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f
}; // 큐브 // 큐브
static const GLfloat boat[] = { // 9개 x 12
1.0f, 0.0f, 1.0f,
1.0f, 0.0f, -1.0f, // 밑판1
-1.0f, 0.0f, 1.0f,
-1.0f, 0.0f, -1.0f, // 밑판2
1.0f, 0.0f, -1.0f,
-1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f,
1.0f, 0.0f, -1.0f,
3.0f, 2.0f, 1.0f, // 오른쪽 옆판 1
3.0f, 2.0f, 1.0f,
1.0f, 0.0f, -1.0f,
3.0f, 2.0f, -1.0f, // 오른쪽 옆판 2
-1.0f, 0.0f, 1.0f,
-1.0f, 0.0f, -1.0f,
-3.0f, 2.0f, 1.0f, // 왼쪽 옆판 1
-1.0f, 0.0f, -1.0f,
-3.0f, 2.0f, -1.0f,
-3.0f, 2.0f, 1.0f, // 왼쪽 옆판 2
-1.0f, 0.0f, 1.0f,
3.0f, 2.0f, 1.0f,
-3.0f, 2.0f, 1.0f, // 앞면 1
-1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f,
3.0f, 2.0f, 1.0f, // 앞면 2
-1.0f, 0.0f, -1.0f,
3.0f, 2.0f, -1.0f,
-3.0f, 2.0f, -1.0f, // 뒷면 1
-1.0f, 0.0f, -1.0f,
1.0f, 0.0f, -1.0f,
3.0f, 2.0f, -1.0f, // 뒷면 2
3.0f, 2.0f, 1.0f,
-3.0f, 2.0f, 1.0f,
-3.0f, 2.0f, -1.0f, // 윗면 1
3.0f, 2.0f, -1.0f,
3.0f, 2.0f, 1.0f,
-3.0f, 2.0f, -1.0f, // 윗면 2
}; // 보트 // 보트모양을 위한 정점의 집합
static const GLfloat sixSide[] = {
-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
0.0f, 1.0f, 0.0f,
1.0f, 1.0f, -1.0f,
0.0f, 1.0f, 0.0f,
1.42f, 1.0f, 0.0f,
1.42f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 1.0f,
0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
0.0f, 1.0f, 0.0f,
-1.42f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
-1.42f, 1.0f, 0.0f,
-1.0f, 1.0f, -1.0f, // 윗 육각형
-1.0f, 0.0f, -1.0f,
1.0f, 0.0f, -1.0f,
0.0f, 0.0f, 0.0f,
1.0f, 0.0f, -1.0f,
0.0f, 0.0f, 0.0f,
1.42f, 0.0f, 0.0f,
1.42f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f,
1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 0.0f,
1.0f, 0.0f, 1.0f,
-1.0f,0.0f, 1.0f,
-1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 0.0f,
-1.42f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f,
-1.42f, 0.0f, 0.0f,
-1.0f, 0.0f, -1.0f, // 밑 육각형
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f, //
1.0f, 1.0f, 1.0f,
1.42f, 1.0f, 0.0f,
1.0f, 0.0f, 1.0f,
1.42f, 1.0f, 0.0f,
1.0f, 0.0f, 1.0f,
1.42f, 0.0f, 0.0f, //
1.0f, 1.0f, -1.0f,
1.42f, 1.0f, 0.0f,
1.42f, 0.0f, 0.0f,
1.0f, 1.0f, -1.0f,
1.0f, 0.0f, -1.0f,
1.42f, 0.0f, 0.0f, //
-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
1.0f, 0.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 0.0f, -1.0f,
1.0f, 0.0f, -1.0f, //
-1.0f, 1.0f, -1.0f,
-1.42f, 1.0f, 0.0f,
-1.0f, 0.0f, -1.0f,
-1.42f, 1.0f, 0.0f,
-1.0f, 0.0f, -1.0f,
-1.42f, 0.0f, 0.0f, //
-1.42f, 1.0f, 0.0f,
-1.0f, 1.0f, 1.0f,
-1.42f, 0.0f ,0.0f,
-1.0f, 1.0f, 1.0f,
-1.42f, 0.0f, 0.0f,
-1.0f, 0.0f, 1.0f
}; // 육각기둥
// One color for each vertex. They were generated randomly.
/*static GLfloat* circle = makeCIrcleVertexData(0.0f, 0.0f, 0.0f, 1.0f, 12);
static GLfloat* circle2 = makeCIrcleVertexData(0.0f, 3.0f, 0.0f, 1.0f, 12);
static const GLfloat* cylinder = MakeCylinder(circle, circle2, 12);*/
static const GLfloat g_color_buffer_data[] = {
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
0.6f, 0.6f, 0.6f,
};
static const GLfloat g_color_buffer_data2[] = {
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.597f, 0.770f, 0.761f,
0.559f, 0.436f, 0.730f,
0.359f, 0.583f, 0.152f,
0.483f, 0.596f, 0.789f,
0.559f, 0.861f, 0.639f,
0.195f, 0.548f, 0.859f,
0.014f, 0.184f, 0.576f,
0.771f, 0.328f, 0.970f,
0.406f, 0.615f, 0.116f,
0.676f, 0.977f, 0.133f,
0.971f, 0.572f, 0.833f,
0.140f, 0.616f, 0.489f,
0.997f, 0.513f, 0.064f,
0.945f, 0.719f, 0.592f,
0.543f, 0.021f, 0.978f,
0.279f, 0.317f, 0.505f,
0.167f, 0.620f, 0.077f,
0.347f, 0.857f, 0.137f,
0.055f, 0.953f, 0.042f,
0.714f, 0.505f, 0.345f,
0.783f, 0.290f, 0.734f,
0.722f, 0.645f, 0.174f,
0.302f, 0.455f, 0.848f,
0.225f, 0.587f, 0.040f,
0.517f, 0.713f, 0.338f,
0.053f, 0.959f, 0.120f,
0.393f, 0.621f, 0.362f,
0.673f, 0.211f, 0.457f,
0.820f, 0.883f, 0.371f,
0.982f, 0.099f, 0.879f
};
static const GLfloat g_color_buffer_boat[] = {
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.597f, 0.770f, 0.761f,
0.559f, 0.436f, 0.730f,
0.359f, 0.583f, 0.152f,
0.597f, 0.770f, 0.761f,
0.559f, 0.436f, 0.730f,
0.359f, 0.583f, 0.152f,
0.597f, 0.770f, 0.761f,
0.559f, 0.436f, 0.730f,
0.359f, 0.583f, 0.152f,
0.483f, 0.596f, 0.789f,
0.559f, 0.861f, 0.639f,
0.195f, 0.548f, 0.859f,
0.483f, 0.596f, 0.789f,
0.559f, 0.861f, 0.639f,
0.195f, 0.548f, 0.859f,
0.483f, 0.596f, 0.789f,
0.559f, 0.861f, 0.639f,
0.195f, 0.548f, 0.859f,
0.014f, 0.184f, 0.576f,
0.771f, 0.328f, 0.970f,
0.406f, 0.615f, 0.116f,
0.014f, 0.184f, 0.576f,
0.771f, 0.328f, 0.970f,
0.406f, 0.615f, 0.116f,
0.014f, 0.184f, 0.576f,
0.771f, 0.328f, 0.970f,
0.406f, 0.615f, 0.116f,
0.676f, 0.977f, 0.133f,
0.971f, 0.572f, 0.833f,
0.140f, 0.616f, 0.489f,
0.676f, 0.977f, 0.133f,
0.971f, 0.572f, 0.833f,
0.140f, 0.616f, 0.489f,
0.676f, 0.977f, 0.133f,
0.971f, 0.572f, 0.833f,
0.140f, 0.616f, 0.489f,
0.997f, 0.513f, 0.064f,
0.945f, 0.719f, 0.592f,
0.543f, 0.021f, 0.978f,
0.997f, 0.513f, 0.064f,
0.945f, 0.719f, 0.592f,
0.543f, 0.021f, 0.978f,
0.997f, 0.513f, 0.064f,
0.945f, 0.719f, 0.592f,
0.543f, 0.021f, 0.978f,
0.279f, 0.317f, 0.505f,
0.167f, 0.620f, 0.077f,
0.347f, 0.857f, 0.137f,
0.279f, 0.317f, 0.505f,
0.167f, 0.620f, 0.077f,
0.347f, 0.857f, 0.137f,
0.279f, 0.317f, 0.505f,
0.167f, 0.620f, 0.077f,
0.347f, 0.857f, 0.137f,
0.055f, 0.953f, 0.042f,
0.714f, 0.505f, 0.345f,
0.783f, 0.290f, 0.734f,
0.055f, 0.953f, 0.042f,
0.714f, 0.505f, 0.345f,
0.783f, 0.290f, 0.734f,
0.055f, 0.953f, 0.042f,
0.714f, 0.505f, 0.345f,
0.783f, 0.290f, 0.734f,
0.722f, 0.645f, 0.174f,
0.302f, 0.455f, 0.848f,
0.225f, 0.587f, 0.040f,
0.722f, 0.645f, 0.174f,
0.302f, 0.455f, 0.848f,
0.225f, 0.587f, 0.040f,
0.722f, 0.645f, 0.174f,
0.302f, 0.455f, 0.848f,
0.225f, 0.587f, 0.040f,
0.517f, 0.713f, 0.338f,
0.053f, 0.959f, 0.120f,
0.393f, 0.621f, 0.362f,
0.517f, 0.713f, 0.338f,
0.053f, 0.959f, 0.120f,
0.393f, 0.621f, 0.362f,
0.517f, 0.713f, 0.338f,
0.053f, 0.959f, 0.120f,
0.393f, 0.621f, 0.362f,
0.673f, 0.211f, 0.457f,
0.820f, 0.883f, 0.371f,
0.982f, 0.099f, 0.879f,
0.673f, 0.211f, 0.457f,
0.820f, 0.883f, 0.371f,
0.982f, 0.099f, 0.879f,
0.673f, 0.211f, 0.457f,
0.820f, 0.883f, 0.371f,
0.982f, 0.099f, 0.879f,
0.532f, 0.532f, 0.543f,
0.532f, 0.532f, 0.543f,
0.532f, 0.532f, 0.543f,
0.532f, 0.532f, 0.543f,
0.532f, 0.532f, 0.543f,
0.532f, 0.532f, 0.543f,
0.532f, 0.532f, 0.543f,
0.532f, 0.532f, 0.543f,
0.532f, 0.532f, 0.543f,
};
static const GLfloat g_uv_buffer_data[] = {
0.000059f, 1.0f - 0.000004f,
0.000103f, 1.0f - 0.336048f,
0.335973f, 1.0f - 0.335903f,
1.000023f, 1.0f - 0.000013f,
0.667979f, 1.0f - 0.335851f,
0.999958f, 1.0f - 0.336064f,
0.667979f, 1.0f - 0.335851f,
0.336024f, 1.0f - 0.671877f,
0.667969f, 1.0f - 0.671889f,
1.000023f, 1.0f - 0.000013f,
0.668104f, 1.0f - 0.000013f,
0.667979f, 1.0f - 0.335851f,
0.000059f, 1.0f - 0.000004f,
0.335973f, 1.0f - 0.335903f,
0.336098f, 1.0f - 0.000071f,
0.667979f, 1.0f - 0.335851f,
0.335973f, 1.0f - 0.335903f,
0.336024f, 1.0f - 0.671877f,
1.000004f, 1.0f - 0.671847f,
0.999958f, 1.0f - 0.336064f,
0.667979f, 1.0f - 0.335851f,
0.668104f, 1.0f - 0.000013f,
0.335973f, 1.0f - 0.335903f,
0.667979f, 1.0f - 0.335851f,
0.335973f, 1.0f - 0.335903f,
0.668104f, 1.0f - 0.000013f,
0.336098f, 1.0f - 0.000071f,
0.000103f, 1.0f - 0.336048f,
0.000004f, 1.0f - 0.671870f,
0.336024f, 1.0f - 0.671877f,
0.000103f, 1.0f - 0.336048f,
0.336024f, 1.0f - 0.671877f,
0.335973f, 1.0f - 0.335903f,
0.667969f, 1.0f - 0.671889f,
1.000004f, 1.0f - 0.671847f,
0.667979f, 1.0f - 0.335851f
};
GLuint vertexbuffer; // 큐브
glGenBuffers(1, &vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data,
GL_STATIC_DRAW);
GLuint colorbuffer; // 기본 컬러 버퍼
glGenBuffers(1, &colorbuffer);
glBindBuffer(GL_ARRAY_BUFFER, colorbuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_color_buffer_data), g_color_buffer_data,
GL_STATIC_DRAW);
GLuint colors; // 회색조 바닥을 위해 만들었던 버퍼 - 텍스쳐로 인해 사용 안함
glGenBuffers(1, &colors);
glBindBuffer(GL_ARRAY_BUFFER, colors);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_color_buffer_data2), g_color_buffer_data2,
GL_STATIC_DRAW);
GLuint colorboat; // 보트색상을 위해 만들었던 버퍼 - 텍스쳐로 인해 보트엔 사용안하고 육면체에 적용
glGenBuffers(1, &colorboat);
glBindBuffer(GL_ARRAY_BUFFER, colorboat);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_color_buffer_boat), g_color_buffer_boat,
GL_STATIC_DRAW);
GLuint boatbuffer; // 보트 랜더링
glGenBuffers(1, &boatbuffer);
glBindBuffer(GL_ARRAY_BUFFER, boatbuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(boat), boat, GL_STATIC_DRAW);
GLuint sixSideBuffer; // 육각기둥 랜더링용
glGenBuffers(1, &sixSideBuffer);
glBindBuffer(GL_ARRAY_BUFFER, sixSideBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(sixSide), sixSide, GL_STATIC_DRAW);
GLuint uvbuffer; // 텍스쳐 맵핑을 위한
glGenBuffers(1, &uvbuffer);
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_uv_buffer_data), g_uv_buffer_data, GL_STATIC_DRAW);
double lastTime = glfwGetTime();
double lastFrameTime = lastTime; // 후에 deltaTime 을 구하기 위함
vec3 gOrientation1, gOrientation2; // 기둥의 팬듈러 운동을 위한 벡터
int viking_flag = 0; // 한쪽으로만 도는것이아닌 왓다갓다를 위한 플래그
vec3 rotation1, translation1;
translation1 = { 14.0f, -11.0f, 0.0f };
vec3 rotation2, translation2, translation3, translation4, translation5, translation6;
translation2 = { 14.5f, 0.0f, 0.0f };
translation3 = { 4.0f, -8.0f, 4.0f };
translation4 = { 4.0f, -8.0f, -4.0f };
translation5 = { -4.0f, -8.0f, -4.0f };
translation6 = { -4.0f, -8.0f, 4.0f };
// 컵들의 위치 및 컵의 회전을 위한 벡터들
glDisable(GL_CULL_FACE); // 마우스,키보드에 따른 컬링에 관한 설정
// 렌더링 부분
do {
//
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// deltaTime
double currentTime = glfwGetTime();
float deltaTime = (float)(currentTime - lastFrameTime);
lastFrameTime = currentTime;
// deltaTime 을 구햇다 ! 현재시간 - 마지막프레임시간 = 현재 프레임 시간 해서
// 1 / 프레임 이라는 deltaTime 이 구해진다. 움직이는 것에 대해서는 곱해주는 것이
// 좋다 아니면
// 휙휙 움직여버리게 되기 때문
// Use our shader
glUseProgram(programID);
// 마우스 키보드 입출력
computeMatricesFromInputs();
glm::mat4 Projection = getProjectionMatrix();
glm::mat4 View = getViewMatrix(); // View 와 Projection 에 대해서 입력 받은값으로
재정의하는부분 ( 으로 생각 )
vec3 groundPosition(0.0f, -10.0f, 0.0f); // 원래 이곳의 벡터들은 While 문 밖에 위치하고 있었지만 매 프레임마다 새로 계산 되어야 하기때문에 While 문 안으로 들어오게되었다.
glm::mat4 Ground = Projection * View * translate(mat4(), groundPosition) *
scale(mat4(), vec3(30.0f, 0.01f, 30.0f));
//Ground 끝
// 바이킹 기둥 1
vec3 viking_pillar1(-25.0f, -5.0f, 0.0f);
glm::mat4 Viking_Pillar1 = Projection * View * translate(mat4(), viking_pillar1)
*eulerAngleXYZ(-0.5f, 0.0f, -0.53f) * scale(mat4(), vec3(0.3f, 10.0f, 0.3f));
// 바이킹 기둥 2
vec3 viking_pillar2(-15.0f, -5.0f, 0.0f);
glm::mat4 Viking_Pillar2 = Projection * View * translate(mat4(), viking_pillar2)
*eulerAngleXYZ(-0.5f, 0.0f, 0.53f) * scale(mat4(), vec3(0.3f, 10.0f, 0.3f));;
// 바이킹 기둥 3
vec3 viking_pillar3(-25.0f, -5.0f, -8.3f);
glm::mat4 Viking_Pillar3 = Projection * View * translate(mat4(), viking_pillar3)
*eulerAngleXYZ(0.5f, 0.0f, -0.53f) * scale(mat4(), vec3(0.3f, 10.0f, 0.3f));;
// 바이킹 기둥 4
vec3 viking_pillar4(-15.0f, -5.0f, -8.3f);
glm::mat4 Viking_Pillar4 = Projection * View * translate(mat4(), viking_pillar4)
*eulerAngleXYZ(0.5f, 0.0f, 0.53f) * scale(mat4(), vec3(0.3f, 10.0f, 0.3f));
// Ground
{
glUseProgram(programID2); // 텍스쳐 사용을 위한 설정
glUniformMatrix4fv(MatrixID2, 1, GL_FALSE, &Ground[0][0]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Texture2);
glUniform1i(TextureID, 0);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glVertexAttribPointer(
1, // attribute. No particular reason for 1,
2, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 12 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
// GROUND 끝
glUseProgram(programID); // 텍스쳐 사용이 끝났으므로
}
// 바이킹
{
// 바이킹 메인 기둥
vec3 viking_pillar_main(-20.0f, 2.0f, -4.15f);
// vec3 returnto_basic(0.0f, 0.0f, -4.5f);
vec3 returnto_basic(0.0f, -4.3f, 0.0f);
//gOrientation1.x = 1.5707f;
gOrientation1.y; // = 0.0f;
gOrientation1.z; // = 0.0f;
if (gOrientation1.x > 1.2f) // 계속 한방향으로 회전하는 것을 멈추기 위함
viking_flag = 1;
else if (gOrientation1.x < -1.2f) // 사실 한방향으로 계속 가지도 못하지만 cos 값이 0 에 도달하면 멈춰버리기때문에
viking_flag = 0;
//1.2f를 넘어가면 +, -1.2f보다 작아지면 -
if (viking_flag == 1)
gOrientation1.x -= 3.14159f / 2.0f * deltaTime * cos(gOrientation1.x) * cos(gOrientation1.x); // 코사인을 두번 해준것은 좀더 바뀌는 곡선을 극적으로 만들기 위함
else
gOrientation1.x += 3.14159f / 2.0f * deltaTime * cos(gOrientation1.x) * cos(gOrientation1.x); // 이로써 올라갈땐 천천히 내려올땐 빨리내려오게 된다.
glm::mat4 Viking_Pillar_Main = Projection * View *translate(mat4(), viking_pillar_main) * eulerAngleYXZ(gOrientation1.y, gOrientation1.x, gOrientation1.z) *translate(mat4(), returnto_basic)
* scale(mat4(), vec3(0.3f, 5.0f, 0.3f)); // 행렬의 계산
// 바이킹 보트
vec3 viking_boat(0.0f, -1.2f, 0.0f);
glm::mat4 Viking_Boat = Viking_Pillar_Main * translate(mat4(), viking_boat) * eulerAngleXYZ(0.0f, 1.7f, 0.0f) * scale(mat4(), vec3(5.0f, 0.3f, 5.0f));
//바이킹 기둥1
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &Viking_Pillar1[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colors);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 12 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
//바이킹 기둥2
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &Viking_Pillar2[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colors);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 12 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
//바이킹 기둥3
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &Viking_Pillar3[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colors);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 12 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
//바이킹 기둥4
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &Viking_Pillar4[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colors);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 12 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
//바이킹 메인 기둥 움직이지만 실제로 랜더링 부분은같다 그저 넘겨받는 행렬이 다를뿐
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &Viking_Pillar_Main[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colors);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 12 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
// 바이킹 보트 텍스쳐 사용을 한다.
{
glUseProgram(programID2); // 텍스쳐를 위한 부분
glUniformMatrix4fv(MatrixID2, 1, GL_FALSE, &Viking_Boat[0][0]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Texture);
glUniform1i(TextureID, 0);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, boatbuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
2, // size 왜냐하면! 2d 텍스쳐이므로 xy 값밖에 없기 때문이다 !
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 3 * 12); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
} // 바이킹
glUseProgram(programID);
// programID = LoadShaders("TransformVertexShader.vertexshader", "ColorFragmentShader.fragmentshader");
// 회전 컵
{
rotation1.y += 3.14159f / 2.0f * deltaTime; // 바닥에 해당하는 부분 그저 돌아간다.
glm::mat4 SixSideMat = Projection * View *translate(mat4(), translation1) * eulerAngleXYZ(rotation1.x, rotation1.y, rotation1.z) * scale(mat4(), vec3(5.0f, 3.0f, 6.0f)); // 위치이동하고 그자리에서 돌아갈뿐 제자리에서
rotation2.y -= 3 * 3.14159f / 2.0f * deltaTime;
glm::mat4 smallSixSideMat1 = Projection * View * translate(mat4(), translation2) *eulerAngleXYZ(rotation1.x, rotation1.y, rotation1.z) *translate(mat4(), translation3) * eulerAngleXYZ(rotation2.x, rotation2.y, rotation2.z);
glm::mat4 smallSixSideMat2 = Projection * View * translate(mat4(), translation2) *eulerAngleXYZ(rotation1.x, rotation1.y, rotation1.z) *translate(mat4(), translation4) * eulerAngleXYZ(rotation2.x, rotation2.y, rotation2.z);
glm::mat4 smallSixSideMat3 = Projection * View * translate(mat4(), translation2) *eulerAngleXYZ(rotation1.x, rotation1.y, rotation1.z) *translate(mat4(), translation5) * eulerAngleXYZ(rotation2.x, rotation2.y, rotation2.z);
glm::mat4 smallSixSideMat4 = Projection * View * translate(mat4(), translation2) *eulerAngleXYZ(rotation1.x, rotation1.y, rotation1.z) *translate(mat4(), translation6) * eulerAngleXYZ(rotation2.x, rotation2.y, rotation2.z);
// 컵들이다. 자기스스로 회전하면서도 하나의 축을 기준으로 회전한다 회전하는 바닥위에서 그 주위를 돌면서 스스로 그 반대로 돌아간다.
// 바닥
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &SixSideMat[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, sixSideBuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colorboat);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 6 * 4 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
// 1번 컵
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &smallSixSideMat1[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, sixSideBuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colorboat);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 6 * 4 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
// 2번컵
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &smallSixSideMat2[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, sixSideBuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colorboat);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 6 * 4 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
//3번컵
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &smallSixSideMat3[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, sixSideBuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colorboat);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 6 * 4 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
//4번컵
{
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &smallSixSideMat4[0][0]);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, sixSideBuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colorboat);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 6 * 4 * 3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
}
glfwSwapBuffers(window);
glfwPollEvents();
} // Check if the ESC key was pressed or the window was closed
while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0);
// Cleanup VBO and shader
glDeleteBuffers(1, &vertexbuffer);
glDeleteBuffers(1, &colorbuffer);
glDeleteProgram(programID);
glDeleteVertexArrays(1, &VertexArrayID);
// Close OpenGL window and terminate GLFW
glfwTerminate();
return 0;
}
// 원기둥 구현 포기...왜 안되지
GLfloat* makeCIrcleVertexData(GLfloat x, GLfloat y, GLfloat z, GLfloat radius, GLint numberOfSides)
{
GLint numberOfVertices = numberOfSides + 1;
GLfloat doublePi = 2.0f * 3.141592f;
GLfloat *circleVerticesX = new GLfloat[numberOfVertices];
GLfloat *circleVerticesY = new GLfloat[numberOfVertices];
GLfloat *circleVerticesZ = new GLfloat[numberOfVertices];
//circleVerticesX[0] = x;
//circleVerticesY[0] = y;
//circleVerticesZ[0] = z;
for (int i = 0; i < numberOfVertices; i++)
{
circleVerticesX[i] = x + (radius * cos(i * doublePi / numberOfSides));
circleVerticesY[i] = y + (radius * sin(i * doublePi / numberOfSides));
circleVerticesZ[i] = z;
}
GLfloat *allCircleVertices = new GLfloat[numberOfVertices * 3];
for (int i = 0; i < numberOfVertices; i++)
{
allCircleVertices[i * 3] = circleVerticesX[i];
allCircleVertices[(i * 3) + 1] = circleVerticesY[i];
allCircleVertices[(i * 3) + 2] = circleVerticesZ[i];
}
return allCircleVertices;
}
GLfloat* MakeCylinder(GLfloat *buffer1, GLfloat *buffer2, GLint num) {
GLfloat *buf = new GLfloat[num * 3 * 2 * 2];
for (int i = 0; i < num; i++) {
buf[i * 36 + 0] = buffer1[i * 9 + 0];
buf[i * 36 + 1] = buffer1[i * 9 + 1];
buf[i * 36 + 2] = buffer1[i * 9 + 2];
buf[i * 36 + 3] = buffer1[i * 9 + 3];
buf[i * 36 + 4] = buffer1[i * 9 + 4];
buf[i * 36 + 5] = buffer1[i * 9 + 5];
buf[i * 36 + 6] = buffer1[i * 9 + 6];
buf[i * 36 + 7] = buffer1[i * 9 + 7];
buf[i * 36 + 8] = buffer1[i * 9 + 8]; // 윗쪽 삼각형
buf[i * 36 + 9] = buffer2[i * 9 + 0];
buf[i * 36 + 10] = buffer2[i * 9 + 1];
buf[i * 36 + 11] = buffer2[i * 9 + 2];
buf[i * 36 + 12] = buffer2[i * 9 + 3];
buf[i * 36 + 13] = buffer2[i * 9 + 4];
buf[i * 36 + 14] = buffer2[i * 9 + 5];
buf[i * 36 + 15] = buffer2[i * 9 + 6];
buf[i * 36 + 16] = buffer2[i * 9 + 7];
buf[i * 36 + 17] = buffer2[i * 9 + 8]; // 아래 삼각형
buf[i * 36 + 18] = buffer1[i * 9 + 0]; // 중간을 잇는 삼각형 1
buf[i * 36 + 19] = buffer1[i * 9 + 1];
buf[i * 36 + 20] = buffer1[i * 9 + 2];
buf[i * 36 + 21] = buffer1[i * 9 + 3];
buf[i * 36 + 22] = buffer1[i * 9 + 4];
buf[i * 36 + 23] = buffer1[i * 9 + 5];
buf[i * 36 + 24] = buffer2[i * 9 + 0];
buf[i * 36 + 25] = buffer2[i * 9 + 1];
buf[i * 36 + 26] = buffer2[i * 9 + 2];
buf[i * 36 + 27] = buffer1[i * 9 + 3]; // 중간을 잇는 삼각형 2
buf[i * 36 + 28] = buffer1[i * 9 + 4];
buf[i * 36 + 29] = buffer1[i * 9 + 5];
buf[i * 36 + 30] = buffer2[i * 9 + 0];
buf[i * 36 + 31] = buffer2[i * 9 + 1];
buf[i * 36 + 32] = buffer2[i * 9 + 2];
buf[i * 36 + 33] = buffer2[i * 9 + 3];
buf[i * 36 + 34] = buffer2[i * 9 + 4];
buf[i * 36 + 35] = buffer2[i * 9 + 5];
}
return buf;
}