Author Topic: [Ndless C] nRayC, a raycasting library for TI-Nspire  (Read 33754 times)

0 Members and 1 Guest are viewing this topic.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
[Ndless C] nRayC, a raycasting library for TI-Nspire
« on: June 12, 2013, 02:58:18 pm »
Hallaw guys,

This is something I wanted to do since ... a year or two :P but I never got it to understand and apply correctly the technique of raycasting.

BUT ! Now it's done :D

So I wrote this library which I named nRayC, because it's an Nspire lib about RAYcasting to be used in C ;D

Although this library is mainly focused on raycasting, it's not its only use : I also included a bunch of functions, like pixel, line and even triangle (why not) drawing, tile detection, bitmaps loading and stuffs.

Currently, the library features raycasting rendered by a unique function :

void nRC_rayCasting(int *map, Vector player, ScreenPoint mapDimensions, Vector dir, Vector planeVec, uint16_t *textures, char *buffer)

It also provides two structures as you can see, ScreenPoint and Vector. I don't release anything for now because I don't think it's ready to be released, but I attach a screenshot of what it can do :)

I'm working actively on it, so expect progress every 2 days ;D

Share comments :)

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #1 on: June 12, 2013, 03:03:53 pm »
That looks very nice!
Does it run fast even with textures?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #2 on: June 12, 2013, 03:29:46 pm »
Indeed that looks awesome. :thumbsup:
And I guess it remains fast with textures, see nDoom which is pretty fast. :)

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #3 on: June 12, 2013, 04:40:25 pm »
Thanks :)

Yeah it's really fast - even too much, I had to set the movement speed to 0.5 and the rotation speed to 6° to be able to move and see what's going on at the same time :P

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #4 on: June 12, 2013, 05:04:06 pm »
Nice, I'm looking forward to the release :)
Ndless.me with the finest TI-Nspire programs

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #5 on: June 12, 2013, 05:09:27 pm »
Awesome! Is this based on Permadi or the lodev info source?

Either way it looks really good, and to hear it runs fast is great :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #6 on: June 13, 2013, 01:16:55 am »
Looks interesting, indeed :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #7 on: June 13, 2013, 03:21:33 am »
Update :P

I finished writing a working R5G6B5(r,g,b) macro, which automatically converts either to R5G6B5 for CX calcs, or a corresponding greyscale for non-CX calcs :) (among other things :P)

I felt like I could post a small demo ;) you need both test.tns and textures.bmp.tns. Since I didn't take care of paths, textures.bmp.tns needs to be in "/documents/ndless/" for the program to work.

I could test it with my Nspire CAS, but I couldn't test with a CX, so if CX users could test it and tell me how it runs, it'd be cool :)

Also @tr1p1ea : it's based on Lode's technique.
« Last Edit: June 13, 2013, 03:22:15 am by Matrefeytontias »

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #8 on: June 13, 2013, 03:51:32 am »
Wow, that's looking cool! And I hope that it has a good speed with textures so that we can get over 9000 fps :P

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline persalteas

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 231
  • Rating: +44/-4
  • z80 poweeer
    • View Profile
    • Tout-82
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #9 on: June 13, 2013, 04:33:52 am »
tested and approved ;)


Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #10 on: June 13, 2013, 05:47:11 am »
Awesome. Though the texture scaling code in the lode example code can really be optimised a lot if you wanted to dive into it deeper.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


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: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #11 on: June 14, 2013, 12:22:50 am »
When I try to run test, nothing happens at all? After running it I can still select through the documents menu like if I didn't even press Enter. I sent both files fine.

Nspire CX non CAS btw

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #12 on: June 14, 2013, 02:19:58 am »
Did you put textures.bmp.tns in “/documents/ndless/“ ?

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #13 on: June 14, 2013, 08:18:56 am »
Bump,

Ready to play the first mini-game ever programmed with nRayC ? :P

I programmed a small maze as a proof of concept ; it runs fast enough, has 5 64*64 textures including one edited each frame (the exit is a block of moving plasmaaaaa  :crazy:) and 4 loaded from an external bitmap, and collision detection to detect the exit :)

To play, same than before : put test.tns wherever you want and textures.bmp.tns in "/documents/ndless/".

And the source is ... 105 lines, including a 24-lines map declaration :thumbsup:

I also release both the source of the example and the engine :D

For now, the engine is nRayC.c and nRayC.h, but later I'll write a doc and compile it in a static lib. You can still use test.c and the functions' prototypes as a small doc ;)

Also beware : the program is much, MUCH slower on an emulator than on-calc. At least on my PC :P
« Last Edit: June 14, 2013, 08:20:00 am by Matrefeytontias »

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« Reply #14 on: June 14, 2013, 04:32:07 pm »
Cool :)
But why don't you use a relative path so we could put the textures.bmp.tns in the same directory as the game?

Also beware : the program is much, MUCH slower on an emulator than on-calc. At least on my PC :P
That's strange, all programs I've seen so far were a bit faster on an emulator than in reality. Also, it's quite fast in nspire_emu on my PC. Faster would be too fast :P