I am trying to find out if the following C++ code that I wrote is acceptable because it uses two different views (of the same variable) but seems to be working fine. The first code segment rotates the terrain. The second code segment centers a rolling ball.
glm::mat4 model = { {1, 0, 0, 0}, { 0,1,0,0 }, { 0,0,1,0 }, { 0,0,0,1 } };
glm::mat4 view = { {1,0,0,0}, {0,1,0,0}, {0,0,1,0}, {0,0,0,1} };
model = glm::translate(model, glm::vec3(-19.5f, 0.0f, -19.5f));
view = c_mycamera.GetViewMatrix();
second segment:
glm::mat4 ball1 = { {1, 0, 0, 0}, { 0,1,0,0 }, { 0,0,1,0 }, { 0,0,0,1 } };
glm::mat4 ball = { {1, 0, 0, 0}, { 0,1,0,0 }, { 0,0,1,0 }, { 0,0,0,1 } };
ball = glm::translate(ball, glm::vec3(0.0f, -0.85f, -6.3f));
ball = glm::rotate(ball, (float)glfwGetTime(), glm::vec3(-1.0f, 0.0f, 0.0f));
ball = glm::scale(ball, scale);
ball1 = glm::translate(ball, glm::vec3(0.0f, 0.0f, 2.5f));
view = glm::inverse(ball) *ball1;
here’s a link to it’s video however the rotate might not be centered!
Thanks in advance,
Josheir