* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: C Programmers, Help With Raycasting Algorithm Needed  (Read 592 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • Full User
  • Join Date: Sep 2015
  • Location: New York, NY
  • Posts: 47
  • Post Rating Ratio: +2/-0
    • acagliano
    • Anthony Cagliano
    • @@ACagliano
    • View Profile
    • ClrHome Productions
  • Gender: Male
C Programmers, Help With Raycasting Algorithm Needed
« on: March 17, 2017, 10:02:59 pm »
Cross-post

So I'm looking for someone decently skilled with C programming to help me learn the ropes of designing a textured raycaster. I have a textured raycaster in C++ that I've been trying to port, but my skills aren't sufficient enough to percieve differences between C and C++ and implement proper substitution, so I am asking for help.

ps: the C++ snippet im looking at is http://lodev.org/cgtutor/files/raycaster_textured.cpp


  • Calculators owned: TI-84+ SE

Offline Ranman

  • Full User
  • Safe-haven access
  • Join Date: Feb 2017
  • Location:
  • Posts: 49
  • Post Rating Ratio: +2/-0
    • View Profile
  • Gender: Male
Change
   #include <cmath>
 to
   #include <math.h>
_____________________________________________

I did not see anywhere in your single C++ file that makes use of the following headers.
   #include <string>
   #include <iostream>
 so comment these lines out and see if it still compiles.

I presume though that there are more files in your project that will make use of them. So your going to have some work here.
  For instance: cout << "hello world" will need to be change to printf("hello world")
_____________________________________________

C does not make use of namespaces... so get rid of them in all of your files
   using namespace QuickCG;
_____________________________________________

Your file is also using the Vector container from the Standard Template Library (STL)
The Vector container is basically an array with a dynamic size.

 You may or may not have quite a bit of work to do here.
   std::vector<Uint32> texture[8];
 will need to be changed to something like this:
   Uint32 texture[8][max_value];
 everything that reference or acts upon 'texture' will need to be modified to act like a static sized C array.
 you are going to need to know the 'max_value' before hand.
 
« Last Edit: March 18, 2017, 03:50:35 am by Ranman »
  • Calculators owned: TI-89 HW1, TI-92+, Casio 9860G Slim, Casio fx6300, Tandy PC7
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator.

Offline ACagliano

  • Full User
  • Join Date: Sep 2015
  • Location: New York, NY
  • Posts: 47
  • Post Rating Ratio: +2/-0
    • acagliano
    • Anthony Cagliano
    • @@ACagliano
    • View Profile
    • ClrHome Productions
  • Gender: Male
Thanks! I've started working on making modifications. Now, for this raycaster, on a 320x240 screen, what sprite sizes would you guys recommend? This algo uses 64x64, but also for a larger screen size
  • Calculators owned: TI-84+ SE

Offline Ranman

  • Full User
  • Safe-haven access
  • Join Date: Feb 2017
  • Location:
  • Posts: 49
  • Post Rating Ratio: +2/-0
    • View Profile
  • Gender: Male
Thanks! I've started working on making modifications. Now, for this raycaster, on a 320x240 screen, what sprite sizes would you guys recommend? This algo uses 64x64, but also for a larger screen size
I've never attempted a first-person shooter. Your 320x240 lcd game will possibly need a combination of sprite sizes: 16x16 for very far away, 32x32 for far away, 64x64 medium distance, maybe larger. Some of the games I've played, when the enemies are right in your face, they take up the entire screen. You'll probably need to look into some scaling routines.
  • Calculators owned: TI-89 HW1, TI-92+, Casio 9860G Slim, Casio fx6300, Tandy PC7
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator.

Offline kotu

  • Walrus Extender Utils
  • Super User
  • Join Date: Aug 2016
  • Location: UK
  • Posts: 914
  • Post Rating Ratio: +7/-7
    • profile.php?id=100010378444176
    • dj_kotu
    • @UCAy2ZF4hbc08iStnTn6jgxQ
    • rowanmedhurst
    • @djkotu
    • @romanov-psyco
    • View Profile
    • futurerave.uk
  • Gender: Male
Thanks! I've started working on making modifications. Now, for this raycaster, on a 320x240 screen, what sprite sizes would you guys recommend? This algo uses 64x64, but also for a larger screen size

Are you making a game for the TI-84+CE ??

You will have nowhere near enough power for a raycaster I am afraid, if that is what you are doing.

Even if you just make a simple polygon renderer I doubt you will have enough FPS for a First person shooter D: soz. And it would have to be in assembler.

*edit*
you might want to look at gLib
https://codewalr.us/index.php?topic=199.msg53456#msg53456
« Last Edit: March 22, 2017, 02:03:58 am by kotu »
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony PS3
we not doing it.
UPDATE we are not doing it.
proud member of the MATEOCONLECHUGA fansite.

Offline DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18212
  • Post Rating Ratio: +91/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Kotu the TI-83+ can run Gemini perfectly fine at 6 MHz. The CE has 48 MHz ez80 and screen resolution is not such a sserious issue with the 8 bits mode. The SNES also runs Wolfeinstein 3D somewhat fine
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

Offline p4nix

  • Full User
  • Join Date: Jun 2015
  • Location: Germany
  • Posts: 414
  • Post Rating Ratio: +6/-1
  • Don't catch the ball.
    • p4nix
    • View Profile
  • Gender: Male
You will have nowhere near enough power for a raycaster I am afraid, if that is what you are doing.

Even if you just make a simple polygon renderer I doubt you will have enough FPS for a First person shooter D: soz. And it would have to be in assembler.
You know that ray casting != ray tracing? Also, if you have trouble with fps just take half the slices, but even in C I don't think making a fast raytracer is that big of a problem if you got efficient algorithms - same goes for asm ofc.
  • Calculators owned: fx9860GII (SH4)

Offline TheMachine02

  • Full User
  • Join Date: Dec 2014
  • Location:
  • Posts: 335
  • Post Rating Ratio: +14/-0
    • View Profile
Raycasting should definitly be faster than polygon engine, if done right. Just totally different use  :P

Offline tr1p1ea

  • Full User
  • Join Date: Feb 2015
  • Location:
  • Posts: 236
  • Post Rating Ratio: +4/-1
    • View Profile
Yes I imagine that a raycaster would be quite doable on the CE, even in C (with asm libs for drawing etc however).

Offline DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18212
  • Post Rating Ratio: +91/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Could the Gemini 3D engine just be ported over or would it require heavy modifications due to the Z80->ez80 transition? Someone re-used it for a full screen grayscale FPS once so I'm sure the source code is still available.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

Offline _iPhoenix_

  • Full User
  • Join Date: Mar 2017
  • Location: Encoded in Binary.
  • Posts: 248
  • Post Rating Ratio: +3/-1
  • █████ ▼ ♪ Best music ♫
    • @dj_iPhoenix
    • @UCytgMNPxAMDsxjimvxHf01w
    • @the-legend-of-iphoenix
    • View Profile
  • Gender: Male
Thanks! I've started working on making modifications. Now, for this raycaster, on a 320x240 screen, what sprite sizes would you guys recommend? This algo uses 64x64, but also for a larger screen size

Are you making a game for the TI-84+CE ??

You will have nowhere near enough power for a raycaster I am afraid, if that is what you are doing.

Even if you just make a simple polygon renderer I doubt you will have enough FPS for a First person shooter D: soz. And it would have to be in assembler.

*edit*
you might want to look at gLib
https://codewalr.us/index.php?topic=199.msg53456#msg53456

If I can make one in pure TI-basic, he can make one in C.
Also, I ran it at about 2000 times faster (cemu plus timelapse), and it was playable. This is in an unpublished test version that has monsters (with exactly zero sprites, the code treats it like a wall), inventory panels, and guns. It was actually playable.

Considering ASM and C are much faster then basic, I'd say it's possible.
« Last Edit: March 24, 2017, 11:20:37 pm by _iPhoenix_ »
  • Calculators owned: A sentient TI-84+ CE, TI-85
  • Consoles, mobile devices and vintage computers owned: TI-99/4a home computer
Help me with a project by voting here! Thanks!

"walruses are better than tuxedo chickens, all hail the great :walrii:" ~ me

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3155
  • Post Rating Ratio: +31/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • View Profile
    • quantuminfinity
  • Gender: Male
I made a nice raycaster a while back: https://github.com/QuantumInfinity/AntiCaster It needs some updating though, since i could optimize out a square root.
Also i should change to a better build system than eclipse project builder... IF i ever get around to it. Anyway maybe you could learn something from the source, though its probably quite complicated and
not very well commented (read: not at all).
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18212
  • Post Rating Ratio: +91/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
@Snektron was this your Euclidian raycaster thing? That was kinda cool.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3155
  • Post Rating Ratio: +31/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • View Profile
    • quantuminfinity
  • Gender: Male
Non euclidean, but yes
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games