XNA Quake

Published July 19, 2007
Advertisement
After pratting around with DOOM with MDX, it's logical to move up to Quake with XNA. After all, the levels are "true" 3D, and there's a healthy amount of new textures (including bump and gloss maps) so that it would make creating an advanced engine easier. My problem is always finding resources.

On the subject of resources, I'm using a system whereby the various classes for game resources (such as the Level or Model class) can implement ResourceLoader.ILoadable, so I can do things like this:

ResourceLoader = new ResourceLoader(@"C:\Program Files\Quake\ID1");Palette DefaultPalette = ResourceLoader.Load("gfx/palette.lmp");Level SomeLevel = ResourceLoader.Load("maps/start.bsp");


This way the ResourceLoader can handle dragging data out of multiple pack (.pak) files or loading override files.

First things first - loading levels. This is nice and easy (unlike DOOM) - the .bsp files contain a list of vertices and a list of edges (each edge contains a start and end vertex index). For testing purposes, I used the Graphics class to draw out each level in 2D:



Next up, I create a point list and render those in 3D:



...and now the edges as a line list:



That seems to be on its side. Quake uses (x, y) as a 2D floor plan and z for height, so I need to swap z and y (and negate y whilst we're at it).



Quake uses faces for solid walls, which are simply convex polygons made up from lists of the aforementioned edges (and may have more than three sides). I'm creating a simple triangle list, and applying some fog to make the world look 3D (there's no lighting):



Texturing would make a welcome addition. Quake uses a rather novel texture coordinate system (at least, I've never seen anything quite like it) whereby each face references a TextureInfo structure, which contains the index of the texture itself, a pair of vectors indicating the horizontal and vertical axis (for aligning the texture against the surface of the face) and an offset in texels (so the texture can be aligned to the edges of the face). Fortunately, the BSP documentation I have indicates how to use this information to calculate the texture offset per-vertex, and by dividing by the texture's width and height I can get "conventional" texture coordinates.



The real Quake textures would be nice, I suppose. As I break up the faces into triangle indices, I group them by texture index. The final triangle list is made up of groups of triangles by texture, so that (for example) triangles 0 to 10 will be texture 0, triangles 11 to 14 will be texture 1, triangle 15 will be texture 2 and so on. I also maintain a list of which triangles use which texture, so to render I simply set the texture, draw a range of triangles from the single list, then move on to the next texture.





It's all pretty brute-force stuff at the moment, but it's still very fast on modern hardware. Next up will be lightmaps. [smile]
0 likes 7 comments

Comments

sirob
Cool stuff!

I like the 2D view :)

If you ever feel like it, you could add a 2D top-down map in a secondary monitor [smile]
July 19, 2007 07:31 AM
benryves
Thanks, that would be interesting. [smile] DOOM's automap didn't have to contend with rooms-above-rooms so could display a meaningful 2D map easily enough.
July 19, 2007 07:53 AM
johnhattan
Purty
July 19, 2007 09:02 AM
Scet
hmmm looks familiar [smile]

Looks good though. Do you plan on making anything out of it, or will it just be a bsp viewer?
July 19, 2007 05:02 PM
katelynreid

This is a great information regarding Graphics Design. best hybrid bicycles under 1000 Every graphic designer who wants to excel in his niche must go through this article.

December 20, 2019 07:43 AM
eliferz

Game devs always are keen of new updates in the games. This new update is also catchy and interesting for the game developers. best hoverboard skins

December 24, 2019 03:55 PM
tareynosborn

Game is a combination of IU and programming. These article shows that game cannot be dependent on a single piece, both the work are necessary to make a complete a game. specialized foldable bikes

December 26, 2019 12:25 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement