joints_2d.h
1 /*************************************************************************/
2 /* joints_2d.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef JOINTS_2D_H
30 #define JOINTS_2D_H
31 
32 
33 #include "node_2d.h"
34 
35 class Joint2D : public Node2D {
36 
37  OBJ_TYPE(Joint2D,Node2D);
38 
39  RID joint;
40 
41  NodePath a;
42  NodePath b;
43  real_t bias;
44 
45  bool exclude_from_collision;
46 
47 
48 protected:
49 
50  void _update_joint();
51 
52  void _notification(int p_what);
53  virtual RID _configure_joint()=0;
54 
55  static void _bind_methods();
56 public:
57 
58  void set_node_a(const NodePath& p_node_a);
59  NodePath get_node_a() const;
60 
61  void set_node_b(const NodePath& p_node_b);
62  NodePath get_node_b() const;
63 
64  void set_bias(real_t p_bias);
65  real_t get_bias() const;
66 
67  void set_exclude_nodes_from_collision(bool p_enable);
68  bool get_exclude_nodes_from_collision() const;
69 
70  RID get_joint() const { return joint; }
71  Joint2D();
72 
73 };
74 
75 
76 class PinJoint2D : public Joint2D {
77 
78  OBJ_TYPE(PinJoint2D,Joint2D);
79 
80  real_t softness;
81 
82 protected:
83 
84  void _notification(int p_what);
85  virtual RID _configure_joint();
86  static void _bind_methods();
87 public:
88 
89  void set_softness(real_t p_stiffness);
90  real_t get_softness() const;
91 
92  PinJoint2D();
93 };
94 
95 class GrooveJoint2D : public Joint2D {
96 
97  OBJ_TYPE(GrooveJoint2D,Joint2D);
98 
99  real_t length;
100  real_t initial_offset;
101 
102 protected:
103 
104  void _notification(int p_what);
105  virtual RID _configure_joint();
106  static void _bind_methods();
107 public:
108 
109  void set_length(real_t p_length);
110  real_t get_length() const;
111 
112  void set_initial_offset(real_t p_initial_offset);
113  real_t get_initial_offset() const;
114 
115  GrooveJoint2D();
116 };
117 
118 class DampedSpringJoint2D : public Joint2D {
119 
120  OBJ_TYPE(DampedSpringJoint2D,Joint2D);
121 
122  real_t stiffness;
123  real_t damping;
124  real_t rest_length;
125  real_t length;
126 
127 protected:
128 
129  void _notification(int p_what);
130  virtual RID _configure_joint();
131  static void _bind_methods();
132 public:
133 
134  void set_length(real_t p_length);
135  real_t get_length() const;
136 
137  void set_rest_length(real_t p_rest_length);
138  real_t get_rest_length() const;
139 
140  void set_damping(real_t p_damping);
141  real_t get_damping() const;
142 
143  void set_stiffness(real_t p_stiffness);
144  real_t get_stiffness() const;
145 
147 };
148 
149 
150 #endif // JOINTS_2D_H
Definition: joints_2d.h:118
Definition: path_db.h:41
Definition: joints_2d.h:95
Definition: rid.h:47
Definition: joints_2d.h:76
Definition: node_2d.h:34
Definition: joints_2d.h:35