# Perspective Projection Matrix

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

## Recommended Posts

Hi everyone! I'm trying to use a perspective projection matrix for a uni assignment. My current problem is when I times my verticies against the matrix I get some form of distance perspective but as my shape moves towards the screen it moves from bottom right to top left staying the same size and then suddenly gets bigger and jumps back down to the bottom right. I'm probably doing something silly as I havn't done prospective projection before. Hopfully my code is straight forward. I normalise my vectors within my draw algorithm.
static double mat[4][4] = { { 1, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, -2*FRAME_WIDE },
{ 0, 0, 1, 0 } };
static double mat1[4][4];
static double mat2[4][4];
static double matp[4][4];
static double pointx = FRAME_WIDE/2;
static double pointy = FRAME_HIGH/2;
memcpy( mat1, identityd, sizeof(double) * 16);
mat1[0][3] = pointx;
mat1[1][3] = pointy;
MatrixTimes44by44( mat1, mat, mat2 );
mat1[0][3] = -pointx;
mat1[1][3] = -pointy;
MatrixTimes44by44( mat2, mat1, matp );
for( int i = 0; i < vjs->vertices->size; ++i ) {
MatrixTimes44by44( matp, vjs->mat, mat1 );
MatrixTimes44by4( mat1, (int*)&vjs->original->v.pos, (int*)&vjs->vertices->v.pos );
}



##### Share on other sites
Creating a perspective matrix really depends on which subsystem you are using. DirectX and OpenGL use different matrices (since one use lefthanded and the other righthanded coordinate systems).

A good reference for perspective matrices are the microsoft directx webpage or the opengl reference book. Another good reference on how they work would be this

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
18

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632997
• Total Posts
3009801
• ### Who's Online (See full list)

There are no registered users currently online

×