EmOneGarand

I searched on here for anything about this and all I've come up with is information for 3D examples, now I don't want to try my hand at a 3D FPS but wanted to experiment with the old 2D Raycasting technique, are there any tutorials or information for simple raycasting math in C#


Re: XNA Game Studio Express 2D Doom/Wolfenstein 3D Ray Casting, how can it be done in C#?

smithy1185

I would like to know too if anyone has any information.




Re: XNA Game Studio Express 2D Doom/Wolfenstein 3D Ray Casting, how can it be done in C#?

Ska Software

2D Wolfenstein 3D I'm in over my head here...





Re: XNA Game Studio Express 2D Doom/Wolfenstein 3D Ray Casting, how can it be done in C#?

Ecrofirt

Wolfenstein 3D, Doom 1 & 3, DUke Nukem 3d, as well as many other early '3D' FPSes weren't done with 3D as we think of it today, but rather were all 2D games made to look 3D.




Re: XNA Game Studio Express 2D Doom/Wolfenstein 3D Ray Casting, how can it be done in C#?

Nick Gravelyn

Doom was definitely a 3D game. It used textured billboards for any object besides the actual level giving it a nice 2D appearance, but it was definitely in 3D. So you would be doing 3D raytracing for the shooting.

There is a decent looking tutorial at http://www.flipcode.com/articles/article_basiccollisions.shtml about some basic collision techniques. You're basically going to cast a ray from the player's location in the direction of the camera (possibly adding a vertical aspect if you are going truly retro with no up-down looking like the original Doom). Then you check to see if this ray passes through a plane that is the same plane the enemy lies on. This will always pass being that the enemy is billboarded, so you will then proceed to find out if the intersection between the ray and the plane is within the bounds of the billboard.




Re: XNA Game Studio Express 2D Doom/Wolfenstein 3D Ray Casting, how can it be done in C#?

redneon

Nick Gravelyn wrote:
Doom was definitely a 3D game. It used textured billboards for any object besides the actual level giving it a nice 2D appearance,


That's not entirely true. Doom was a 2D game that was rendered in 3D. If you read any interviews with Carmack and co. he talks about how the levels were made in 2D and then kind of extruded to a 3D game. In the end it is in three dimensions but the game logic itself is in two dimensions. That's why when you fire it doesn't matter where the enemy is in the Y because it only checks if you're firing in two dimensions.

Check out the source code for Doom at some point. It's quite impressive. There's a number of ports available here.





Re: XNA Game Studio Express 2D Doom/Wolfenstein 3D Ray Casting, how can it be done in C#?

Joel Martinez

You might try and get in contact with this guy. He's writing a ray tracer with XNA, and describes his technique as such:

Ití»s all homegrown code. Essentially, Ií»m building up a Texture2D object by casting rays into the scene and looking for objects that the rays intersect with. At each intersection point (closest to the camera) I compute a color. That color is modulated by the lights in the scene, each objectí»s material properties and so on. At the end of each pass I draw the resulting texture to the screen.

Ií»m going to publish the code shortly (after I finish the next iteration on acceleration techniques í¬ ití»s a bit slow at the moment).






Re: XNA Game Studio Express 2D Doom/Wolfenstein 3D Ray Casting, how can it be done in C#?

Shawn Hargreaves - MSFT

Paradoxically, I think you'll find the easiest way of making a Wolfenstein style game these days is just to use regular 3D meshes with textured polygons, and just not include any slopes in your floors or ever tilt the camera!

Modern hardware (and the XNA libraries) do a ton of stuff to make rendering 3D meshes easy, so if you build a level in a modelling tool, you can render it really quite easily to the screen.

Doing fake-3D via 2D raycasting, on the other hand, is a lot of fairly complex code you'll have to write, and also won't run anywhere near as fast because it won't be able to take advantage of GPU acceleration.





Re: XNA Game Studio Express 2D Doom/Wolfenstein 3D Ray Casting, how can it be done in C#?

ProfEclipse

Shawn Hargreaves - MSFT wrote:
Paradoxically, I think you'll find the easiest way of making a Wolfenstein style game these days is just to use regular 3D meshes with textured polygons, and just not include any slopes in your floors or ever tilt the camera!

Modern hardware (and the XNA libraries) do a ton of stuff to make rendering 3D meshes easy, so if you build a level in a modelling tool, you can render it really quite easily to the screen.

Doing fake-3D via 2D raycasting, on the other hand, is a lot of fairly complex code you'll have to write, and also won't run anywhere near as fast because it won't be able to take advantage of GPU acceleration.

Exactly. The only reason those games used 2D raycasting was because there was no readily available 3D hardware accelleration. Now that 3D hardware is the norm, there is really no reason to use raycasting for this other than as a learning experience.