# Degenerate scissor rect?

I have a problem calculating the scissor rectangle of a box.
This only seems to happen with a long and narrow box when the camera direction is almost the same as the “long” side of the box. (It is not in the box.)
Shot: http://tenebrae.sourceforge.net/tenebrae2/broken.jpg
The box is about double the height as you see in the shot so there is a part of it behind the near plane. It works nomally untill suddenly the box “flips” over. I tried checking for w < 0 but that doesn’t fix it. (As it only uses the 4 vertices before the front plane then.)

This is the code used to calculate it. (But well, I hate reading the posted code here myself…) It just projects the 8 points.
I tried using gluProject, but it gives exacly the same results.

for (i=1; i<=8; i++) {
float *v = &verts[i*3];
point = v;
point = v;
point = v;
point = 1.0f;

``````  Mat_Mul_1x4_4x4(point, modelviewproj, res);

px = (res*(1/res)+1.0) * 0.5 * r_Iviewport + r_Iviewport;
py = (res*(1/res)+1.0) * 0.5 * r_Iviewport + r_Iviewport;

if (px > maxx) maxx = px;
if (px < minx) minx = px;
if (py > maxy) maxy = py;
if (py < miny) miny = py;
``````

}

Charles

Originally posted by Pentagram:

[quote]

for (i=1; i<=8; i++) {
float *v = &verts[i*3];

[/QUOTE]You’re sure these two lines are right?

No it’s not that
Altrough it looks fishy… but the first vertex in the list is used for something else.
As I said it works if the camera is ortogonal-ish to the “long” side of the box.
See: http://tenebrae.sourceforge.net/tenebrae2/working.jpg

Charles

[This message has been edited by Pentagram (edited 04-26-2003).]