summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/area.cpp4
-rw-r--r--scene/3d/camera.cpp12
-rw-r--r--scene/3d/immediate_geometry.cpp9
-rw-r--r--scene/3d/immediate_geometry.h2
-rw-r--r--scene/3d/light.cpp6
-rw-r--r--scene/3d/remote_transform.cpp132
-rw-r--r--scene/3d/remote_transform.h30
-rw-r--r--scene/3d/visual_instance.cpp4
8 files changed, 188 insertions, 11 deletions
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index a8a4122016..c1d0d1a97c 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -640,8 +640,8 @@ void Area::_bind_methods() {
ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
+ ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index e76c0938fb..76543b67c6 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -648,12 +648,16 @@ void Camera::_bind_methods() {
ObjectTypeDB::bind_method( _MD("get_zfar"),&Camera::get_zfar );
ObjectTypeDB::bind_method( _MD("get_znear"),&Camera::get_znear );
ObjectTypeDB::bind_method( _MD("get_projection"),&Camera::get_projection );
+ ObjectTypeDB::bind_method( _MD("set_h_offset","ofs"),&Camera::set_h_offset );
+ ObjectTypeDB::bind_method( _MD("get_h_offset"),&Camera::get_h_offset );
+ ObjectTypeDB::bind_method( _MD("set_v_offset","ofs"),&Camera::set_v_offset );
+ ObjectTypeDB::bind_method( _MD("get_v_offset"),&Camera::get_v_offset );
ObjectTypeDB::bind_method( _MD("set_visible_layers","mask"),&Camera::set_visible_layers );
ObjectTypeDB::bind_method( _MD("get_visible_layers"),&Camera::get_visible_layers );
- ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&Camera::set_environment);
- ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&Camera::get_environment);
- ObjectTypeDB::bind_method(_MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode);
- ObjectTypeDB::bind_method(_MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode);
+ ObjectTypeDB::bind_method( _MD("set_environment","env:Environment"),&Camera::set_environment );
+ ObjectTypeDB::bind_method( _MD("get_environment:Environment"),&Camera::get_environment );
+ ObjectTypeDB::bind_method( _MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode );
+ ObjectTypeDB::bind_method( _MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode );
//ObjectTypeDB::bind_method( _MD("_camera_make_current"),&Camera::_camera_make_current );
BIND_CONSTANT( PROJECTION_PERSPECTIVE );
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index e83fa69b4f..99c7fd047f 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -72,6 +72,7 @@ void ImmediateGeometry::add_vertex(const Vector3& p_vertex){
if (empty) {
aabb.pos=p_vertex;
aabb.size=Vector3();
+ empty=false;
} else {
aabb.expand_to(p_vertex);
}
@@ -102,7 +103,7 @@ DVector<Face3> ImmediateGeometry::get_faces(uint32_t p_usage_flags) const {
-void ImmediateGeometry::add_sphere(int p_lats,int p_lons,float p_radius) {
+void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) {
for(int i = 1; i <= p_lats; i++) {
double lat0 = Math_PI * (-0.5 + (double) (i - 1) / p_lats);
@@ -132,6 +133,10 @@ void ImmediateGeometry::add_sphere(int p_lats,int p_lons,float p_radius) {
};
#define ADD_POINT(m_idx)\
+ if (p_add_uv) {\
+ set_uv(Vector2(Math::atan2(v[m_idx].x,v[m_idx].z)/Math_PI * 0.5+0.5,v[m_idx].y*0.5+0.5));\
+ set_tangent(Plane(Vector3(-v[m_idx].z,v[m_idx].y,v[m_idx].x),1)); \
+ }\
set_normal(v[m_idx]);\
add_vertex(v[m_idx]*p_radius);
@@ -156,7 +161,7 @@ void ImmediateGeometry::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_uv","uv"),&ImmediateGeometry::set_uv);
ObjectTypeDB::bind_method(_MD("set_uv2","uv"),&ImmediateGeometry::set_uv2);
ObjectTypeDB::bind_method(_MD("add_vertex","pos"),&ImmediateGeometry::add_vertex);
- ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius"),&ImmediateGeometry::add_sphere);
+ ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius","add_uv"),&ImmediateGeometry::add_sphere,DEFVAL(true));
ObjectTypeDB::bind_method(_MD("end"),&ImmediateGeometry::end);
ObjectTypeDB::bind_method(_MD("clear"),&ImmediateGeometry::clear);
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h
index c1cc4f87d5..fc7f4de634 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry.h
@@ -62,7 +62,7 @@ public:
void clear();
- void add_sphere(int p_lats,int p_lons,float p_radius);
+ void add_sphere(int p_lats,int p_lons,float p_radius,bool p_add_uv=true);
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 227bb3a59d..5b221d1574 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -446,6 +446,10 @@ bool editor_ok=true;
editor_ok = (get_tree()->get_edited_scene_root() && (this==get_tree()->get_edited_scene_root() || get_owner()==get_tree()->get_edited_scene_root()));
}
}
+#else
+ if (editor_only) {
+ editor_ok=false;
+ }
#endif
VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible() && enabled && editor_ok);
@@ -672,5 +676,3 @@ void SpotLight::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/spot_attenuation", PROPERTY_HINT_EXP_EASING, "spot_attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ATTENUATION );
}
-
-
diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp
new file mode 100644
index 0000000000..d43870417a
--- /dev/null
+++ b/scene/3d/remote_transform.cpp
@@ -0,0 +1,132 @@
+
+/*************************************************************************/
+/* remote_transform.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "remote_transform.h"
+
+void RemoteTransform::_update_cache() {
+ cache=0;
+ if (has_node(remote_node)) {
+ Node *node = get_node(remote_node);
+ if (!node || this==node || node->is_a_parent_of(this) || this->is_a_parent_of(node)) {
+ return;
+ }
+
+ cache=node->get_instance_ID();
+ }
+}
+
+void RemoteTransform::_update_remote() {
+
+
+ if (!is_inside_tree())
+ return;
+
+ if (!cache)
+ return;
+
+ Object *obj = ObjectDB::get_instance(cache);
+ if (!obj)
+ return;
+
+ Spatial *n = obj->cast_to<Spatial>();
+ if (!n)
+ return;
+
+ if (!n->is_inside_tree())
+ return;
+
+ //todo make faster
+ n->set_global_transform(get_global_transform());
+
+}
+
+void RemoteTransform::_notification(int p_what) {
+
+ switch(p_what) {
+
+ case NOTIFICATION_READY: {
+
+ _update_cache();
+
+ } break;
+ case NOTIFICATION_TRANSFORM_CHANGED: {
+ if (!is_inside_tree())
+ break;
+
+ if (cache) {
+
+ _update_remote();
+
+ }
+
+ } break;
+
+ }
+}
+
+
+void RemoteTransform::set_remote_node(const NodePath& p_remote_node) {
+
+ remote_node=p_remote_node;
+ if (is_inside_tree())
+ _update_cache();
+
+ update_configuration_warning();
+}
+
+NodePath RemoteTransform::get_remote_node() const{
+
+ return remote_node;
+}
+
+
+String RemoteTransform::get_configuration_warning() const {
+
+ if (!has_node(remote_node) || !get_node(remote_node) || !get_node(remote_node)->cast_to<Spatial>()) {
+ return TTR("Path property must point to a valid Spatial node to work.");
+ }
+
+ return String();
+}
+
+void RemoteTransform::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform::set_remote_node);
+ ObjectTypeDB::bind_method(_MD("get_remote_node"),&RemoteTransform::get_remote_node);
+
+ ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),_SCS("set_remote_node"),_SCS("get_remote_node"));
+}
+
+RemoteTransform::RemoteTransform() {
+
+ cache=0;
+
+}
+
diff --git a/scene/3d/remote_transform.h b/scene/3d/remote_transform.h
new file mode 100644
index 0000000000..78f0fec1e9
--- /dev/null
+++ b/scene/3d/remote_transform.h
@@ -0,0 +1,30 @@
+#ifndef REMOTETRANSFORM_H
+#define REMOTETRANSFORM_H
+
+#include "scene/3d/spatial.h"
+
+class RemoteTransform : public Spatial
+{
+ OBJ_TYPE(RemoteTransform,Spatial);
+
+ NodePath remote_node;
+
+ ObjectID cache;
+
+ void _update_remote();
+ void _update_cache();
+
+protected:
+ static void _bind_methods();
+ void _notification(int p_what);
+public:
+ void set_remote_node(const NodePath& p_remote_node);
+ NodePath get_remote_node() const;
+
+ virtual String get_configuration_warning() const;
+
+ RemoteTransform();
+
+};
+
+#endif // REMOTETRANSFORM_H
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index b15226cce3..b4f7a4e5b4 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -128,6 +128,8 @@ void VisualInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"), &VisualInstance::set_layer_mask);
ObjectTypeDB::bind_method(_MD("get_layer_mask"), &VisualInstance::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb);
+
ADD_PROPERTY( PropertyInfo( Variant::INT, "layers",PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
@@ -376,6 +378,8 @@ void GeometryInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_extra_cull_margin","margin"), &GeometryInstance::set_extra_cull_margin);
ObjectTypeDB::bind_method(_MD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
+ ObjectTypeDB::bind_method(_MD("get_aabb"),&GeometryInstance::get_aabb);
+
ObjectTypeDB::bind_method(_MD("_baked_light_changed"), &GeometryInstance::_baked_light_changed);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE);