body_description.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 <memory>
33 #include "../../Core/Math/vec2.h"
34 
35 namespace clan
36 {
39 
40 class BodyDescription_Impl;
41 class Pointf;
42 class Angle;
43 class PhysicsWorld;
44 class PhysicsContext;
45 class XMLResourceDocument;
46 
48  enum BodyType
49  {
53  };
55 class CL_API_PHYSICS BodyDescription
56 {
57 public:
58 
61 public:
62 
65 
69  BodyDescription(const PhysicsWorld &pw);
70 
75 
81  BodyDescription(const PhysicsContext &pc, const std::string &resource_id, const XMLResourceDocument &resources);
82 
86  BodyDescription(const BodyDescription &copy);
87 
88  virtual ~BodyDescription();
89 
93 public:
94 
96  bool is_null() const { return !impl; }
97 
99  void throw_if_null() const;
100 
101 
105 public:
106 
108  BodyDescription &operator =(const BodyDescription &copy);
109 
110  void set_type(const BodyType type);
111 
112  void set_position(const Vec2f &position);
113  void set_position(const Pointf &position);
114  void set_position(const int x, const int y);
115  void set_position(const float x, const float y);
116 
118  void set_angle(const Angle &angle);
119 
121  void set_linear_velocity(const Vec2f &velocity);
122 
124  void set_angular_velocity(const Angle &velocity);
125 
126  void set_linear_damping(const float damping);
127 
128  void set_angular_damping(const float damping);
129 
130  void allow_sleep(const bool value = true);
131 
133  void set_awake(const bool value = true);
134 
136  void set_fixed_rotation(const bool value);
137 
139  void set_as_bullet(const bool value = true);
140 
142  void set_active(const bool value = true);
143 
145  void set_gravity_scale(const float scale);
146 
150 private:
151 
152  std::shared_ptr<BodyDescription_Impl> impl;
154  friend class Body;
155  friend class Body_Impl;
156 };
157 
158 }
159 /// \}
Definition: body_description.h:51
Definition: body_description.h:52
Angle class.
Definition: angle.h:63
BodyDescription class.
Definition: body_description.h:55
Definition: body_description.h:50
Top-level world class.
Definition: physics_world.h:52
Body class.
Definition: body.h:52
bool is_null() const
Returns true if this object is invalid.
Definition: body_description.h:96
BodyType
Body types.
Definition: body_description.h:48
Definition: physics_context.h:45
XML Resource Document.
Definition: xml_resource_document.h:49
2D (x,y) point structure - Float
Definition: point.h:73