osg::PositionAttitudeTransform* creation_CHARRR(float posx, float posy, osg::Node* terrain){
	osg::Node* LECHARRR = osgDB::readNodeFile("t72-tank_des.flt");
	osg::PositionAttitudeTransform* pos_tank = new osg::PositionAttitudeTransform;
	osg::Vec3 pos, normal;
	intersection_terrain(posx, posy, terrain, pos, normal);
	pos_tank->setPosition(pos);
	osg::Quat rotation;
	rotation.makeRotate(osg::Vec3f(0, 0, 1), normal);
	pos_tank->setAttitude(rotation);
	pos_tank->addChild(LECHARRR);
	pos_tank->setUpdateCallback(new Deplacement);
	
	return pos_tank;
}
bool GestionEvenements::handle( const osgGA::GUIEventAdapter& ea,
 osgGA::GUIActionAdapter& aa)
{
	switch(ea.getEventType()){
		case osgGA::GUIEventAdapter::KEYDOWN :
		
			switch(ea.getKey()){
				
				case 'q':
					noeudTourelle = rechercheTourelle.getNode();
					if (noeudTourelle != NULL){
						osgSim::DOFTransform* tourelleDOF = dynamic_cast<osgSim::DOFTransform*>(noeudTourelle);
						tourelleDOF->setCurrentHPR(osg::Vec3(tourelleDOF->getCurrentHPR().x() + osg::DegreesToRadians(20.0), 0.0, 0.0));
					}
					break;
				case 'd':
					noeudTourelle = rechercheTourelle.getNode();
					if (noeudTourelle != NULL){
						osgSim::DOFTransform* tourelleDOF = dynamic_cast<osgSim::DOFTransform*>(noeudTourelle);
						tourelleDOF->setCurrentHPR(osg::Vec3(tourelleDOF->getCurrentHPR().x() - osg::DegreesToRadians(20.0), 0.0, 0.0));
					}
					break;
				case '8':
					intersection_terrain(LECHARRR->getPosition().x(), LECHARRR->getPosition().y() + 3, terrain, posTank, normalTank);
					LECHARRR->setPosition(posTank);
					rotation.makeRotate(osg::Vec3f(0, 0, 1), normalTank);
					LECHARRR->setAttitude(rotation);
					fumeeTank->setPosition(LECHARRR->getPosition());
					break;
				case '2':
					intersection_terrain(LECHARRR->getPosition().x(), LECHARRR->getPosition().y() - 3, terrain, posTank, normalTank);
					LECHARRR->setPosition(posTank);
					rotation.makeRotate(osg::Vec3f(0, 0, 1), normalTank);
					LECHARRR->setAttitude(rotation);
					fumeeTank->setPosition(LECHARRR->getPosition());
					break;
				case '4':
					intersection_terrain(LECHARRR->getPosition().x() - 3, LECHARRR->getPosition().y(), terrain, posTank, normalTank);
					LECHARRR->setPosition(posTank);
					rotation.makeRotate(osg::Vec3f(0, 0, 1), normalTank);
					LECHARRR->setAttitude(rotation);
					fumeeTank->setPosition(LECHARRR->getPosition());
					break;
				case '6':
					intersection_terrain(LECHARRR->getPosition().x() + 3, LECHARRR->getPosition().y(), terrain, posTank, normalTank);
					LECHARRR->setPosition(posTank);
					rotation.makeRotate(osg::Vec3f(0, 0, 1), normalTank);
					LECHARRR->setAttitude(rotation);
					fumeeTank->setPosition(LECHARRR->getPosition());
					break;
				case 'p':
					LECHARRR->setScale(LECHARRR->getScale() + osg::Vec3(1.0, 1.0, 1.0));
					LECHARRR->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
					fumeeTank->setScale(fumeeTank->getScale() + 5);
					break;
				case 'm':
					LECHARRR->setScale(LECHARRR->getScale() - osg::Vec3(1.0, 1.0, 1.0));
					LECHARRR->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
					fumeeTank->setScale(fumeeTank->getScale() - 5);
					break;
				case 'f':
				scene->addChild(new osgParticle::ExplosionEffect(osg::Vec3(posCanonX, posCanonY, posCanonZ), 1.0f, 1.0f));
					break;
			}
			break;
		
		case osgGA::GUIEventAdapter::PUSH :{
			int x = ea.getX();
			int y = ea.getY();
			if( ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
				//std::cout << "bouton gauche" << std::endl;
			if (ea.getButton() == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
				//std::cout << "bouton milieu" << std::endl;
			if (ea.getButton() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
				//std::cout << "bouton droit" << std::endl;
			break;
 }
		case osgGA::GUIEventAdapter::DOUBLECLICK :
			break;
			}
 return false; // pour que l'événement soit traité par d'autres gestionnaires
}