Added ground clutter.

This commit is contained in:
Relintai 2019-11-10 02:33:02 +01:00
parent f0cd4008fc
commit 356621bf12
6 changed files with 101 additions and 0 deletions

3
SCsub
View File

@ -61,3 +61,6 @@ env.add_source_files(env.modules_sources,"world_generator/world_generator.cpp")
env.add_source_files(env.modules_sources,"areas/world_area.cpp")
env.add_source_files(env.modules_sources,"clutter/ground_clutter.cpp")
env.add_source_files(env.modules_sources,"clutter/ground_clutter_foliage.cpp")

View File

@ -0,0 +1,13 @@
#include "ground_clutter.h"
GroundClutter::GroundClutter() {
}
GroundClutter::~GroundClutter() {
}
void GroundClutter::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "should"), "_should_spawn", PropertyInfo(Variant::OBJECT, "buffer", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
BIND_VMETHOD(MethodInfo("_add_meshes_to", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
BIND_VMETHOD(MethodInfo("_add_textures_to", PropertyInfo(Variant::OBJECT, "packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker")));
}

19
clutter/ground_clutter.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef GROUND_CLUTTER_H
#define GROUND_CLUTTER_H
#include "core/resource.h"
class GroundClutter : public Resource {
GDCLASS(GroundClutter, Resource);
public:
GroundClutter();
~GroundClutter();
private:
static void _bind_methods();
private:
};
#endif

View File

@ -0,0 +1,32 @@
#include "ground_clutter_foliage.h"
int GroundClutterFoliage::get_texture_count() const {
return _textures.size();
}
Ref<Texture> GroundClutterFoliage::get_texture(const int index) {
ERR_FAIL_COND_V(index, _textures.size(), Ref<Texture>());
return _textures.get(index);
}
void GroundClutterFoliage::remove_texture(const int index) {
ERR_FAIL_COND(index, _textures.size());
_textures.remove(index);
}
void GroundClutterFoliage::add_texture(Ref<Texture> texture) {
_textures.push_back(texture);
}
GroundClutterFoliage::GroundClutterFoliage() {
}
GroundClutterFoliage::~GroundClutterFoliage() {
_textures.clear();
}
void GroundClutterFoliage::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_count"), &VoxelMesher::get_texture_count);
ClassDB::bind_method(D_METHOD("get_texture", "index"), &VoxelMesher::get_texture);
ClassDB::bind_method(D_METHOD("remove_texture", "index"), &VoxelMesher::remove_texture);
ClassDB::bind_method(D_METHOD("add_texture", "texture"), &VoxelMesher::add_texture);
}

View File

@ -0,0 +1,29 @@
#ifndef GROUND_CLUTTER_FOLIAGE_H
#define GROUND_CLUTTER_FOLIAGE_H
#include "ground_clutter.h"
#include "core/vector.h"
#include "scene/resources/texture.h"
class GroundClutterFoliage : public GroundClutter {
GDCLASS(GroundClutterFoliage, GroundClutter);
public:
int get_texture_count() const;
Ref<Texture> get_texture(const int index);
void remove_texture(const int index);
void add_texture(Ref<Texture> texture);
GroundClutterFoliage();
~GroundClutterFoliage();
private:
static void _bind_methods();
private:
Vector<Ref<Texture> > _textures;
};
#endif

View File

@ -51,6 +51,9 @@
#include "areas/world_area.h"
#include "clutter/ground_clutter.h"
#include "clutter/ground_clutter_foliage.h"
void register_voxelman_types() {
ClassDB::register_class<VoxelMesher>();
@ -104,6 +107,8 @@ void register_voxelman_types() {
ClassDB::register_class<WorldGenerator>();
ClassDB::register_class<WorldArea>();
ClassDB::register_class<GroundClutterFoliage>();
}
void unregister_voxelman_types() {