bool TouchSensorRenderModel::initRenderModel() {

	bool meshLoadingA = this->partA_->loadMesh(
			   RobogenUtils::getMeshFile(this->getModel(),
				  TouchSensorModel::B_SENSOR_BASE_ID));

	if (!meshLoadingA) {
		std::cerr << "[TouchSensorRenderModel] Error loading model"
				<< std::endl;
		return false;
	}

	if (isDebugActive()) {
		this->showDebugView();
	}

	// PART A
	osg::ref_ptr<osg::PositionAttitudeTransform> partA =
			this->partA_->getMesh();
	partA->setAttitude(RobogenUtils::getRelativeAttitude(this->getModel(),
			  TouchSensorModel::B_SENSOR_BASE_ID));
	partA->setPosition(RobogenUtils::getRelativePosition(this->getModel(),
			  TouchSensorModel::B_SENSOR_BASE_ID));

	partA_->setColor(osg::Vec4(1, 0, 0, 0.5));

	osg::ref_ptr<osg::PositionAttitudeTransform> patPartA(
			new osg::PositionAttitudeTransform());
	patPartA->addChild(partA);

	this->getMeshes()->addChild(patPartA.get());
	patPartA->setUpdateCallback(
			new BodyCallback(this->getModel(),
					TouchSensorModel::B_SENSOR_BASE_ID));

	if(isDebugActive()) {
		this->activateTransparency(patPartA->getOrCreateStateSet());
	}

	return true;

}
bool TouchSensorRenderModel::initRenderModel() {

	bool meshLoadingA = this->partA_->loadMesh("../models/TouchSensor.stl");

	if (!meshLoadingA) {
		std::cerr << "[TouchSensorRenderModel] Error loading model"
				<< std::endl;
		return false;
	}

	if (isDebugActive()) {
		this->showDebugView();
		return true;
	}

	// PART A
	osg::ref_ptr<osg::PositionAttitudeTransform> partA =
			this->partA_->getMesh();
	partA->setAttitude(osg::Quat(osg::inDegrees(-90.0), osg::Vec3(0, 0, 1)));
	partA->setPosition(
			fromOde(
					osg::Vec3(
							TouchSensorModel::SENSOR_BASE_THICKNESS / 2
									+ TouchSensorModel::SENSOR_THICKNESS / 2
									- 0.002, 0, 0)));

	partA_->setColor(osg::Vec4(1, 0, 0, 1));

	osg::ref_ptr<osg::PositionAttitudeTransform> patPartA(
			new osg::PositionAttitudeTransform());
	patPartA->addChild(partA);

	this->getRootNode()->addChild(patPartA.get());
	patPartA->setUpdateCallback(
			new BodyCallback(this->getModel(),
					TouchSensorModel::B_SENSOR_BASE_ID));

	return true;

}
bool ActiveCardanRenderModel::initRenderModel() {

	bool meshLoadingA = this->partA_->loadMesh(
			"../models/ActiveCardanHinge_Servo_Holder.stl");

	if (!meshLoadingA) {
		std::cerr << "[ActiveCardanRenderModel] Error loading model"
				<< std::endl;
		return false;
	}

	bool meshLoadingB = this->partB_->loadMesh(
			"../models/ActiveCardanHinge_Servo_Holder.stl");

	if (!meshLoadingB) {
		std::cerr << "[ActiveCardanRenderModel] Error loading model"
				<< std::endl;
		return false;
	}

	bool meshLoadingC = this->patCross_->loadMesh(
			"../models/ActiveCardan_CrossShaft.stl");

	if (!meshLoadingC) {
		std::cerr << "[ActiveCardanRenderModel] Error loading model"
				<< std::endl;
		return false;
	}

	if (isDebugActive()) {
		this->showDebugView();
	}

	float meshCorrection = inMm(0.5);

	// PART A
	osg::ref_ptr<osg::PositionAttitudeTransform> partA =
			this->partA_->getMesh();

	partA_->setColor(osg::Vec4(1, 0, 0, 1));
	partB_->setColor(osg::Vec4(0, 1, 0, 1));

	partA->setPosition(
			osg::Vec3(
					fromOde(meshCorrection +
							ActiveCardanModel::SLOT_THICKNESS
									+ ActiveCardanModel::CONNNECTION_PART_LENGTH
											/ 2), 0, 0));

	partA->setAttitude(osg::Quat(osg::inDegrees(90.0), osg::Vec3(0, 0, 1)) *
			osg::Quat(osg::inDegrees(90.0), osg::Vec3(1, 0, 0)));

	osg::ref_ptr<osg::PositionAttitudeTransform> patPartA(
			new osg::PositionAttitudeTransform());
	patPartA->addChild(partA);

	this->getRootNode()->addChild(patPartA.get());
	patPartA->setUpdateCallback(
			new BodyCallback(this->getModel(), ActiveCardanModel::B_SLOT_A_ID));

	//attachAxis(patPartA);

	// Cross
	osg::ref_ptr<osg::PositionAttitudeTransform> cross =
			this->patCross_->getMesh();

	osg::ref_ptr<osg::PositionAttitudeTransform> patCross(
			new osg::PositionAttitudeTransform());
	patCross->addChild(cross.get());

	this->getRootNode()->addChild(patCross.get());
	patCross->setUpdateCallback(
			new BodyCallback(this->getModel(),
					ActiveCardanModel::B_CROSS_PART_A_ID));
	//attachAxis(patCross);

	// PART B
	osg::ref_ptr<osg::PositionAttitudeTransform> partB =
			this->partB_->getMesh();
	partB->setPosition(
			fromOde(
					osg::Vec3(
							-(meshCorrection + ActiveCardanModel::SLOT_THICKNESS
									+ ActiveCardanModel::CONNNECTION_PART_LENGTH
											/ 2), 0, 0)));

	osg::Quat rotateY(osg::inDegrees(90.0), osg::Vec3(0, 1, 0));
	osg::Quat rotateServoX(osg::inDegrees(90.0), osg::Vec3(1, 0, 0));
	partB->setAttitude(rotateServoX * rotateY *
			osg::Quat(osg::inDegrees(90.0), osg::Vec3(1, 0, 0)));

	osg::ref_ptr<osg::PositionAttitudeTransform> patPartB(
			new osg::PositionAttitudeTransform());
	patPartB->addChild(partB.get());

	this->getRootNode()->addChild(patPartB.get());
	patPartB->setUpdateCallback(
			new BodyCallback(this->getModel(), ActiveCardanModel::B_SLOT_B_ID));

	//attachAxis(patPartB);

	return true;

}