2016-05-07 16:09:00 -07:00
|
|
|
#ifndef VOXEL_MESHER
|
|
|
|
#define VOXEL_MESHER
|
2016-05-01 06:00:02 -07:00
|
|
|
|
|
|
|
#include <reference.h>
|
|
|
|
#include <scene/resources/mesh.h>
|
|
|
|
#include <scene/resources/surface_tool.h>
|
|
|
|
#include "voxel.h"
|
|
|
|
#include "voxel_buffer.h"
|
2016-10-13 15:16:46 -07:00
|
|
|
#include "voxel_library.h"
|
2017-04-01 11:10:38 -07:00
|
|
|
#include "zprofiling.h"
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2016-05-07 16:09:00 -07:00
|
|
|
class VoxelMesher : public Reference {
|
2017-03-24 17:23:36 -07:00
|
|
|
GDCLASS(VoxelMesher, Reference)
|
2016-05-01 06:00:02 -07:00
|
|
|
|
2016-05-01 13:20:27 -07:00
|
|
|
public:
|
2016-12-31 19:40:16 -08:00
|
|
|
static const unsigned int MAX_MATERIALS = 8; // Arbitrary. Tweak if needed.
|
2016-05-01 06:00:02 -07:00
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
VoxelMesher();
|
2016-05-01 06:00:02 -07:00
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
void set_material(Ref<Material> material, unsigned int id);
|
2016-12-31 20:23:22 -08:00
|
|
|
Ref<Material> get_material(unsigned int id) const;
|
2016-05-01 06:00:02 -07:00
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
void set_library(Ref<VoxelLibrary> library);
|
2016-12-31 20:23:22 -08:00
|
|
|
Ref<VoxelLibrary> get_library() const { return _library; }
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
void set_occlusion_darkness(float darkness);
|
2016-12-31 20:23:22 -08:00
|
|
|
float get_occlusion_darkness() const { return _baked_occlusion_darkness; }
|
2016-12-31 19:40:16 -08:00
|
|
|
|
|
|
|
void set_occlusion_enabled(bool enable);
|
2016-12-31 20:23:22 -08:00
|
|
|
bool get_occlusion_enabled() const { return _bake_occlusion; }
|
2016-12-31 19:40:16 -08:00
|
|
|
|
|
|
|
Ref<Mesh> build(const VoxelBuffer & buffer_ref);
|
|
|
|
Ref<Mesh> build_ref(Ref<VoxelBuffer> buffer_ref);
|
2016-05-04 05:52:23 -07:00
|
|
|
|
2016-05-01 06:00:02 -07:00
|
|
|
protected:
|
2016-12-31 19:40:16 -08:00
|
|
|
static void _bind_methods();
|
2016-05-01 06:00:02 -07:00
|
|
|
|
2016-12-31 20:23:22 -08:00
|
|
|
private:
|
|
|
|
Ref<VoxelLibrary> _library;
|
|
|
|
Ref<Material> _materials[MAX_MATERIALS];
|
|
|
|
SurfaceTool _surface_tool[MAX_MATERIALS];
|
|
|
|
float _baked_occlusion_darkness;
|
|
|
|
bool _bake_occlusion;
|
|
|
|
|
2017-04-01 11:10:38 -07:00
|
|
|
#ifdef VOXEL_PROFILING
|
|
|
|
ZProfiler _zprofiler;
|
|
|
|
Dictionary get_profiling_info() const { return _zprofiler.get_all_serialized_info(); }
|
|
|
|
#endif
|
2016-05-01 06:00:02 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-05-07 16:09:00 -07:00
|
|
|
#endif // VOXEL_MESHER
|