Jump to content
  • Advertisement
Sign in to follow this  
Raptisoft

Turn this projection matrix orthographic

This topic is 1702 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

 

I have a projection matrix that I'm building manually...

 

Can anyone tell me how I can turn this to an orthographic view matrix?  I keep trying examples online, but always get non-orthographic, sometimes hilarious, results.

 

(Note: For reasons of a tyrannical co-programmer, I can't simply use the Direct3DX functions to do this)

 

Thanks!

	float aAspect = (float)gPageWidth/(float)gPageHeight;
	float aNear = gZNear;
	float aFar = GetZDepth();

	float aWidth=COS(theFOV / 2.0f);
	float aHeight=COS(theFOV / 2.0f);
	if (aAspect > 1.0) aWidth /= aAspect;
	else aHeight *= aAspect;


	float s  = SIN(theFOV / 2.0f);
	float d  = 1.0f - aNear/aFar;

	float aMatrix[4][4];
	aMatrix[0][0]=aWidth;
	aMatrix[1][0]=0;
	aMatrix[2][0]=0;
	aMatrix[3][0]=0;
	aMatrix[0][1]=0;
	aMatrix[1][1]=aHeight;
	aMatrix[2][1]=0;
	aMatrix[3][1]=0;
	aMatrix[0][2]=0;
	aMatrix[1][2]=0;
	aMatrix[2][2]=s/d;
	aMatrix[3][2]=-(s * aNear / d);
	aMatrix[0][3]=0;
	aMatrix[1][3]=0;
	aMatrix[2][3]=s;
	aMatrix[3][3]=0;


Edited by Raptisoft

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!