From d4c350721e9ccb78919fd2728e7c8e87151b3072 Mon Sep 17 00:00:00 2001 From: Luca Conte Date: Thu, 25 Apr 2024 16:03:58 +0200 Subject: [PATCH] u05-2 make tower more pretty --- u05-2/main.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/u05-2/main.c b/u05-2/main.c index 817ea81..1f5e0b4 100644 --- a/u05-2/main.c +++ b/u05-2/main.c @@ -278,7 +278,8 @@ void draw(void) { GLfloat up[3] = {0.0f, 1.0f, 0.0f}; GLfloat viewingTransformation[16]; - lookAt(viewingTransformation, cameraPosition, origin, up); + GLfloat fixedCameraPosition[3] = {cos(stepi) * 4.0f, 1.5f, sin(stepi) * 4.0f}; + lookAt(viewingTransformation, fixedCameraPosition, origin, up); @@ -315,24 +316,17 @@ void draw(void) { glUniformMatrix4fv(glGetUniformLocation(program, "globalTransformation"), 1, GL_FALSE, globalTransformation); - GLfloat position[3] = {0.0f, -3.0f, 0.0f}; - GLfloat scaleVec[3] = {3.0f, 0.1f, 3.0f}; + GLfloat position[3] = {0.0f, -2.0f, 0.0f}; + GLfloat scaleVec[3] = {3.0f, 0.2f, 3.0f}; GLfloat rotateVec[3] = {0.0f, 0.0f, 0.0f}; - drawCube(position, scaleVec, rotateVec); + for (int i=0; i < 10; i++) { + position[1] += 0.4; + rotateVec[1] += 0.2; + scaleVec[0] -= 0.3; + scaleVec[2] -= 0.3; + drawCube(position, scaleVec, rotateVec); + } - position[1] = -2.8f; - scaleVec[0] = 2.0f; - scaleVec[2] = 2.0f; - rotateVec[0] = pi; - drawCube(position, scaleVec, rotateVec); - - position[1] = -2.4f; - scaleVec[0] = 1.0f; - scaleVec[1] = 0.3f; - scaleVec[2] = 1.0f; - rotateVec[0] = 0.0f; - rotateVec[1] = pi / 4; - drawCube(position, scaleVec, rotateVec); } void framebuffer_size_callback(GLFWwindow *window, int width, int height) {