Flatland
model_body.h
1 /*
2  * ______ __ __ __
3  * /\ _ \ __ /\ \/\ \ /\ \__
4  * \ \ \L\ \ __ __ /\_\ \_\ \ \ \____ ___\ \ ,_\ ____
5  * \ \ __ \/\ \/\ \\/\ \ /'_` \ \ '__`\ / __`\ \ \/ /',__\
6  * \ \ \/\ \ \ \_/ |\ \ \/\ \L\ \ \ \L\ \/\ \L\ \ \ \_/\__, `\
7  * \ \_\ \_\ \___/ \ \_\ \___,_\ \_,__/\ \____/\ \__\/\____/
8  * \/_/\/_/\/__/ \/_/\/__,_ /\/___/ \/___/ \/__/\/___/
9  * @copyright Copyright 2017 Avidbots Corp.
10  * @name model_body.h
11  * @brief Defines Model Body
12  * @author Chunshang Li
13  *
14  * Software License Agreement (BSD License)
15  *
16  * Copyright (c) 2017, Avidbots Corp.
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions
21  * are met:
22  *
23  * * Redistributions of source code must retain the above copyright
24  * notice, this list of conditions and the following disclaimer.
25  * * Redistributions in binary form must reproduce the above
26  * copyright notice, this list of conditions and the following
27  * disclaimer in the documentation and/or other materials provided
28  * with the distribution.
29  * * Neither the name of the Avidbots Corp. nor the names of its
30  * contributors may be used to endorse or promote products derived
31  * from this software without specific prior written permission.
32  *
33  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
36  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
39  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
43  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44  * POSSIBILITY OF SUCH DAMAGE.
45  */
46 
47 #ifndef FLATLAND_SERVER_MODEL_BODY_H
48 #define FLATLAND_SERVER_MODEL_BODY_H
49 
50 #include <flatland_server/body.h>
51 #include <flatland_server/collision_filter_registry.h>
52 #include <flatland_server/model.h>
53 #include <flatland_server/yaml_reader.h>
54 #include <yaml-cpp/yaml.h>
55 
56 namespace flatland_server {
57 
58 class Model;
59 
65 class ModelBody : public Body {
66  public:
68 
83  ModelBody(b2World *physics_world, CollisionFilterRegistry *cfr, Model *model,
84  const std::string &name, const Color &color, const Pose &pose,
85  b2BodyType body_type, const YAML::Node &properties,
86  double linear_damping, double angular_damping);
87 
91  const CollisionFilterRegistry *GetCfr() const;
92 
98  void LoadFootprints(YamlReader &footprints_reader);
99 
106  void ConfigFootprintDef(YamlReader &footprint_reader,
107  b2FixtureDef &fixture_def);
108 
114  void LoadCircleFootprint(YamlReader &footprint_reader);
115 
121  void LoadPolygonFootprint(YamlReader &footprint_reader);
122 
130  static ModelBody *MakeBody(b2World *physics_world,
131  CollisionFilterRegistry *cfr, Model *model,
132  YamlReader &body_node);
133 };
134 }; // namespace flatland_server
135 #endif // FLATLAND_MODEL_BODY_H
Definition: collision_filter_registry.h:63
void LoadCircleFootprint(YamlReader &footprint_reader)
Loads a circle footprint.
Definition: model_body.cpp:155
void LoadFootprints(YamlReader &footprints_reader)
Load footprints (Box2D fixtures) into the body.
Definition: model_body.cpp:108
CollisionFilterRegistry * cfr_
collision filter registry
Definition: model_body.h:67
Definition: body.h:55
Definition: model_body.h:65
Definition: model.h:67
void LoadPolygonFootprint(YamlReader &footprint_reader)
Loads a circle footprint.
Definition: model_body.cpp:170
Definition: types.h:84
Definition: types.h:110
void ConfigFootprintDef(YamlReader &footprint_reader, b2FixtureDef &fixture_def)
Configures the common properties of footprints.
Definition: model_body.cpp:127
ModelBody(b2World *physics_world, CollisionFilterRegistry *cfr, Model *model, const std::string &name, const Color &color, const Pose &pose, b2BodyType body_type, const YAML::Node &properties, double linear_damping, double angular_damping)
Constructor for the Model Body.
Definition: model_body.cpp:53
const CollisionFilterRegistry * GetCfr() const
Definition: model_body.cpp:62
Definition: body.h:61
Definition: yaml_reader.h:76
static ModelBody * MakeBody(b2World *physics_world, CollisionFilterRegistry *cfr, Model *model, YamlReader &body_node)
Factory method to create a model body.
Definition: model_body.cpp:64