Monthly Archives: October 2012
So i have loaded them using couple of techniques: without spatial partitioning, using Quad Trees, Oct Trees, Axis Aligned BSP or KD Tree. Quad Trees are good but Oct Trees turned out to be better choice. Also KD Tree is little buggy right now and i may leave it as it for now and fix it later when i decide to do all BSP related offline rendering techniques. For now i am mainly focusing on OctTree related techniques which can be used in RealTime that means no offline pre processing.
I managed to export those levels to 3ds Max using couple of tools from Nem’s Tools. So it was just like loading any level from 3ds Max. We can load BSP files generated inside source engine directly also, there’s alot of info available on internet about the format and with a little bit of more effort it can be done. But I don’t think it was worth the effort unless you are willing to go one step further and implement BSP rendering path to take advantage of all those useful features provided by BSP
There can be many ways to load level mesh from 3ds Max. Simplest being if you want to load the whole level as a single mesh using X Files it’s just one function call – D3DXLoadMeshFromX. With a little bit of extra effort you can extract textures also.
But the way I am doing things is
- I load X Files using Hierarchical Loading Method to create separate D3DXMesh Objects for each mesh.
- Each of this mesh is then passed to my loader class which serves as interface between D3DxMesh and SpatialPartitioning code.
- Loader Class converts each of this meshes into Triangle Soup or Large Array of Triangles. Each triangle having its vertices, normal and a material id.
- These triangles are then passed to Spatial partitioning system as input which stores them depending on actual technique being used , whether polygon clipping is on or off etc.
Here are the results when Dust2 and HLTransition2 were rendered as single mesh and with Spatial Partitioning.
(Note – When loading level as single mesh Collision Detection is off because level is a single mesh and collision detection will involve testing object against each of those triangles in the scene which isn’t possible for realtime application as the triangle count is very high.)
I am still not done with this , in fact this is just the start of what needs to be done to render such large game scene with many dynamic objects. I am exploring and implementing further techniques / optimizations to further improve the performance and also working on adding more dynamic objects and some AI characters to test this in a better way.
I will also upload a video of collision detection in action on one of these maps in a couple of days.