Bennu Game Development

English Forums => General => Mensaje iniciado por: MisterN en Agosto 02, 2011, 03:32:59 am

Título: Raycasting without .dll's
Publicado por: MisterN en Agosto 02, 2011, 03:32:59 am
Exactly what I mean lol. I knew how to raycast back in game maker 4 and some other coding thing (i forget, i think games factory?) I was wondering if it would be possible to do a raycasting of some kind in div/fenix/bennu.
Título: Re: Raycasting without .dll's
Publicado por: MisterN en Agosto 03, 2011, 04:34:03 pm
bump
Título: Re: Raycasting without .dll's
Publicado por: josebita en Agosto 03, 2011, 04:53:11 pm
What is raycasting?
Título: Re: Raycasting without .dll's
Publicado por: gecko en Agosto 03, 2011, 04:58:22 pm
I thought that raycasting was a technique / effect used by 3D render engines to reflect more realistic lights and shadows into objects...

And I have no idea how to do that.
Título: Re: Raycasting without .dll's
Publicado por: handsource-dyko en Agosto 03, 2011, 05:07:45 pm
Raycasting is the opposite of raytracing. Raytracing is used in professional 3d modelling software, but it is way too slow for use in games wich require "real time" rendering. Raycasting is simpler, faster, but limited in comparision with ray tracing. If you really want realistic images such as required by architectural renderings, you'll have to use raytracing and wait several hours for the result. But in games you need something that can handle 50+ frames/second, so this can be achieved with raycasting.
Título: Re: Raycasting without .dll's
Publicado por: MisterN en Agosto 03, 2011, 08:12:03 pm
I was wondering if there was some king of ray casting lol
Título: Re: Raycasting without .dll's
Publicado por: BlackCurtain en Agosto 03, 2011, 10:33:31 pm
"Raycasting" is also a term used for 3d collisions to determine if a collision has been made in the direction of a "ray".
Título: Re: Raycasting without .dll's
Publicado por: gecko en Agosto 03, 2011, 10:46:00 pm
so... what kind of Raycasting do you want, DoctorN? :P
Título: Re: Raycasting without .dll's
Publicado por: MisterN en Agosto 03, 2011, 11:02:25 pm
a Wolfenstein 3D tutorial added to the wiki :3
Título: Re: Raycasting without .dll's
Publicado por: josebita en Agosto 03, 2011, 11:24:32 pm
No idea, really :)
Título: Re: Raycasting without .dll's
Publicado por: l1nk3rn3l en Agosto 04, 2011, 01:02:39 am

adapt this code to bennu
http://www.shdon.com/dos/gfx/techniques

http://lodev.org/cgtutor/raycasting.html
http://lodev.org/cgtutor/raycasting2.html
http://lodev.org/cgtutor/raycasting3.html

http://www.permadi.com/tutorial/raycast/index.html

Título: Re: Raycasting without .dll's
Publicado por: Windgate en Agosto 05, 2011, 04:09:17 am
Wait... You mean manage raycast in 2D or 3D?

Raycast in 2D is easy if you make a process with a graph that it is a line with 1px of width, it is really easy if its control point is the beggining of the line.

In Bennu 3D there is a premade function for raycast.
Título: Re: Raycasting without .dll's
Publicado por: MisterN en Agosto 05, 2011, 05:21:42 am
http://www.youtube.com/watch?v=C00n4rDUMNo (http://www.youtube.com/watch?v=C00n4rDUMNo)
like that, the game is actually fully 2d but its made to look 3d lol
Título: Re: Raycasting without .dll's
Publicado por: popcade en Agosto 14, 2011, 07:33:03 pm
I think you mean a technique called Mode7?
Título: Re: Raycasting without .dll's
Publicado por: MisterN en Agosto 15, 2011, 02:09:13 am
no... mode7 wasnt even invented by time wolfenstein came out in 1992 most likely
Título: Re: Raycasting without .dll's
Publicado por: BlackCurtain en Agosto 15, 2011, 11:53:24 am
no... mode7 wasnt even invented by time wolfenstein came out in 1992 most likely
Mode7 is a Super Nintendo invention so I believe it was.
Título: Re: Raycasting without .dll's
Publicado por: MisterN en Agosto 15, 2011, 12:05:24 pm
And as I recall wolfenstein 3d nor doom on the snes used mode 7 at all (doom used the superfx chip, wolfenstein did not). But this keeps going off topic. I am pretty sure raycasting can be done for it was created without plugins, therefore someone must know how to have a raycasting code. If you cannot process what raycasting is. Raycasting is fake 3D believe it or not. The level is entirely 2D. And some code makes it so that each block (wall) represents a cube with textures. I am not entirely sure how its done, I just know it is.
Título: Re: Raycasting without .dll's
Publicado por: BlackCurtain en Agosto 15, 2011, 12:13:22 pm
I believe it's called "sprite scaling" when you scale the sprites in a certain way to give them a 3d perspective. Galaxy Force 2 used this method, it looked fully 3d but was actually 2d.
Título: Re: Raycasting without .dll's
Publicado por: Fuseki en Noviembre 14, 2011, 09:17:07 am
You could probably use a combination of mode7 and size scaling and angling of sprites to do raycasting. Someone did a Wolfenstein port for DIV1 using this method, back when it was popular, but unfortunately, the code and game has been lost to the sands of time. The basic process is to draw a map in 2D and have "rays" shoot out from your player object. Anything that falls in front of that object, depending on the distance and angle within the rays, would be drawn in a specific size. If I remember the Game Maker raycasting engine correctly, solid sprites that were already "textured" were used and drawn in this manner.


Come to think of it, I've got the old DIV1 cart racing game source code if that would be helpful, although it doesn't use raycasting, but does use size scaling depending on distance. I have all of the example games that came with that package (40mb download) and just uploaded them to my DC Fenix page at http://atari.vg-network.com (http://atari.vg-network.com). There's also the source code and files for Nazca Dreams, which used a lot of mode7 tricks, on the page as well...
Título: Re: Raycasting without .dll's
Publicado por: MisterN en Enero 18, 2012, 11:49:29 pm
site doesnt work anymore
Título: Re: Raycasting without .dll's
Publicado por: Fuseki en Diciembre 09, 2012, 11:30:28 pm
site doesnt work anymore


You're right. It's back up now. I moved a redirect index to the wrong directory by mistake, months ago...
Título: Re:Raycasting without .dll's
Publicado por: SplinterGU en Diciembre 10, 2012, 12:12:36 am
m7 isn't for create wolfenstein clones...

I was thinking lot of time about m7 and wall and other objetcts, but it isn't mode7... then I forget all idea of add this features to mode7...

http://en.wikipedia.org/wiki/Mode_7

for 3d, we need other thing.
Título: Re:Raycasting without .dll's
Publicado por: handsource-dyko en Diciembre 10, 2012, 07:48:42 am
M7 is for super mario kart style games isn't it? A lot of SNES games made creative use of it, like super probotector (a.k.a. contra 3) and turtles in time's neon night riders stage.
Título: Re:Raycasting without .dll's
Publicado por: SplinterGU en Diciembre 10, 2012, 02:07:20 pm
yes
Título: Re:Raycasting without .dll's
Publicado por: theosk en Diciembre 24, 2012, 09:15:36 pm
Yeah, it can be done.

I was toying some time ago and made this:
http://www.youtube.com/watch?v=TGRvZsEVHzA (https://www.youtube.com/watch?v=TGRvZsEVHzA)

My implementation is quite lame, but there's a reason for that.

This was made in fenix forever ago. I followed lodev's tutorial and adapted it to what fenix could do with a reasonable frame rate (about 60fps at 640x400). Walls render fast enough, but I couldn't make the floor render as I wanted. Since drawing functions are slow as hell and accessing the image buffer didn't make a difference, what I did was to create one process per vertical line (that's 640 in the example). Then, every texture was split in various 1xn textures (having 64x64px textures, that's 64 1x64px maps per texture). Then every process has a size depending on the distance to the camera based on the line cast.

I got bored before I implemented the sprites, but using regions and fenix/bennu's size variable should make it easy.

Sorry for my horrible explanation, lodev's tutorial explains it all and does it great.
Título: Re:Raycasting without .dll's
Publicado por: SplinterGU en Diciembre 24, 2012, 09:32:18 pm
nice!
Título: Re:Raycasting without .dll's
Publicado por: l1nk3rn3l en Diciembre 27, 2012, 03:08:14 pm
 :o AMAZING


please share!!! 


thx
Título: Re:Raycasting without .dll's
Publicado por: handsource-dyko en Diciembre 27, 2012, 04:11:30 pm
pretty nice. reminds me of wolfenstein 3d days.
Título: Re:Raycasting without .dll's
Publicado por: theosk en Diciembre 30, 2012, 11:49:38 pm
Hi, I attached my code to this post.

There's a version without textures too, which boosts the FPS counter to infinity. I'm sorry for this horrible piece of code, It was an almost direct conversion of the tutorials and I was learning about raycasting on the go. I lost interest once I got it working so I don't think I'll keep working on it. If you find this useful at all, please feel free to do whatever you wish with this :)
Título: Re:Raycasting without .dll's
Publicado por: SplinterGU en Diciembre 30, 2012, 11:53:46 pm
thanks!
Título: Re:Raycasting without .dll's
Publicado por: theosk en Diciembre 31, 2012, 12:02:15 am
I don't know if this issue was addressed in bennu:
There are some lines like this in my code:
Código: [Seleccionar]
if(rayDirX==0.0)rayDirX=0.00000000001;end
that's because floating numbers should allow division by zero in c++ (there's an IEEE code for infinite), but fenix segfaulted anyway, so I had to do that in order to avoid divisions by zero. Sorry for the massive offtopic, but I didn't feel like a new thread was worth for this alone :/
Título: Re:Raycasting without .dll's
Publicado por: SplinterGU en Diciembre 31, 2012, 12:03:44 am
float divisions by zero in bennugd give you infinite....
Título: Re:Raycasting without .dll's
Publicado por: theosk en Diciembre 31, 2012, 12:09:09 am
Woah, that was fast. Thanks, then the code should run without all these lines now :)
Título: Re:Raycasting without .dll's
Publicado por: SplinterGU en Diciembre 31, 2012, 12:58:03 am
Woah, that was fast. Thanks, then the code should run without all these lines now :)

well, without these lines, in 320x200, without scale2x and replace all fabs by abs... it give me to up 110-180fps... depend what need render on screen... oh, I remove the draws functions too.
Título: Re:Raycasting without .dll's
Publicado por: theosk en Diciembre 31, 2012, 01:27:29 am
Well, this code was written in fenix some time ago so I had to do REALLY weird things to avoid some old bugs. (abs wasn't even working properly with floats back then... tough times). The drawing functions were meant for higher resolutions, where small sized tile slices became less than 1px wide and wouldn't draw and far away walls became invisible, so fog-like brown lines would fill these gaps. That's why there are various sized tile slices, not the right thing to do, but the way it would work fast enough back then.

Over 100 fps is a huge boost, for sure! I should update myself regarding the current divlike scene, I'm glad to see things are moving forward over here.
Título: Re:Raycasting without .dll's
Publicado por: l1nk3rn3l en Enero 07, 2013, 12:52:35 am
THX...
Título: Re:Raycasting without .dll's
Publicado por: MisterN en Enero 08, 2013, 01:10:28 am
so can you post the updated code?
Título: Re:Raycasting without .dll's
Publicado por: Imerion en Febrero 21, 2013, 04:10:54 pm
Yep, would be nice to see the updated source! :)