Archived

This topic is now archived and is closed to further replies.

Fredric

Newbie Clipping question

Recommended Posts

Fredric    122
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.

Share this post


Link to post
Share on other sites
Fredric    122
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.

Share this post


Link to post
Share on other sites
Fredric    122
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.

Share this post


Link to post
Share on other sites
Julio    116
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

Share this post


Link to post
Share on other sites
Fredric    122
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.

Share this post


Link to post
Share on other sites
Steven    136
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

Share this post


Link to post
Share on other sites
Fredric    122
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.

Share this post


Link to post
Share on other sites
Steven    136
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

Share this post


Link to post
Share on other sites
ByteMe95    122
Well, I dont really know how Andre uses his clipper method nor have I read that book, but from what I can see he is simply setting the values to impossible values (left=64000 and right=-64000). Therefore, values MUST fall in to fill in those areas when there are checks for them.
The reason to set it to 64000 and not 640 is cause it''s safer to set it to 64000. It makes no difference in speed/mem but it makes the check pretty much 100% if u set it that high, that''s probably the only reason.



ByteMe95::~ByteMe95()

Share this post


Link to post
Share on other sites
Fredric    122
Heh, thanks.. I was thinking that, but then I thought, "Nahh, that''s impossible!" Heh, I guess I was right. Thanks though for comfirming- I have a very strong grasp on all of this now.

There are three types of people in the world; those who can count, and those who can't.

Share this post


Link to post
Share on other sites