godot_voxel/voxel_mesher.h

48 lines
1.2 KiB
C
Raw Normal View History

#ifndef VOXEL_MESHER
#define VOXEL_MESHER
#include <reference.h>
#include <scene/resources/mesh.h>
#include <scene/resources/surface_tool.h>
#include "voxel.h"
#include "voxel_buffer.h"
#include "voxel_library.h"
class VoxelMesher : public Reference {
2017-01-01 05:23:22 +01:00
OBJ_TYPE(VoxelMesher, Reference)
public:
2017-01-01 04:40:16 +01:00
static const unsigned int MAX_MATERIALS = 8; // Arbitrary. Tweak if needed.
2017-01-01 04:40:16 +01:00
VoxelMesher();
2017-01-01 04:40:16 +01:00
void set_material(Ref<Material> material, unsigned int id);
2017-01-01 05:23:22 +01:00
Ref<Material> get_material(unsigned int id) const;
2017-01-01 04:40:16 +01:00
void set_library(Ref<VoxelLibrary> library);
2017-01-01 05:23:22 +01:00
Ref<VoxelLibrary> get_library() const { return _library; }
2017-01-01 04:40:16 +01:00
void set_occlusion_darkness(float darkness);
2017-01-01 05:23:22 +01:00
float get_occlusion_darkness() const { return _baked_occlusion_darkness; }
2017-01-01 04:40:16 +01:00
void set_occlusion_enabled(bool enable);
2017-01-01 05:23:22 +01:00
bool get_occlusion_enabled() const { return _bake_occlusion; }
2017-01-01 04:40:16 +01:00
Ref<Mesh> build(const VoxelBuffer & buffer_ref);
Ref<Mesh> build_ref(Ref<VoxelBuffer> buffer_ref);
protected:
2017-01-01 04:40:16 +01:00
static void _bind_methods();
2017-01-01 05:23:22 +01:00
private:
Ref<VoxelLibrary> _library;
Ref<Material> _materials[MAX_MATERIALS];
SurfaceTool _surface_tool[MAX_MATERIALS];
float _baked_occlusion_darkness;
bool _bake_occlusion;
};
#endif // VOXEL_MESHER