Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualKaiserJohan

Posted 06 January 2013 - 06:13 AM

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


#4KaiserJohan

Posted 06 January 2013 - 06:12 AM

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

#3KaiserJohan

Posted 06 January 2013 - 06:12 AM

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();        }    }
And if I scale with Vec3(0.5f, 1.0f, 1.0f) it scales X correctly but moves to the right. Also If I apply Vec3(0.5f, 0.5f, 0.5f) nothing happens..

What could be wrong?

EDIT: I can note that if I do translate instead of scale, the cube would move as expected

#2KaiserJohan

Posted 06 January 2013 - 06:11 AM

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();        }    }
And if I scale with Vec3(0.5f, 1.0f, 1.0f) it scales X correctly but moves to the right. Also If I apply Vec3(0.5f, 0.5f, 0.5f) nothing happens..

What could be wrong?

EDIT: I can note that if I do translate instead of scale, the cube would move as expected

#1KaiserJohan

Posted 06 January 2013 - 06:10 AM

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();
        }
    }

 

And if I scale with Vec3(0.5f, 1.0f, 1.0f) it scales X correctly but moves to the right. Also If I apply Vec3(0.5f, 0.5f, 0.5f) nothing happens..

 

What could be wrong?

 

 

 


PARTNERS