mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
Added ground clutter.
This commit is contained in:
parent
f0cd4008fc
commit
356621bf12
3
SCsub
3
SCsub
@ -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")
|
||||
|
||||
|
13
clutter/ground_clutter.cpp
Normal file
13
clutter/ground_clutter.cpp
Normal 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
19
clutter/ground_clutter.h
Normal 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
|
32
clutter/ground_clutter_foliage.cpp
Normal file
32
clutter/ground_clutter_foliage.cpp
Normal 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);
|
||||
}
|
29
clutter/ground_clutter_foliage.h
Normal file
29
clutter/ground_clutter_foliage.h
Normal 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
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user