mirror of
https://github.com/Relintai/voxelman.git
synced 2025-01-25 15:09:18 +01:00
Now materials in Library are stored with vectors. This makes it possible to have different materials for every lod level for example.
This commit is contained in:
parent
ddfdb4489f
commit
541abb954d
@ -24,32 +24,200 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "../props/prop_data.h"
|
#include "../props/prop_data.h"
|
||||||
|
|
||||||
Ref<Material> VoxelmanLibrary::get_material() const {
|
//Materials
|
||||||
return _material;
|
Ref<Material> VoxelmanLibrary::get_material(const int index) {
|
||||||
}
|
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<VoxelSurface>(NULL));
|
||||||
void VoxelmanLibrary::set_material(Ref<Material> mat) {
|
|
||||||
_material = mat;
|
return _materials[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> VoxelmanLibrary::get_prop_material() const {
|
void VoxelmanLibrary::add_material(const Ref<Material> &value) {
|
||||||
return _prop_material;
|
ERR_FAIL_COND(!value.is_valid());
|
||||||
}
|
|
||||||
void VoxelmanLibrary::set_prop_material(Ref<Material> mat) {
|
_materials.push_back(value);
|
||||||
_prop_material = mat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> VoxelmanLibrary::get_liquid_material() const {
|
void VoxelmanLibrary::set_material(const int index, const Ref<Material> &value) {
|
||||||
return _liquid_material;
|
ERR_FAIL_INDEX(index, _materials.size());
|
||||||
}
|
|
||||||
void VoxelmanLibrary::set_liquid_material(Ref<Material> mat) {
|
_materials.set(index, value);
|
||||||
_liquid_material = mat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> VoxelmanLibrary::get_clutter_material() const {
|
void VoxelmanLibrary::remove_material(const int index) {
|
||||||
return _clutter_material;
|
_materials.remove(index);
|
||||||
}
|
}
|
||||||
void VoxelmanLibrary::set_clutter_material(Ref<Material> mat) {
|
|
||||||
_clutter_material = mat;
|
int VoxelmanLibrary::get_num_materials() const {
|
||||||
|
return _materials.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::clear_materials() {
|
||||||
|
_materials.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Variant> VoxelmanLibrary::get_materials() {
|
||||||
|
Vector<Variant> r;
|
||||||
|
for (int i = 0; i < _materials.size(); i++) {
|
||||||
|
r.push_back(_materials[i].get_ref_ptr());
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::set_materials(const Vector<Variant> &materials) {
|
||||||
|
_materials.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < materials.size(); i++) {
|
||||||
|
Ref<Material> material = Ref<Material>(materials[i]);
|
||||||
|
|
||||||
|
_materials.push_back(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Prop Materials
|
||||||
|
Ref<Material> VoxelmanLibrary::get_prop_material(const int index) {
|
||||||
|
ERR_FAIL_INDEX_V(index, _prop_materials.size(), Ref<VoxelSurface>(NULL));
|
||||||
|
|
||||||
|
return _prop_materials[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::add_prop_material(const Ref<Material> &value) {
|
||||||
|
ERR_FAIL_COND(!value.is_valid());
|
||||||
|
|
||||||
|
_prop_materials.push_back(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::set_prop_material(const int index, const Ref<Material> &value) {
|
||||||
|
ERR_FAIL_INDEX(index, _prop_materials.size());
|
||||||
|
|
||||||
|
_prop_materials.set(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::remove_prop_material(const int index) {
|
||||||
|
_prop_materials.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoxelmanLibrary::get_num_prop_materials() const {
|
||||||
|
return _prop_materials.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::clear_prop_materials() {
|
||||||
|
_prop_materials.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Variant> VoxelmanLibrary::get_prop_materials() {
|
||||||
|
Vector<Variant> r;
|
||||||
|
for (int i = 0; i < _prop_materials.size(); i++) {
|
||||||
|
r.push_back(_prop_materials[i].get_ref_ptr());
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::set_prop_materials(const Vector<Variant> &materials) {
|
||||||
|
_prop_materials.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < materials.size(); i++) {
|
||||||
|
Ref<Material> material = Ref<Material>(materials[i]);
|
||||||
|
|
||||||
|
_prop_materials.push_back(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Liquid Materials
|
||||||
|
Ref<Material> VoxelmanLibrary::get_liquid_material(const int index) {
|
||||||
|
ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref<VoxelSurface>(NULL));
|
||||||
|
|
||||||
|
return _liquid_materials[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::add_liquid_material(const Ref<Material> &value) {
|
||||||
|
ERR_FAIL_COND(!value.is_valid());
|
||||||
|
|
||||||
|
_liquid_materials.push_back(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::set_liquid_material(const int index, const Ref<Material> &value) {
|
||||||
|
ERR_FAIL_INDEX(index, _liquid_materials.size());
|
||||||
|
|
||||||
|
_liquid_materials.set(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::remove_liquid_material(const int index) {
|
||||||
|
_liquid_materials.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoxelmanLibrary::get_num_liquid_materials() const {
|
||||||
|
return _liquid_materials.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::clear_liquid_materials() {
|
||||||
|
_liquid_materials.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Variant> VoxelmanLibrary::get_liquid_materials() {
|
||||||
|
Vector<Variant> r;
|
||||||
|
for (int i = 0; i < _liquid_materials.size(); i++) {
|
||||||
|
r.push_back(_liquid_materials[i].get_ref_ptr());
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::set_liquid_materials(const Vector<Variant> &materials) {
|
||||||
|
_liquid_materials.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < materials.size(); i++) {
|
||||||
|
Ref<Material> material = Ref<Material>(materials[i]);
|
||||||
|
|
||||||
|
_liquid_materials.push_back(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clutter Materials
|
||||||
|
Ref<Material> VoxelmanLibrary::get_clutter_material(const int index) {
|
||||||
|
ERR_FAIL_INDEX_V(index, _clutter_materials.size(), Ref<VoxelSurface>(NULL));
|
||||||
|
|
||||||
|
return _clutter_materials[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::add_clutter_material(const Ref<Material> &value) {
|
||||||
|
ERR_FAIL_COND(!value.is_valid());
|
||||||
|
|
||||||
|
_clutter_materials.push_back(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::set_clutter_material(const int index, const Ref<Material> &value) {
|
||||||
|
ERR_FAIL_INDEX(index, _clutter_materials.size());
|
||||||
|
|
||||||
|
_clutter_materials.set(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::remove_clutter_material(const int index) {
|
||||||
|
_clutter_materials.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoxelmanLibrary::get_num_clutter_materials() const {
|
||||||
|
return _clutter_materials.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::clear_clutter_materials() {
|
||||||
|
_clutter_materials.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Variant> VoxelmanLibrary::get_clutter_materials() {
|
||||||
|
Vector<Variant> r;
|
||||||
|
for (int i = 0; i < _clutter_materials.size(); i++) {
|
||||||
|
r.push_back(_clutter_materials[i].get_ref_ptr());
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrary::set_clutter_materials(const Vector<Variant> &materials) {
|
||||||
|
_clutter_materials.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < materials.size(); i++) {
|
||||||
|
Ref<Material> material = Ref<Material>(materials[i]);
|
||||||
|
|
||||||
|
_clutter_materials.push_back(material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Surfaces
|
//Surfaces
|
||||||
@ -58,7 +226,7 @@ Ref<VoxelSurface> VoxelmanLibrary::get_voxel_surface(const int index) {
|
|||||||
}
|
}
|
||||||
void VoxelmanLibrary::add_voxel_surface(Ref<VoxelSurface> value) {
|
void VoxelmanLibrary::add_voxel_surface(Ref<VoxelSurface> value) {
|
||||||
}
|
}
|
||||||
void VoxelmanLibrary::set_voxel_surface(const int index, Ref<VoxelSurface> value) {
|
void VoxelmanLibrary::set_voxel_surface(int index, Ref<VoxelSurface> value) {
|
||||||
}
|
}
|
||||||
void VoxelmanLibrary::remove_surface(const int index) {
|
void VoxelmanLibrary::remove_surface(const int index) {
|
||||||
}
|
}
|
||||||
@ -74,7 +242,7 @@ Ref<VoxelSurface> VoxelmanLibrary::get_liquid_surface(const int index) {
|
|||||||
}
|
}
|
||||||
void VoxelmanLibrary::add_liquid_surface(Ref<VoxelSurface> value) {
|
void VoxelmanLibrary::add_liquid_surface(Ref<VoxelSurface> value) {
|
||||||
}
|
}
|
||||||
void VoxelmanLibrary::set_liquid_surface(const int index, Ref<VoxelSurface> value) {
|
void VoxelmanLibrary::set_liquid_surface(int index, Ref<VoxelSurface> value) {
|
||||||
}
|
}
|
||||||
void VoxelmanLibrary::remove_liquid_surface(const int index) {
|
void VoxelmanLibrary::remove_liquid_surface(const int index) {
|
||||||
}
|
}
|
||||||
@ -89,7 +257,7 @@ Ref<PropData> VoxelmanLibrary::get_prop(const int id) {
|
|||||||
}
|
}
|
||||||
void VoxelmanLibrary::add_prop(Ref<PropData> value) {
|
void VoxelmanLibrary::add_prop(Ref<PropData> value) {
|
||||||
}
|
}
|
||||||
void VoxelmanLibrary::set_prop(const int id, Ref<PropData> value) {
|
void VoxelmanLibrary::set_prop(int id, Ref<PropData> value) {
|
||||||
}
|
}
|
||||||
void VoxelmanLibrary::remove_prop(const int id) {
|
void VoxelmanLibrary::remove_prop(const int id) {
|
||||||
}
|
}
|
||||||
@ -112,30 +280,58 @@ VoxelmanLibrary::VoxelmanLibrary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VoxelmanLibrary::~VoxelmanLibrary() {
|
VoxelmanLibrary::~VoxelmanLibrary() {
|
||||||
_material.unref();
|
_materials.clear();
|
||||||
_prop_material.unref();
|
_prop_materials.clear();
|
||||||
_liquid_material.unref();
|
_liquid_materials.clear();
|
||||||
_clutter_material.unref();
|
_clutter_materials.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelmanLibrary::_bind_methods() {
|
void VoxelmanLibrary::_bind_methods() {
|
||||||
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::INT, "material_index"), PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
|
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::INT, "material_index"), PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_material"), &VoxelmanLibrary::get_material);
|
ClassDB::bind_method(D_METHOD("get_material", "index"), &VoxelmanLibrary::get_material);
|
||||||
ClassDB::bind_method(D_METHOD("set_material", "value"), &VoxelmanLibrary::set_material);
|
ClassDB::bind_method(D_METHOD("add_material", "value"), &VoxelmanLibrary::add_material);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material");
|
ClassDB::bind_method(D_METHOD("set_material", "index", "value"), &VoxelmanLibrary::set_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("remove_material", "index"), &VoxelmanLibrary::remove_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_num_materials"), &VoxelmanLibrary::get_num_materials);
|
||||||
|
ClassDB::bind_method(D_METHOD("clear_materials"), &VoxelmanLibrary::clear_materials);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_prop_material"), &VoxelmanLibrary::get_prop_material);
|
ClassDB::bind_method(D_METHOD("get_materials"), &VoxelmanLibrary::get_materials);
|
||||||
ClassDB::bind_method(D_METHOD("set_prop_material", "value"), &VoxelmanLibrary::set_prop_material);
|
ClassDB::bind_method(D_METHOD("set_materials"), &VoxelmanLibrary::set_materials);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_prop_material", "get_prop_material");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_materials", "get_materials");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_liquid_material"), &VoxelmanLibrary::get_liquid_material);
|
ClassDB::bind_method(D_METHOD("get_prop_material", "index"), &VoxelmanLibrary::get_prop_material);
|
||||||
ClassDB::bind_method(D_METHOD("set_liquid_material", "value"), &VoxelmanLibrary::set_liquid_material);
|
ClassDB::bind_method(D_METHOD("add_prop_material", "value"), &VoxelmanLibrary::add_prop_material);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "liquid_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_liquid_material", "get_liquid_material");
|
ClassDB::bind_method(D_METHOD("set_prop_material", "index", "value"), &VoxelmanLibrary::set_prop_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("remove_prop_material", "index"), &VoxelmanLibrary::remove_prop_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_num_prop_materials"), &VoxelmanLibrary::get_num_prop_materials);
|
||||||
|
ClassDB::bind_method(D_METHOD("clear_prop_materials"), &VoxelmanLibrary::clear_prop_materials);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_clutter_material"), &VoxelmanLibrary::get_clutter_material);
|
ClassDB::bind_method(D_METHOD("get_prop_materials"), &VoxelmanLibrary::get_prop_materials);
|
||||||
ClassDB::bind_method(D_METHOD("set_clutter_material", "value"), &VoxelmanLibrary::set_clutter_material);
|
ClassDB::bind_method(D_METHOD("set_prop_materials"), &VoxelmanLibrary::set_prop_materials);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "clutter_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_clutter_material", "get_clutter_material");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_prop_materials", "get_prop_materials");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_liquid_material", "index"), &VoxelmanLibrary::get_liquid_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("add_liquid_material", "value"), &VoxelmanLibrary::add_liquid_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_liquid_material", "index", "value"), &VoxelmanLibrary::set_liquid_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("remove_liquid_material", "index"), &VoxelmanLibrary::remove_liquid_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_num_liquid_materials"), &VoxelmanLibrary::get_num_liquid_materials);
|
||||||
|
ClassDB::bind_method(D_METHOD("clear_liquid_materials"), &VoxelmanLibrary::clear_liquid_materials);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_liquid_materials"), &VoxelmanLibrary::get_liquid_materials);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_liquid_materials"), &VoxelmanLibrary::set_liquid_materials);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_liquid_materials", "get_liquid_materials");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_clutter_material", "index"), &VoxelmanLibrary::get_clutter_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("add_clutter_material", "value"), &VoxelmanLibrary::add_clutter_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_clutter_material", "index", "value"), &VoxelmanLibrary::set_clutter_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("remove_clutter_material", "index"), &VoxelmanLibrary::remove_clutter_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_num_clutter_materials"), &VoxelmanLibrary::get_num_clutter_materials);
|
||||||
|
ClassDB::bind_method(D_METHOD("clear_clutter_materials"), &VoxelmanLibrary::clear_clutter_materials);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_clutter_materials"), &VoxelmanLibrary::get_clutter_materials);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_clutter_materials"), &VoxelmanLibrary::set_clutter_materials);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "clutter_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_clutter_materials", "get_clutter_materials");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &VoxelmanLibrary::get_voxel_surface);
|
ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &VoxelmanLibrary::get_voxel_surface);
|
||||||
ClassDB::bind_method(D_METHOD("add_voxel_surface", "value"), &VoxelmanLibrary::add_voxel_surface);
|
ClassDB::bind_method(D_METHOD("add_voxel_surface", "value"), &VoxelmanLibrary::add_voxel_surface);
|
||||||
|
@ -45,17 +45,45 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ref<Material> get_material() const;
|
Ref<Material> get_material(const int index);
|
||||||
void set_material(Ref<Material> mat);
|
void add_material(const Ref<Material> &value);
|
||||||
|
void set_material(const int index, const Ref<Material> &value);
|
||||||
|
void remove_material(const int index);
|
||||||
|
int get_num_materials() const;
|
||||||
|
void clear_materials();
|
||||||
|
|
||||||
Ref<Material> get_prop_material() const;
|
Vector<Variant> get_materials();
|
||||||
void set_prop_material(Ref<Material> mat);
|
void set_materials(const Vector<Variant> &materials);
|
||||||
|
|
||||||
Ref<Material> get_liquid_material() const;
|
Ref<Material> get_prop_material(const int index);
|
||||||
void set_liquid_material(Ref<Material> mat);
|
void add_prop_material(const Ref<Material> &value);
|
||||||
|
void set_prop_material(const int index, const Ref<Material> &value);
|
||||||
|
void remove_prop_material(const int index);
|
||||||
|
int get_num_prop_materials() const;
|
||||||
|
void clear_prop_materials();
|
||||||
|
|
||||||
Ref<Material> get_clutter_material() const;
|
Vector<Variant> get_prop_materials();
|
||||||
void set_clutter_material(Ref<Material> mat);
|
void set_prop_materials(const Vector<Variant> &materials);
|
||||||
|
|
||||||
|
Ref<Material> get_liquid_material(const int index);
|
||||||
|
void add_liquid_material(const Ref<Material> &value);
|
||||||
|
void set_liquid_material(const int index, const Ref<Material> &value);
|
||||||
|
void remove_liquid_material(const int index);
|
||||||
|
int get_num_liquid_materials() const;
|
||||||
|
void clear_liquid_materials();
|
||||||
|
|
||||||
|
Vector<Variant> get_liquid_materials();
|
||||||
|
void set_liquid_materials(const Vector<Variant> &materials);
|
||||||
|
|
||||||
|
Ref<Material> get_clutter_material(const int index);
|
||||||
|
void add_clutter_material(const Ref<Material> &value);
|
||||||
|
void set_clutter_material(const int index, const Ref<Material> &value);
|
||||||
|
void remove_clutter_material(const int index);
|
||||||
|
int get_num_clutter_materials() const;
|
||||||
|
void clear_clutter_materials();
|
||||||
|
|
||||||
|
Vector<Variant> get_clutter_materials();
|
||||||
|
void set_clutter_materials(const Vector<Variant> &materials);
|
||||||
|
|
||||||
virtual Ref<VoxelSurface> get_voxel_surface(const int index);
|
virtual Ref<VoxelSurface> get_voxel_surface(const int index);
|
||||||
virtual void add_voxel_surface(Ref<VoxelSurface> value);
|
virtual void add_voxel_surface(Ref<VoxelSurface> value);
|
||||||
@ -89,10 +117,10 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ref<Material> _material;
|
Vector<Ref<Material> > _materials;
|
||||||
Ref<Material> _prop_material;
|
Vector<Ref<Material> > _prop_materials;
|
||||||
Ref<Material> _liquid_material;
|
Vector<Ref<Material> > _liquid_materials;
|
||||||
Ref<Material> _clutter_material;
|
Vector<Ref<Material> > _clutter_materials;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VOXEL_LIBRARY_H
|
#endif // VOXEL_LIBRARY_H
|
||||||
|
@ -384,47 +384,67 @@ void VoxelmanLibraryMerger::refresh_rects() {
|
|||||||
void VoxelmanLibraryMerger::_setup_material_albedo(int material_index, Ref<Texture> texture) {
|
void VoxelmanLibraryMerger::_setup_material_albedo(int material_index, Ref<Texture> texture) {
|
||||||
Ref<SpatialMaterial> mat;
|
Ref<SpatialMaterial> mat;
|
||||||
|
|
||||||
switch (material_index) {
|
int count = 0;
|
||||||
case MATERIAL_INDEX_VOXELS:
|
|
||||||
mat = get_material();
|
|
||||||
break;
|
|
||||||
case MATERIAL_INDEX_PROP:
|
|
||||||
mat = get_prop_material();
|
|
||||||
break;
|
|
||||||
case MATERIAL_INDEX_LIQUID:
|
|
||||||
mat = get_liquid_material();
|
|
||||||
break;
|
|
||||||
case MATERIAL_INDEX_CLUTTER:
|
|
||||||
mat = get_clutter_material();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<SpatialMaterial> spmat;
|
|
||||||
|
|
||||||
if (spmat.is_valid()) {
|
|
||||||
spmat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<ShaderMaterial> shmat;
|
|
||||||
|
|
||||||
switch (material_index) {
|
switch (material_index) {
|
||||||
case MATERIAL_INDEX_VOXELS:
|
case MATERIAL_INDEX_VOXELS:
|
||||||
shmat = get_material();
|
count = get_num_materials();
|
||||||
break;
|
break;
|
||||||
case MATERIAL_INDEX_PROP:
|
case MATERIAL_INDEX_PROP:
|
||||||
shmat = get_prop_material();
|
count = get_num_prop_materials();
|
||||||
break;
|
break;
|
||||||
case MATERIAL_INDEX_LIQUID:
|
case MATERIAL_INDEX_LIQUID:
|
||||||
shmat = get_liquid_material();
|
count = get_num_liquid_materials();
|
||||||
break;
|
break;
|
||||||
case MATERIAL_INDEX_CLUTTER:
|
case MATERIAL_INDEX_CLUTTER:
|
||||||
shmat = get_clutter_material();
|
count = get_num_clutter_materials();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shmat.is_valid()) {
|
for (int i = 0; i < count; ++i) {
|
||||||
shmat->set_shader_param("texture_albedo", texture);
|
|
||||||
|
switch (material_index) {
|
||||||
|
case MATERIAL_INDEX_VOXELS:
|
||||||
|
mat = get_material(i);
|
||||||
|
break;
|
||||||
|
case MATERIAL_INDEX_PROP:
|
||||||
|
mat = get_prop_material(i);
|
||||||
|
break;
|
||||||
|
case MATERIAL_INDEX_LIQUID:
|
||||||
|
mat = get_liquid_material(i);
|
||||||
|
break;
|
||||||
|
case MATERIAL_INDEX_CLUTTER:
|
||||||
|
mat = get_clutter_material(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<SpatialMaterial> spmat;
|
||||||
|
|
||||||
|
if (spmat.is_valid()) {
|
||||||
|
spmat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<ShaderMaterial> shmat;
|
||||||
|
|
||||||
|
switch (material_index) {
|
||||||
|
case MATERIAL_INDEX_VOXELS:
|
||||||
|
shmat = get_material(i);
|
||||||
|
break;
|
||||||
|
case MATERIAL_INDEX_PROP:
|
||||||
|
shmat = get_prop_material(i);
|
||||||
|
break;
|
||||||
|
case MATERIAL_INDEX_LIQUID:
|
||||||
|
shmat = get_liquid_material(i);
|
||||||
|
break;
|
||||||
|
case MATERIAL_INDEX_CLUTTER:
|
||||||
|
shmat = get_clutter_material(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shmat.is_valid()) {
|
||||||
|
shmat->set_shader_param("texture_albedo", texture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ void VoxelMesher::build_mesh_into(RID mesh) {
|
|||||||
VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VisualServer::PRIMITIVE_TRIANGLES, arr);
|
VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VisualServer::PRIMITIVE_TRIANGLES, arr);
|
||||||
|
|
||||||
if (_material.is_valid())
|
if (_material.is_valid())
|
||||||
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _library->get_material()->get_rid());
|
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _library->get_material(0)->get_rid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelMesher::generate_normals(bool p_flip) {
|
void VoxelMesher::generate_normals(bool p_flip) {
|
||||||
|
@ -25,24 +25,24 @@ SOFTWARE.
|
|||||||
#include "../world/voxel_chunk.h"
|
#include "../world/voxel_chunk.h"
|
||||||
#include "prop_data_prop.h"
|
#include "prop_data_prop.h"
|
||||||
|
|
||||||
int PropData::get_id() {
|
int PropData::get_id() const {
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
void PropData::set_id(int value) {
|
void PropData::set_id(const int value) {
|
||||||
_id = value;
|
_id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PropData::get_snap_to_mesh() {
|
bool PropData::get_snap_to_mesh() const {
|
||||||
return _snap_to_mesh;
|
return _snap_to_mesh;
|
||||||
}
|
}
|
||||||
void PropData::set_snap_to_mesh(bool value) {
|
void PropData::set_snap_to_mesh(const bool value) {
|
||||||
_snap_to_mesh = value;
|
_snap_to_mesh = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 PropData::get_snap_axis() {
|
Vector3 PropData::get_snap_axis() const {
|
||||||
return _snap_axis;
|
return _snap_axis;
|
||||||
}
|
}
|
||||||
void PropData::set_snap_axis(Vector3 value) {
|
void PropData::set_snap_axis(const Vector3 &value) {
|
||||||
_snap_axis = value;
|
_snap_axis = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,14 +46,14 @@ class PropData : public Resource {
|
|||||||
GDCLASS(PropData, Resource);
|
GDCLASS(PropData, Resource);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int get_id();
|
int get_id() const;
|
||||||
void set_id(int value);
|
void set_id(const int value);
|
||||||
|
|
||||||
bool get_snap_to_mesh();
|
bool get_snap_to_mesh() const;
|
||||||
void set_snap_to_mesh(bool value);
|
void set_snap_to_mesh(const bool value);
|
||||||
|
|
||||||
Vector3 get_snap_axis();
|
Vector3 get_snap_axis() const;
|
||||||
void set_snap_axis(Vector3 value);
|
void set_snap_axis(const Vector3 &value);
|
||||||
|
|
||||||
Ref<PropDataEntry> get_prop(const int index) const;
|
Ref<PropDataEntry> get_prop(const int index) const;
|
||||||
void set_prop(const int index, const Ref<PropDataEntry> prop);
|
void set_prop(const int index, const Ref<PropDataEntry> prop);
|
||||||
|
@ -781,11 +781,11 @@ void VoxelChunkDefault::_build_phase(int phase) {
|
|||||||
|
|
||||||
if (!mesher.is_valid()) {
|
if (!mesher.is_valid()) {
|
||||||
mesher = m;
|
mesher = m;
|
||||||
mesher->set_material(get_library()->get_material());
|
mesher->set_material(get_library()->get_material(0));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mesher->set_material(get_library()->get_material());
|
mesher->set_material(get_library()->get_material(0));
|
||||||
mesher->add_mesher(m);
|
mesher->add_mesher(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,8 +807,8 @@ void VoxelChunkDefault::_build_phase(int phase) {
|
|||||||
|
|
||||||
VS::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
VS::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||||
|
|
||||||
if (_library->get_material().is_valid())
|
if (_library->get_material(0).is_valid())
|
||||||
VS::get_singleton()->mesh_surface_set_material(_mesh_rid, 0, _library->get_material()->get_rid());
|
VS::get_singleton()->mesh_surface_set_material(_mesh_rid, 0, _library->get_material(0)->get_rid());
|
||||||
|
|
||||||
next_phase();
|
next_phase();
|
||||||
|
|
||||||
@ -834,7 +834,7 @@ void VoxelChunkDefault::_build_phase(int phase) {
|
|||||||
ERR_CONTINUE(!mesher.is_valid());
|
ERR_CONTINUE(!mesher.is_valid());
|
||||||
|
|
||||||
mesher->bake_colors(this);
|
mesher->bake_colors(this);
|
||||||
mesher->set_material(get_library()->get_material());
|
mesher->set_material(get_library()->get_material(0));
|
||||||
|
|
||||||
ERR_FAIL_COND(_prop_mesh_rid == RID());
|
ERR_FAIL_COND(_prop_mesh_rid == RID());
|
||||||
|
|
||||||
@ -849,8 +849,8 @@ void VoxelChunkDefault::_build_phase(int phase) {
|
|||||||
|
|
||||||
VS::get_singleton()->mesh_add_surface_from_arrays(_prop_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, arr);
|
VS::get_singleton()->mesh_add_surface_from_arrays(_prop_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, arr);
|
||||||
|
|
||||||
if (_library->get_material().is_valid())
|
if (_library->get_material(0).is_valid())
|
||||||
VS::get_singleton()->mesh_surface_set_material(_prop_mesh_rid, 0, _library->get_material()->get_rid());
|
VS::get_singleton()->mesh_surface_set_material(_prop_mesh_rid, 0, _library->get_material(0)->get_rid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user