Sign in to follow this  
DaWanderer

[.net] C# OpenGL BSP engine code

Recommended Posts

RipTorn has graciously hosted my code for a C# OpenGL BSP engine. You can download it from here. The game is a simple FPS that loads Quake 3 BSP files (probably not 100% correctly...). Only 2 weapons available (numeric keys 1 & 2) ;) The GameServer.msi installer will install the server program that will host a game session so multiple players can connect and fight against each other. There are a few different game types including a simple deathmatch mode, an item collecting contest, and a "marked man" mode where you have to be the marked man at the end of the round to win (you get marked by shooting the current marked man). This was my final project for my game programming class. I hope other will find the code useful in some way.

Share this post


Link to post
Share on other sites
That is pretty nice. I noticed you couldn't jump if you were on a slope though.

The code is interesting too, thanks alot for sharing :)

EDIT: Its seems like the GameSetup and ServerSetup Projects are missing.

Share this post


Link to post
Share on other sites
Quote:
Original post by Smit
Its seems like the GameSetup and ServerSetup Projects are missing.


Yeah, I had to cut out some of the files to make in under 10MB so I could send the file through GMail. I still have all the files, though.

There's also a cool bug that I found. Go to the giant columns outside (up the stairs) and jump against them while running; you'll run up them! My code for gravity and jumping tests to see if the difference between your current height and the next height is small enough. I set it to a certain threshold for the smooth incline in the middle of the stairs leading outside, but it apparently works for the columns since they're at a slight angle.

Share this post


Link to post
Share on other sites
Although the new Axiom is still in the process of being made independant from RealmForge, its BSP loader is available here. Any clue what the difference is between yours and Axiom's?

Share this post


Link to post
Share on other sites
the axiom loader is much more complex and has more features(shaders,patches?). but it is also integrated with axiom.

DaWanderers code is very easy to read and to understand and has few dependencies.

Share this post


Link to post
Share on other sites
Quote:
Original post by Rob Loach
Any clue what the difference is between yours and Axiom's?


I based mine off a series of tutorials I found on the web (I can't remember where now...). Perhaps my loader and Axiom's are similar if we used the same tutorials. In any case, if you want to "roll your own", it's good to have a few different perspectives.

I've also sent RipTorn the setup projects for the engine, so they should be part of the package soon if anyone is interested.

Share this post


Link to post
Share on other sites
Well, it's not Managed DirectX, but I guess it's gonna be an interesting piece of code to take a look at nevertheless. Many kudos for sharing it! [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Rob Loach
Although the new Axiom is still in the process of being made independant from RealmForge, its BSP loader is available here. Any clue what the difference is between yours and Axiom's?


Thanks for pointing that out, it is awesome news indeed.

Share this post


Link to post
Share on other sites
It wont let me run it since I don't have the .NET framework 1.1, doesn't 2.0 have backwards compatability? I have the .NET 2.0 framework

Share this post


Link to post
Share on other sites
The frameworks are meant to be installed side-by-side. 2.0 is not necessarily backwards compatible, but I believe the point releases (1.0, 1.1) must be.

Share this post


Link to post
Share on other sites
hi, i couldnt compile.render system is error.

i include tao but Gl.glVertexPointer is false.it cant convert void to System.IntPtr.can you help me

Share this post


Link to post
Share on other sites
Quote:
Original post by cutler258
hi, i couldnt compile.render system is error.

i include tao but Gl.glVertexPointer is false.it cant convert void to System.IntPtr.can you help me


I don't understand your question, but tao's glVertexPointer binding is fine.

This suggestion is just a guess based on what you've written: try using "IntPtr.Zero". Notice also that there's an overload that accepts an object instead of an IntPtr. Try using that instead.

If that isn't helpfull, please try rephrasing the question more clearly and post the exact error.

Share this post


Link to post
Share on other sites
Post the source code line that gives the error.

Was the Tao library included in your download, or did you use the version from the Tao site? There were quite quite a lot changes since this game was released, but should be easy to fix.

Share this post


Link to post
Share on other sites
i am using tao 2.0

http://img470.imageshack.us/img470/7731/ekranmg6.jpg

i have this picture :(

i convert render system to csgl..

theese are codes:

--------------------------------------------------------

private unsafe void RenderPolygonFace(int FaceIndex)
{
BSPFace CurrentFace = Faces[FaceIndex];

if (Textures[CurrentFace.TextureID] != null)
{
//Vertices
fixed (void* VertexPtr = &Vertices[CurrentFace.StartVertexIndex * 3])
{
GL.glVertexPointer(3, Gl.GL_FLOAT, 0, VertexPtr);
}

if (CurrentFace.LightmapID >= 0)
{
if (Lightmaps[CurrentFace.LightmapID] != null)
{
//Lightmap
Gl.glBindTexture(Gl.GL_TEXTURE_2D,Lightmaps[CurrentFace.LightmapID].TextureID);

//Setup blending
GL.glDisable(Gl.GL_BLEND);
GL.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_REPLACE);

//Set texture coordinates
fixed (void* LightmapCoordPtr = &LightmapCoords[CurrentFace.StartVertexIndex * 2])
{
GL.glTexCoordPointer(2, Gl.GL_FLOAT, 0, LightmapCoordPtr);
}

//Draw face
fixed (uint* IndexPtr = &MeshIndices[CurrentFace.MeshVertexIndex])
{
GL.glDrawElements(Gl.GL_TRIANGLES, CurrentFace.NumMeshVertices,
GL.GL_UNSIGNED_INT, IndexPtr);
}
}
}

//Decal texture
Gl.glBindTexture(Gl.GL_TEXTURE_2D, Textures[CurrentFace.TextureID].TextureID);

//Setup blending
GL.glEnable(Gl.GL_BLEND);
GL.glBlendFunc(Gl.GL_DST_COLOR, Gl.GL_SRC_COLOR);
GL.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_REPLACE);

//Set texture coordinates
fixed (void* TexCoordPtr = &TextureCoords[CurrentFace.StartVertexIndex * 2])
{
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, TexCoordPtr);
}

//Draw face
fixed (uint* IndexPtr = &MeshIndices[CurrentFace.MeshVertexIndex])
{
GL.glDrawElements(GL.GL_TRIANGLES, CurrentFace.NumMeshVertices,
GL.GL_UNSIGNED_INT, IndexPtr);
}
}
}

-------------------------------------------------------------

Share this post


Link to post
Share on other sites
Hm... I cant see whats wrong in the code, but csgl is extremely outdated. Tao is the way to go.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this