1 /**
2 Physics body that simulates the behaviour of a car.
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.vehiclebody;
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.rigidbody;
24 import godot.physicsbody;
25 import godot.collisionobject;
26 import godot.spatial;
27 import godot.node;
28 /**
29 Physics body that simulates the behaviour of a car.
30 
31 This nodes implements all the physics logic needed to simulate a car. It is based on the raycast vehicle system commonly found in physics engines. You will need to add a $(D CollisionShape) for the main body of your vehicle and add $(D VehicleWheel) nodes for the wheels. You should also add a $(D MeshInstance) to this node for the 3D model of your car but this model should not include meshes for the wheels. You should control the vehicle by using the $(D brake), $(D engineForce), and $(D steering) properties and not change the position or orientation of this node directly.
32 Note that the origin point of your VehicleBody will determine the center of gravity of your vehicle so it is better to keep this low and move the $(D CollisionShape) and $(D MeshInstance) upwards.
33 */
34 @GodotBaseClass struct VehicleBody
35 {
36 	enum string _GODOT_internal_name = "VehicleBody";
37 public:
38 @nogc nothrow:
39 	union { godot_object _godot_object; RigidBody _GODOT_base; }
40 	alias _GODOT_base this;
41 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
42 	package(godot) __gshared bool _classBindingInitialized = false;
43 	package(godot) static struct _classBinding
44 	{
45 		__gshared:
46 		@GodotName("set_engine_force") GodotMethod!(void, double) setEngineForce;
47 		@GodotName("get_engine_force") GodotMethod!(double) getEngineForce;
48 		@GodotName("set_brake") GodotMethod!(void, double) setBrake;
49 		@GodotName("get_brake") GodotMethod!(double) getBrake;
50 		@GodotName("set_steering") GodotMethod!(void, double) setSteering;
51 		@GodotName("get_steering") GodotMethod!(double) getSteering;
52 	}
53 	bool opEquals(in VehicleBody other) const { return _godot_object.ptr is other._godot_object.ptr; }
54 	VehicleBody opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
55 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
56 	mixin baseCasts;
57 	static VehicleBody _new()
58 	{
59 		static godot_class_constructor constructor;
60 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VehicleBody");
61 		if(constructor is null) return typeof(this).init;
62 		return cast(VehicleBody)(constructor());
63 	}
64 	@disable new(size_t s);
65 	/**
66 	
67 	*/
68 	void setEngineForce(in double engine_force)
69 	{
70 		checkClassBinding!(typeof(this))();
71 		ptrcall!(void)(_classBinding.setEngineForce, _godot_object, engine_force);
72 	}
73 	/**
74 	
75 	*/
76 	double getEngineForce() const
77 	{
78 		checkClassBinding!(typeof(this))();
79 		return ptrcall!(double)(_classBinding.getEngineForce, _godot_object);
80 	}
81 	/**
82 	
83 	*/
84 	void setBrake(in double brake)
85 	{
86 		checkClassBinding!(typeof(this))();
87 		ptrcall!(void)(_classBinding.setBrake, _godot_object, brake);
88 	}
89 	/**
90 	
91 	*/
92 	double getBrake() const
93 	{
94 		checkClassBinding!(typeof(this))();
95 		return ptrcall!(double)(_classBinding.getBrake, _godot_object);
96 	}
97 	/**
98 	
99 	*/
100 	void setSteering(in double steering)
101 	{
102 		checkClassBinding!(typeof(this))();
103 		ptrcall!(void)(_classBinding.setSteering, _godot_object, steering);
104 	}
105 	/**
106 	
107 	*/
108 	double getSteering() const
109 	{
110 		checkClassBinding!(typeof(this))();
111 		return ptrcall!(double)(_classBinding.getSteering, _godot_object);
112 	}
113 	/**
114 	Accelerates the vehicle by applying an engine force. The vehicle is only speed up if the wheels that have $(D VehicleWheel.setUseAsTraction) set to true and are in contact with a surface. The $(D RigidBody.mass) of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. Note that the simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears.
115 	A negative value will result in the vehicle reversing.
116 	*/
117 	@property double engineForce()
118 	{
119 		return getEngineForce();
120 	}
121 	/// ditto
122 	@property void engineForce(double v)
123 	{
124 		setEngineForce(v);
125 	}
126 	/**
127 	Slows down the vehicle by applying a braking force. The vehicle is only slowed down if the wheels are in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the $(D RigidBody.mass) of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.
128 	*/
129 	@property double brake()
130 	{
131 		return getBrake();
132 	}
133 	/// ditto
134 	@property void brake(double v)
135 	{
136 		setBrake(v);
137 	}
138 	/**
139 	The steering angle for the vehicle. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have $(D VehicleWheel.setUseAsSteering) set to true will automatically be rotated.
140 	*/
141 	@property double steering()
142 	{
143 		return getSteering();
144 	}
145 	/// ditto
146 	@property void steering(double v)
147 	{
148 		setSteering(v);
149 	}
150 }