Click here to Skip to main content
Licence CPOL
First Posted 9 Jan 2002
Views 229,987
Downloads 2,412
Bookmarked 84 times

ExoEngine - a C# 3D engine

By Ben Houston | 27 Jul 2002
A basic 3D engine built using C# and the .NET platform
3 votes, 21.4%
1

2
2 votes, 14.3%
3
1 vote, 7.1%
4
8 votes, 57.1%
5
4.60/5 - 24 votes
3 removed
μ 4.03, σa 2.93 [?]

Screenshots



(click the thumbnails to expand)

Introduction

For my fourth year computer graphics course I wrote a little 3D engine using C# and the .NET platform.  I decided to go this route as opposed to the C++ route that everyone else took in the course because I wanted to see whether C# lived up to it's hype.  Surprising, after writing about 600kB of code in C# it seems like it is a decent language after all and possibly an effective replacement for the C++ even in demanding field of real-time graphics.  When I compare C# to C++ I find it's best features are garbage collection, less convoluted syntax and true object orientation.

Just a quick disclaimer before I go too far -- please remember that I am only a student (and a cognitive science/neuroscience student at that) and not John Carmack thus don't get your expectations too high.

How the Engine Works

I must immediately give credit for the OpenGL/C# library that Lloyd Dupont created -- it is an amazingly easy library to use.  I have modified the library in the course of creating this project but not significantly.

This 3D engine imports it's level/worlds data from the popular Worldcraft editor .  Strangely, Worldcraft outputs it's world/level data in sets of bounding planes which define the contours of solid objects.  Thus one has to convert the bounding plane sets into their respective sets of polygons.  The resulting set of faces is then quickly optimized to remove hidden/redundancy faces created by adjacent objects.  Then this face set is converted into a binary space partition tree (commonly just called a "BSP tree") representation for both collision detection purposes and efficient visibility calculations.  There is also some auxiliary code that recognizes specifically defined entities in the Worldcraft data such as the animated pond and the various duck sprites -- but that is pretty simple.

This engine allows for polygons to be rendered using reflection mapping, (fake) Phong shading, Gouraud shading or just simple flat shading.  The engine uses reflection mapping to get the somewhat realistic look of the pond's waves.  The (fake) Phong shading is used on the ducks in order to make them look shiny and smoothly rounded -- the primary effect of Phong shading (usually called specular reflection) is the viewer/camera dependent white highlights.

The 600kB of code responsible for this engine is divided into three parts: "ExocortexNative", a C++ support library for OpenGL and TIFF images, "Exocortex", a C# library that I am using across projects, and "ExoEngine", the code that is specific to this application.  The "Exocortex" library actually contains some fairly reusable classes for 3D applications such as OpenGL compatible matrix, vector and quaternion classes as well as more specialized classes for Marching Cubes and multidimensional fast Fourier transforms.

Source Code

Full Source Code with VS.NET RC1 Project Files (2.3MB)

  • Will compile and run successfully on .NET v1.0.3328
  • Will compile and crash on .NET v1.0.2914

Binaries

Currently distributing C# applications is a lot of trouble since the .NET platform is still in beta.  Hopefully the compatibility between different .NET versions will be better after it's release.

Option A: Full Installer (24.4MB)

  • choose this option if you haven't installed any .NET beta software.
  • includes the application (one exe and 2 dll's) and the .NET platform (build: v1.0.3328)
  • no source code included

Option B: Application Files Only (1.0MB)

  • choose this option if you currently have v1.0.3328 of the .NET platform installed
  • includes just the application files (one exe and 2 dll's)
  • no source code included

Option C: Sorry, no binaries for you.

  • if you have another version of .NET beside v1.0.3328 you can not download binaries from me that will work on you machine.
  • if may be possible to download and then compile the source code?
     

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ben Houston

Web Developer

Canada Canada

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalconcept Pinmemberzhima19883:31 14 May '10  
GeneralExo engine installer PinmemberAnthony_Yio3:44 16 Apr '04  
GeneralRe: Exo engine installer PinmemberBen Houston6:22 16 Apr '04  
Generalit rocks! Pinmemberchenhuisheng23:00 8 Apr '04  
QuestionWhere are the marching cubes? PinmemberPeter Schatz8:20 27 Feb '04  
AnswerRe: Where are the marching cubes? PinmemberBen Houston6:22 16 Apr '04  
GeneralC# game programming feasability PinmemberFilip Strugar12:05 17 Oct '03  
I couldn't not notice that many people laugh at the idea of using C#/.NET because of it's executing performance. However, in my opinion, performance of the C# is the last thing that stops C# (or slows it?) in replacing C++. Real issues are development community inertia, politics (it's bad, it's Micro$oft, etc.), lack of support (literature, tools, code samples), some code reuse difficulties, deployment issues (maybe Xbox2 will support .NET platform, but other than that only really supported platform is PC/Win) and the lack of general knowledge of the .NET/C#.
 
Why is performance of C# the least important of those reasons?
 
First of all, in reality, C# is approximately twice slower (the actual values depends on comparision area) than regular C++ when doing hard core calculations and algorithms, and that can be somewhat reduced with proper knowlidge of C# & .NET IL. It takes less time than a single game development cycle, for the PC hardware improvements (CPU speed) to offset that difference. More than that, as the game software becomes more and more complex, most of the CPU processing power is lost pushing unoptimized algorithms, and the optimizations simply require too much development time and are too expensive. Also more programmer's development time is used for code organization, not for coding. So if a C# as a development environment can payoff in better organization and reduced development time than more time could be spent on performance optimization, giving the project even better performance than it's C++ counterpart. Or more likely making the project much cheaper, with greater hardware requirements Smile | :) But that is nothing new, it's a process that's happening in all programming fields for a long time, and that is a reason why no modern game is written in asm. The programming language level is shifting up with the complexity of the project.
And C# even enables C++ code integration, so old C++ code can be reused, however with some overhead work.
 
The second reason is that in the game development more and more processing work is shifted from CPU to graphic card's GPU. That even more reduces the importance of C# vs C++ performance difference. So the main question is if/when Microsoft will push C# as a game programming language, with some more serious support.
 

At the end I must say that I'm still very much new in the game development business, so I might be overlooking some important factor. My main experience comes from my C#/DirectX9 project that pushes 8Mil polys/sec on the 1Ghz Celeron/GF FX 5200 (more than 10mil on faster FXs) in 1024x768 with two mesh blend, two textures blend, range based fog, normal based lighting, etc. Although most of the work is done on the GPU the project still does some CPU work using C# - data multithread streaming, simple cclusion and simple display optimizations, and leaves most of the CPU time free. It's not a 3D engine, simply a small part of it used to demonstrate my LOD technique, but it shows the possibilities of C#. More info about the project (and project download) can be seen at www.affinegraphics.com. And I plan on releasing the source code of the renderer as soon as I make it more readable Smile | :)

GeneralRe: C# game programming feasability PinmemberRoman Godhill0:49 27 Dec '06  
GeneralPerformance (or not) PinmemberBrian Azzopardi0:25 29 Jul '02  
GeneralRe: Performance (or not) PinmemberBen Houston8:15 29 Jul '02  
QuestionWorking on ver 1.0 ? PinmemberTrond Nilsen11:49 23 Jan '02  
AnswerRe: Working on ver 1.0 ? PinmemberBen Houston10:25 24 Mar '02  
GeneralExoEngine PinmemberPaul Selormey18:08 10 Jan '02  
GeneralRe: ExoEngine PinmemberBen Houston19:02 10 Jan '02  
GeneralImpressive!!!! PinmemberNish [BusterBoy]17:55 10 Jan '02  
General[Msg Deleted] PinmemberFazlul Kabir17:42 10 Jan '02  
GeneralRe: C# and Real Time Graphics PinmemberBen Houston19:06 10 Jan '02  
GeneralRe: C# and Real Time Graphics PinmemberNish [BusterBoy]20:45 10 Jan '02  
GeneralRe: C# and Real Time Graphics PinmemberCLaW21:55 10 Jan '02  
GeneralRe: C# and Real Time Graphics PinmemberNish [BusterBoy]22:08 10 Jan '02  
GeneralRe: C# and Real Time Graphics PinmemberBrit10:38 9 May '02  
GeneralRe: C# and Real Time Graphics PinmemberMr Morden18:23 10 Jul '02  
GeneralRe: C# and Real Time Graphics PinmemberBrit19:12 10 Jul '02  
GeneralRe: C# and Real Time Graphics Pinmembereltwo6:46 27 Jul '02  
GeneralRe: C# and Real Time Graphics PinsussAnonymous11:50 27 Jan '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120210.1 | Last Updated 28 Jul 2002
Article Copyright 2002 by Ben Houston
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid