C# ExoEngine


Introduction

For my fourth year computer graphics course Iwrote a little 3D engine using C# and the .NET platform. I decided togo this route as opposed to the C++ route that everyone else took inthe 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 isa decent language after all and possibly an effective replacement forthe C++ even in demanding field of real-time graphics. When I compareC# to C++ I find it's best features are garbage collection, lessconvoluted syntax and true object orientation.

Just a quick disclaimer before I go too far –please remember that I am only a student (and a cognitivescience/neuroscience student at that) and not John Carmack thus don'tget your expectations too high.

How the Engine Works

I must immediately give credit for theOpenGL/C# library that Lloyd Dupont created — it is an amazingly easylibrary to use. I have modified the library in the course of creatingthis project but not significantly.

This 3D engine imports it's level/worlds datafrom the popular Worldcraft editor . Strangely, Worldcraft outputs it'sworld/level data in sets of bounding planes which define the contoursof solid objects. Thus one has to convert the bounding plane sets intotheir respective sets of polygons. The resulting set of faces is thenquickly optimized to remove hidden/redundancy faces created by adjacentobjects. Then this face set is converted into a binary space partitiontree (commonly just called a "BSP tree") representation for bothcollision detection purposes and efficient visibility calculations.There is also some auxiliary code that recognizes specifically definedentities in the Worldcraft data such as the animated pond and thevarious duck sprites — but that is pretty simple.This engine allows for polygons to be rendered using reflectionmapping, (fake) Phong shading, Gouraud shading or just simple flatshading. The engine uses reflection mapping to get the somewhatrealistic look of the pond's waves. The (fake) Phong shading is used onthe ducks in order to make them look shiny and smoothly rounded — theprimary effect of Phong shading (usually called specular reflection) isthe viewer/camera dependent white highlights.The 600kB of code responsible for this engine is divided into threeparts: "ExocortexNative", a C++ support library for OpenGL and TIFFimages, "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 for3D applications such as OpenGL compatible matrix, vector and quaternionclasses as well as more specialized classes for Marching Cubes andmultidimensional fast Fourier transforms.

pic1 C# ExoEngine   pic2 C# ExoEngine

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

Most Commented Articles :

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!