Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00825_source.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a00825_source.php on line 2
The ARGoS Website

dynamics3d_floor_plugin.cpp
Go to the documentation of this file.
1 
8 
9 namespace argos {
10 
11  /****************************************/
12  /****************************************/
13 
15  /* Get the floor height */
16  Real fHeight = 0.0f;
17  GetNodeAttributeOrDefault(t_tree, "height", fHeight, fHeight);
18  /* Get the arena center and size from the arena node */
19  CVector3 cArenaCenter(0.0f, 0.0f, 0.0f);
20  CVector3 cArenaSize(0.0f, 0.0f, 0.0f);
21  TConfigurationNode& tArena = GetNode(CSimulator::GetInstance().GetConfigurationRoot(), "arena");
22  GetNodeAttribute(tArena, "size", cArenaSize);
23  GetNodeAttributeOrDefault(tArena, "center", cArenaCenter, cArenaCenter);
24  /* Configure the floor */
25  m_cFloorExtents = btVector3(cArenaSize.GetX(), fHeight, cArenaSize.GetY());
26  m_cFloorOrigin = btVector3(cArenaCenter.GetX(), -fHeight * 0.5f, -cArenaCenter.GetY());
27  /* Call the destructors for the floor components */
28  m_cFloor.~btRigidBody();
29  m_cFloorShape.~btBoxShape();
30  /* Call the constructors for the floor components */
31  new (&m_cFloorShape) btBoxShape(m_cFloorExtents * 0.5f);
32  new (&m_cFloor) btRigidBody(0, nullptr, &m_cFloorShape);
33  m_cFloor.setUserPointer(nullptr);
34  m_cFloor.getWorldTransform().setOrigin(m_cFloorOrigin);
35  /* Add floor to world */
36  m_pcEngine->GetWorld().addRigidBody(&m_cFloor);
37  }
38 
39  /****************************************/
40  /****************************************/
41 
43  /* Remove floor from world */
44  m_pcEngine->GetWorld().removeRigidBody(&m_cFloor);
45  /* Call the destructors for the floor components */
46  m_cFloor.~btRigidBody();
47  m_cFloorShape.~btBoxShape();
48  /* Call the constructors for the floor components */
49  new (&m_cFloorShape) btBoxShape(m_cFloorExtents * 0.5f);
50  new (&m_cFloor) btRigidBody(0, nullptr, &m_cFloorShape);
51  m_cFloor.setUserPointer(nullptr);
52  m_cFloor.getWorldTransform().setOrigin(m_cFloorOrigin);
53  /* Add floor to world */
54  m_pcEngine->GetWorld().addRigidBody(&m_cFloor);
55  }
56 
57  /****************************************/
58  /****************************************/
59 
61  /* Remove floor from world */
62  m_pcEngine->GetWorld().removeRigidBody(&m_cFloor);
63  }
64 
65  /****************************************/
66  /****************************************/
67 
69  "floor",
70  "Michael Allwright [allsey87@gmail.com]",
71  "1.0",
72  "Inserts a floor into the 3D dynamics engine",
73  "For a description on how to use this plugin, please consult the documentation\n"
74  "for the dynamics3d physics engine plugin",
75  "Usable");
76 
77  /****************************************/
78  /****************************************/
79 
80 }
A 3D vector class.
Definition: vector3.h:29
void GetNodeAttributeOrDefault(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer, const T &t_default)
Returns the value of a node's attribute, or the passed default value.
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
CDynamics3DEngine * m_pcEngine
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:93
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:109
TConfigurationNode & GetNode(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns the first of its child nodes with the wanted name.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
REGISTER_DYNAMICS3D_PLUGIN(CDynamics3DFloorPlugin,"floor","Michael Allwright [allsey87@gmail.com]","1.0","Inserts a floor into the 3D dynamics engine","For a description on how to use this plugin, please consult the documentation\n""for the dynamics3d physics engine plugin","Usable")
btMultiBodyDynamicsWorld & GetWorld()
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
virtual void Init(TConfigurationNode &t_tree)
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
Definition: simulator.cpp:78