Author Topic: Nspire Raycaster  (Read 105211 times)

0 Members and 1 Guest are viewing this topic.

Offline AaroneusTheGreat

  • Moderator
  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 287
  • Rating: +26/-1
    • View Profile
Re: Nspire Raycaster
« Reply #180 on: April 07, 2010, 06:44:24 pm »
Maybe the scrolling could be set by the client program, so that each game could scroll the background as they liked. Plus that could allow a program to use the background to make clouds moving in the distance when the player stood still. It would make programming games for the engine much more programmer friendly. 

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Nspire Raycaster
« Reply #181 on: April 07, 2010, 11:18:17 pm »
Does anyone have advice/code/pseudocode on how to do multiple height walls? I could use some guidance on how to optimize the feature (I think I have the math right now, but I haven't started implementing yet because it looks messy).

Offline critor

  • Editor
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2079
  • Rating: +439/-13
    • View Profile
    • TI-Planet
Re: Nspire Raycaster
« Reply #182 on: April 08, 2010, 03:00:41 am »
Does anyone have advice/code/pseudocode on how to do multiple height walls? I could use some guidance on how to optimize the feature (I think I have the math right now, but I haven't started implementing yet because it looks messy).


The casted ray must not stop at the 1st hitten wall. It has to go through it
With the ray, I'm building a list of objects to display.

Each time the ray hits a wall, I'm adding an object to the list.

Each object consists of its coordinates for the line() function and its color or texture tile.
If we are higher than the top of the wall(or if its texture is transparent), a 2nd object for drawing the top of the wall (floor) is added.
If we are lower than the bottom of the wall (or if its texture is transparent), an object for drawing the bottom of the wall (ceiling) is added
If the texture is transparent, a last object for drawing the back of the wall is added.

The ray stops at the end of the world.
If the world is too big, it may be much slower, when looking far away.

Then I'm drawing objects, from the farthest to the nearest.
So nearer objects are drawn over farther objects, which is natural.


You may then make some optimisations:
- stopping the ray when it is too far (but the effect is not "natural" if you don't add some shading-, fog- or water-effect)
- adding an object to the list, only if it is partially visible (not hidden completly by nearest objects)
- stopping the ray if nothing more can be visible (all pixels from the bottom to the top of the screen have been drawn)
« Last Edit: April 08, 2010, 03:01:30 am by critor »
TI-Planet co-admin.

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Nspire Raycaster
« Reply #183 on: April 12, 2010, 09:47:40 pm »
New demo!
Walls now have variable heights. Sadly, the floor-drawing code doesn't work (so when you see the top of a cube, bad things happen). Also, the sprite clipping behaves strangely sometimes (since the old 1D Z-Buffer no longer works).

critor: do you have the formulas/source code for drawing the floor segments? I can't seem to figure it out :(
« Last Edit: April 12, 2010, 10:42:21 pm by bwang »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Nspire Raycaster
« Reply #184 on: April 12, 2010, 11:26:24 pm »
Sorry to hear about the issues you got :(

However, this looks FRIGGIN AWESOME! Do you think you could be able to make the lower walls textures not squished vertically? It would look even better

Regardless, I'm saving this on my PC and trying ASAP!

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Nspire Raycaster
« Reply #185 on: April 12, 2010, 11:28:55 pm »
However, this looks FRIGGIN AWESOME! Do you think you could be able to make the lower walls textures not squished vertically? It would look even better
Yeah, I had the same thought. I'd imagine it could look pretty bad on very tall walls, too.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Nspire Raycaster
« Reply #186 on: April 12, 2010, 11:32:43 pm »
Or you could simply have a tiling texture that only had a few bricks, and stretched it to fit. That way, it would still stretch a little, but not that bad. Or, you could have it simply cut off at the ends

Don't know how feasible this is...I haven't had much experience with this sort of thing! It Looks awesome, though! Will you be able to stand on lower portions eventually?

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Nspire Raycaster
« Reply #187 on: April 13, 2010, 12:57:29 am »
The textures will tile in the final version.
You will certainly be able to stand on lower walls (after all, what use are stairs if you can't climb them?)
A word of warning: this demo is very buggy. Don't expect too much from it.

Offline AaroneusTheGreat

  • Moderator
  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 287
  • Rating: +26/-1
    • View Profile
Re: Nspire Raycaster
« Reply #188 on: April 13, 2010, 01:21:28 am »
Quote
Or, you could have it simply cut off at the ends

Good call, that's what I'd suggest, since you're drawing wall slices as if they were vertical sprite slices of the wall, clipping in the space provided shouldn't be too much of an issue. You won't have to worry about coding a tiling routine for the textures, they would simply clip to the drawing space you calculated.

I'm pretty much blown away by the way. Quite impressive. I can't wait for this to be completed, my mind is already turning with things I want to do with this engine. *diabolical grin*
« Last Edit: April 13, 2010, 01:23:35 am by AaroneusTheGreat »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Nspire Raycaster
« Reply #189 on: April 13, 2010, 01:23:51 am »
I tried it and nice despite the bugs. I noticed you made collision detection closer to walls again, though. I still think it should be made at greater distance (seeing 4 or 5 rows of bricks at once at least), like in FPS'es, it would reduce the risks of getting too close to walls and having major slow downs

Offline Silver Shadow

  • Beta Tester
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +27/-7
    • View Profile
Re: Nspire Raycaster
« Reply #190 on: April 13, 2010, 03:33:03 am »
Yum! That screenie looks delicious! ;D
Former Coder of Tomorrow


Offline critor

  • Editor
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2079
  • Rating: +439/-13
    • View Profile
    • TI-Planet
Re: Nspire Raycaster
« Reply #191 on: April 13, 2010, 05:19:15 am »
Good work, great! :-)

critor: do you have the formulas/source code for drawing the floor segments? I can't seem to figure it out :(

You can get the source of my Java engine, but it may take more time to study it than to build your own algorithm.


When the ray enters a square-wall, if that wall is visible I'm calculating the top and bottom coordinates and drawing the wall.
Those coordinates are kept in the program for being used when the ray exits the square-wall.

When the ray exits the square-wall, I'm calculating those farther top and bottom coordinates, exactly as if I wanted to draw the back of the wall.

If the wall uses a transparent texture, that wall is really drawn.
If the top of the wall is visible, I'm drawing a line between the old and new top-coordinates.
If the bottom of the wall is visible, I'm drawing a line between the old and new bottom-coordinates.

Then of course, by exiting the square-wall, the ray is entering another square-wall.
So I'm looping, drawing the front of the new wall (if visible) again...

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Nspire Raycaster
« Reply #192 on: April 13, 2010, 11:25:17 am »
Ah good, my suggestion wasn't stupid.

So far, the program looks excellent to me. One thing I'm a little confused on:
Mode7 is a floor rendering thing, right? And raycasting is for walls, so combining them gives textured walls, floors and ceilings. Is that right?

How much more power is used by Actual 3D than Raycasting?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Nspire Raycaster
« Reply #193 on: April 13, 2010, 11:35:30 am »
I wonder if for floors he used Mode 7 but it looked very similar. I know this is what the old F-Zero games, as well as Calc84Maniac 83+ F-Zero clone and F-Zero 68K uses for drawing floors.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Nspire Raycaster
« Reply #194 on: April 13, 2010, 11:39:00 am »
Yeah. It was also used for Secret of Mana's Overworld map, I believe, as well as FF6's chocobo riding. It kind of gives the isometric feel, but a little better quality with rotation and all.