diff --git a/prop_tool/prop_tool_light.cpp b/prop_tool/prop_tool_light.cpp new file mode 100644 index 0000000..d3059bd --- /dev/null +++ b/prop_tool/prop_tool_light.cpp @@ -0,0 +1,48 @@ +/* +Copyright (c) 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_tool_light.h" + +/* + +var _prop_light : PropDataLight + +func get_data() -> PropDataLight: + if not visible: + return null + + if _prop_light == null: + _prop_light = PropDataLight.new() + + _prop_light.light_color = light_color + _prop_light.light_size = omni_range + + return _prop_light + +func set_data(light : PropDataLight) -> void: + _prop_light = light + + light_color = _prop_light.light_color + omni_range = _prop_light.light_size + light_energy = _prop_light.light_size + +*/ \ No newline at end of file diff --git a/prop_tool/prop_tool_light.h b/prop_tool/prop_tool_light.h new file mode 100644 index 0000000..6e8144a --- /dev/null +++ b/prop_tool/prop_tool_light.h @@ -0,0 +1,60 @@ +/* +Copyright (c) 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_TOOL_LIGHT_H +#define PROP_TOOL_LIGHT_H + +class EditorNode; +class EditorPlugin; +class PropData; + +#include "../props/prop_data_light.h" +#include "scene/3d/light.h" + +class propData; + +class PropToolLight : public OmniLight { + GDCLASS(PropToolLight, OmniLight); + +public: + Ref get_data(); + void set_data(const Ref &data); + + bool get_snap_to_mesh() const; + void set_snap_to_mesh(const bool value); + + void generate(); + + PropToolLight(); + ~PropToolLight(); + +protected: + void set_generate(bool value); + + static void _bind_methods(); + +private: + Ref _prop_mesh; + bool _snap_to_mesh; +}; + +#endif diff --git a/prop_tool/prop_tool_mesh.cpp b/prop_tool/prop_tool_mesh.cpp new file mode 100644 index 0000000..d0b409f --- /dev/null +++ b/prop_tool/prop_tool_mesh.cpp @@ -0,0 +1,113 @@ +/* +Copyright (c) 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_tool_mesh.h" + +/* +tool +extends MeshInstance +class_name PropToolMesh + +export(MeshDataResource) var mesh_data : MeshDataResource setget set_prop_mesh +export(Texture) var texture : Texture setget set_texture +export(bool) var snap_to_mesh : bool = false +export(Vector3) var snap_axis : Vector3 = Vector3(0, -1, 0) + +export(bool) var generate : bool setget set_generate + +var _prop_mesh : PropDataMesh +var _material : SpatialMaterial + +func get_data() -> PropDataMesh: + if not visible or mesh_data == null: + return null + + if _prop_mesh == null: + _prop_mesh = PropDataMesh.new() + + _prop_mesh.mesh = mesh_data + _prop_mesh.texture = texture + _prop_mesh.snap_to_mesh = snap_to_mesh + _prop_mesh.snap_axis = snap_axis + + return _prop_mesh + +func set_data(data : PropDataMesh) -> void: + _prop_mesh = data + + set_texture(_prop_mesh.texture) + set_prop_mesh(_prop_mesh.mesh) + + snap_to_mesh = _prop_mesh.snap_to_mesh + snap_axis = _prop_mesh.snap_axis + +func set_prop_mesh(md : MeshDataResource) -> void: + mesh_data = md + + set_generate(true) + +func set_texture(tex : Texture) -> void: + texture = tex + +func set_generate(val : bool) -> void: + if val: + if !mesh_data: + mesh = null + return + + var m : ArrayMesh = ArrayMesh.new() + + var arr = [] + arr.resize(ArrayMesh.ARRAY_MAX) + + var v : PoolVector3Array = PoolVector3Array() + v.append_array(mesh_data.array[Mesh.ARRAY_VERTEX]) + arr[Mesh.ARRAY_VERTEX] = v + + var norm : PoolVector3Array = PoolVector3Array() + norm.append_array(mesh_data.array[Mesh.ARRAY_NORMAL]) + arr[Mesh.ARRAY_NORMAL] = norm + + var uv : PoolVector2Array = PoolVector2Array() + uv.append_array(mesh_data.array[Mesh.ARRAY_TEX_UV]) + arr[Mesh.ARRAY_TEX_UV] = uv + + var ind : PoolIntArray = PoolIntArray() + ind.append_array(mesh_data.array[Mesh.ARRAY_INDEX]) + arr[Mesh.ARRAY_INDEX] = ind + + m.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arr) + + mesh = m + + if texture != null: + if _material == null: + _material = SpatialMaterial.new() + + _material.albedo_texture = texture + + material_override = _material + + + + +*/ \ No newline at end of file diff --git a/prop_tool/prop_tool_mesh.h b/prop_tool/prop_tool_mesh.h new file mode 100644 index 0000000..47f4996 --- /dev/null +++ b/prop_tool/prop_tool_mesh.h @@ -0,0 +1,67 @@ +/* +Copyright (c) 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_TOOL_MESH_H +#define PROP_TOOL_MESH_H + +class EditorNode; +class EditorPlugin; +class PropData; + +#include "../props/prop_data_mesh.h" +#include "scene/3d/mesh_instance.h" + +class propData; + +class PropToolMesh : public MeshInstance { + GDCLASS(PropToolMesh, MeshInstance); + +public: + Ref get_data(); + void set_data(const Ref &data); + + Ref get_texture(); + void set_texture(const Ref &tex); + + bool get_snap_to_mesh() const; + void set_snap_to_mesh(const bool value); + + Ref get_prop_mesh(); + void set_prop_mesh(const Ref &data); + + void generate(); + + PropToolMesh(); + ~PropToolMesh(); + +protected: + void set_generate(bool value); + + static void _bind_methods(); + +private: + Ref _prop_mesh; + Ref _material; + bool _snap_to_mesh; +}; + +#endif