mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-22 10:57:30 +01:00
174 lines
6.2 KiB
C++
174 lines
6.2 KiB
C++
/*
|
|
Copyright (c) 2019-2020 Péter Magyar
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
|
|
#include "voxel_chunk_prop_data.h"
|
|
|
|
int VoxelChunkPropData::get_x() {
|
|
return _x;
|
|
}
|
|
void VoxelChunkPropData::set_x(int value) {
|
|
_x = value;
|
|
}
|
|
|
|
int VoxelChunkPropData::get_y() {
|
|
return _y;
|
|
}
|
|
void VoxelChunkPropData::set_y(int value) {
|
|
_y = value;
|
|
}
|
|
|
|
int VoxelChunkPropData::get_z() {
|
|
return _z;
|
|
}
|
|
void VoxelChunkPropData::set_z(int value) {
|
|
_z = value;
|
|
}
|
|
|
|
Vector3 VoxelChunkPropData::get_rotation() {
|
|
return _rotation;
|
|
}
|
|
void VoxelChunkPropData::set_rotation(Vector3 value) {
|
|
_rotation = value;
|
|
}
|
|
|
|
Vector3 VoxelChunkPropData::get_scale() {
|
|
return _scale;
|
|
}
|
|
void VoxelChunkPropData::set_scale(Vector3 value) {
|
|
_scale = value;
|
|
}
|
|
|
|
bool VoxelChunkPropData::get_snap_to_mesh() {
|
|
return _snap_to_mesh;
|
|
}
|
|
void VoxelChunkPropData::set_snap_to_mesh(bool value) {
|
|
_snap_to_mesh = value;
|
|
}
|
|
|
|
Vector3 VoxelChunkPropData::get_snap_axis() {
|
|
return _snap_axis;
|
|
}
|
|
void VoxelChunkPropData::set_snap_axis(Vector3 value) {
|
|
_snap_axis = value;
|
|
}
|
|
|
|
Ref<MeshDataResource> VoxelChunkPropData::get_mesh() const {
|
|
return _mesh;
|
|
}
|
|
void VoxelChunkPropData::set_mesh(const Ref<MeshDataResource> value) {
|
|
_mesh = value;
|
|
}
|
|
|
|
Ref<Texture> VoxelChunkPropData::get_mesh_texture() const {
|
|
return _texture;
|
|
}
|
|
void VoxelChunkPropData::set_mesh_texture(const Ref<Texture> value) {
|
|
_texture = value;
|
|
}
|
|
|
|
Ref<PropDataLight> VoxelChunkPropData::get_light() const {
|
|
return _light;
|
|
}
|
|
void VoxelChunkPropData::set_light(const Ref<PropDataLight> value) {
|
|
_light = value;
|
|
}
|
|
|
|
Ref<PropData> VoxelChunkPropData::get_prop() const {
|
|
return _prop;
|
|
}
|
|
void VoxelChunkPropData::set_prop(const Ref<PropData> value) {
|
|
_prop = value;
|
|
}
|
|
|
|
Ref<PackedScene> VoxelChunkPropData::get_scene() const {
|
|
return _scene;
|
|
}
|
|
void VoxelChunkPropData::set_scene(const Ref<PackedScene> value) {
|
|
_scene = value;
|
|
}
|
|
|
|
VoxelChunkPropData::VoxelChunkPropData() {
|
|
_x = 0;
|
|
_y = 0;
|
|
_z = 0;
|
|
_scale = Vector3(1, 1, 1);
|
|
_snap_to_mesh = false;
|
|
_snap_axis = Vector3(0, -1, 0);
|
|
}
|
|
VoxelChunkPropData::~VoxelChunkPropData() {
|
|
_mesh.unref();
|
|
_texture.unref();
|
|
_light.unref();
|
|
_prop.unref();
|
|
_scene.unref();
|
|
}
|
|
|
|
void VoxelChunkPropData::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("get_x"), &VoxelChunkPropData::get_x);
|
|
ClassDB::bind_method(D_METHOD("set_x", "value"), &VoxelChunkPropData::set_x);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "x"), "set_x", "get_x");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_y"), &VoxelChunkPropData::get_y);
|
|
ClassDB::bind_method(D_METHOD("set_y", "value"), &VoxelChunkPropData::set_y);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "y"), "set_y", "get_y");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_z"), &VoxelChunkPropData::get_z);
|
|
ClassDB::bind_method(D_METHOD("set_z", "value"), &VoxelChunkPropData::set_z);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "z"), "set_z", "get_z");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_rotation"), &VoxelChunkPropData::get_rotation);
|
|
ClassDB::bind_method(D_METHOD("set_rotation", "value"), &VoxelChunkPropData::set_rotation);
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation"), "set_rotation", "get_rotation");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_scale"), &VoxelChunkPropData::get_scale);
|
|
ClassDB::bind_method(D_METHOD("set_scale", "value"), &VoxelChunkPropData::set_scale);
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &VoxelChunkPropData::get_snap_to_mesh);
|
|
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &VoxelChunkPropData::set_snap_to_mesh);
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_snap_axis"), &VoxelChunkPropData::get_snap_axis);
|
|
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &VoxelChunkPropData::set_snap_axis);
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_mesh"), &VoxelChunkPropData::get_mesh);
|
|
ClassDB::bind_method(D_METHOD("set_mesh", "value"), &VoxelChunkPropData::set_mesh);
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_mesh_texture"), &VoxelChunkPropData::get_mesh_texture);
|
|
ClassDB::bind_method(D_METHOD("set_mesh_texture", "value"), &VoxelChunkPropData::set_mesh_texture);
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_mesh_texture", "get_mesh_texture");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_light"), &VoxelChunkPropData::get_light);
|
|
ClassDB::bind_method(D_METHOD("set_light", "value"), &VoxelChunkPropData::set_light);
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "PropDataLight"), "set_light", "get_light");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_prop"), &VoxelChunkPropData::get_prop);
|
|
ClassDB::bind_method(D_METHOD("set_prop", "value"), &VoxelChunkPropData::set_prop);
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop", "get_prop");
|
|
|
|
ClassDB::bind_method(D_METHOD("get_scene"), &VoxelChunkPropData::get_scene);
|
|
ClassDB::bind_method(D_METHOD("set_scene", "value"), &VoxelChunkPropData::set_scene);
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
|
|
}
|