1 /** 2 Static body for 3D Physics. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.staticbody; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.physicsbody; 24 import godot.physicsmaterial; 25 import godot.collisionobject; 26 import godot.spatial; 27 import godot.node; 28 /** 29 Static body for 3D Physics. 30 31 A static body is a simple body that is not intended to move. They don't consume any CPU resources in contrast to a $(D RigidBody3D) so they are great for scenario collision. 32 A static body can also be animated by using simulated motion mode. This is useful for implementing functionalities such as moving platforms. When this mode is active the body can be animated and automatically computes linear and angular velocity to apply in that frame and to influence other bodies. 33 Alternatively, a constant linear or angular velocity can be set for the static body, so even if it doesn't move, it affects other bodies as if it was moving (this is useful for simulating conveyor belts or conveyor wheels). 34 */ 35 @GodotBaseClass struct StaticBody 36 { 37 enum string _GODOT_internal_name = "StaticBody"; 38 public: 39 @nogc nothrow: 40 union { godot_object _godot_object; PhysicsBody _GODOT_base; } 41 alias _GODOT_base this; 42 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 43 package(godot) __gshared bool _classBindingInitialized = false; 44 package(godot) static struct _classBinding 45 { 46 __gshared: 47 @GodotName("set_constant_linear_velocity") GodotMethod!(void, Vector3) setConstantLinearVelocity; 48 @GodotName("set_constant_angular_velocity") GodotMethod!(void, Vector3) setConstantAngularVelocity; 49 @GodotName("get_constant_linear_velocity") GodotMethod!(Vector3) getConstantLinearVelocity; 50 @GodotName("get_constant_angular_velocity") GodotMethod!(Vector3) getConstantAngularVelocity; 51 @GodotName("set_friction") GodotMethod!(void, double) setFriction; 52 @GodotName("get_friction") GodotMethod!(double) getFriction; 53 @GodotName("set_bounce") GodotMethod!(void, double) setBounce; 54 @GodotName("get_bounce") GodotMethod!(double) getBounce; 55 @GodotName("set_physics_material_override") GodotMethod!(void, PhysicsMaterial) setPhysicsMaterialOverride; 56 @GodotName("get_physics_material_override") GodotMethod!(PhysicsMaterial) getPhysicsMaterialOverride; 57 @GodotName("_reload_physics_characteristics") GodotMethod!(void) _reloadPhysicsCharacteristics; 58 } 59 bool opEquals(in StaticBody other) const { return _godot_object.ptr is other._godot_object.ptr; } 60 StaticBody opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 61 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 62 mixin baseCasts; 63 static StaticBody _new() 64 { 65 static godot_class_constructor constructor; 66 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("StaticBody"); 67 if(constructor is null) return typeof(this).init; 68 return cast(StaticBody)(constructor()); 69 } 70 @disable new(size_t s); 71 /** 72 73 */ 74 void setConstantLinearVelocity(in Vector3 vel) 75 { 76 checkClassBinding!(typeof(this))(); 77 ptrcall!(void)(_classBinding.setConstantLinearVelocity, _godot_object, vel); 78 } 79 /** 80 81 */ 82 void setConstantAngularVelocity(in Vector3 vel) 83 { 84 checkClassBinding!(typeof(this))(); 85 ptrcall!(void)(_classBinding.setConstantAngularVelocity, _godot_object, vel); 86 } 87 /** 88 89 */ 90 Vector3 getConstantLinearVelocity() const 91 { 92 checkClassBinding!(typeof(this))(); 93 return ptrcall!(Vector3)(_classBinding.getConstantLinearVelocity, _godot_object); 94 } 95 /** 96 97 */ 98 Vector3 getConstantAngularVelocity() const 99 { 100 checkClassBinding!(typeof(this))(); 101 return ptrcall!(Vector3)(_classBinding.getConstantAngularVelocity, _godot_object); 102 } 103 /** 104 105 */ 106 void setFriction(in double friction) 107 { 108 checkClassBinding!(typeof(this))(); 109 ptrcall!(void)(_classBinding.setFriction, _godot_object, friction); 110 } 111 /** 112 113 */ 114 double getFriction() const 115 { 116 checkClassBinding!(typeof(this))(); 117 return ptrcall!(double)(_classBinding.getFriction, _godot_object); 118 } 119 /** 120 121 */ 122 void setBounce(in double bounce) 123 { 124 checkClassBinding!(typeof(this))(); 125 ptrcall!(void)(_classBinding.setBounce, _godot_object, bounce); 126 } 127 /** 128 129 */ 130 double getBounce() const 131 { 132 checkClassBinding!(typeof(this))(); 133 return ptrcall!(double)(_classBinding.getBounce, _godot_object); 134 } 135 /** 136 137 */ 138 void setPhysicsMaterialOverride(PhysicsMaterial physics_material_override) 139 { 140 checkClassBinding!(typeof(this))(); 141 ptrcall!(void)(_classBinding.setPhysicsMaterialOverride, _godot_object, physics_material_override); 142 } 143 /** 144 145 */ 146 Ref!PhysicsMaterial getPhysicsMaterialOverride() const 147 { 148 checkClassBinding!(typeof(this))(); 149 return ptrcall!(PhysicsMaterial)(_classBinding.getPhysicsMaterialOverride, _godot_object); 150 } 151 /** 152 153 */ 154 void _reloadPhysicsCharacteristics() 155 { 156 Array _GODOT_args = Array.empty_array; 157 String _GODOT_method_name = String("_reload_physics_characteristics"); 158 this.callv(_GODOT_method_name, _GODOT_args); 159 } 160 /** 161 The body friction, from 0 (frictionless) to 1 (full friction). 162 */ 163 @property double friction() 164 { 165 return getFriction(); 166 } 167 /// ditto 168 @property void friction(double v) 169 { 170 setFriction(v); 171 } 172 /** 173 The body bounciness. 174 */ 175 @property double bounce() 176 { 177 return getBounce(); 178 } 179 /// ditto 180 @property void bounce(double v) 181 { 182 setBounce(v); 183 } 184 /** 185 186 */ 187 @property PhysicsMaterial physicsMaterialOverride() 188 { 189 return getPhysicsMaterialOverride(); 190 } 191 /// ditto 192 @property void physicsMaterialOverride(PhysicsMaterial v) 193 { 194 setPhysicsMaterialOverride(v); 195 } 196 /** 197 The constant linear velocity for the body. This does not move the body, but affects other bodies that touch it, as if it was in a state of movement. 198 */ 199 @property Vector3 constantLinearVelocity() 200 { 201 return getConstantLinearVelocity(); 202 } 203 /// ditto 204 @property void constantLinearVelocity(Vector3 v) 205 { 206 setConstantLinearVelocity(v); 207 } 208 /** 209 The constant angular velocity for the body. This does not rotate the body, but affects other bodies that touch it, as if it was in a state of rotation. 210 */ 211 @property Vector3 constantAngularVelocity() 212 { 213 return getConstantAngularVelocity(); 214 } 215 /// ditto 216 @property void constantAngularVelocity(Vector3 v) 217 { 218 setConstantAngularVelocity(v); 219 } 220 }