25 #include "configurationhelper.h"
33 #warning QUESTE COSTANTI DEVONO PROBABILMENTE DIVENTARE DEI PARAMETRI
41 const real defaultHeight = 0.3f;
48 const real planeThickness = 0.1;
55 const real smallCylinderRadius = 0.03;
62 const real bigCylinderRadius = 0.06;
69 const real targetAreasHeight = 0.001;
76 const real targetAreasProtrusion = 0.0005;
83 m_plane(createPlane(params, prefix, m_z)),
94 for (
int i = 0; i < m_objects2DList.size(); i++) {
95 delete m_objects2DList[i];
111 d.
describeReal(
"z").
def(0.0).
help(
"The z coordinate of the plane in the world frame of reference",
"This is the z coordinate of the upper part of the plane in the world frame of reference");
119 #warning IMPLEMENTARE QUESTA!!!
138 Box2DWrapper* b = createBox(color, (end - start).norm(), thickness, height, Box2DWrapper::Wall);
142 const real angle = atan2(end.y - start.y, end.x - start.x);
143 const wVector centerPosition = start + (end - start).scale(0.5);
154 return createCylinder(color, smallCylinderRadius, height, Cylinder2DWrapper::SmallCylinder);
159 return createCylinder(color, bigCylinderRadius, height, Cylinder2DWrapper::BigCylinder);
167 Cylinder2DWrapper* c = createCylinder(color, radius, targetAreasHeight, Cylinder2DWrapper::CircularTargetArea);
170 mtr.
w_pos = wVector(0.0, 0.0, m_z - (targetAreasHeight / 2.0) + targetAreasProtrusion);
182 Box2DWrapper* b = createBox(color, width, depth, targetAreasHeight, Box2DWrapper::RectangularTargetArea);
185 mtr.
w_pos = wVector(0.0, 0.0, m_z - (targetAreasHeight / 2.0) + targetAreasProtrusion);
198 height = defaultHeight;
201 PhyCylinder* cylinder =
new PhyCylinder(radius, height, m_world,
"cylinder");
203 mtr.w_pos = wVector(0.0, 0.0, m_z + (height / 2.0));
204 cylinder->setMatrix(mtr);
205 cylinder->setUseColorTextureOfOwner(
false);
206 cylinder->setColor(color);
207 cylinder->setTexture(
"");
210 Cylinder2DWrapper* wrapper =
new Cylinder2DWrapper(cylinder, type);
213 m_objects2DList.append(wrapper);
218 Box2DWrapper* Arena::createBox(QColor color, real width, real depth, real height,
Box2DWrapper::Type type)
224 height = defaultHeight;
227 PhyBox* box =
new PhyBox(width, depth, height, m_world,
"box");
231 mtr.w_pos = wVector(0.0, 0.0, m_z + (height / 2.0));
233 box->setUseColorTextureOfOwner(
false);
234 box->setColor(color);
238 Box2DWrapper* wrapper =
new Box2DWrapper(box, type);
241 m_objects2DList.append(wrapper);
246 void Arena::resourceChanged(QString resourceName, ResourceChangeType changeType)
248 if (resourceName ==
"world") {
249 switch (changeType) {
252 m_world = getResource<World>();
259 Logger::info(
"Unknown resource " + resourceName +
" for Arena");
263 Box2DWrapper* Arena::createPlane(ConfigurationParameters& params, QString prefix, real z)
270 SimpleResourcesUser* r = params.getResourcesUserForResource(
"world");
274 World* world = r->getResource<World>(
"world");
276 PhyBox* plane =
new PhyBox(planeWidth, planeHeight, planeThickness, world,
"plane");
277 plane->setPosition(wVector(0.0, 0.0, z - (planeThickness / 2.0)));
278 plane->setStatic(
true);
279 plane->setColor(Qt::white);
280 plane->setTexture(
"tile2");
283 world->setSize(wVector(-planeWidth, -planeHeight, -planeThickness), wVector(planeWidth, planeHeight, +6.0));
286 return new Box2DWrapper(plane, Box2DWrapper::Plane);