Have been working on this alot over the last days. Moved around lots of code, optimized for speed, improved something here and there.
Well, I am nearing completion. Actually, the code is there, but I think without any kind of documentation, this will not be of great use to anyone. So I've started with writing document information for at least the public functions. Hopefully, I'll have that done by tomorrow. *crossing fingers*
To give you a basic overview of the classes it'll contain:
- TileTextureManager
This class creates and manages the texture atlas you will need later on. You can pass your textures directly here (as Ogre::Images) or let it load the textures from disc. It will put them into a texture atlas and load this texture atlas dynamically. Can be deleted after this work has been done.
- TileManager
This is where you do everything with your heightmap. In this class, the map (containing different chunks which are managed by the class TileChunk, which I will not mention here) is being created (so, pass your heightmap and "tiledata" - information about which texture to draw where - to this class) and basically managed (you should use TileInterface for most actions, though). You will also retrieve your data here (such as if you wish to save the map later on).
- TileInterface
A pointer to this class will probably be held in your frameListener. This class manages the dynamic loading/unloading of chunks (which are out of view distance) and the selection of tiles and change of height at selected tiles. For tile selection you can pass it a "brush" (a vector of floats) which it uses for tile selection, then you simply call the TileInterface::selectTile(mouseX,mouseY) function with the current position of your mouse and it will select the tile for you.
To mention some features of the TileBasedTerrain (some of which have been mentioned above):
- Automatic creation of the texture atlas for the terrain texture.
- ready-to-use interface for selecting tiles (with a brush) and performing height changes on them (so yes, its editable!)
- dynamic loading/unloading of chunks depending on a view distance (you can set)
- two levels of detail (high and low) for the chunks, the lower of which applies from a certain distance (there's a glitch still, which I won't fix before the release, but perhaps the community has an idea for that - IIRC SPT had that issue at the beginning, too)
If there's any interest, I'll reimplement the "grid" feature from the old terrain manager (shouldn't be hard) which allows for activating a grid on the terrain. But that won't be in the first release then.
Oh and on the todo list there's:
- Correct calculation of normals (right now, wrong normals are applied).
I really don't want to keep the code locked up so long, but when I release it, I want it to be stable, tidy and without a high risk of interface breaks in the near future.
So, perhaps that'll be this weekend - if not, perhaps the week after (and so on).
Oh, and sorry for any mistakes in the text above. It's late here now.
- Trosan