3D Game Engine Using DirectX11 (C++)


This piece of work is what I’m most proud of this semester; it is also one of the projects I had the most fun working on; and because of that, I am currently building upon it and plan to continue over the summer. This is the first time I have ever used a 3D engine, or attempted building my own framework.


Framework

The engine uses a scene graph to handle the objects in the scene; once the user creates one of the nodes and adds it to the graph, the Initialisation, Updating and Rendering is handled in the underlying framework. I tried to make it so that the user would be able to simply add something to the scene, whilst maintaining as much control as possible. The user is able to create and add a node using 2 lines of code; this then adds the object to the scene graph and everything is handled in the under lying code, the result of this code would load, update and render that object onto the window.

The Renderer is what I’ve used as the main DirectX interface; it handles all the shaders, rasteriser states and drawing itself. The other objects then build a vertex, index buffer and the other required information, which is then sent to the renderer and drawn on screen. Lighting and the view matrix is also handled here.

Models

 To load in a model, a secondary resource manager is used; this loads the textures and meshes into a container and given a Resource ID which is held by the object. This is to avoid loading in the same mesh or texture multiple times. In order to load in models, I have used ASSIMP library (http://assimp.sourceforge.net/ ) which loads the model files into the resource manager. Once the mesh is loaded in, the model objects then can be drawn to the screen.

A Skydome class (which can be essentially any model), inherits from model ,which moves with the camera.

Terrain

 Terrain is another main aspect of the engine; firstly a grid of quads are generated and an index and vertex buffer is created from that grid. Then, depending on the user specification, the terrain can be loaded in from a height map; or the terrain can be procedurally generated using a number seed. At the same time, a texture can be loaded in to encompass the entire mesh. The method I used for the terrain generation is Perlin Noise (more info can be found here http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).


Camera and Controls 

 I am using a first person camera which uses the method found here (http://www.braynzarsoft.net/index.php?p=D3D11FPC ). It handles the Yaw, Pitch and Roll axis and then builds a look at vector based on those values and the cameras position.

The camera in the demo uses both keyboard controls and a games for windows live controller; to use this I had to include the XINPUT Api.

Collision

The collision is handled fairly poorly admittedly and is definitely something I need to improve upon. Currently, only a model or something that inherits from model can be checked for collision. There are three levels of bounding; None, Sphere or Box (the box actually uses both a sphere and box, hence the reason I’m unhappy with it). I generate the bounding shapes using the “DirectXBoundingVolumes” class which is shipped with DirectX11.1; it seemed a waste to re-write a class I already had available.

The user can then use a “SetColliable” function which then stores a pointer to the model in a container. Then every update, we retrieve the spheres using the pointers, and test them against one another; then, if it is returned true, the boxes are checked, provided they have been built. An over writable method is then called for the user to implement.


If you would like any more information regarding the engine, please feel free to contact me!

Comments

Popular posts from this blog

MIPS Graphics Library

3D Renderer (C++)