Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Aug 2012
Offline Last Active Mar 13 2013 10:46 PM

Posts I've Made

In Topic: Orthographic matrix not working

01 March 2013 - 11:00 PM

I managed to figure this out - apparently I was not accessing the matrix elements correctly - transposing their accessors = m03 instead of m30 for example for the translation matrix.  All is well now! Thanks everyone. 

In Topic: Orthographic matrix not working

01 March 2013 - 08:52 AM

This is how I send it to the shader: I know this part works since the perspective projection matrix works, but the ortho produces wierd results. 


As for my previous projection matrix - this is my first projection matrix - so I am not multiplying it by anything before sending it tothe shader. Should I be?

///upload matrices to uniform varis in shader
        GL20.glUniformMatrix4(projectionMatrixLocation, false, matrix44Buffer);
        GL20.glUniformMatrix4(viewMatrixLocation, false, matrix44Buffer);
        GL20.glUniformMatrix4(modelMatrixLocation, false, matrix44Buffer);

In Topic: Orthographic matrix not working

28 February 2013 - 02:41 PM

Bump - anyone? This is super frustrating.  Is my ortho matrix still messed up?

In Topic: Orthographic matrix not working

25 February 2013 - 11:44 PM

Ok- so i used Shogun's method, I messed around with the camera position and near and far plane.



near plane is 1f, far plane is 100f (though I dont see why this matters in an ortho projection)

Camera is located at 0,0,-1


Sprite is at 0,0,0 dim: 10x10 pixels.


I can actually see it on the screen now, but it seems like everything is vanishing at the origin point, as attached:


This is supposed to be a quad, but the perspective is all wonky. Any idea what's going on now?

In Topic: Orthographic matrix not working

23 February 2013 - 02:14 PM

Ok, so I have a sprite with x,y,z (10,10,0)  with w/h 10fx10f


I have left as 0 and right as 680

top as as 480, bottom as 0


Still I see nothing.


Also, I am using lwjgl, in which if you have a matrix4f, I think m23 means 2nd column, 3rd row. 






              Sprite sprite = new Sprite("assets/texture/redman.png", 50f, 50f, 10f, 10f );
projectionMatrix.m00 = 2/WIDTH;
        projectionMatrix.m11 = 2/HEIGHT;
        projectionMatrix.m22 = -2/(far_plane - near_plane);
        projectionMatrix.m30 = -1;
        projectionMatrix.m31 = -1;
        projectionMatrix.m32 = -((far_plane + near_plane)/(far_plane - near_plane));
        projectionMatrix.m33 = 1;

         cameraPos = new Vector3f(0,0,-1); ...



//Translate camera        
Matrix4f.translate(cameraPos, viewMatrix, viewMatrix);

        //Scale, translate and rotate model
        Matrix4f.scale(modelScale, modelMatrix, modelMatrix);
        Matrix4f.translate(modelPos, modelMatrix, modelMatrix);
        Matrix4f.rotate((float)Math.toRadians(modelAngle.z), new Vector3f(0,0,1), modelMatrix, modelMatrix);
        Matrix4f.rotate((float)Math.toRadians(modelAngle.y), new Vector3f(0,1,0), modelMatrix, modelMatrix);
        Matrix4f.rotate((float)Math.toRadians(modelAngle.x), new Vector3f(1,0,0), modelMatrix, modelMatrix);