This is an example that converts a mesh, loaded by collada, to voxels and renders them.
#include "blub/log/global.hpp"
#include "blub/log/system.hpp"
#include "blub/math/math.hpp"
#include "blub/math/quaternion.hpp"
#include "blub/math/sphere.hpp"
#include "blub/math/transform.hpp"
#include "blub/sync/identifier.hpp"
#include "blub/procedural/voxel/edit/mesh.hpp"
#include "blub/procedural/voxel/edit/sphere.hpp"
#include "blub/procedural/voxel/simple/container/inMemory.hpp"
#include "blub/procedural/voxel/terrain/accessor.hpp"
#include "blub/procedural/voxel/terrain/surface.hpp"
#include "blub/procedural/voxel/terrain/renderer.hpp"
#include "blub/procedural/voxel/tile/container.hpp"
#include "OgreTile.hpp"
#include "Handler.hpp"
int main(int , char* [])
{
blub::log::system::addConsole();
blub::log::system::addFile("voxelterrain.log");
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
scopedPointer<t_voxelContainer> voxelContainer;
scopedPointer<t_voxelAccessor> voxelAccessor;
scopedPointer<t_voxelSurface> voxelSurface;
scopedPointer<t_voxelRenderer> voxelRenderer;
{
const int32 numLod(3);
voxelAccessor.reset(
new t_voxelAccessor(terrainDispatcher, *voxelContainer, numLod));
voxelSurface.reset(
new t_voxelSurface(terrainDispatcher, *voxelAccessor));
const t_voxelRenderer::t_createTileCallback callbackCreate = boost::bind(t_renderTile::create, handler.
renderScene,
"none", &handler.
graphicDispatcher);
voxelRenderer.reset(
new t_voxelRenderer(terrainDispatcher, *voxelSurface, lodRadien));
voxelRenderer->setCreateTileCallback(callbackCreate);
cameraIdentifier = sync::identifier::create();
voxelRenderer->addCamera(cameraIdentifier, handler.
camera->getPosition());
handler.
signalFrame()->connect(
[&] (real)
{
voxelRenderer->updateCamera(cameraIdentifier, handler.camera->getPosition());
}
);
handler.
signalMouseGotPressed()->connect(
[&] (bool &left)
{
createSphere(voxelContainer.get(), handler.camera->getPosition()+handler.camera->getDirection()*10., !left);
}
);
}
{
voxelContainer->editVoxel(mesh);
}
{
terrainDispatcher.start();
handler.
renderSystem->startRendering();
terrainDispatcher.stop();
}
return EXIT_SUCCESS;
}
{
BLUB_LOG_OUT() << "createSphere";
sphereEdit->setCut(cut);
}