summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/camera.cpp24
-rw-r--r--scene/3d/camera.h2
-rw-r--r--scene/3d/spatial.cpp113
-rw-r--r--scene/3d/spatial.h15
-rw-r--r--scene/3d/visual_instance.cpp15
-rw-r--r--scene/3d/visual_instance.h4
6 files changed, 150 insertions, 23 deletions
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 95eafa0df4..db69182ca0 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -152,11 +152,11 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
case PROJECTION_PERSPECTIVE: {
- p_list->push_back( PropertyInfo( Variant::REAL, "fov" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_NOEDITOR) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "fov" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_NOEDITOR) );
if (keep_aspect==KEEP_WIDTH)
- p_list->push_back( PropertyInfo( Variant::REAL, "fovx" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_EDITOR) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "fovx" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_EDITOR) );
else
- p_list->push_back( PropertyInfo( Variant::REAL, "fovy" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_EDITOR) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "fovy" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_EDITOR) );
} break;
@@ -680,8 +680,6 @@ void Camera::_bind_methods() {
ObjectTypeDB::bind_method( _MD("get_projection"),&Camera::get_projection );
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("look_at","target","up"),&Camera::look_at );
- ObjectTypeDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Camera::look_at_from_pos );
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);
@@ -752,22 +750,6 @@ Vector<Plane> Camera::get_frustum() const {
-void Camera::look_at(const Vector3& p_target, const Vector3& p_up_normal) {
-
- Transform lookat;
- lookat.origin=get_camera_transform().origin;
- lookat=lookat.looking_at(p_target,p_up_normal);
- set_global_transform(lookat);
-}
-
-void Camera::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal) {
-
- Transform lookat;
- lookat.origin=p_pos;
- lookat=lookat.looking_at(p_target,p_up_normal);
- set_global_transform(lookat);
-
-}
void Camera::set_v_offset(float p_offset) {
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 950688dfda..de03282021 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -139,8 +139,6 @@ public:
void set_keep_aspect_mode(KeepAspect p_aspect);
KeepAspect get_keep_aspect_mode() const;
- void look_at(const Vector3& p_target, const Vector3& p_up_normal);
- void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
void set_v_offset(float p_offset);
float get_v_offset() const;
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index a5b009823c..6e11855543 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -593,6 +593,97 @@ bool Spatial::_is_visible_() const {
return !is_hidden();
}
+void Spatial::rotate(const Vector3& p_normal,float p_radians) {
+
+ Transform t =get_transform();
+ t.basis.rotate(p_normal,p_radians);
+ set_transform(t);
+}
+
+void Spatial::rotate_x(float p_radians) {
+
+ Transform t =get_transform();
+ t.basis.rotate(Vector3(1,0,0),p_radians);
+ set_transform(t);
+
+}
+
+void Spatial::rotate_y(float p_radians){
+
+ Transform t =get_transform();
+ t.basis.rotate(Vector3(0,1,0),p_radians);
+ set_transform(t);
+
+}
+void Spatial::rotate_z(float p_radians){
+
+ Transform t =get_transform();
+ t.basis.rotate(Vector3(0,0,1),p_radians);
+ set_transform(t);
+
+}
+
+void Spatial::translate(const Vector3& p_offset){
+
+ Transform t =get_transform();
+ t.origin+=p_offset;
+ set_transform(t);
+
+}
+void Spatial::scale(const Vector3& p_ratio){
+
+ Transform t =get_transform();
+ t.basis.scale(p_ratio);
+ set_transform(t);
+
+}
+void Spatial::global_rotate(const Vector3& p_normal,float p_radians){
+
+ Matrix3 rotation(p_normal,p_radians);
+ Transform t = get_global_transform();
+ t.basis= rotation * t.basis;
+ set_global_transform(t);
+
+}
+void Spatial::global_translate(const Vector3& p_offset){
+ Transform t = get_global_transform();
+ t.origin+=p_offset;
+ set_global_transform(t);
+
+}
+
+void Spatial::orthonormalize() {
+
+ Transform t = get_transform();
+ t.orthonormalize();
+ set_transform(t);
+
+}
+
+void Spatial::set_identity() {
+
+ set_transform(Transform());
+
+}
+
+
+void Spatial::look_at(const Vector3& p_target, const Vector3& p_up_normal) {
+
+ Transform lookat;
+ lookat.origin=get_global_transform().origin;
+ lookat=lookat.looking_at(p_target,p_up_normal);
+ set_global_transform(lookat);
+}
+
+void Spatial::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal) {
+
+ Transform lookat;
+ lookat.origin=p_pos;
+ lookat=lookat.looking_at(p_target,p_up_normal);
+ set_global_transform(lookat);
+
+}
+
void Spatial::_bind_methods() {
@@ -633,6 +724,28 @@ void Spatial::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_set_visible_"), &Spatial::_set_visible_);
ObjectTypeDB::bind_method(_MD("_is_visible_"), &Spatial::_is_visible_);
+ void rotate(const Vector3& p_normal,float p_radians);
+ void rotate_x(float p_radians);
+ void rotate_y(float p_radians);
+ void rotate_z(float p_radians);
+ void translate(const Vector3& p_offset);
+ void scale(const Vector3& p_ratio);
+ void global_rotate(const Vector3& p_normal,float p_radians);
+ void global_translate(const Vector3& p_offset);
+
+ ObjectTypeDB::bind_method( _MD("rotate","normal","radians"),&Spatial::rotate );
+ ObjectTypeDB::bind_method( _MD("global_rotate","normal","radians"),&Spatial::global_rotate );
+ ObjectTypeDB::bind_method( _MD("rotate_x","radians"),&Spatial::rotate_x );
+ ObjectTypeDB::bind_method( _MD("rotate_y","radians"),&Spatial::rotate_y );
+ ObjectTypeDB::bind_method( _MD("rotate_z","radians"),&Spatial::rotate_z );
+ ObjectTypeDB::bind_method( _MD("translate","offset"),&Spatial::translate );
+ ObjectTypeDB::bind_method( _MD("global_translate","offset"),&Spatial::global_translate );
+ ObjectTypeDB::bind_method( _MD("orthonormalize"),&Spatial::orthonormalize );
+ ObjectTypeDB::bind_method( _MD("set_identity"),&Spatial::set_identity );
+
+ ObjectTypeDB::bind_method( _MD("look_at","target","up"),&Spatial::look_at );
+ ObjectTypeDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Spatial::look_at_from_pos );
+
BIND_CONSTANT( NOTIFICATION_TRANSFORM_CHANGED );
BIND_CONSTANT( NOTIFICATION_ENTER_WORLD );
BIND_CONSTANT( NOTIFICATION_EXIT_WORLD );
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index 49ecf5779b..f2cde8f1e6 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -167,6 +167,21 @@ public:
Transform get_relative_transform(const Node *p_parent) const;
+ void rotate(const Vector3& p_normal,float p_radians);
+ void rotate_x(float p_radians);
+ void rotate_y(float p_radians);
+ void rotate_z(float p_radians);
+ void translate(const Vector3& p_offset);
+ void scale(const Vector3& p_ratio);
+ void global_rotate(const Vector3& p_normal,float p_radians);
+ void global_translate(const Vector3& p_offset);
+
+ void look_at(const Vector3& p_target, const Vector3& p_up_normal);
+ void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
+
+ void orthonormalize();
+ void set_identity();
+
void show();
void hide();
bool is_visible() const;
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index a82c69e67f..45c7fa912c 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -310,6 +310,17 @@ int GeometryInstance::get_baked_light_texture_id() const{
return baked_light_texture_id;
}
+void GeometryInstance::set_extra_cull_margin(float p_margin) {
+
+ ERR_FAIL_COND(p_margin<0);
+ extra_cull_margin=p_margin;
+ VS::get_singleton()->instance_set_extra_visibility_margin(get_instance(),extra_cull_margin);
+}
+
+float GeometryInstance::get_extra_cull_margin() const{
+
+ return extra_cull_margin;
+}
void GeometryInstance::_bind_methods() {
@@ -328,6 +339,9 @@ void GeometryInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_baked_light_texture_id","id"), &GeometryInstance::set_baked_light_texture_id);
ObjectTypeDB::bind_method(_MD("get_baked_light_texture_id"), &GeometryInstance::get_baked_light_texture_id);
+ 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("_baked_light_changed"), &GeometryInstance::_baked_light_changed);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE);
@@ -336,6 +350,7 @@ void GeometryInstance::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/receive_shadows"), _SCS("set_flag"), _SCS("get_flag"),FLAG_RECEIVE_SHADOWS);
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_begin",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_begin"), _SCS("get_draw_range_begin"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_end",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_end"), _SCS("get_draw_range_end"));
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "geometry/extra_cull_margin",PROPERTY_HINT_RANGE,"0,16384,0"), _SCS("set_extra_cull_margin"), _SCS("get_extra_cull_margin"));
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard_y"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD_FIX_Y);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/depth_scale"), _SCS("set_flag"), _SCS("get_flag"),FLAG_DEPH_SCALE);
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index e9fefe1ba0..e08acbe9a2 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -108,6 +108,7 @@ private:
void _find_baked_light();
BakedLightInstance *baked_light_instance;
int baked_light_texture_id;
+ float extra_cull_margin;
void _baked_light_changed();
void _update_visibility();
@@ -132,6 +133,9 @@ public:
void set_baked_light_texture_id(int p_id);
int get_baked_light_texture_id() const;
+ void set_extra_cull_margin(float p_margin);
+ float get_extra_cull_margin() const;
+
GeometryInstance();
};