0
\$\begingroup\$

I'm trying to write a little program with a bouncing cube but I can't find the right values for it. I have these lines:

modelMatrix = glm::mat4(1)

modelMatrix *= Translate(x, y, z)

modelMatrix *= RotateOZ(angle)

RenderMesh(mesh["cube"], shaders["V"], modelMatrix)

I add/sub the y in a interval and the angle too.I have a problem because I don't really know with which values to increment/sub these values.

enter image description here

I want the same effect as in the image but at all angles [0 - 180].

EDIT++

So I want my cube to bounce while it's rotating like in the image. First the cube will have the arrow down to show what's his position first at y0 and x0. Then he will rotate in the [0 - 90] range. I want the cube to have the arrow up meaning that the cube will be rotated at 90 angle when he will hit y1 and x1/2. Then he will start to descend at an angle [90 - 180] so he will be at y0 but with at x1. I tried incrementing the x, y and the angle with a small value like 0.1 and then decreasing the y when it hit a point. The result is close but I can see that it's not perfect. I hope that made sense.

Thank you for your time!

\$\endgroup\$
4
  • \$\begingroup\$ Is your problem really about rendering, or is it about physics? OpenGL is all about rendering, if your problem is on physics, OpenGL is not concerned. Side note: put your code in code tags, for easier reading. Also, a minimal reproducible example is welcome to help us to help you. \$\endgroup\$ – Sacha Dec 8 '20 at 19:57
  • \$\begingroup\$ Well it's about physics sir \$\endgroup\$ – NeedHelpFast Dec 8 '20 at 20:00
  • \$\begingroup\$ Ok then leave OpenGL alone at it is only about 3D rendering. Put your code in code tags, and explains with more details what is your goal (expected results), what you've attempted and what is the result you got. \$\endgroup\$ – Sacha Dec 8 '20 at 20:19
  • \$\begingroup\$ I'm sorry but I'm still not sure of what you're trying to achieve. I understand that you want a way of simulating the physics for this cube. How is the rotation happening? Does the cube rotates instantaneously when hitting the ground? How is the rotation linked to the position/velocity of the cube? \$\endgroup\$ – Sacha Dec 10 '20 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.