#include "CPyloneRM.h"

CPyloneRM::CPyloneRM(scene::ISceneManager *smg,video::IVideoDriver* dr)
{
    smgr=smg;
    driver=dr;
    monteeSupportCompression=1; //Pyline type Support par défaut
    descenteSupportCompression=1;

    //init pointers
    meshPylone=0;
    nodePylone=0;
    meshPotenceTSTC=0;
    nodePotenceTSTC=0;
    meshPoulie1M=0;
    nodePoulie1D=0;
    meshPoulie2M=0;
    meshPoulie2D=0;

    type=0;
}

void CPyloneRM::SetType(u32 t)
{
	type=t;
}

u32 CPyloneRM::GetType() {
    return type;
}

void CPyloneRM::setPosition(core::vector3df p)
{
    nodePylone->setPosition(p);
}

core::vector3df CPyloneRM::getPosition()
{
    return nodePylone->getAbsolutePosition();
}

void CPyloneRM::setRotation(core::vector3df r)
{
	if(nodePylone)
    {
        nodePylone->setRotation(r);
        nodePylone->updateAbsolutePosition();
    }
}

core::vector3df CPyloneRM::getRotation()
{
    return nodePylone->getRotation();
}

void CPyloneRM::AnimatePylone(f32 vitesse)
{
    core::vector3df rotationPoulieM;
    core::vector3df rotationPoulieD;


    switch(type)
    {
        case CPyloneRM::PYLONE_TKF_MONTEE_DESCENTE:
            //Poulie Montée
            rotationPoulieM=nodePoulie1M->getRotation();

            if(monteeSupportCompression==1) {
                 rotationPoulieM.Z+=vitesse;
                if(rotationPoulieM.Z>360.0f)
                {
                    rotationPoulieM.Z=rotationPoulieM.Z-360.0f;
                }
            }
            if(monteeSupportCompression==-1) {
                rotationPoulieM.Z-=vitesse;
                if(rotationPoulieM.Z<0.0f)
                {
                    rotationPoulieM.Z=rotationPoulieM.Z+360.0f;
                }
            }
            nodePoulie1M->setRotation(rotationPoulieM);

            //Poulie Descente
            rotationPoulieD=nodePoulie1D->getRotation();


            if(descenteSupportCompression==1) {
                rotationPoulieD.Z-=vitesse;
                if(rotationPoulieD.Z>360.0f)
                {
                    rotationPoulieD.Z=rotationPoulieD.Z-360.0f;
                }
            }

            if(descenteSupportCompression==-1) {
                rotationPoulieD.Z+=vitesse;
                if(rotationPoulieD.Z<0.0f)
                {
                    rotationPoulieD.Z=rotationPoulieD.Z+360.0f;
                }
            }

            nodePoulie1D->setRotation(rotationPoulieD);
        break;

        case CPyloneRM::PYLONE_TKF_MONTEE:
            rotationPoulieM=nodePoulie1M->getRotation();


            if(monteeSupportCompression==1) {
                rotationPoulieM.Z+=vitesse;
                if(rotationPoulieM.Z>360.0f) {
                    rotationPoulieM.Z=rotationPoulieM.Z-360.0f;
                }
            }

            if(monteeSupportCompression==-1) {
                rotationPoulieM.Z-=vitesse;
                if(rotationPoulieM.Z<0.0f) {
                    rotationPoulieM.Z=rotationPoulieM.Z+360.0f;
                }
            }
            nodePoulie1M->setRotation(rotationPoulieM);

        break;

        case CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_BAS:
        case CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_MOYEN:
        case CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_HAUT:
            if(monteeSupportCompression==1) {
                rotationPoulieM.Z+=(vitesse*50);
                if(rotationPoulieM.Z>360.0f)
                {
                    rotationPoulieM.Z=rotationPoulieM.Z-360.0f;
                }
                nodePoulie1M->setRotation(rotationPoulieM);
            } else {
                rotationPoulieM.Z-=(vitesse*50);
                if(rotationPoulieM.Z<0.0f) {
                    rotationPoulieM.Z=rotationPoulieM.Z+360.0f;
                }
                nodePoulie1M->setRotation(rotationPoulieM);
            }

        break;
    }


}

void CPyloneRM::DrawPylone(core::vector3df position,core::vector3df rotation)
{
    switch(type)
    {
        case CPyloneRM::PYLONE_TKF_MONTEE_DESCENTE:
            meshPylone = smgr->getMesh("media/pyloneTKFixe-inverse.obj");
            materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePylone=smgr->addMeshSceneNode( meshPylone );
            nodePylone->setScale(core::vector3df(1.5,1.5,1.5));
            nodePylone->setRotation(rotation);
            nodePylone->getMaterial(0) = materialPylone;
            nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePylone->setPosition(position);
            nodePylone->updateAbsolutePosition();

            meshPoulie1M= smgr->getMesh("media/poulieTK.obj");
            materialPoulie1M.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
            nodePoulie1M->getMaterial(0) = materialPoulie1M;
            nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1M->setScale(core::vector3df(0.3,0.3,0.3));
            nodePoulie1M->setRotation(core::vector3df(90,0,0));
            nodePoulie1M->setPosition(core::vector3df(0,5.0,-1.4));
            nodePoulie1M->updateAbsolutePosition();

            meshPoulie1D= smgr->getMesh("media/poulieTK.obj");
            materialPoulie1D.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePoulie1D=smgr->addMeshSceneNode( meshPoulie1D,nodePylone );
            nodePoulie1D->getMaterial(0) = materialPoulie1D;
            nodePoulie1D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1D->setScale(core::vector3df(0.3,0.3,0.3));
            nodePoulie1D->setRotation(core::vector3df(-90,0,0));
            nodePoulie1D->setPosition(core::vector3df(0,7.2,1.5));
            nodePoulie1D->updateAbsolutePosition();

            posMonteePylone=smgr->addEmptySceneNode(nodePylone);
            posMonteePylone->setPosition(core::vector3df(0,5.0,-1.4));
            posMonteePylone->updateAbsolutePosition();

            posDescentePylone=smgr->addEmptySceneNode(nodePylone);
            posDescentePylone->setPosition(core::vector3df(0,7.2,1.5));
            posDescentePylone->updateAbsolutePosition();
        break;

        case CPyloneRM::PYLONE_TKF_MONTEE:
            meshPylone = smgr->getMesh("media/pyloneTKFixe-inverse-montee.obj");
            materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePylone=smgr->addMeshSceneNode( meshPylone );
            nodePylone->setScale(core::vector3df(1.5,1.5,1.5));
            nodePylone->getMaterial(0) = materialPylone;
            nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
            //nodePylone->setRotation(rotation);
            nodePylone->setPosition(position);
            nodePylone->updateAbsolutePosition();

            meshPoulie1M= smgr->getMesh("media/poulieTK.obj");
            materialPoulie1M.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
            nodePoulie1M->getMaterial(0) = materialPoulie1M;
            nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1M->setScale(core::vector3df(0.3,0.3,0.3));
            nodePoulie1M->setRotation(core::vector3df(90,0,0));
            nodePoulie1M->setPosition(core::vector3df(0,5.0,-1.4));
            nodePoulie1M->updateAbsolutePosition();

            posMonteePylone=smgr->addEmptySceneNode(nodePylone);
            posMonteePylone->setPosition(core::vector3df(0,5.0,-1.4));
            posMonteePylone->updateAbsolutePosition();
        break;

        case CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_MOYEN:
            meshPylone = smgr->getMesh("media/pyloneTS-moyen.obj");
            materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePylone=smgr->addMeshSceneNode( meshPylone );
            nodePylone->setScale(core::vector3df(2,2,2));
            nodePylone->getMaterial(0) = materialPylone;
            nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePylone->setRotation(rotation);
            nodePylone->setPosition(position);
            nodePylone->updateAbsolutePosition();

            if(monteeSupportCompression==1) {
                meshPotenceTSTC= smgr->getMesh("media/potenceTSSupp4G.obj");
                nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
            } else {
                meshPotenceTSTC= smgr->getMesh("media/potenceTSComp4G.obj");
                nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
            }
            materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePotenceTSTC->setScale(core::vector3df(1.5,1.5,1.5));
            nodePotenceTSTC->getMaterial(0) = materialPotenceTSTC;
            nodePotenceTSTC->setMaterialFlag(video::EMF_LIGHTING, false);
            //nodePotenceTSTC->setRotation(core::vector3df(rotation.X,rotation.Y+180,rotation.Z));
            nodePotenceTSTC->setPosition(core::vector3df(0,8.0,0));
            nodePotenceTSTC->updateAbsolutePosition();

            meshPoulie1M= smgr->getMesh("media/galet.obj");
            nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
            nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie1M->setRotation(core::vector3df(90,0,0));
            nodePoulie1M->setPosition(core::vector3df(-1,8.0,1.6));
            nodePoulie1M->updateAbsolutePosition();

            meshPoulie2M= smgr->getMesh("media/galet.obj");
            nodePoulie2M=smgr->addMeshSceneNode( meshPoulie2M,nodePylone );
            nodePoulie2M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie2M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie2M->setRotation(core::vector3df(90,0,0));
            nodePoulie2M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie2M->updateAbsolutePosition();

            meshPoulie3M= smgr->getMesh("media/galet.obj");
            nodePoulie3M=smgr->addMeshSceneNode( meshPoulie3M,nodePylone );
            nodePoulie3M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie3M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie3M->setRotation(core::vector3df(90,0,0));
            nodePoulie3M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie3M->updateAbsolutePosition();

            meshPoulie4M= smgr->getMesh("media/galet.obj");
            nodePoulie4M=smgr->addMeshSceneNode( meshPoulie4M,nodePylone );
            nodePoulie4M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie4M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie4M->setRotation(core::vector3df(90,0,0));
            nodePoulie4M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie4M->updateAbsolutePosition();

            meshPoulie1D= smgr->getMesh("media/galet.obj");
            nodePoulie1D=smgr->addMeshSceneNode( meshPoulie1D,nodePylone );
            nodePoulie1D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie1D->setRotation(core::vector3df(-90,0,0));
            nodePoulie1D->setPosition(core::vector3df(1,8.0,-1.6));
            nodePoulie1D->updateAbsolutePosition();

            meshPoulie2D= smgr->getMesh("media/galet.obj");
            nodePoulie2D=smgr->addMeshSceneNode( meshPoulie2D,nodePylone );
            nodePoulie2D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie2D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie2D->setRotation(core::vector3df(-90,0,0));
            nodePoulie2D->setPosition(core::vector3df(0.5,8.0,-1.6));
            nodePoulie2D->updateAbsolutePosition();

            meshPoulie3D= smgr->getMesh("media/galet.obj");
            nodePoulie3D=smgr->addMeshSceneNode( meshPoulie3D,nodePylone );
            nodePoulie3D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie3D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie3D->setRotation(core::vector3df(-90,0,0));
            nodePoulie3D->setPosition(core::vector3df(-0.5,8.0,-1.6));
            nodePoulie3D->updateAbsolutePosition();

            meshPoulie4D= smgr->getMesh("media/galet.obj");
            nodePoulie4D=smgr->addMeshSceneNode( meshPoulie4D,nodePylone );
            nodePoulie4D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie4D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie4D->setRotation(core::vector3df(-90,0,0));
            nodePoulie4D->setPosition(core::vector3df(-1.0,8.0,-1.6));
            nodePoulie4D->updateAbsolutePosition();


            posMonteePylone=smgr->addEmptySceneNode(nodePylone);
            posMonteePylone->setPosition(core::vector3df(0,8.0,1.6));
            posMonteePylone->updateAbsolutePosition();

            posDescentePylone=smgr->addEmptySceneNode(nodePylone);
            posDescentePylone->setPosition(core::vector3df(0,8.2,-1.6));
            posDescentePylone->updateAbsolutePosition();
        break;

        case CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_BAS:
            meshPylone = smgr->getMesh("media/pyloneTS-bas.obj");
            materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePylone=smgr->addMeshSceneNode( meshPylone );
            nodePylone->setScale(core::vector3df(2,2,2));
            nodePylone->getMaterial(0) = materialPylone;
            nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePylone->setRotation(rotation);
            nodePylone->setPosition(position);
            nodePylone->updateAbsolutePosition();

            if(monteeSupportCompression==1) {
                meshPotenceTSTC= smgr->getMesh("media/potenceTSSupp4G.obj");
                materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
                nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
            } else {
                meshPotenceTSTC= smgr->getMesh("media/potenceTSComp4G.obj");
                materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
                nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
            }
            materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePotenceTSTC->setScale(core::vector3df(1.5,1.5,1.5));
            nodePotenceTSTC->getMaterial(0) = materialPotenceTSTC;
            nodePotenceTSTC->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePotenceTSTC->setRotation(core::vector3df(0,0,0));
            nodePotenceTSTC->setPosition(core::vector3df(0,5.0,-1.4));
            nodePotenceTSTC->updateAbsolutePosition();

            meshPoulie1M= smgr->getMesh("media/galet.obj");
            nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
            nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie1M->setRotation(core::vector3df(90,0,0));
            nodePoulie1M->setPosition(core::vector3df(-1,8.0,1.6));
            nodePoulie1M->updateAbsolutePosition();

            meshPoulie2M= smgr->getMesh("media/galet.obj");
            nodePoulie2M=smgr->addMeshSceneNode( meshPoulie2M,nodePylone );
            nodePoulie2M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie2M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie2M->setRotation(core::vector3df(90,0,0));
            nodePoulie2M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie2M->updateAbsolutePosition();

            meshPoulie3M= smgr->getMesh("media/galet.obj");
            nodePoulie3M=smgr->addMeshSceneNode( meshPoulie3M,nodePylone );
            nodePoulie3M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie3M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie3M->setRotation(core::vector3df(90,0,0));
            nodePoulie3M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie3M->updateAbsolutePosition();

            meshPoulie4M= smgr->getMesh("media/galet.obj");
            nodePoulie4M=smgr->addMeshSceneNode( meshPoulie4M,nodePylone );
            nodePoulie4M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie4M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie4M->setRotation(core::vector3df(90,0,0));
            nodePoulie4M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie4M->updateAbsolutePosition();

            meshPoulie1D= smgr->getMesh("media/galet.obj");
            nodePoulie1D=smgr->addMeshSceneNode( meshPoulie1D,nodePylone );
            nodePoulie1D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie1D->setRotation(core::vector3df(-90,0,0));
            nodePoulie1D->setPosition(core::vector3df(1,8.0,-1.6));
            nodePoulie1D->updateAbsolutePosition();

            meshPoulie2D= smgr->getMesh("media/galet.obj");
            nodePoulie2D=smgr->addMeshSceneNode( meshPoulie2D,nodePylone );
            nodePoulie2D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie2D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie2D->setRotation(core::vector3df(-90,0,0));
            nodePoulie2D->setPosition(core::vector3df(0.5,8.0,-1.6));
            nodePoulie2D->updateAbsolutePosition();

            meshPoulie3D= smgr->getMesh("media/galet.obj");
            nodePoulie3D=smgr->addMeshSceneNode( meshPoulie3D,nodePylone );
            nodePoulie3D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie3D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie3D->setRotation(core::vector3df(-90,0,0));
            nodePoulie3D->setPosition(core::vector3df(-0.5,8.0,-1.6));
            nodePoulie3D->updateAbsolutePosition();

            meshPoulie4D= smgr->getMesh("media/galet.obj");
            nodePoulie4D=smgr->addMeshSceneNode( meshPoulie4D,nodePylone );
            nodePoulie4D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie4D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie4D->setRotation(core::vector3df(-90,0,0));
            nodePoulie4D->setPosition(core::vector3df(-1.0,8.0,-1.6));
            nodePoulie4D->updateAbsolutePosition();


            posMonteePylone=smgr->addEmptySceneNode(nodePylone);
            posMonteePylone->setPosition(core::vector3df(0,5.0,-1.4));
            posMonteePylone->updateAbsolutePosition();

            posDescentePylone=smgr->addEmptySceneNode(nodePylone);
            posDescentePylone->setPosition(core::vector3df(0,7.2,1.5));
            posDescentePylone->updateAbsolutePosition();
        break;

        case CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_HAUT:
            meshPylone = smgr->getMesh("media/pyloneTS-haut.obj");
            materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePylone=smgr->addMeshSceneNode( meshPylone );
            nodePylone->setScale(core::vector3df(2,2,2));
            nodePylone->getMaterial(0) = materialPylone;
            nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePylone->setRotation(rotation);
            nodePylone->setPosition(position);
            nodePylone->updateAbsolutePosition();

            if(monteeSupportCompression==1) {
                meshPotenceTSTC= smgr->getMesh("media/potenceTSSupp4G.obj");
                materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
                nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
            } else {
                meshPotenceTSTC= smgr->getMesh("media/potenceTSComp4G.obj");
                materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
                nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
            }
            materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePotenceTSTC->setScale(core::vector3df(1.5,1.5,1.5));
            nodePotenceTSTC->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePotenceTSTC->setRotation(core::vector3df(0,0,0));
            nodePotenceTSTC->setPosition(core::vector3df(0,10.0,-1.4));
            nodePotenceTSTC->updateAbsolutePosition();

            meshPoulie1M= smgr->getMesh("media/galet.obj");
            nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
            nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie1M->setRotation(core::vector3df(90,0,0));
            nodePoulie1M->setPosition(core::vector3df(-1,8.0,1.6));
            nodePoulie1M->updateAbsolutePosition();

            meshPoulie2M= smgr->getMesh("media/galet.obj");
            nodePoulie2M=smgr->addMeshSceneNode( meshPoulie2M,nodePylone );
            nodePoulie2M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie2M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie2M->setRotation(core::vector3df(90,0,0));
            nodePoulie2M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie2M->updateAbsolutePosition();

            meshPoulie3M= smgr->getMesh("media/galet.obj");
            nodePoulie3M=smgr->addMeshSceneNode( meshPoulie3M,nodePylone );

            nodePoulie3M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie3M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie3M->setRotation(core::vector3df(90,0,0));
            nodePoulie3M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie3M->updateAbsolutePosition();

            meshPoulie4M= smgr->getMesh("media/galet.obj");
            nodePoulie4M=smgr->addMeshSceneNode( meshPoulie4M,nodePylone );
            nodePoulie4M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie4M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie4M->setRotation(core::vector3df(90,0,0));
            nodePoulie4M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie4M->updateAbsolutePosition();

            meshPoulie1D= smgr->getMesh("media/galet.obj");
            nodePoulie1D=smgr->addMeshSceneNode( meshPoulie1D,nodePylone );
            nodePoulie1D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie1D->setRotation(core::vector3df(-90,0,0));
            nodePoulie1D->setPosition(core::vector3df(1,8.0,-1.6));
            nodePoulie1D->updateAbsolutePosition();

            meshPoulie2D= smgr->getMesh("media/galet.obj");
            nodePoulie2D=smgr->addMeshSceneNode( meshPoulie2D,nodePylone );
            nodePoulie2D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie2D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie2D->setRotation(core::vector3df(-90,0,0));
            nodePoulie2D->setPosition(core::vector3df(0.5,8.0,-1.6));
            nodePoulie2D->updateAbsolutePosition();

            meshPoulie3D= smgr->getMesh("media/galet.obj");
            nodePoulie3D=smgr->addMeshSceneNode( meshPoulie3D,nodePylone );
            nodePoulie3D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie3D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie3D->setRotation(core::vector3df(-90,0,0));
            nodePoulie3D->setPosition(core::vector3df(-0.5,8.0,-1.6));
            nodePoulie3D->updateAbsolutePosition();

            meshPoulie4D= smgr->getMesh("media/galet.obj");
            nodePoulie4D=smgr->addMeshSceneNode( meshPoulie4D,nodePylone );
            nodePoulie4D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie4D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie4D->setRotation(core::vector3df(-90,0,0));
            nodePoulie4D->setPosition(core::vector3df(-1.0,8.0,-1.6));
            nodePoulie4D->updateAbsolutePosition();


            posMonteePylone=smgr->addEmptySceneNode(nodePylone);
            posMonteePylone->setPosition(core::vector3df(0,10.0,-1.4));
            posMonteePylone->updateAbsolutePosition();

            posDescentePylone=smgr->addEmptySceneNode(nodePylone);
            posDescentePylone->setPosition(core::vector3df(0,10.0,1.5));
            posDescentePylone->updateAbsolutePosition();
        break;
    }
}

void CPyloneRM::DropPylone() {
    nodePylone->remove();
    nodePylone->drop();
    smgr->getMeshCache()->removeMesh(meshPylone);
    /*nodePoulie1M->drop();
    if(nodePoulie1D) {
        nodePoulie1D->drop();
    }*/
}

//Permet de changer le type de pylone -> on supprime puis on recrée le mesh et le scene node du pylone
void CPyloneRM::ChangeTypePylone(s32 typePyl,core::vector3df position,core::vector3df rotation) {
    //Si c'est le meme pylone, on ne change rien et on quitte la fonction
    /*if(typePyl==type) {
        return;
    }*/

    nodePylone->remove();

    type=typePyl;

    materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
    if(type==CPyloneRM::PYLONE_TKF_MONTEE_DESCENTE) {
        meshPylone = smgr->getMesh("media/pyloneTKFixe-inverse.obj");
        nodePylone=smgr->addMeshSceneNode( meshPylone );
        nodePylone->setScale(core::vector3df(1.5,1.5,1.5));
        nodePylone->setRotation(rotation);
        nodePylone->getMaterial(0) = materialPylone;
        nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePylone->setPosition(position);
        nodePylone->updateAbsolutePosition();

        meshPoulie1M= smgr->getMesh("media/poulieTK.obj");
        materialPoulie1M.setTexture(0,driver->getTexture("media/texture-pylone.png"));
        nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
        nodePoulie1M->getMaterial(0) = materialPoulie1M;
        nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie1M->setScale(core::vector3df(0.3,0.3,0.3));
        nodePoulie1M->setRotation(core::vector3df(90,0,0));
        nodePoulie1M->setPosition(core::vector3df(0,5.0,-1.4));
        nodePoulie1M->updateAbsolutePosition();

        meshPoulie1D= smgr->getMesh("media/poulieTK.obj");
        materialPoulie1D.setTexture(0,driver->getTexture("media/texture-pylone.png"));
        nodePoulie1D=smgr->addMeshSceneNode( meshPoulie1D,nodePylone );
        nodePoulie1D->getMaterial(0) = materialPoulie1D;
        nodePoulie1D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie1D->setScale(core::vector3df(0.3,0.3,0.3));
        nodePoulie1D->setRotation(core::vector3df(-90,0,0));
        nodePoulie1D->setPosition(core::vector3df(0,7.2,1.5));
        nodePoulie1D->updateAbsolutePosition();

        posMonteePylone=smgr->addEmptySceneNode(nodePylone);
        posMonteePylone->setPosition(core::vector3df(0,5.0,-1.4));
        posMonteePylone->updateAbsolutePosition();

        posDescentePylone=smgr->addEmptySceneNode(nodePylone);
        posDescentePylone->setPosition(core::vector3df(0,7.2,1.5));
        posDescentePylone->updateAbsolutePosition();
    }

    if(type==CPyloneRM::PYLONE_TKF_MONTEE) {
        meshPylone = smgr->getMesh("media/pyloneTKFixe-inverse-montee.obj");
        nodePylone=smgr->addMeshSceneNode( meshPylone );
        nodePylone->setScale(core::vector3df(1.5,1.5,1.5));
        nodePylone->setRotation(rotation);
        nodePylone->getMaterial(0) = materialPylone;
        nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePylone->setPosition(position);
        nodePylone->updateAbsolutePosition();

        meshPoulie1M= smgr->getMesh("media/poulieTK.obj");
        materialPoulie1M.setTexture(0,driver->getTexture("media/texture-pylone.png"));
        nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
        nodePoulie1M->getMaterial(0) = materialPoulie1M;
        nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie1M->setScale(core::vector3df(0.3,0.3,0.3));
        nodePoulie1M->setRotation(core::vector3df(90,0,0));
        nodePoulie1M->setPosition(core::vector3df(0,5.0,-1.5));
        nodePoulie1M->updateAbsolutePosition();

        posMonteePylone=smgr->addEmptySceneNode(nodePylone);
        posMonteePylone->setPosition(core::vector3df(0,5.0,-1.4));
        posMonteePylone->updateAbsolutePosition();
    }

    if(type==CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_BAS) {
        meshPylone = smgr->getMesh("media/pyloneTS-bas.obj");
        materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
        nodePylone=smgr->addMeshSceneNode( meshPylone );
        nodePylone->setScale(core::vector3df(2,2,2));
        nodePylone->getMaterial(0) = materialPylone;
        nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePylone->setRotation(rotation);
        nodePylone->setPosition(position);
        nodePylone->updateAbsolutePosition();

        if(monteeSupportCompression==1) {
            meshPotenceTSTC= smgr->getMesh("media/potenceTSSupp4G.obj");
            materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
        } else {
            meshPotenceTSTC= smgr->getMesh("media/potenceTSComp4G.obj");
            materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
        }
        materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
        nodePotenceTSTC->setScale(core::vector3df(1.5,1.5,1.5));
        nodePotenceTSTC->getMaterial(0) = materialPotenceTSTC;
        nodePotenceTSTC->setMaterialFlag(video::EMF_LIGHTING, false);
        //nodePotenceTSTC->setRotation(core::vector3df(0,0,0));
        nodePotenceTSTC->setPosition(core::vector3df(0,5.3,0.0));
        nodePotenceTSTC->updateAbsolutePosition();

        meshPoulie1M= smgr->getMesh("media/galet.obj");
        nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
        nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie1M->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie1M->setRotation(core::vector3df(90,0,0));
        nodePoulie1M->setPosition(core::vector3df(-1.0,5.3,1.6));
        nodePoulie1M->updateAbsolutePosition();

        meshPoulie2M= smgr->getMesh("media/galet.obj");
        nodePoulie2M=smgr->addMeshSceneNode( meshPoulie2M,nodePylone );
        nodePoulie2M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie2M->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie2M->setRotation(core::vector3df(90,0,0));
        nodePoulie2M->setPosition(core::vector3df(-0.5,5.3,1.6));
        nodePoulie2M->updateAbsolutePosition();

        meshPoulie3M= smgr->getMesh("media/galet.obj");
        nodePoulie3M=smgr->addMeshSceneNode( meshPoulie3M,nodePylone );
        nodePoulie3M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie3M->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie3M->setRotation(core::vector3df(90,0,0));
        nodePoulie3M->setPosition(core::vector3df(0.5,5.3,1.6));
        nodePoulie3M->updateAbsolutePosition();

        meshPoulie4M= smgr->getMesh("media/galet.obj");
        nodePoulie4M=smgr->addMeshSceneNode( meshPoulie4M,nodePylone );
        nodePoulie4M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie4M->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie4M->setRotation(core::vector3df(90,0,0));
        nodePoulie4M->setPosition(core::vector3df(1.0,5.3,1.6));
        nodePoulie4M->updateAbsolutePosition();

        meshPoulie1D= smgr->getMesh("media/galet.obj");
        nodePoulie1D=smgr->addMeshSceneNode( meshPoulie1D,nodePylone );
        nodePoulie1D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie1D->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie1D->setRotation(core::vector3df(-90,0,0));
        nodePoulie1D->setPosition(core::vector3df(1.0,5.3,-1.6));
        nodePoulie1D->updateAbsolutePosition();

        meshPoulie2D= smgr->getMesh("media/galet.obj");
        nodePoulie2D=smgr->addMeshSceneNode( meshPoulie2D,nodePylone );
        nodePoulie2D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie2D->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie2D->setRotation(core::vector3df(-90,0,0));
        nodePoulie2D->setPosition(core::vector3df(0.5,5.3,-1.6));
        nodePoulie2D->updateAbsolutePosition();

        meshPoulie3D= smgr->getMesh("media/galet.obj");
        nodePoulie3D=smgr->addMeshSceneNode( meshPoulie3D,nodePylone );
        nodePoulie3D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie3D->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie3D->setRotation(core::vector3df(-90,0,0));
        nodePoulie3D->setPosition(core::vector3df(-0.5,5.3,-1.6));
        nodePoulie3D->updateAbsolutePosition();

        meshPoulie4D= smgr->getMesh("media/galet.obj");
        nodePoulie4D=smgr->addMeshSceneNode( meshPoulie4D,nodePylone );
        nodePoulie4D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie4D->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie4D->setRotation(core::vector3df(-90,0,0));
        nodePoulie4D->setPosition(core::vector3df(-1.0,5.3,-1.6));
        nodePoulie4D->updateAbsolutePosition();

        posMonteePylone=smgr->addEmptySceneNode(nodePylone);
        posMonteePylone->setPosition(core::vector3df(0,5.3,1.6));
        posMonteePylone->updateAbsolutePosition();

        posDescentePylone=smgr->addEmptySceneNode(nodePylone);
        posDescentePylone->setPosition(core::vector3df(0,5.3,-1.6));
        posDescentePylone->updateAbsolutePosition();
    }

    if(type==CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_MOYEN) {
       meshPylone = smgr->getMesh("media/pyloneTS-moyen.obj");
            materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePylone=smgr->addMeshSceneNode( meshPylone );
            nodePylone->setScale(core::vector3df(2,2,2));
            nodePylone->getMaterial(0) = materialPylone;
            nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePylone->setRotation(rotation);
            nodePylone->setPosition(position);
            nodePylone->updateAbsolutePosition();

            if(monteeSupportCompression==1) {
                meshPotenceTSTC= smgr->getMesh("media/potenceTSSupp4G.obj");
                materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
                nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
                printf("Potence pyl moyen TS Support\n");
            } else {
                meshPotenceTSTC= smgr->getMesh("media/potenceTSComp4G.obj");
                materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
                nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
                printf("Potence pyl moyen TS compression\n");
            }
            materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePotenceTSTC->setScale(core::vector3df(1.5,1.5,1.5));
            nodePotenceTSTC->getMaterial(0) = materialPotenceTSTC;
            nodePotenceTSTC->setMaterialFlag(video::EMF_LIGHTING, false);
            //nodePotenceTSTC->setRotation(core::vector3df(0,180,0));
            nodePotenceTSTC->setPosition(core::vector3df(0,8.0,0));
            nodePotenceTSTC->updateAbsolutePosition();

            meshPoulie1M= smgr->getMesh("media/galet.obj");
            nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
            nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie1M->setRotation(core::vector3df(90,0,0));
            nodePoulie1M->setPosition(core::vector3df(-1,8.0,1.6));
            nodePoulie1M->updateAbsolutePosition();

            meshPoulie2M= smgr->getMesh("media/galet.obj");
            nodePoulie2M=smgr->addMeshSceneNode( meshPoulie2M,nodePylone );
            nodePoulie2M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie2M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie2M->setRotation(core::vector3df(90,0,0));
            nodePoulie2M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie2M->updateAbsolutePosition();

            meshPoulie3M= smgr->getMesh("media/galet.obj");
            nodePoulie3M=smgr->addMeshSceneNode( meshPoulie3M,nodePylone );
            nodePoulie3M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie3M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie3M->setRotation(core::vector3df(90,0,0));
            nodePoulie3M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie3M->updateAbsolutePosition();

            meshPoulie4M= smgr->getMesh("media/galet.obj");
            nodePoulie4M=smgr->addMeshSceneNode( meshPoulie4M,nodePylone );
            nodePoulie4M->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie4M->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie4M->setRotation(core::vector3df(90,0,0));
            nodePoulie4M->setPosition(core::vector3df(-0.5,8.0,1.6));
            nodePoulie4M->updateAbsolutePosition();

            meshPoulie1D= smgr->getMesh("media/galet.obj");
            nodePoulie1D=smgr->addMeshSceneNode( meshPoulie1D,nodePylone );
            nodePoulie1D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie1D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie1D->setRotation(core::vector3df(-90,0,0));
            nodePoulie1D->setPosition(core::vector3df(1,7.9,-1.6));
            nodePoulie1D->updateAbsolutePosition();

            meshPoulie2D= smgr->getMesh("media/galet.obj");
            nodePoulie2D=smgr->addMeshSceneNode( meshPoulie2D,nodePylone );
            nodePoulie2D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie2D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie2D->setRotation(core::vector3df(-90,0,0));
            nodePoulie2D->setPosition(core::vector3df(0.5,7.95,-1.6));
            nodePoulie2D->updateAbsolutePosition();

            meshPoulie3D= smgr->getMesh("media/galet.obj");
            nodePoulie3D=smgr->addMeshSceneNode( meshPoulie3D,nodePylone );
            nodePoulie3D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie3D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie3D->setRotation(core::vector3df(-90,0,0));
            nodePoulie3D->setPosition(core::vector3df(-0.5,8.1,-1.6));
            nodePoulie3D->updateAbsolutePosition();

            meshPoulie4D= smgr->getMesh("media/galet.obj");
            nodePoulie4D=smgr->addMeshSceneNode( meshPoulie4D,nodePylone );
            nodePoulie4D->setMaterialFlag(video::EMF_LIGHTING, false);
            nodePoulie4D->setScale(core::vector3df(0.05,0.05,0.05));
            nodePoulie4D->setRotation(core::vector3df(-90,0,0));
            nodePoulie4D->setPosition(core::vector3df(-1.0,8.2,-1.6));
            nodePoulie4D->updateAbsolutePosition();

            posMonteePylone=smgr->addEmptySceneNode(nodePylone);
            posMonteePylone->setPosition(core::vector3df(0,8.0,1.6));
            posMonteePylone->updateAbsolutePosition();

            posDescentePylone=smgr->addEmptySceneNode(nodePylone);
            posDescentePylone->setPosition(core::vector3df(0,8.0,-1.6));
            posDescentePylone->updateAbsolutePosition();
    }

    if(type==CPyloneRM::PYLONE_TSF_MONTEE_DESCENTE_HAUT) {
        meshPylone = smgr->getMesh("media/pyloneTS-haut.obj");
        materialPylone.setTexture(0,driver->getTexture("media/texture-pylone.png"));
        nodePylone=smgr->addMeshSceneNode( meshPylone );
        nodePylone->setScale(core::vector3df(2,2,2));
        nodePylone->getMaterial(0) = materialPylone;
        nodePylone->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePylone->setRotation(rotation);
        nodePylone->setPosition(position);
        nodePylone->updateAbsolutePosition();

        if(monteeSupportCompression==1) {
            meshPotenceTSTC= smgr->getMesh("media/potenceTSSupp4G.obj");
            materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
        } else {
            meshPotenceTSTC= smgr->getMesh("media/potenceTSComp4G.obj");
            materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
            nodePotenceTSTC=smgr->addMeshSceneNode(meshPotenceTSTC,nodePylone);
        }
        materialPotenceTSTC.setTexture(0,driver->getTexture("media/texture-pylone.png"));
        nodePotenceTSTC->setScale(core::vector3df(1.5,1.5,1.5));
        nodePotenceTSTC->getMaterial(0) = materialPotenceTSTC;
        nodePotenceTSTC->setMaterialFlag(video::EMF_LIGHTING, false);
        //nodePotenceTSTC->setRotation(core::vector3df(0,0,0));
        nodePotenceTSTC->setPosition(core::vector3df(0,13.0,0.0));
        nodePotenceTSTC->updateAbsolutePosition();

         meshPoulie1M= smgr->getMesh("media/galet.obj");
        nodePoulie1M=smgr->addMeshSceneNode( meshPoulie1M,nodePylone );
        nodePoulie1M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie1M->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie1M->setRotation(core::vector3df(90,0,0));
        nodePoulie1M->setPosition(core::vector3df(-1,13.0,1.6));
        nodePoulie1M->updateAbsolutePosition();

        meshPoulie2M= smgr->getMesh("media/galet.obj");
        nodePoulie2M=smgr->addMeshSceneNode( meshPoulie2M,nodePylone );
        nodePoulie2M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie2M->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie2M->setRotation(core::vector3df(90,0,0));
        nodePoulie2M->setPosition(core::vector3df(-0.5,13.0,1.6));
        nodePoulie2M->updateAbsolutePosition();

        meshPoulie3M= smgr->getMesh("media/galet.obj");
        nodePoulie3M=smgr->addMeshSceneNode( meshPoulie3M,nodePylone );
        nodePoulie3M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie3M->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie3M->setRotation(core::vector3df(90,0,0));
        nodePoulie3M->setPosition(core::vector3df(0.5,13.0,1.6));
        nodePoulie3M->updateAbsolutePosition();

        meshPoulie4M= smgr->getMesh("media/galet.obj");
        nodePoulie4M=smgr->addMeshSceneNode( meshPoulie4M,nodePylone );
        nodePoulie4M->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie4M->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie4M->setRotation(core::vector3df(90,0,0));
        nodePoulie4M->setPosition(core::vector3df(1.0,13.0,1.6));
        nodePoulie4M->updateAbsolutePosition();

        meshPoulie1D= smgr->getMesh("media/galet.obj");
        nodePoulie1D=smgr->addMeshSceneNode( meshPoulie1D,nodePylone );
        nodePoulie1D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie1D->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie1D->setRotation(core::vector3df(-90,0,0));
        nodePoulie1D->setPosition(core::vector3df(1.0,13.0,-1.6));
        nodePoulie1D->updateAbsolutePosition();

        meshPoulie2D= smgr->getMesh("media/galet.obj");
        nodePoulie2D=smgr->addMeshSceneNode( meshPoulie2D,nodePylone );
        nodePoulie2D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie2D->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie2D->setRotation(core::vector3df(-90,0,0));
        nodePoulie2D->setPosition(core::vector3df(0.5,13.0,-1.6));
        nodePoulie2D->updateAbsolutePosition();

        meshPoulie3D= smgr->getMesh("media/galet.obj");
        nodePoulie3D=smgr->addMeshSceneNode( meshPoulie3D,nodePylone );
        nodePoulie3D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie3D->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie3D->setRotation(core::vector3df(-90,0,0));
        nodePoulie3D->setPosition(core::vector3df(-0.5,13.0,-1.6));
        nodePoulie3D->updateAbsolutePosition();

        meshPoulie4D= smgr->getMesh("media/galet.obj");
        nodePoulie4D=smgr->addMeshSceneNode( meshPoulie4D,nodePylone );
        nodePoulie4D->setMaterialFlag(video::EMF_LIGHTING, false);
        nodePoulie4D->setScale(core::vector3df(0.05,0.05,0.05));
        nodePoulie4D->setRotation(core::vector3df(-90,0,0));
        nodePoulie4D->setPosition(core::vector3df(-1.0,13.0,-1.6));
        nodePoulie4D->updateAbsolutePosition();

        posMonteePylone=smgr->addEmptySceneNode(nodePylone);
        posMonteePylone->setPosition(core::vector3df(0,13.0,1.6));
        posMonteePylone->updateAbsolutePosition();

        posDescentePylone=smgr->addEmptySceneNode(nodePylone);
        posDescentePylone->setPosition(core::vector3df(0,13.0,-1.6));
        posDescentePylone->updateAbsolutePosition();
    }

}

CPyloneRM::~CPyloneRM()
{
    if(meshPylone!=0) {
        delete meshPylone;
        meshPylone=0;
    }
    if(nodePylone!=0) {
        delete nodePylone;
        nodePylone=0;
    }
    if(meshPoulie1M!=0) {
        delete meshPoulie1M;
        meshPoulie1M=0;
    }
    if(nodePoulie1D!=0) {
        delete nodePoulie1D;
        nodePoulie1D=0;
    }
    if(meshPoulie2M!=0) {
        delete meshPoulie2M;
        meshPoulie2M=0;
    }
    if(meshPoulie2D!=0) {
        delete meshPoulie2D;
        meshPoulie2D=0;
    }
}
