Download
Documentation
Development
Examples
Donations
Contributions
Forum
Main Page
Related Pages
Modules
Classes
Sources
API
Physics2D
Dynamics
body.h
1
/*
2
** ClanLib SDK
3
** Copyright (c) 1997-2013 The ClanLib Team
4
**
5
** This software is provided 'as-is', without any express or implied
6
** warranty. In no event will the authors be held liable for any damages
7
** arising from the use of this software.
8
**
9
** Permission is granted to anyone to use this software for any purpose,
10
** including commercial applications, and to alter it and redistribute it
11
** freely, subject to the following restrictions:
12
**
13
** 1. The origin of this software must not be misrepresented; you must not
14
** claim that you wrote the original software. If you use this software
15
** in a product, an acknowledgment in the product documentation would be
16
** appreciated but is not required.
17
** 2. Altered source versions must be plainly marked as such, and must not be
18
** misrepresented as being the original software.
19
** 3. This notice may not be removed or altered from any source distribution.
20
**
21
** Note: Some of the libraries ClanLib may link to may have additional
22
** requirements or restrictions.
23
**
24
** File Author(s):
25
**
26
** Arkadiusz Kalinowski
27
*/
28
29
#pragma once
30
31
#include "../api_physics2d.h"
32
#include "body_description.h"
33
#include <memory>
34
#include "../../Core/Math/vec2.h"
35
#include "../../Core/Signals/signal_v0.h"
36
#include "../../Core/Signals/signal_v1.h"
37
38
namespace
clan
39
{
42
43
class
XMLResourceDocument;
44
class
PhysicsWorld;
45
class
BodyDescription;
46
class
Body_Impl;
47
class
FixtureDescription;
48
class
PhysicsContext;
49
class
PhysicsObject;
50
52
class
CL_API_PHYSICS
Body
53
{
54
57
public
:
59
Body
();
60
65
Body
(
PhysicsContext
&pc,
const
BodyDescription
&description);
66
72
Body
(
PhysicsContext
&pc,
const
std::string &resource_id,
const
XMLResourceDocument
&resources);
73
74
~
Body
();
75
79
public
:
80
82
bool
is_null
()
const
{
return
!impl; }
83
85
void
throw_if_null()
const
;
86
88
Vec2f
get_position()
const
;
89
91
Angle
get_angle()
const
;
92
94
Vec2f
get_linear_velocity()
const
;
95
97
Angle
get_angular_velocity()
const
;
98
100
float
get_gravity_scale();
101
103
BodyType
get_type()
const
;
104
106
bool
has_fixed_rotation()
const
;
107
109
float
get_linear_damping()
const
;
110
112
float
get_angular_damping()
const
;
113
115
int
get_id()
const
;
116
118
bool
is_dummy()
const
;
119
121
bool
is_awake()
const
;
122
124
bool
is_active()
const
;
125
127
bool
is_bullet()
const
;
128
130
PhysicsObject
*get_data();
134
public
:
135
137
Body
&operator =(
const
Body
©);
138
140
//void create_fixture(const FixtureDescription &fixture);
141
143
void
set_position(
const
Vec2f
&pos);
144
146
void
set_angle(
const
Angle
&angle);
147
149
void
set_linear_velocity(
const
Vec2f
&velocity);
150
152
void
set_angular_velocity(
const
Angle
&velocity);
153
160
void
apply_force (
const
Vec2f
&force,
const
Vec2f
&point);
161
165
void
apply_force_to_center (
const
Vec2f
&force);
166
171
void
apply_torque (
const
float
torque);
172
177
void
apply_linear_impulse (
const
Vec2f
&impulse,
const
Vec2f
&point);
178
182
void
apply_angular_impulse (
const
float
impulse);
183
185
void
set_gravity_scale(
const
float
scale);
186
188
void
set_type(
const
BodyType
type);
189
191
void
set_as_bullet(
const
bool
value =
true
);
192
194
void
set_awake(
const
bool
value =
true
);
195
197
void
set_active(
const
bool
value =
true
);
198
200
void
set_fixed_rotation(
const
bool
value =
true
);
201
203
void
set_linear_damping(
const
float
damping);
204
206
void
set_angular_damping(
const
float
damping);
207
211
void
reset_mass_data();
212
214
void
kill();
215
217
void
set_data(
PhysicsObject
*data);
218
222
public
:
226
Signal_v1<Body>
&sig_begin_collision();
227
231
Signal_v1<Body>
&sig_end_collision();
232
236
Signal_v0
&sig_body_deletion();
237
241
private
:
242
243
std::shared_ptr<Body_Impl> impl;
245
friend
class
PhysicsContext_Impl;
246
247
friend
class
Fixture
;
248
friend
class
Fixture_Impl;
249
friend
class
Body_Impl;
250
friend
class
PhysicsContext
;
251
friend
class
PhysicsListener;
252
253
friend
class
DistanceJointDescription
;
254
friend
class
RevoluteJointDescription
;
255
friend
class
PrismaticJointDescription
;
256
friend
class
MouseJointDescription
;
257
258
};
259
260
}
261
/// \}
clan::Body::is_null
bool is_null() const
Returns true if this object is invalid.
Definition:
body.h:82
clan::Angle
Angle class.
Definition:
angle.h:63
clan::MouseJointDescription
MouseJointDescription class.
Definition:
mouse_joint_description.h:47
clan::BodyDescription
BodyDescription class.
Definition:
body_description.h:55
clan::Signal_v1
Signal_v1.
Definition:
signal_v1.h:110
clan::PhysicsObject
Physics Object class.
Definition:
physics_object.h:44
clan::Vec2< float >
clan::PrismaticJointDescription
PrismaticJointDescription class.
Definition:
prismatic_joint_description.h:47
clan::Body
Body class.
Definition:
body.h:52
clan::DistanceJointDescription
DistanceJointDescription class.
Definition:
distance_joint_description.h:47
clan::BodyType
BodyType
Body types.
Definition:
body_description.h:48
clan::PhysicsContext
Definition:
physics_context.h:45
clan::XMLResourceDocument
XML Resource Document.
Definition:
xml_resource_document.h:49
clan::RevoluteJointDescription
RevoluteJointDescription class.
Definition:
revolute_joint_description.h:47
clan::Signal_v0
Signal_v0.
Definition:
signal_v0.h:107
clan::Fixture
Fixture class.
Definition:
fixture.h:48