Page 10 of 14

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Sun Jan 29, 2012 9:51 pm
by jfroco
Hi Jasoco,

Did you implemented doors? I'm not fan of doors as I said before, but I've been reading a couple of articles about and it doesn't seem to be trivial. Please let us know!!!!

I'm kind of upset of not being able to do floor casting without using dynamic quads... don't get me wrong, I think your implementation is fantastic and I too should use whatever technology is available , the problem for me is that it is not "portable"... but anyway.. I was playing with floor casting until I realized that I coded a simple 3d to 2d projection code, and then I remembered an old game that is fantastic "The Colony" (1987-Macintosh). So instead of trying to make the floorcasting work, I dropped all my raycasting code and made this:



I can't use textures (without using canvas+dynamic quads ;) ), but it was fun to implement :)

Best regards

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Sun Jan 29, 2012 11:59 pm
by Jasoco
jfroco wrote:Hi Jasoco,

Did you implemented doors? I'm not fan of doors as I said before, but I've been reading a couple of articles about and it doesn't seem to be trivial. Please let us know!!!!

I'm kind of upset of not being able to do floor casting without using dynamic quads... don't get me wrong, I think your implementation is fantastic and I too should use whatever technology is available , the problem for me is that it is not "portable"... but anyway.. I was playing with floor casting until I realized that I coded a simple 3d to 2d projection code, and then I remembered an old game that is fantastic "The Colony" (1987-Macintosh). So instead of trying to make the floorcasting work, I dropped all my raycasting code and made this:

[youtube]kyeZ4nMkNtU[youtube]

I can't use textures (without using canvas+dynamic quads ;) ), but it was fun to implement :)

Best regards
Daaaaaaaamn. I loved watching videos of The Colony on YouTune a while ago. It was actually what I was going to try and make at first if I was unable to do textures. You gotta share that code.

I'm still working on doors. I have a wireframe right now showing where the door would be, but I have to figure out how to draw it with images. I'm thinking it should be as easy as:
1) Take the side of the door you are looking at. i.e. Right or Left/Up or Down
2) Calculate the left and right most pixels on the screen where the door lies
3) Cast rays from the left to right pixels using the inset of the door as an offset, add each slice to the drawing pool as long as the slice is not covered up by the slice already existing at that point. (i.e. don't draw it if it's inside the wall. If the door is closed and not transparent, replace the slice that's already there, otherwise add a new one to draw in front.)

I just need to figure out the math to do the casting. I'll try taking the existing raycaster and make a secondary doorcaster function.

Experimenting will be fun. Right now I have a wireframe and working open/close functionality.

I would love to not have to rely on canvases and wish they weren't so unportable, but there's really no other way to do this with speed without Löve having the ability to Distort images and quads like you can in PhotoShop. It's really the only thing keeping us from being able to make realistic 3D. As I have shown before, I can totally calculate 3D, but if I could also distort images to any shape by moving the four corners independently you wouldn't have to use solid polygons and I wouldn't need to use raycasting to draw the 3D view as an array of 1 pixel strips. It would probably be faster because, say I have a view and you can see 10 wall tiles from your perspective, it would only require 10 draw calls and transform calls instead of 320 or 640 of them across the screen. For the floor I would simply need to add visible floor tiles to a table as my rays are passing through them and then draw only the ones you can see using the same distort feature.
Distort.png
Distort.png (5.62 KiB) Viewed 7343 times
Basically we need access to some more modern image manipulation features. Yeah, I know, I know, "Löve2D", but really, it doesn't have to be 100% 2D if we are provided the right tools. (Although, then I wouldn't be able to do depth shading on the floor or walls at a per pixel basis. Nor could I do proper z-ordering of objects and wall slices unless we had actual texture clipping like normal 3D engines.)

But I'm getting off-topic. A game like DOOM could be totally possible with a little work. The main difference between how Wolfenstein worked and DOOM worked is Wolfenstein's walls are all on a grid. Whereas DOOM's could be anywhere. So in order to do it, DOOM had to create a lookup table of every sector that could be seen from every other sector so the engine wouldn't have to do as many calculations on sectors that aren't even visible. The fun part would be creating the BSP generator.

I do have plans on adding some other features like maybe simple sloped walls and higher floors and lower ceilings if I can figure out the best way to do it. (Which would probably consist of making separate Floor/Ceiling inner and outer canvases for each height level. I'd be afraid I'll reach the limit of most graphic cards this way though.)

This is a WIP and will probably be for a while, but hopefully it's a fun ride. The use of LuaJIT made it much more fun though since it's now faster. I just fear I will be building something too powerful for many computers, even ones with high-end components. So I can't wait to open it up to the public here officially to get peoples testing and help and input.

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Tue Jan 31, 2012 11:27 pm
by jfroco
Hi Jasoco,

It's fun... it seems that we are working most of the time in the same thing.s

I was reading about affine transformationes in order to simulate projection...

I read this post about implementing shear/skew using rotation/scaling: viewtopic.php?f=4&t=2267
And this interesting image from Wikipedia:

Image

And implemented this (using two triangles per floor tile + affine transformations):

Image

It's not 100% accurate but with one-color tiles it looks very similar and with textures doesn't look that bad.

Any news about your doors?

Best regards

Re: Working Raycasting example?

Posted: Wed Feb 01, 2012 12:50 am
by legendman3
Jasoco wrote:You have 0.8.0, right?
Im missing something, where is the 0.8.0 download?

Re: Working Raycasting example?

Posted: Wed Feb 01, 2012 1:06 am
by slime
legendman3 wrote:
Jasoco wrote:You have 0.8.0, right?
Im missing something, where is the 0.8.0 download?
Windows: The latest build here https://love2d.org/builds/ (or a LuaJIT build at http://dl.dropbox.com/u/4214717/LoveJIT-0.8.0-win32.zip )
Mac OS 10.7: http://dl.dropbox.com/u/4214717/love-0.8.0.zip

I haven't been following the conversations very well, but you guys know love.graphics.draw has shear parameters in 0.8.0 right? Unless you're already using that and I'm being dumb.

Re: Working Raycasting example?

Posted: Wed Feb 01, 2012 1:15 am
by legendman3
slime wrote:
legendman3 wrote:
Jasoco wrote:You have 0.8.0, right?
Im missing something, where is the 0.8.0 download?
Windows: The latest build here https://love2d.org/builds/ (or a LuaJIT build at http://dl.dropbox.com/u/4214717/LoveJIT-0.8.0-win32.zip )
Mac OS 10.7: http://dl.dropbox.com/u/4214717/love-0.8.0.zip

I haven't been following the conversations very well, but you guys know love.graphics.draw has shear parameters in 0.8.0 right? Unless you're already using that and I'm being dumb.
Ok one more question, whats luaJIT?

Re: Working Raycasting example?

Posted: Wed Feb 01, 2012 2:32 am
by jfroco
slime wrote:
I haven't been following the conversations very well, but you guys know love.graphics.draw has shear parameters in 0.8.0 right? Unless you're already using that and I'm being dumb.
Hi slime,

Nope, I didn't know.... but sounds great!!! Thank you for the inforamtion. I'm using 0.7.2. When will 0.8.0 be released?

Best regards

Re: Working Raycasting example?

Posted: Wed Feb 01, 2012 7:21 am
by Jasoco
slime wrote:I haven't been following the conversations very well, but you guys know love.graphics.draw has shear parameters in 0.8.0 right? Unless you're already using that and I'm being dumb.
You're going to have to explain and show me some examples because I so want to play with this now.

And no, doors are still escaping me. I need to sit down and think straight to get it right.

Re: Working Raycasting example?

Posted: Wed Feb 01, 2012 9:10 am
by hryx
jfroco, that demo looks awesome. All these demos look awesome. Coolest thing since Jasoco's Star Fox demo.
legendman3 wrote:Ok one more question, whats luaJIT?
LuaJIT an alternative Lua interpreter written from scratch that uses special techniques (Just-in-time compilation, hence "JIT") to make certain tasks perform very quickly.

(You really should search before you ask, though.)

Re: Working Raycasting example?

Posted: Wed Feb 01, 2012 9:46 am
by Jasoco
hryx wrote:jfroco, that demo looks awesome. All these demos look awesome. Coolest thing since Jasoco's Star Fox demo.
One of these days I am going to resurrect that and create an optimized working engine. Complete with retro looking SNES style resolution and graphics. Going to be awesome to the max. One of these days. Should be easier to design when I put all the knowledge I've gained since then to use.

Edit: This topic continued into another thread. When I release the alpha/beta/whatever of the engine for download, I will start a new topic anyway. For now, this..
viewtopic.php?f=4&t=7800&start=10#p48535