Zadanie 4 make ball 3d

This commit is contained in:
Władysław Kuczerenko 2024-06-29 17:55:54 +02:00
parent 81ec3695cb
commit 98ac748dbe
2 changed files with 11 additions and 7 deletions

View File

@ -1,10 +1,10 @@
#version 330 core
layout (location = 0) in vec2 aPos;
layout (location = 0) in vec3 aPos;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(aPos, 0.0, 1.0);
gl_Position = projection * view * model * vec4(aPos, 1.0);
}

View File

@ -56,14 +56,18 @@ GLuint bezierVAO, bezierVBO;
GLuint sphereVAO, sphereVBO, sphereEBO;
std::vector<glm::vec3> controlPoints = {
glm::vec3(-1.0f, 0.0f, 0.0f),
glm::vec3(-0.5f, 5.0f, 0.0f),
glm::vec3(0.5f, -5.0f, 0.0f),
glm::vec3(1.0f, 3.0f, 0.0f)
glm::vec3(-1.0f, -1.0f, 0.0f),
glm::vec3(-0.5f, 4.0f, 0.0f),
glm::vec3(0.5f, -6.0f, 0.0f),
glm::vec3(1.0f, 2.0f, 0.0f)
};
float easingFn(float t) {
return pow(t, 3);
// return 1 - pow(1 - t, 3);
return t < 0.5
? (1 - pow(1 - 2*t, 3)) / 2
: (pow(2*t - 1, 3) + 1) / 2;
}
glm::vec3 cubicBezier(const glm::vec3& P0, const glm::vec3& P1, const glm::vec3& P2, const glm::vec3& P3, float t) {