A027298

11-26-2002, 10:00 PM

Hi graphics people!!!

What I want to do is to calculate a projection matrix, where I can specify any orientation for the near plane. This means, I want to be able to rotate the near plane of my viewing volume.

I looked at Foley and tried to derivate it from his 6 steps, but it doesn' really work. Currently I am doing it like this:

1) I calculate the u,v,n -axis. I think this works. It gives me the following Matrix:

ux uy uz 0

R = vx vy vz 0

nx ny nz 0

0 0 0 1

(With the n-axis I specify the orientation with the near plane and calculate the u- and v-axis according to the n-axis)

2) after that I convert the frustum to the symmetric frustum by a shear transformation

shx = (left + right) / (2 * near)

shy = (bottom + top) / (2 * near)

1 0 shx 0

H = 0 1 shy 0

0 0 1 0

0 0 0 1

3) Here I scale the sides to: x = +/-z, z = -far, z = -near

The required scaling matrix is therefore:

xscale = 2 * near / (left - right)

yscale = 2 * near / (top - bottom)

zscale = 1

xscale 0 0 0

S = 0 yscale 0 0

0 0 zscale 0

0 0 0 1

4) In this step I transform the far plane to the plane z = +1 and the near plane to z = -1 using projection normalization.

a = -(far + near) / (far - near)

b = (-2 * far * near) / (far - near)

1 0 0 0

N = 0 1 0 0

0 0 a b

0 0 -1 0

With multiplication of the matrices above I should get my projection matrix, with a flexible near plane:

P = N * S * H * R

But it doesn't work. I think that something is wrong with the rotation part. But I just did it like Foley. Without the last multiplication by R, it's just like the normal OpenGL projection matrix.

It would be so cool if somebody of yous could give me a suggestion to this, because it should be possible.

Thanks!!!

[This message has been edited by A027298 (edited 11-26-2002).]

What I want to do is to calculate a projection matrix, where I can specify any orientation for the near plane. This means, I want to be able to rotate the near plane of my viewing volume.

I looked at Foley and tried to derivate it from his 6 steps, but it doesn' really work. Currently I am doing it like this:

1) I calculate the u,v,n -axis. I think this works. It gives me the following Matrix:

ux uy uz 0

R = vx vy vz 0

nx ny nz 0

0 0 0 1

(With the n-axis I specify the orientation with the near plane and calculate the u- and v-axis according to the n-axis)

2) after that I convert the frustum to the symmetric frustum by a shear transformation

shx = (left + right) / (2 * near)

shy = (bottom + top) / (2 * near)

1 0 shx 0

H = 0 1 shy 0

0 0 1 0

0 0 0 1

3) Here I scale the sides to: x = +/-z, z = -far, z = -near

The required scaling matrix is therefore:

xscale = 2 * near / (left - right)

yscale = 2 * near / (top - bottom)

zscale = 1

xscale 0 0 0

S = 0 yscale 0 0

0 0 zscale 0

0 0 0 1

4) In this step I transform the far plane to the plane z = +1 and the near plane to z = -1 using projection normalization.

a = -(far + near) / (far - near)

b = (-2 * far * near) / (far - near)

1 0 0 0

N = 0 1 0 0

0 0 a b

0 0 -1 0

With multiplication of the matrices above I should get my projection matrix, with a flexible near plane:

P = N * S * H * R

But it doesn't work. I think that something is wrong with the rotation part. But I just did it like Foley. Without the last multiplication by R, it's just like the normal OpenGL projection matrix.

It would be so cool if somebody of yous could give me a suggestion to this, because it should be possible.

Thanks!!!

[This message has been edited by A027298 (edited 11-26-2002).]