I'm a complete beginner with C++, and I have an assignement to do, may I ask for a little bit of help ?
So my project consist in creating a bouncing ball, particle explosion and people walking, all in 3D using GLM. I have to use gravity and all of those stuff but i don't understand how to implement it. Here is my code for the bouncing ball :
glm::mat4 mv_matrix_sphere =
glm::translate(glm::vec3(-2.0f, 0.5f + t, 0.0f)) *
glm::rotate(-t, glm::vec3(0.0f, 1.0f, 0.0f)) *
glm::rotate(-t, glm::vec3(1.0f, 0.0f, 0.0f)) *
glm::mat4(1.0f);
mySphere.mv_matrix = myGraphics.viewMatrix * mv_matrix_sphere;
mySphere.proj_matrix = myGraphics.proj_matrix;
if (t == 0.5) {
while (t != 0) {
t -= f; // increment movement variable
}
}
t += 0.01f; // increment movement variable
When I execute, the function is working( the ball is moving but it doesn't stop) so that means that the ball never come back (doesn't bounce) And here my particle explosion :
void particles() {
vel = new glm::vec3[numParticles];
for (int i = 0; i < numParticles; i++) {
vel[i] = glm::normalize(glm::vec3((rand() % 1500 - 750) / 10000.0f, (rand() % 1500 - 750) / 10000.0f, (rand() % 1500 - 750) / 10000.0f));
}
}
I found this code on internet but it doesn't work and I don't understand why.
I would be really grateful if you guys can help me. Many thanks !