#1 2016-01-10 18:18:38

gaya
Member

API for creating blocks in a new level?

So, i was diving into the code and trying to find the code which actually manipulates level data. Unfortunately, i wasn't able to find something so here i am asking. Basically, i was looking for something that allowed me to "addblock(block, x, y, z)" or similar, being block the block data (size, etc.) and xyz it's position. Is there something like this?

I'm working on a BMP to level converter. Initially, i'll place tall blocks on black pixels, "ground" blocks on gray and nothing on white. Hopefully, i can extend this to something more interesting in the future. Thanks for the help!

Offline

#2 2016-01-11 10:37:59

chasester
Member

Re: API for creating blocks in a new level?

I think I wrote something on this before look at the minecraft look alike posts. Simply put

You need to use a selinfo to do any kinda voxel manipulations (each point of a cube is basically a voxel). Because the map acts like a 3d grid of points each point either beeing on or off, it is easier to just use the system in place then trying to handle manipulating the raw data, (which could be done I guess).

Either way, you need to create a selinfo, then define it over the selinfo called sel (defined in game.h, but used in world.cpp). Now you can make whatever call you want, say delcube, or addcube or pastecubes etc. All level manipulation is in world.cpp (this is mostly for entities) and in octaedit (mostly for ui and cube manipulation).

I would start with the rendereditcursor() (definded in octaedit.cpp, declared in engine.h). This is where all the updating of the selinfo sel is done so you should get good example code there.


chasester

Offline

Board footer