mirror of
https://github.com/Relintai/props.git
synced 2024-11-12 10:15:25 +01:00
Moved PropData from Voxelman to here.
This commit is contained in:
parent
26cc4e9b3d
commit
3ede345c82
9
SCsub
9
SCsub
@ -14,6 +14,15 @@ sources = [
|
||||
|
||||
"register_types.cpp",
|
||||
|
||||
"props/prop_data.cpp",
|
||||
"props/prop_data_entry.cpp",
|
||||
"props/prop_data_scene.cpp",
|
||||
"props/prop_data_mesh.cpp",
|
||||
"props/prop_data_light.cpp",
|
||||
"props/prop_data_prop.cpp",
|
||||
"props/prop_data_entity.cpp",
|
||||
|
||||
|
||||
"clutter/ground_clutter.cpp",
|
||||
"clutter/ground_clutter_foliage.cpp",
|
||||
|
||||
|
@ -10,6 +10,13 @@ def configure(env):
|
||||
|
||||
def get_doc_classes():
|
||||
return [
|
||||
"PropDataEntity",
|
||||
"PropDataEntry",
|
||||
"PropDataLight",
|
||||
"PropDataMesh",
|
||||
"PropDataProp",
|
||||
"PropDataScene",
|
||||
"PropData",
|
||||
|
||||
"GroundClutterFoliage",
|
||||
"GroundClutter",
|
||||
|
265
props/prop_data.cpp
Normal file
265
props/prop_data.cpp
Normal file
@ -0,0 +1,265 @@
|
||||
/*
|
||||
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 "prop_data.h"
|
||||
|
||||
#include "prop_data_prop.h"
|
||||
|
||||
#include "../../voxelman/world/voxel_chunk.h"
|
||||
|
||||
int PropData::get_id() const {
|
||||
return _id;
|
||||
}
|
||||
void PropData::set_id(const int value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
bool PropData::get_snap_to_mesh() const {
|
||||
return _snap_to_mesh;
|
||||
}
|
||||
void PropData::set_snap_to_mesh(const bool value) {
|
||||
_snap_to_mesh = value;
|
||||
}
|
||||
|
||||
Vector3 PropData::get_snap_axis() const {
|
||||
return _snap_axis;
|
||||
}
|
||||
void PropData::set_snap_axis(const Vector3 &value) {
|
||||
_snap_axis = value;
|
||||
}
|
||||
|
||||
Ref<PropDataEntry> PropData::get_prop(const int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _props.size(), Ref<PropDataEntry>());
|
||||
|
||||
return _props.get(index);
|
||||
}
|
||||
void PropData::set_prop(const int index, const Ref<PropDataEntry> prop) {
|
||||
ERR_FAIL_INDEX(index, _props.size());
|
||||
|
||||
_props.set(index, prop);
|
||||
}
|
||||
void PropData::add_prop(const Ref<PropDataEntry> prop) {
|
||||
_props.push_back(prop);
|
||||
}
|
||||
void PropData::remove_prop(const int index) {
|
||||
ERR_FAIL_INDEX(index, _props.size());
|
||||
|
||||
_props.remove(index);
|
||||
}
|
||||
|
||||
int PropData::get_prop_count() const {
|
||||
return _props.size();
|
||||
}
|
||||
|
||||
Vector<Variant> PropData::get_props() {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _props.size(); i++) {
|
||||
r.push_back(_props[i].get_ref_ptr());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void PropData::set_props(const Vector<Variant> &props) {
|
||||
_props.clear();
|
||||
for (int i = 0; i < props.size(); i++) {
|
||||
Ref<PropDataEntry> prop = Ref<PropDataEntry>(props[i]);
|
||||
|
||||
_props.push_back(prop);
|
||||
}
|
||||
}
|
||||
|
||||
void PropData::add_textures_into(Ref<TexturePacker> texture_packer) {
|
||||
ERR_FAIL_COND(!texture_packer.is_valid());
|
||||
|
||||
for (int i = 0; i < _props.size(); ++i) {
|
||||
Ref<PropDataEntry> entry = _props.get(i);
|
||||
|
||||
Ref<PropDataMesh> pmesh = entry;
|
||||
|
||||
if (pmesh.is_valid() && pmesh->get_texture().is_valid()) {
|
||||
texture_packer->add_texture(pmesh->get_texture());
|
||||
}
|
||||
|
||||
Ref<PropDataProp> pdataprop = entry;
|
||||
|
||||
if (pdataprop.is_valid() && pdataprop->get_prop().is_valid()) {
|
||||
pdataprop->get_prop()->add_textures_into(texture_packer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PropData::add_prop_lights_into(Ref<VoxelChunk> chunk, Transform parent_transform, bool allow_snap) {
|
||||
ERR_FAIL_COND(!chunk.is_valid());
|
||||
|
||||
for (int i = 0; i < _props.size(); ++i) {
|
||||
Ref<PropDataEntry> entry = _props.get(i);
|
||||
|
||||
Ref<PropDataLight> pl = entry;
|
||||
|
||||
if (pl.is_valid()) {
|
||||
Transform t = parent_transform * pl->get_transform();
|
||||
|
||||
Vector3 px = t.origin / chunk->get_voxel_scale();
|
||||
|
||||
Ref<VoxelLight> vl;
|
||||
vl.instance();
|
||||
vl->set_world_position(px.x + chunk->get_position_x() * chunk->get_size_x(), px.y + chunk->get_position_y() * chunk->get_size_y(), px.z + chunk->get_position_z() * chunk->get_size_z());
|
||||
vl->set_color(pl->get_light_color());
|
||||
vl->set_size(pl->get_light_size());
|
||||
|
||||
chunk->bake_light(vl);
|
||||
}
|
||||
|
||||
Ref<PropDataProp> pdataprop = entry;
|
||||
|
||||
if (pdataprop.is_valid() && pdataprop->get_prop().is_valid()) {
|
||||
Ref<PropData> pd = pdataprop->get_prop();
|
||||
|
||||
if (allow_snap) {
|
||||
if (pd->get_snap_to_mesh())
|
||||
print_error(pd->get_name());
|
||||
|
||||
pd->add_prop_lights_into(chunk, get_next_snapped_prop_transform(chunk->get_voxel_world(), parent_transform * pdataprop->get_transform(), pd->get_snap_to_mesh(), pd->get_snap_axis()), allow_snap);
|
||||
} else {
|
||||
pd->add_prop_lights_into(chunk, parent_transform * pdataprop->get_transform(), allow_snap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PropData::add_meshes_into(Ref<VoxelMesher> mesher, Ref<TexturePacker> texture_packer, Transform parent_transform, Spatial *snap_spatial) {
|
||||
ERR_FAIL_COND(!mesher.is_valid());
|
||||
ERR_FAIL_COND(!texture_packer.is_valid());
|
||||
ERR_FAIL_COND(texture_packer->get_generated_texture_count() == 0);
|
||||
ERR_FAIL_COND(snap_spatial != NULL && !ObjectDB::instance_validate(snap_spatial));
|
||||
|
||||
Vector2 texsize = texture_packer->get_generated_texture(0)->get_size();
|
||||
|
||||
for (int i = 0; i < _props.size(); ++i) {
|
||||
Ref<PropDataEntry> entry = _props.get(i);
|
||||
|
||||
Ref<PropDataMesh> pmesh = entry;
|
||||
|
||||
if (pmesh.is_valid()) {
|
||||
|
||||
Rect2 reg = Rect2(0, 0, 1, 1);
|
||||
|
||||
if (pmesh->get_texture().is_valid()) {
|
||||
|
||||
Ref<AtlasTexture> at = texture_packer->get_texture(pmesh->get_texture());
|
||||
|
||||
reg = at->get_region();
|
||||
|
||||
reg.position.x /= texsize.x;
|
||||
reg.position.y /= texsize.y;
|
||||
reg.size.x /= texsize.x;
|
||||
reg.size.y /= texsize.y;
|
||||
}
|
||||
|
||||
if (snap_spatial != NULL)
|
||||
mesher->add_mesh_data_resource_transform(pmesh->get_mesh(), get_next_snapped_prop_transform(snap_spatial, parent_transform * pmesh->get_transform(), pmesh->get_snap_to_mesh(), pmesh->get_snap_axis()), reg);
|
||||
else
|
||||
mesher->add_mesh_data_resource_transform(pmesh->get_mesh(), parent_transform * pmesh->get_transform(), reg);
|
||||
}
|
||||
|
||||
Ref<PropDataProp> pdataprop = entry;
|
||||
|
||||
if (pdataprop.is_valid() && pdataprop->get_prop().is_valid()) {
|
||||
|
||||
if (snap_spatial != NULL)
|
||||
pdataprop->get_prop()->add_meshes_into(mesher, texture_packer, get_next_snapped_prop_transform(snap_spatial, parent_transform * pdataprop->get_transform(), pdataprop->get_snap_to_mesh(), pdataprop->get_snap_axis()), snap_spatial);
|
||||
else
|
||||
pdataprop->get_prop()->add_meshes_into(mesher, texture_packer, parent_transform * pmesh->get_transform(), snap_spatial);
|
||||
}
|
||||
}
|
||||
}
|
||||
void PropData::add_meshes_into_bind(Ref<VoxelMesher> mesher, Ref<TexturePacker> texture_packer, Transform parent_transform, Node *snap_spatial) {
|
||||
Spatial *s = Object::cast_to<Spatial>(snap_spatial);
|
||||
|
||||
ERR_FAIL_COND(s != NULL && !ObjectDB::instance_validate(s));
|
||||
|
||||
add_meshes_into(mesher, texture_packer, parent_transform, s);
|
||||
}
|
||||
|
||||
Transform PropData::get_next_snapped_prop_transform(Spatial *s, Transform parent_transform, bool snap_to_mesh, Vector3 snap_axis) {
|
||||
if (snap_to_mesh) {
|
||||
Vector3 pos = s->to_global(parent_transform.origin);
|
||||
Vector3 world_snap_axis = s->to_global(parent_transform.xform(snap_axis));
|
||||
Vector3 world_snap_dir = world_snap_axis - pos;
|
||||
world_snap_dir *= 100;
|
||||
|
||||
PhysicsDirectSpaceState *space_state = s->get_world()->get_direct_space_state();
|
||||
|
||||
ERR_FAIL_COND_V(space_state == NULL, parent_transform);
|
||||
|
||||
PhysicsDirectSpaceState::RayResult res;
|
||||
|
||||
if (space_state->intersect_ray(pos - world_snap_dir, pos + world_snap_dir, res, Set<RID>(), 1)) {
|
||||
parent_transform.origin = s->to_local(res.position);
|
||||
}
|
||||
}
|
||||
|
||||
return parent_transform;
|
||||
}
|
||||
Transform PropData::get_next_snapped_prop_transform_bind(Node *spatial, Transform parent_transform, bool snap_to_mesh, Vector3 snap_axis) {
|
||||
Spatial *s = Object::cast_to<Spatial>(spatial);
|
||||
|
||||
ERR_FAIL_COND_V(!ObjectDB::instance_validate(s), parent_transform);
|
||||
|
||||
return get_next_snapped_prop_transform(s, parent_transform, snap_to_mesh, snap_axis);
|
||||
}
|
||||
|
||||
PropData::PropData() {
|
||||
_id = 0;
|
||||
_snap_to_mesh = false;
|
||||
_snap_axis = Vector3(0, -1, 0);
|
||||
}
|
||||
PropData::~PropData() {
|
||||
_props.clear();
|
||||
}
|
||||
|
||||
void PropData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropData::get_snap_to_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropData::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"), &PropData::get_snap_axis);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropData::set_snap_axis);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_prop", "index"), &PropData::get_prop);
|
||||
ClassDB::bind_method(D_METHOD("set_prop", "index", "spell"), &PropData::set_prop);
|
||||
ClassDB::bind_method(D_METHOD("add_prop", "prop"), &PropData::add_prop);
|
||||
ClassDB::bind_method(D_METHOD("remove_prop", "index"), &PropData::remove_prop);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_prop_count"), &PropData::get_prop_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_props"), &PropData::get_props);
|
||||
ClassDB::bind_method(D_METHOD("set_props", "props"), &PropData::set_props);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PropDataEntry", PROPERTY_USAGE_DEFAULT, "PropDataEntry"), "set_props", "get_props");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData::add_textures_into);
|
||||
ClassDB::bind_method(D_METHOD("add_prop_lights_into", "chunk", "parent_transform", "allow_snap"), &PropData::add_prop_lights_into);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_meshes_into", "mesher", "texture_packer", "parent_transform", "snap_spatial"), &PropData::add_meshes_into_bind);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_next_snapped_prop_transform", "spatial", "parent_transform", "snap_to_mesh", "snap_axis"), &PropData::get_next_snapped_prop_transform_bind);
|
||||
}
|
90
props/prop_data.h
Normal file
90
props/prop_data.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PROP_DATA_H
|
||||
#define PROP_DATA_H
|
||||
|
||||
#include "core/math/rect2.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/vector2.h"
|
||||
#include "core/math/vector3.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "servers/physics_server.h"
|
||||
|
||||
#include "prop_data_entry.h"
|
||||
#include "prop_data_mesh.h"
|
||||
|
||||
#include "../../voxelman/meshers/voxel_mesher.h"
|
||||
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
|
||||
class Spatial;
|
||||
class VoxelChunk;
|
||||
|
||||
class PropData : public Resource {
|
||||
GDCLASS(PropData, Resource);
|
||||
|
||||
public:
|
||||
int get_id() const;
|
||||
void set_id(const int value);
|
||||
|
||||
bool get_snap_to_mesh() const;
|
||||
void set_snap_to_mesh(const bool value);
|
||||
|
||||
Vector3 get_snap_axis() const;
|
||||
void set_snap_axis(const Vector3 &value);
|
||||
|
||||
Ref<PropDataEntry> get_prop(const int index) const;
|
||||
void set_prop(const int index, const Ref<PropDataEntry> prop);
|
||||
void add_prop(const Ref<PropDataEntry> prop);
|
||||
void remove_prop(const int index);
|
||||
|
||||
int get_prop_count() const;
|
||||
|
||||
Vector<Variant> get_props();
|
||||
void set_props(const Vector<Variant> &props);
|
||||
|
||||
void add_textures_into(Ref<TexturePacker> texture_packer);
|
||||
void add_prop_lights_into(Ref<VoxelChunk> chunk, Transform parent_transform, bool allow_snap);
|
||||
void add_meshes_into(Ref<VoxelMesher> mesher, Ref<TexturePacker> texture_packer, Transform parent_transform, Spatial *snap_spatial = NULL);
|
||||
void add_meshes_into_bind(Ref<VoxelMesher> mesher, Ref<TexturePacker> texture_packer, Transform parent_transform, Node *snap_spatial = NULL);
|
||||
|
||||
Transform get_next_snapped_prop_transform(Spatial *s, Transform parent_transform, bool snap_to_mesh, Vector3 snap_axis);
|
||||
Transform get_next_snapped_prop_transform_bind(Node *spatial, Transform parent_transform, bool snap_to_mesh, Vector3 snap_axis);
|
||||
|
||||
PropData();
|
||||
~PropData();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _id;
|
||||
bool _snap_to_mesh;
|
||||
Vector3 _snap_axis;
|
||||
|
||||
Vector<Ref<PropDataEntry> > _props;
|
||||
};
|
||||
|
||||
#endif
|
54
props/prop_data_entity.cpp
Normal file
54
props/prop_data_entity.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
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 "prop_data_entity.h"
|
||||
|
||||
int PropDataEntity::get_entity_data_id() const {
|
||||
return _entity_data_id;
|
||||
}
|
||||
void PropDataEntity::set_entity_data_id(const int value) {
|
||||
_entity_data_id = value;
|
||||
}
|
||||
|
||||
int PropDataEntity::get_level() const {
|
||||
return _level;
|
||||
}
|
||||
void PropDataEntity::set_level(const int value) {
|
||||
_level = value;
|
||||
}
|
||||
|
||||
PropDataEntity::PropDataEntity() {
|
||||
_entity_data_id = 0;
|
||||
_level = 1;
|
||||
}
|
||||
PropDataEntity::~PropDataEntity() {
|
||||
}
|
||||
|
||||
void PropDataEntity::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_id"), &PropDataEntity::get_entity_data_id);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_data_id", "value"), &PropDataEntity::set_entity_data_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "entity_data_id"), "set_entity_data_id", "get_entity_data_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_level"), &PropDataEntity::get_level);
|
||||
ClassDB::bind_method(D_METHOD("set_level", "value"), &PropDataEntity::set_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "level"), "set_level", "get_level");
|
||||
}
|
49
props/prop_data_entity.h
Normal file
49
props/prop_data_entity.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PROP_DATA_ENTITY_H
|
||||
#define PROP_DATA_ENTITY_H
|
||||
|
||||
#include "prop_data_entry.h"
|
||||
|
||||
class PropDataEntity : public PropDataEntry {
|
||||
GDCLASS(PropDataEntity, PropDataEntry);
|
||||
|
||||
public:
|
||||
int get_entity_data_id() const;
|
||||
void set_entity_data_id(const int value);
|
||||
|
||||
int get_level() const;
|
||||
void set_level(const int value);
|
||||
|
||||
PropDataEntity();
|
||||
~PropDataEntity();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _level;
|
||||
int _entity_data_id;
|
||||
};
|
||||
|
||||
#endif
|
41
props/prop_data_entry.cpp
Normal file
41
props/prop_data_entry.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
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 "prop_data_entry.h"
|
||||
|
||||
Transform PropDataEntry::get_transform() const {
|
||||
return _transform;
|
||||
}
|
||||
void PropDataEntry::set_transform(const Transform value) {
|
||||
_transform = value;
|
||||
}
|
||||
|
||||
PropDataEntry::PropDataEntry() {
|
||||
}
|
||||
PropDataEntry::~PropDataEntry() {
|
||||
}
|
||||
|
||||
void PropDataEntry::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_transform"), &PropDataEntry::get_transform);
|
||||
ClassDB::bind_method(D_METHOD("set_transform", "value"), &PropDataEntry::set_transform);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform");
|
||||
}
|
46
props/prop_data_entry.h
Normal file
46
props/prop_data_entry.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PROP_DATA_DATA_H
|
||||
#define PROP_DATA_DATA_H
|
||||
|
||||
#include "core/math/transform.h"
|
||||
#include "core/resource.h"
|
||||
|
||||
class PropDataEntry : public Resource {
|
||||
GDCLASS(PropDataEntry, Resource);
|
||||
|
||||
public:
|
||||
Transform get_transform() const;
|
||||
void set_transform(const Transform value);
|
||||
|
||||
PropDataEntry();
|
||||
~PropDataEntry();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Transform _transform;
|
||||
};
|
||||
|
||||
#endif
|
53
props/prop_data_light.cpp
Normal file
53
props/prop_data_light.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
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 "prop_data_light.h"
|
||||
|
||||
Color PropDataLight::get_light_color() const {
|
||||
return _light_color;
|
||||
}
|
||||
void PropDataLight::set_light_color(const Color value) {
|
||||
_light_color = value;
|
||||
}
|
||||
|
||||
int PropDataLight::get_light_size() const {
|
||||
return _light_size;
|
||||
}
|
||||
void PropDataLight::set_light_size(const int value) {
|
||||
_light_size = value;
|
||||
}
|
||||
|
||||
PropDataLight::PropDataLight() {
|
||||
_light_size = 5;
|
||||
}
|
||||
PropDataLight::~PropDataLight() {
|
||||
}
|
||||
|
||||
void PropDataLight::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_light_color"), &PropDataLight::get_light_color);
|
||||
ClassDB::bind_method(D_METHOD("set_light_color", "value"), &PropDataLight::set_light_color);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), "set_light_color", "get_light_color");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_light_size"), &PropDataLight::get_light_size);
|
||||
ClassDB::bind_method(D_METHOD("set_light_size", "value"), &PropDataLight::set_light_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_size"), "set_light_size", "get_light_size");
|
||||
}
|
51
props/prop_data_light.h
Normal file
51
props/prop_data_light.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PROP_DATA_LIGHT_H
|
||||
#define PROP_DATA_LIGHT_H
|
||||
|
||||
#include "prop_data_entry.h"
|
||||
|
||||
#include "core/color.h"
|
||||
|
||||
class PropDataLight : public PropDataEntry {
|
||||
GDCLASS(PropDataLight, PropDataEntry);
|
||||
|
||||
public:
|
||||
Color get_light_color() const;
|
||||
void set_light_color(const Color value);
|
||||
|
||||
int get_light_size() const;
|
||||
void set_light_size(const int value);
|
||||
|
||||
PropDataLight();
|
||||
~PropDataLight();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Color _light_color;
|
||||
int _light_size;
|
||||
};
|
||||
|
||||
#endif
|
78
props/prop_data_mesh.cpp
Normal file
78
props/prop_data_mesh.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
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 "prop_data_mesh.h"
|
||||
|
||||
Ref<MeshDataResource> PropDataMesh::get_mesh() const {
|
||||
return _mesh;
|
||||
}
|
||||
void PropDataMesh::set_mesh(const Ref<MeshDataResource> mesh) {
|
||||
_mesh = mesh;
|
||||
}
|
||||
|
||||
Ref<Texture> PropDataMesh::get_texture() const {
|
||||
return _texture;
|
||||
}
|
||||
void PropDataMesh::set_texture(const Ref<Texture> texture) {
|
||||
_texture = texture;
|
||||
}
|
||||
|
||||
bool PropDataMesh::get_snap_to_mesh() {
|
||||
return _snap_to_mesh;
|
||||
}
|
||||
void PropDataMesh::set_snap_to_mesh(bool value) {
|
||||
_snap_to_mesh = value;
|
||||
}
|
||||
|
||||
Vector3 PropDataMesh::get_snap_axis() {
|
||||
return _snap_axis;
|
||||
}
|
||||
void PropDataMesh::set_snap_axis(Vector3 value) {
|
||||
_snap_axis = value;
|
||||
}
|
||||
|
||||
PropDataMesh::PropDataMesh() {
|
||||
_snap_to_mesh = true;
|
||||
_snap_axis = Vector3(0, 1, 0);
|
||||
}
|
||||
PropDataMesh::~PropDataMesh() {
|
||||
if (_mesh.is_valid())
|
||||
_mesh.unref();
|
||||
}
|
||||
|
||||
void PropDataMesh::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &PropDataMesh::get_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_mesh", "value"), &PropDataMesh::set_mesh);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_texture"), &PropDataMesh::get_texture);
|
||||
ClassDB::bind_method(D_METHOD("set_texture", "value"), &PropDataMesh::set_texture);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataMesh::get_snap_to_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataMesh::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"), &PropDataMesh::get_snap_axis);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataMesh::set_snap_axis);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
|
||||
}
|
62
props/prop_data_mesh.h
Normal file
62
props/prop_data_mesh.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PROP_DATA_MESH_H
|
||||
#define PROP_DATA_MESH_H
|
||||
|
||||
#include "core/math/vector3.h"
|
||||
#include "prop_data_entry.h"
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#include "../../mesh_data_resource/mesh_data_resource.h"
|
||||
|
||||
class PropDataMesh : public PropDataEntry {
|
||||
GDCLASS(PropDataMesh, PropDataEntry);
|
||||
|
||||
public:
|
||||
Ref<MeshDataResource> get_mesh() const;
|
||||
void set_mesh(const Ref<MeshDataResource> mesh);
|
||||
|
||||
Ref<Texture> get_texture() const;
|
||||
void set_texture(const Ref<Texture> texture);
|
||||
|
||||
bool get_snap_to_mesh();
|
||||
void set_snap_to_mesh(bool value);
|
||||
|
||||
Vector3 get_snap_axis();
|
||||
void set_snap_axis(Vector3 value);
|
||||
|
||||
PropDataMesh();
|
||||
~PropDataMesh();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
bool _snap_to_mesh;
|
||||
Vector3 _snap_axis;
|
||||
Ref<MeshDataResource> _mesh;
|
||||
Ref<Texture> _texture;
|
||||
};
|
||||
|
||||
#endif
|
67
props/prop_data_prop.cpp
Normal file
67
props/prop_data_prop.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
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 "prop_data_prop.h"
|
||||
|
||||
Ref<PropData> PropDataProp::get_prop() const {
|
||||
return _prop;
|
||||
}
|
||||
void PropDataProp::set_prop(const Ref<PropData> value) {
|
||||
_prop = value;
|
||||
}
|
||||
|
||||
bool PropDataProp::get_snap_to_mesh() {
|
||||
return _snap_to_mesh;
|
||||
}
|
||||
void PropDataProp::set_snap_to_mesh(bool value) {
|
||||
_snap_to_mesh = value;
|
||||
}
|
||||
|
||||
Vector3 PropDataProp::get_snap_axis() {
|
||||
return _snap_axis;
|
||||
}
|
||||
void PropDataProp::set_snap_axis(Vector3 value) {
|
||||
_snap_axis = value;
|
||||
}
|
||||
|
||||
PropDataProp::PropDataProp() {
|
||||
_snap_to_mesh = false;
|
||||
_snap_axis = Vector3(0, 1, 0);
|
||||
}
|
||||
PropDataProp::~PropDataProp() {
|
||||
if (_prop.is_valid())
|
||||
_prop.unref();
|
||||
}
|
||||
|
||||
void PropDataProp::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_prop"), &PropDataProp::get_prop);
|
||||
ClassDB::bind_method(D_METHOD("set_prop", "value"), &PropDataProp::set_prop);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop", "get_prop");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataProp::get_snap_to_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataProp::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"), &PropDataProp::get_snap_axis);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataProp::set_snap_axis);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
|
||||
}
|
56
props/prop_data_prop.h
Normal file
56
props/prop_data_prop.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PROP_DATA_PROP_H
|
||||
#define PROP_DATA_PROP_H
|
||||
|
||||
#include "core/math/vector3.h"
|
||||
#include "prop_data_entry.h"
|
||||
|
||||
#include "prop_data.h"
|
||||
|
||||
class PropDataProp : public PropDataEntry {
|
||||
GDCLASS(PropDataProp, PropDataEntry);
|
||||
|
||||
public:
|
||||
Ref<PropData> get_prop() const;
|
||||
void set_prop(const Ref<PropData> value);
|
||||
|
||||
bool get_snap_to_mesh();
|
||||
void set_snap_to_mesh(bool value);
|
||||
|
||||
Vector3 get_snap_axis();
|
||||
void set_snap_axis(Vector3 value);
|
||||
|
||||
PropDataProp();
|
||||
~PropDataProp();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
bool _snap_to_mesh;
|
||||
Vector3 _snap_axis;
|
||||
Ref<PropData> _prop;
|
||||
};
|
||||
|
||||
#endif
|
67
props/prop_data_scene.cpp
Normal file
67
props/prop_data_scene.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
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 "prop_data_scene.h"
|
||||
|
||||
Ref<PackedScene> PropDataScene::get_scene() const {
|
||||
return _scene;
|
||||
}
|
||||
void PropDataScene::set_scene(const Ref<PackedScene> value) {
|
||||
_scene = value;
|
||||
}
|
||||
|
||||
bool PropDataScene::get_snap_to_mesh() {
|
||||
return _snap_to_mesh;
|
||||
}
|
||||
void PropDataScene::set_snap_to_mesh(bool value) {
|
||||
_snap_to_mesh = value;
|
||||
}
|
||||
|
||||
Vector3 PropDataScene::get_snap_axis() {
|
||||
return _snap_axis;
|
||||
}
|
||||
void PropDataScene::set_snap_axis(Vector3 value) {
|
||||
_snap_axis = value;
|
||||
}
|
||||
|
||||
PropDataScene::PropDataScene() {
|
||||
_snap_to_mesh = true;
|
||||
_snap_axis = Vector3(0, 1, 0);
|
||||
}
|
||||
PropDataScene::~PropDataScene() {
|
||||
if (_scene.is_valid())
|
||||
_scene.unref();
|
||||
}
|
||||
|
||||
void PropDataScene::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_scene"), &PropDataScene::get_scene);
|
||||
ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropDataScene::set_scene);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataScene::get_snap_to_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataScene::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"), &PropDataScene::get_snap_axis);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataScene::set_snap_axis);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
|
||||
}
|
56
props/prop_data_scene.h
Normal file
56
props/prop_data_scene.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PROP_DATA_SCENE_H
|
||||
#define PROP_DATA_SCENE_H
|
||||
|
||||
#include "core/math/vector3.h"
|
||||
#include "prop_data_entry.h"
|
||||
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
class PropDataScene : public PropDataEntry {
|
||||
GDCLASS(PropDataScene, PropDataEntry);
|
||||
|
||||
public:
|
||||
Ref<PackedScene> get_scene() const;
|
||||
void set_scene(const Ref<PackedScene> value);
|
||||
|
||||
bool get_snap_to_mesh();
|
||||
void set_snap_to_mesh(bool value);
|
||||
|
||||
Vector3 get_snap_axis();
|
||||
void set_snap_axis(Vector3 value);
|
||||
|
||||
PropDataScene();
|
||||
~PropDataScene();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
bool _snap_to_mesh;
|
||||
Vector3 _snap_axis;
|
||||
Ref<PackedScene> _scene;
|
||||
};
|
||||
|
||||
#endif
|
@ -22,6 +22,14 @@ SOFTWARE.
|
||||
|
||||
#include "register_types.h"
|
||||
|
||||
#include "props/prop_data.h"
|
||||
#include "props/prop_data_entity.h"
|
||||
#include "props/prop_data_entry.h"
|
||||
#include "props/prop_data_light.h"
|
||||
#include "props/prop_data_mesh.h"
|
||||
#include "props/prop_data_prop.h"
|
||||
#include "props/prop_data_scene.h"
|
||||
|
||||
#include "clutter/ground_clutter.h"
|
||||
#include "clutter/ground_clutter_foliage.h"
|
||||
|
||||
@ -35,6 +43,14 @@ SOFTWARE.
|
||||
#include "prop_instance_job.h"
|
||||
|
||||
void register_props_types() {
|
||||
ClassDB::register_class<PropData>();
|
||||
ClassDB::register_class<PropDataEntry>();
|
||||
ClassDB::register_class<PropDataScene>();
|
||||
ClassDB::register_class<PropDataMesh>();
|
||||
ClassDB::register_class<PropDataLight>();
|
||||
ClassDB::register_class<PropDataProp>();
|
||||
ClassDB::register_class<PropDataEntity>();
|
||||
|
||||
ClassDB::register_class<GroundClutter>();
|
||||
ClassDB::register_class<GroundClutterFoliage>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user