#944 - regularkid - Sun Jan 12, 2003 6:17 pm
Hey! I'm learing raycasting right now and have a few questions. I understand the basics for a room with no doors or windows or bad guys, just the plain old walls, floors and ceilings. Here are my questions:
1. I assume that bad guys are just the GBA sprites scaled based on the distance away from the player. However, I'm confused onto how they get clipped? Like when you are looking around a corner and can only see half of the enemy? How are the gba sprites clipped?
2. How are doors done? I have read about techniques where you cast two rays and draw the one farther away last, and this makes sense to me for windows, but what about doors? I'm confused because the doors are moving objects and windows aren't. Are they sprites, or wall geometry?
3. What about two level maps? All the raycasting techniques I've read only deal with one story buildings. Is it possible to do raycasting on two story buildings?
Thanks!!
_________________
- RegularKid
#947 - subbie - Sun Jan 12, 2003 6:45 pm
"1. I assume that bad guys are just the GBA sprites scaled based on the distance away from the player. However, I'm confused onto how they get clipped? Like when you are looking around a corner and can only see half of the enemy? How are the gba sprites clipped? "
I believe you have to draw them directly into your scene insted of using gba sprite hardware since there is no way to clip them unless you edit the sprite in vram and manualy clip it.
"3. What about two level maps? All the raycasting techniques I've read only deal with one story buildings. Is it possible to do raycasting on two story buildings?"
I believe with raycasting it is not posible to do stories on a map due to the limitations of mapping. It might be posible to fake it but it is probably not posible to do it where it would be posible to see parts of two floors at the same time. You could posibly just have the player go into a seeled off elevator and then swap maps for the 2nd floor.
#950 - regularkid - Sun Jan 12, 2003 6:55 pm
Thanks. Good idea with the elevator!
_________________
- RegularKid
#959 - Splam - Sun Jan 12, 2003 7:53 pm
For the sprite clipping then most games seem to use the "plot on screen" method, but you can do it with sprites. u simply make them out of vertical 8x?? strips, then the only clipping that needs doing is on 1 of those strips ( you simply don't display the others that would be behind the wall). Saves plotting into the background each time then (redrawing constantly) you only have to redraw the sprite "strips" which would be clipped inside the 8x??.
eg a sprite that looks like this...
ABC
ABC
ABC
ABC
If the player was 1/2 way behind a wall you turn off the AAAA sprite and clip the data within the BBBB sprite.
If there were only a couple of players on screen you could use windows to disable the sprite display in the "behind wall" area.
#981 - regularkid - Sun Jan 12, 2003 10:54 pm
Yeah, I see what you are saying about the sprite strips, however without using the gba's hardware sprites, there really isn't a fast way of doing transparent sprites (or strips of sprites). Sucks.
_________________
- RegularKid
#986 - Splam - Mon Jan 13, 2003 12:34 am
But surely you wanted to use the hardware sprites?
1. I assume that bad guys are just the GBA sprites scaled based on the distance away from the player. However, I'm confused onto how they get clipped? Like when you are looking around a corner and can only see half of the enemy? How are the gba sprites clipped?
?
#987 - regularkid - Mon Jan 13, 2003 1:08 am
Doh! Now I understand, you meant have a different sprite for each vertical strip in the bad guys. Ok, that makes sense now because transparency and scaling will work. Ok, thanks!
_________________
- RegularKid
#990 - Splam - Mon Jan 13, 2003 1:36 am
n/p I can be a bit obtuse with my messages sometimes because I'm coding about 5 different things on 3 different platforms at the moment so my brain goes into "I know how to do this" mode and loads of waffle comes out.
#994 - Splam - Mon Jan 13, 2003 2:29 am
One problem you will encounter using the sprites method is if they are scaled up too much you're clipping will still only be on the original pixles and so part of the scaled pixel (only 1 pixel will be a problem) will still be visible when it should really be clipped. Might be the time to use a window to mask it then (which would also save having to clip ANY sprites).
#1052 - regularkid - Tue Jan 14, 2003 5:24 am
Window? Could you explain what a window is and does? I think I saw something on this in the regdispcnt register, but it didn't say what it was. Thanks.
_________________
- RegularKid
#1118 - pulstar_3 - Tue Jan 14, 2003 8:11 pm
Hi,
I window is like a seperate screen. SO you can split the screen into 3 sub-sections and have different things displayed in eaxh window e.g. Window 0 has BG0 and 1, WIN1 has Sprites and everything else is outside of the window. Each window wil have the same mode as the main screen, so if the main mode is 1, all the windows are mode 1 as well.
Pulstar.
#1123 - regularkid - Tue Jan 14, 2003 8:52 pm
Is everything that is outside of a window clipped? Like, if I say I want window 0 to be just for sprites, and I draw a sprite half inside of the window and half outside of the window, will it only draw the half that is inside the window? Is that what windows are for? Thanks
_________________
- RegularKid
#1125 - Splam - Tue Jan 14, 2003 8:56 pm
There are 2 windows available WIN0 and WIN1.
For each of these you can set a rectangular area of the screen you wish the window functions to act upon. This rectangle can of course be changed using hdma or hblank interrupts so theoreticaly they're not rectangles :) ie you could have a triangular window.
For each window there are 2 registers (inside of window and outside of window control). These allow you to "switch off or on" any of the backgrounds or OBJ's and also enable/disable colour effects (blending etc).
#1126 - Splam - Tue Jan 14, 2003 8:57 pm
regularkid wrote: |
Is everything that is outside of a window clipped? Like, if I say I want window 0 to be just for sprites, and I draw a sprite half inside of the window and half outside of the window, will it only draw the half that is inside the window? Is that what windows are for? Thanks |
Exactly :)
#1127 - regularkid - Tue Jan 14, 2003 9:00 pm
Sweet! That may just work. Thanks for all your help!
_________________
- RegularKid
#1315 - Ped - Thu Jan 16, 2003 6:13 pm
Well, if you do understand raycasting basics, than why are you asking about doors and windows? What is unclear?
You have simple 2D tile map, where you raycast, don't you? If tile is marked as "door", you may do raycast with additional lines (for not full_tile_thick_doors) to get cross position and draw gfx accordingly the position and the t (0..max) parameter of door_opened.
I'm still assuming you are trying to do wolf3d like classic raycasting engine, where the whole column is single hit, i.e. no windows possible.
If you want windows, you may use Doom renderer, where you keep min/max y "already filled" coordinate for each column. Than window is upper wall with some max_y, and lower wall with some min_y .. you continue to search for walls for column as long as min_y < max_y (when the are equal, you have filled the whole column).
This allows you to do pretty complex enviroment as long as any wall is either attached to ceiling or/and to the floor. (so you can't do a bridge, where the body of bridge is neither connected to ceiling or to floor) ... study DOOM by playing it to see, what's the limitation. :)
But final notice: WHY RAYCASTING ??? ... stop with that shit immediately, especially if you are doing wolf-like raycast.
Using DOOM like BSP trees with geometry transformations is faster, and makes the ceiling/floor texturing simple to calculate (to be honest, I (and my friend sayza) did some raycast engine back in 1995 or so at PC and I was unable to get ceiling/floor texturing right for several days, it was always deformed at clipped edges, etc.. than we throw out whole engine a started a bsp-doom like one ... faster, more complex scenes, and windows possible ...
The raycasting could beat polygons only in special cases like some curved shapes, etc... but than you must raycast through more smooth map and you don't have that CPU power at GBA to raycast through 256x256 field or so.
Only good use of raycast for GBA is voxel landscape, where it allows you to have big size tiles for fast raycast but you can interpolate the values for each pixel to get somewhat "curved" envinroment
_________________
-- Ped - ped at 7gods dot sk
there used to be times, when sex was safe and flying was dangerous...
#1318 - regularkid - Thu Jan 16, 2003 6:25 pm
Ped,
Thanks for the reply. I honestly am just learning raycasting and so what I meant by understanding the basics was that I new how each ray cast on the 2d grid finds the walls and draws them. However, I was still kind of confused about how the animating doors and enemies work. I will definetly look into the BSP thing you talked about. I will search for a good tutorial on the subject, but if you know of a good one off the top of your head, please post a link to it here. Thanks!
_________________
- RegularKid