Jump to content


- - - - -

Projection matrices


2 replies to this topic

#1 Xcrypt

    New Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationBelgium

Posted 12 September 2011 - 02:00 PM

Hi,
I've been wondering if I had to post this in the graphics or math section, since it is closely related to DirectX. So If I chose wrong, please move this thread.


XMMATRIX matScale = XMMatrixScaling(10.0f,10.0f,1.0f);

XMMATRIX matTranslate = XMMatrixTranslation(10.0f,10.0f,0.0f);

XMMATRIX matWorld = XMMatrixMultiply(matScale,matTranslate);


XMMATRIX matProj = XMMatrixOrthographicOffCenterLH( 0.0f, 300.0f, 0.0f, 225.0f, 0.1f, 100.0f );

XMMATRIX matMvp = XMMatrixMultiply(matWorld, matProj);

matMvp = XMMatrixTranspose(matMvp);

With this code I've learned to change the offset and scale of the axis. This moves the origin to the bottom-left corner of my rendertarget. However, if I wanted the origin to be at the top-left corner of my rendertarget(and also inverse the Y coordinates), what would I have to do?

#2 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2725 posts

Posted 12 September 2011 - 02:16 PM

you could always go pos.y=-pos.y in the shader, that would flip it then, but that only helps if your using shaders, you can actually modify that orthographic matrix to do it, maybe itll involve the view matrix too... trial and error?
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#3 Xcrypt

    New Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationBelgium

Posted 12 September 2011 - 03:07 PM

pos.y = -pos.y in the shader wouldn't be correct. It would flip everything indeed, but that's not really what I meant to ask. Right now if I Set that translation matrix to (0.0f,0.0f,0.0f) (and the vertices are centered as well) the surface would show up centered, at the bottom-left corner of the rendertarget. I want it to show up centered, at the top-left corner of the rendertarget. the Y value of the translationmatrix should be 0 for the top-left corner, and the height of the rendertarget for the bottom-left corner.

I have tried trial and error. I couldn't immediately find anything... That's why I am asking here.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users