1
//! Specialized body class.
4
* Predefined body class. Ready to use in a RobotActor.
5
* This body represents the front part of the robot.
11
#include <srBody/kitScrew.h>
15
// units need to be around one to make the ode most stable. Hereby 1 length union is equal to 5cm.
16
#define SCALE_3DS 0.02
18
#define COLLISION_SIDE (64*SCALE_3DS) //60 // cm
19
#define COLLISION_LENGTH (64*SCALE_3DS) //85
21
// units need to be around one to make the ode most stable. Hereby 1 length union is equal to 5cm.
22
#define BODY_LENGTH 1.7 // equals 85 mm
23
#define BODY_HEIGHT 1.2
24
#define BODY_WIDTH 1.2
25
#define BODY_MASS 0.3 //0.13
27
using namespace srCore;
30
/*! @param id a 16bit id, used to set the colliding bit parameter.
31
* @param x, y, z the position of the hinge in the world coordinate system.
32
* @param heading, pitch, roll the orientation of the axis of the hinge in the world coordinate system.
33
* @param Scene the scene in which the body should be placed.
36
KITScrew::KITScrew( RobotActorBase* robot,
37
float x, float y, float z,
38
float heading, float pitch, float roll)
42
// initializing. parameters: name, id (of the robot), position, orientation and the scene
43
// needs to be done first
44
// todo: at the moment scene needs to be given to each element, although we only have one scene
45
this->init("KITScrew", robot, x, y, z, heading, pitch, roll);
50
if (SimulationUtils::getDetailedGraphics())
51
sprintf(file, "%s/StaticMeshes/newKITScrew.3ds", SimulationUtils::getStageProjectPath().c_str());
53
sprintf(file, "%s/StaticMeshes/symbrionDummy.3ds", SimulationUtils::getStageProjectPath().c_str()); //use this model in case of a bad graphics card
55
printf ("loading file %s ...\n", file);
57
SetModelTranslation(osg::Vec3(0,0,0));
62
this->setScale(SCALE_3DS,SCALE_3DS,SCALE_3DS);
64
// defining the collision box
65
this->setCollisionBox(COLLISION_SIDE, COLLISION_SIDE, COLLISION_SIDE);
67
// our Object just needs a mass now ...
68
this->setMass(BODY_MASS, COLLISION_SIDE, COLLISION_SIDE, COLLISION_SIDE);
70
dtCore::Object* collModel = new dtCore::Object();
72
dtCore::Transform xform;
73
sprintf(file, "%s/StaticMeshes/screwCollModel.3ds", SimulationUtils::getStageProjectPath().c_str());
75
collModel->LoadFile(file);
76
collModel->SetScale(this->GetScale());
77
SetCollisionCategoryBits(UNSIGNED_BIT(2));
78
SetCollisionCollideBits(UNSIGNED_BIT(1));
79
SetCollisionMesh(collModel->GetOSGNode());
81
osg::StateSet* stateset;
82
stateset = collModel->GetOSGNode()->getOrCreateStateSet();
83
osg::Material * mm = dynamic_cast<osg::Material*>(stateset->getAttribute
84
(osg::StateAttribute::MATERIAL));
87
mm = new osg::Material;
89
mm->setAlpha(osg::Material::FRONT, 0.2);
90
mm->setAmbient(osg::Material::FRONT, osg::Vec4(0,0,0,0));
91
stateset->setAttributeAndModes( mm, osg::StateAttribute::OVERRIDE |
92
osg::StateAttribute::ON);
93
stateset->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE |
94
osg::StateAttribute::ON );
95
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
96
osg::StateAttribute::ON );
97
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
101
this->renderCollisionGeometry(false);
103
this->SetCollisionMesh(collModel->GetOSGNode());
105
this->AddChild(collModel);
107
this->setCollisionModel(collModel->GetOSGNode());
111
// to check if the collision geometry fits to the model:
112
// this->renderCollisionGeometry();
114
// ... and then, it is ready to place it in the scene
120
KITScrew::~KITScrew()