calculating clipping planes...

This is probably an easy question, but I’ll ask it anyway

How can I calculate the plane equation between 2 arbitrary points (plane is always going to be perfectly vertical) given my viewpoint position?

This only has to be in 2d (you can ignore the y [up] axis).

Thanks!

Originally posted by timmie:
[b]This is probably an easy question, but I’ll ask it anyway

How can I calculate the plane equation between 2 arbitrary points (plane is always going to be perfectly vertical) given my viewpoint position?

This only has to be in 2d (you can ignore the y [up] axis).

Thanks![/b]

Depends. If the vector between these two points are parallell to the up vector, you can’t find a suitable plane.

Otherwise, let the vector between your points be V. Then, the plane normal N is N = V x (V x UP), where x is the cross-product.

[This message has been edited by antipop (edited 02-19-2003).]

You can define a plane in 3D by a normal and one point; so if your normal is up (0, 1, 0), you just need one point in 3D to define the plane.

The concept of a plane in 2D is beyond me though. I’m also not sure to understand how the viewpoint position is a variable.

If you’re looking for a 3D plane that intersects the XZ plane along the line defined by your two 2D points (let’s call them (x1,z1) and (x2,z2), then you can create it from these 3 points for example:

  • (x1, 0, z1)
  • (x2, 0, z2)
  • (x2, 1, z2)

Y.

Hmm, a bit of elaboration, I guess…

The map data I’m using is 2D (Doom engine) and I want to set up a clip plane aligned with a given line. The reason for this is I am implementing mirrors (ala Duke3D) and want to set up a clipping plane so only things on the far side of the mirror are drawn.
http://members.shaw.ca/timstump/images/zdoomgl_37.jpg (kinda dark, but you get the idea)

How the mirror works is I basically just move the viewpoint to the virtual location/orientation in the mirror and draw the scene again.

The problem is, sometimes I get things coming through the mirror (mostly due to mapping errors, since the same bizarre things happen in software mode).

Not a big deal, really, since the problems aren’t really the engines fault, but I’d still like to minimize them.

Would a reflective cubemap do the trick for ya???

Originally posted by timmie:
[b]Hmm, a bit of elaboration, I guess…

The map data I’m using is 2D (Doom engine) and I want to set up a clip plane aligned with a given line. The reason for this is I am implementing mirrors (ala Duke3D) and want to set up a clipping plane so only things on the far side of the mirror are drawn.
http://members.shaw.ca/timstump/images/zdoomgl_37.jpg (kinda dark, but you get the idea)

How the mirror works is I basically just move the viewpoint to the virtual location/orientation in the mirror and draw the scene again.

The problem is, sometimes I get things coming through the mirror (mostly due to mapping errors, since the same bizarre things happen in software mode).

Not a big deal, really, since the problems aren’t really the engines fault, but I’d still like to minimize them.[/b]

Originally posted by timmie:
[b]Hmm, a bit of elaboration, I guess…

The map data I’m using is 2D (Doom engine)
[/b]

This should be quite straight-forward: Your points (in 3D) is p1 and p2.

Plane equation:
N.x *x + N.y *y + N.z *z + D = 0

To find the values:

v1 = p2-p1;
v2 = up (from modelview matrix)
N = v1 X v2 // Maybe normalize it?
D = -(N.xp1.x + N.yp1.y + N.z*p2.z)

Would a reflective cubemap do the trick for ya???

Probably, but right now it still runs on a Voodoo3 (which a surprising number of people still use, to my chagrin)

Oh, and thanks for the info, antipop!