Newbie Clipping question

Started by
10 comments, last by Fredric 23 years, 9 months ago
In Andre''s TOTWGP, he sets up a bounding box by putting the following code....

  region_data->rdh.rcBound.left    =  64000;
  region_data->rdh.rcBound.top     =  64000;
  region_data->rdh.rcBound.right   = -64000;
  region_data->rdh.rcBound.bottom   = -64000;
  
... why does he do that? why does he make the value for the bounding rectangle to be 64000/-64000? I just don''t get it. Thanks for help. There are three types of people in the world; those who can count, and those who can't.
3D Math- The type of mathematics that'll put hair on your chest!
Advertisement
those look like the xmin, xmax, ymin, and ymax values. you need those four values to test whether or not that sqaure has intersected with another square. read over his explanation of it. it''s probably the best.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
His explanation of the bounding box is this:
"... then you need to set up the bounding box, and then...."

heh, it''s NULL! I know, the bounding box is used for the minx miny etc, but why 64000? The resolution is only 640 by 480!!

There are three types of people in the world; those who can count, and those who can't.
3D Math- The type of mathematics that'll put hair on your chest!
just because the reolution is 640x480 doesn''t mean a bounding box can''t be bigger than it. How big is the sprite the he is using for testing. if the sprite''s really small then it wouldn''t make sense.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
He isn''t using any sprites- he is just showing us how to set up the clipper.
If I want to clip within the screen- which is 640 by 480, why would I need a 64000 bounding box? It doesn''t make any sense to me...

As an example in the book to show how to use the clippper, he makes the blt''er blt rectangles all across the screen (any fool can do that) and have them clipped 3 areas (when I mean clip, I actually mean to show; you can see them), but WHY would the bounding box be 64000?!
...And what the heck IS a bounding box/why is it needed?

Thanks for your help Julio! You''re a gentleman.

There are three types of people in the world; those who can count, and those who can't.
3D Math- The type of mathematics that'll put hair on your chest!
well, since most people don''t like to program pixel perfect collision detection, they use an imaginary box around the sprite. when these boxes collide there''s a collision. you could e-mail Andre himself. his e-mail address should be on his site. he can probably answer your question better than me. xgames3d.com for his site.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Thankyou for your help Julio.. I have already contacted Andre LaMothe, but for some reason, he has been beating around the bush and not directly teaching me why the hell he chose 64,000 as the bounding rectangle value. Is there any other form out there who can tell me why he might have chosen 64,000...

What? Are collisions bad? I see that all the time where two images are like.. heh, colliding... if there is no problem with two images colliding, what''s the point of the rcBound? If two images collide, does one have priority over the other so that it overlaps there other? I''m clueless here- but this is all thanks to Andre''s terrible explanation.

There are three types of people in the world; those who can count, and those who can't.
3D Math- The type of mathematics that'll put hair on your chest!
I take it the code is on page 342-343 for this (Part 2, Chaper 7).

He initalises the clipper object to be way out of bounds, and then closes the clipper down to the correct sizes.

Also look at the code closely :

region_data->rdh.rcBound.left = 64000;
region_data->rdh.rcBound.top = 64000;
region_data->rdh.rcBound.right = -64000;
region_data->rdh.rcBound.bottom = -64000;


This is making a rectangle where the top left corner is at the bottom right of the virtual screen.

the next few lines of code run though the passed clipper list and move the top, left, right and bottom sides of the bounding box to the correct maximums for these sides.

e.g.:

If you have 2 clipping regoins in your list (top, left, bottom, right):

1: 0,0,320,200
2: (320,200,640,400);

you pass these into the function on page 342, and it runs thought them and the out put for the bounding box would be:

region_data->rdh.rcBound.left = 0;
region_data->rdh.rcBound.top = 0;
region_data->rdh.rcBound.right = 640;
region_data->rdh.rcBound.bottom = 400;

hence your clipper is now set to 0,0 - 640,400.


Edited by - Steven on July 23, 2000 8:24:13 AM
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
Why would he go to all that trouble and not initialize the bounding box to be the correct sizes? Do I ever need to change this in my own programs (the bounding box value)?

Thanks for your help Steven! I''m almost able to understand it, I just need another push... thanks, again.

There are three types of people in the world; those who can count, and those who can't.
3D Math- The type of mathematics that'll put hair on your chest!
First of all - I was able to help someone with something I know nothing about - cool.

I'm not 100% sure about that reason, but it might have something to do with not overdrawing graphics for overlay screens, i.e. the information bar at the bottom of Diablo.

As i said I'm not sure about the in and outs of the clipper but that is the only reason I can think of at the moment.

Check here for my code (it's under the Iso Engine project)

www.stevesprogpage.f2s.com

Edited by - Steven on July 23, 2000 3:05:46 PM
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site

This topic is closed to new replies.

Advertisement