I have a mesh to which I apply Scale.
Here's before I apply scale to the cube behind:
http://s7.postimage.org/r25iv2s0r/1png.png
And here's after:
http://s2.postimage.org/6qfk75ul5/image.png
The cube scaled correctly, but why did the cube move?
Here's the code for rendering it:
void OpenGLRenderer::RenderMesh(MeshPtr mesh, const Mat4& modelMatrix, const Mat4& viewMatrix, const Mat4& projectionMatrix)
{
if (mesh)
{
// upload MVP matrix
Mat4 MVP = projectionMatrix * viewMatrix * modelMatrix; // modelMatrix is a Mat4(1.0f) that has been applied glm::scale(Mat4(1.0f), Vec3(2.0f, 1.0f, 1.0f))
ShaderData shaderData;
shaderData.Color.x = 1.0f; shaderData.Color.y = 0.5f; shaderData.Color.z = 0.5f; shaderData.Color.w = 1.0f;
shaderData.MVPMatrix = MVP;
mUniBuffer.SetData(shaderData);
// render
mesh->GetVertexBuffer()->Render();
}
}
What could be wrong?
EDIT: I can note that if I do translate instead of scale, the cube would move as expected