Geometry loading
346
0
Advertisement
PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Excuse the horrible textures.
I've been messing about writing a simple geometry loader for the very simple 3D game I intend to write using Bullet.
I decided that my XCS format would be perfectly good for storing level geometry. The above scene looks like this in the XCS file:
textures{ t0="block.bmp"; t1="crate.bmp";}geometry{ floor { type=cuboid; size="20,0,20"; pos="0,0,0"; top { texture=0; u=20; v=20; } } roof { type=cuboid; size="20,0,20"; pos="0,10,0"; base { texture=1; u=10; v=10; } } frontwall { type=cuboid; size="20,10,0"; pos="0,5,-10"; back { texture=1; u=10; v=5; } } backwall { type=cuboid; size="20,10,0"; pos="0,5,10"; front { texture=1; u=10; v=5; } } leftwall { type=cuboid; size="0,10,20"; pos="-10,5,0"; right { texture=1; u=10; v=5; } } rightwall { type=cuboid; size="0,10,20"; pos="10,5,0"; left { texture=1; u=10; v=5; } } block { type=cuboid; size="2,2,2"; pos="0,1,0"; front { texture=1; u=1; v=1; } back { texture=1; u=1; v=1; } left { texture=1; u=1; v=1; } right { texture=1; u=1; v=1; } top { texture=1; u=1; v=1; } } bar { type=cuboid; size="5,0.5,0.5"; pos="3.5,0.25,0"; front { texture=1; u=5; v=1; } back { texture=1; u=5; v=1; } top { texture=1; u=5; v=1; } right { texture=1; u=1; v=1; } } box { type=cuboid; size="2,4,2"; pos="-3,2,-3"; front { texture=1; u=1; v=2; } back { texture=1; u=1; v=2; } left { texture=1; u=1; v=2; } right { texture=1; u=1; v=2; } top { texture=1; u=1; v=1; } } box2 { type=cuboid; size="3,0.5,3"; pos="-4,0.25,4"; front { texture=1; u=1; v=0.5; } back { texture=1; u=1; v=0.5; } left { texture=1; u=1; v=0.5; } right { texture=1; u=1; v=0.5; } top { texture=1; u=2; v=2; } }}Any sides of the cuboid you don't specify are skipped, so you only specify visible sides.
The above is then loaded into an ID3DXMesh inside my Mesh class, which also keeps a list of which texture index to remap each mesh stage to.
The whole idea is that it will be very easy to use the same data above to feed into the Bullet static object list in order to create the collision primitives for the level.
Obviously eventually I'll need to write a very basic editor to create the XCS files as above, at which point it will probably be better to convert over to a binary format, but it is nice to prove yet another success for my XCS library, if I do say so myself.
Next up, probably tomorrow, I need to implement Bullet into this project, set up a floor plane and the ability to throw cubes into the game world, then convert the above geometry into Bullet static primitives and throw cubes at them to confirm it works.
Advertisement
Advertisement
Advertisement
Discussion