You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

C Programmers, Help With Raycasting Algorithm Needed

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/General Help publicado por u/ACagliano 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
Inicia sesión o crea una cuenta para dejar un comentario
u/Ranman March 18, 2017, 03:42:56 AM
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
u/ACagliano March 21, 2017, 01:09:54 PM
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
u/Ranman March 22, 2017, 01:37:37 AM
Quote from: ACagliano on March 21, 2017, 01:09:54 PM
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.
u/kotu March 22, 2017, 01:59:04 AM
Quote from: ACagliano on March 21, 2017, 01:09:54 PM
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
u/Dream of Omnimaga March 22, 2017, 04:47:04 PM
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
u/p4nix March 22, 2017, 04:49:27 PM
Quote from: kotu on March 22, 2017, 01:59:04 AM
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.
u/TheMachine02 March 22, 2017, 04:53:52 PM
Raycasting should definitly be faster than polygon engine, if done right. Just totally different use  :P
u/tr1p1ea March 22, 2017, 08:57:15 PM
Yes I imagine that a raycaster would be quite doable on the CE, even in C (with asm libs for drawing etc however).
u/Dream of Omnimaga March 23, 2017, 05:25:21 AM
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.
u/_iPhoenix_ March 24, 2017, 11:10:23 PM
Quote from: kotu on March 22, 2017, 01:59:04 AM
Quote from: ACagliano on March 21, 2017, 01:09:54 PM
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_
u/Snektron March 25, 2017, 12:28:39 AM
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).
u/Dream of Omnimaga March 25, 2017, 05:40:00 AM
@Snektron was this your Euclidian raycaster thing? That was kinda cool.
u/Snektron March 25, 2017, 02:50:33 PM
Non euclidean, but yes
Start a Discussion

b/General Help

Need programming or hardware help? Need software installing or running support, or just help with technology in general? Then this is the place to ask in.

77
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal