From 310f9f2b39f4da19ebd11ebf7ab82dc329c3accb Mon Sep 17 00:00:00 2001 From: Caenneth Date: Mon, 24 Jun 2024 13:03:24 +0200 Subject: [PATCH 1/6] animation --- scene-graph.scg | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/scene-graph.scg b/scene-graph.scg index 9ae36a3..e730d17 100644 --- a/scene-graph.scg +++ b/scene-graph.scg @@ -1574,27 +1574,37 @@ rotateZ 0.0 translate -12.0 2.66 -4.0 parent 0 -# Chalkboard 1 # -obj 138 -use 2 -name myChalkboard1 +# Chalkboard Parent # +obj 147 +use +name myChalkboard scale 1.9 1.9 1.9 rotateX 0.0 rotateY 0.0 rotateZ 0.0 translate 6.5 -0.4 0.3 -parent 0 + +# Chalkboard 1 # +obj 138 +use 2 +name myChalkboard1 +scale 1.0 1.0 1.0 +rotateX 0.0 +rotateY 0.0 +rotateZ 0.0 +translate 6.5 -0.4 0.3 +parent 147 # Chalkboard 2 # obj 139 use 2 name myChalkboard2 -scale 1.9 1.9 1.9 +scale 1.0 1.0 1.0 rotateX 0.0 rotateY 0.0 rotateZ 0.0 -translate 6.5 -0.4 6.15 -parent 0 +translate 0.0 0.0 6.15 +parent 147 # Chalkboard Pole 1 # obj 140 @@ -1605,7 +1615,7 @@ rotateX 0.0 rotateY 0.0 rotateZ 0.0 translate 0.0 0.0 3.07 -parent 138 +parent 147 # Chalkboard Pole 2 # obj 141 @@ -1616,7 +1626,7 @@ rotateX 0.0 rotateY 0.0 rotateZ 0.0 translate 0.0 0.0 0.0 -parent 138 +parent 147 # Table 1 # From aaa50e6a288e781bb3c895cc58c9d5c392bdfad6 Mon Sep 17 00:00:00 2001 From: Caenneth Date: Mon, 24 Jun 2024 15:24:20 +0200 Subject: [PATCH 2/6] updated pos of chalkboard --- scene-graph.scg | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scene-graph.scg b/scene-graph.scg index e730d17..f91c40c 100644 --- a/scene-graph.scg +++ b/scene-graph.scg @@ -1576,13 +1576,12 @@ parent 0 # Chalkboard Parent # obj 147 -use name myChalkboard scale 1.9 1.9 1.9 rotateX 0.0 -rotateY 0.0 +rotateY -1.5 rotateZ 0.0 -translate 6.5 -0.4 0.3 +translate 0.0 -0.5 6.5 # Chalkboard 1 # obj 138 @@ -1592,7 +1591,7 @@ scale 1.0 1.0 1.0 rotateX 0.0 rotateY 0.0 rotateZ 0.0 -translate 6.5 -0.4 0.3 +translate 0.0 0.0 0.0 parent 147 # Chalkboard 2 # @@ -1603,7 +1602,7 @@ scale 1.0 1.0 1.0 rotateX 0.0 rotateY 0.0 rotateZ 0.0 -translate 0.0 0.0 6.15 +translate 0.0 0.0 3.05 parent 147 # Chalkboard Pole 1 # @@ -1614,7 +1613,7 @@ scale 1.0 1.0 1.0 rotateX 0.0 rotateY 0.0 rotateZ 0.0 -translate 0.0 0.0 3.07 +translate 0.0 0.0 3.05 parent 147 # Chalkboard Pole 2 # From 4c65103fd67ba71c79d9a007f59c4c9010db9846 Mon Sep 17 00:00:00 2001 From: Caenneth Date: Mon, 24 Jun 2024 13:27:59 +0200 Subject: [PATCH 3/6] animation test --- src/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.c b/src/main.c index 7246cdb..9154311 100644 --- a/src/main.c +++ b/src/main.c @@ -93,6 +93,11 @@ void handleInputs(double deltaTime) { cameraPosition.y -= deltaTime * 10; } + if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) { + SceneNode* chalkboard = findNodeByName("myChalkboard1", SceneNode* root); + chalkboard->transformation[3][1] += 0.1f; // Erhöht die Y-Position + } + if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) { objectPosition.x += deltaTime * 10; } From e5203bbc63b0c6469f8bda93104a81212f3f4e53 Mon Sep 17 00:00:00 2001 From: Caenneth Date: Mon, 24 Jun 2024 16:51:03 +0200 Subject: [PATCH 4/6] animation for chalkboard --- scene-graph.scg | 6 +++--- src/main.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/scene-graph.scg b/scene-graph.scg index f91c40c..9e5fabe 100644 --- a/scene-graph.scg +++ b/scene-graph.scg @@ -48,7 +48,7 @@ texture ../texture/floor/Carpet.png obj 0 use 1 name myChair1_1 -rotateY -1.5 +rotateY 0.0 scale 1.0 1.0 1.0 # Platz 2 # @@ -1579,9 +1579,9 @@ obj 147 name myChalkboard scale 1.9 1.9 1.9 rotateX 0.0 -rotateY -1.5 +rotateY 0.0 rotateZ 0.0 -translate 0.0 -0.5 6.5 +translate 6.4 -0.3 0.3 # Chalkboard 1 # obj 138 diff --git a/src/main.c b/src/main.c index 9154311..f6e6881 100644 --- a/src/main.c +++ b/src/main.c @@ -56,6 +56,7 @@ SceneNode* rootNode; /** * Input handler for camera movement. * */ +float chalkboardYPosition = 0.0f; void handleInputs(double deltaTime) { assert(window != NULL); @@ -93,11 +94,33 @@ void handleInputs(double deltaTime) { cameraPosition.y -= deltaTime * 10; } + SceneNode* chalkboard = findNodeByName("myChalkboard1", rootNode); + if (!chalkboard) return; if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) { - SceneNode* chalkboard = findNodeByName("myChalkboard1", SceneNode* root); - chalkboard->transformation[3][1] += 0.1f; // Erhöht die Y-Position + if (chalkboardYPosition >= 1.0f) { + chalkboardYPosition = 1.0f; + return; + } + chalkboardYPosition += deltaTime * 1.0f; + chalkboard->transformation = (mat4){1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, chalkboardYPosition, 0.0f, 1.0f}; + updateSceneNode(chalkboard, &findNodeByName("myChalkboard", rootNode)->worldTransformation); } - + if (glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS) { + if (chalkboardYPosition <= 0.0f) { + chalkboardYPosition = 0.0f; + return; + } + chalkboardYPosition -= deltaTime * 1.0f; + chalkboard->transformation = (mat4){1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, chalkboardYPosition, 0.0f, 1.0f}; + updateSceneNode(chalkboard, &findNodeByName("myChalkboard", rootNode)->worldTransformation); + } + if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) { objectPosition.x += deltaTime * 10; } From db3870b45f17fb785b023024e576614abb63f0e7 Mon Sep 17 00:00:00 2001 From: Caenneth Date: Mon, 24 Jun 2024 17:00:51 +0200 Subject: [PATCH 5/6] fixed max values --- src/main.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index f6e6881..7717596 100644 --- a/src/main.c +++ b/src/main.c @@ -97,11 +97,8 @@ void handleInputs(double deltaTime) { SceneNode* chalkboard = findNodeByName("myChalkboard1", rootNode); if (!chalkboard) return; if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) { - if (chalkboardYPosition >= 1.0f) { - chalkboardYPosition = 1.0f; - return; - } chalkboardYPosition += deltaTime * 1.0f; + chalkboardYPosition = fminf(chalkboardYPosition, 1.0f); chalkboard->transformation = (mat4){1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, @@ -109,11 +106,8 @@ void handleInputs(double deltaTime) { updateSceneNode(chalkboard, &findNodeByName("myChalkboard", rootNode)->worldTransformation); } if (glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS) { - if (chalkboardYPosition <= 0.0f) { - chalkboardYPosition = 0.0f; - return; - } chalkboardYPosition -= deltaTime * 1.0f; + chalkboardYPosition = fmaxf(chalkboardYPosition, 0.0f); chalkboard->transformation = (mat4){1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, From bcc82553cca7a67babb278ff764939869c229052 Mon Sep 17 00:00:00 2001 From: Caenneth Date: Mon, 24 Jun 2024 15:13:16 +0200 Subject: [PATCH 6/6] changed uv-mapping for chalkboard --- obj/chalkboard/Chalkboard.obj | 54 ++++++++++++++++------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/obj/chalkboard/Chalkboard.obj b/obj/chalkboard/Chalkboard.obj index e712baf..fd9877b 100644 --- a/obj/chalkboard/Chalkboard.obj +++ b/obj/chalkboard/Chalkboard.obj @@ -4,37 +4,31 @@ mtllib Chalkboard.mtl o Board_Left_Cube.007 v -0.010000 0.100000 -0.103724 v -0.010000 1.100000 -0.103724 -v -0.010000 0.100000 -3.103724 -v -0.010000 1.100000 -3.103724 -v 0.010000 0.100000 -0.103724 +v -0.010000 1.100001 -3.103724 +v -0.010000 0.100001 -3.103724 +v 0.010000 1.100001 -3.103724 +v 0.010000 0.100001 -3.103724 v 0.010000 1.100000 -0.103724 -v 0.010000 0.100000 -3.103724 -v 0.010000 1.100000 -3.103724 -vt 0.375000 0.000000 -vt 0.625000 0.000000 -vt 0.625000 0.250000 -vt 0.375000 0.250000 -vt 0.625000 0.500000 -vt 0.375000 0.500000 -vt 0.625000 0.750000 -vt 0.375000 0.750000 -vt 0.625000 1.000000 -vt 0.375000 1.000000 -vt 0.125000 0.500000 -vt 0.125000 0.750000 -vt 0.875000 0.500000 -vt 0.875000 0.750000 -vn -1.0000 0.0000 0.0000 +v 0.010000 0.100000 -0.103724 +vt 0.000842 0.005279 +vt 0.000743 0.996240 +vt 0.999129 0.994899 +vt 0.999298 0.001063 +vt 0.999759 0.995048 +vt 0.999840 0.000181 +vt -0.000193 0.996350 +vt 0.000018 0.004470 +vn -1.0000 -0.0000 0.0000 vn 0.0000 0.0000 -1.0000 -vn 1.0000 0.0000 0.0000 -vn 0.0000 0.0000 1.0000 -vn 0.0000 -1.0000 0.0000 +vn 1.0000 -0.0000 0.0000 +vn 0.0000 -0.0000 1.0000 +vn 0.0000 -1.0000 -0.0000 vn 0.0000 1.0000 0.0000 usemtl TestChalk.001 -s off -f 1/1/1 2/2/1 4/3/1 3/4/1 -f 3/4/2 4/3/2 8/5/2 7/6/2 -f 7/6/3 8/5/3 6/7/3 5/8/3 -f 5/8/4 6/7/4 2/9/4 1/10/4 -f 3/11/5 7/6/5 5/8/5 1/12/5 -f 8/5/6 4/13/6 2/14/6 6/7/6 +s 1 +f 1/1/1 2/2/1 3/3/1 4/4/1 +f 4/4/2 3/3/2 5/5/2 6/6/2 +f 6/6/3 5/5/3 7/7/3 8/8/3 +f 8/8/4 7/7/4 2/2/4 1/1/4 +f 4/4/5 6/6/5 8/8/5 1/1/5 +f 5/5/6 3/3/6 2/2/6 7/7/6