#include "CRemontee.h"

CRemontee::CRemontee()
{
    constructionFinie=false;
    // CREATE AUDIO DEVICE:
    //deviceA(OpenDevice());
    deviceA=OpenDevice();
}

void CRemontee::SetPositionArrivee(core::vector3df p)
{
	positionArrivee=p;
}

void CRemontee::SetPositionDepart(core::vector3df p)
{
}

core::vector3df CRemontee::GetRotationRM()
{
    core::vector3df result=positionArrivee-positionDepart;
    result=result.getHorizontalAngle();
    return result;
}

core::vector3df CRemontee::GetPositionDepart() {
    return positionDepart;
}

core::vector3df CRemontee::GetPositionArrivee() {
    return positionArrivee;
}

void CRemontee::DrawRemonteeDepart()
{
}

void CRemontee::DrawRemonteeArrivee()
{
}

void CRemontee::RedrawCable()
{

}

void CRemontee::AnimateRm(core::vector3df camPosition,f32 deltaTime)
{

}

void CRemontee::UpdateTroncons()
{

}

void CRemontee::PlaySoundMoteur(bool play)
{

}

OutputStreamPtr CRemontee::GetSoundMoteur() {
    return soundMoteur;
}

CTronconRM* CRemontee::GetTronconByNumero(u32 num)
{
    for(unsigned int i=0;i<arrTroncons.size();i++){

        if(arrTroncons[i]->numero==num)
        {
            return arrTroncons[i];
        }
    }

    return 0;
}

// Get angle between vectors
f32 CRemontee::GetAngleBetween (const core::vector3df& vec1,const core::vector3df& vec2)
{
    f32 angle;
    angle = acos((vec1.X * vec2.X + vec1.Y * vec2.Y + vec1.Z * vec2.Z)/(
    sqrt(vec1.X*vec1.X + vec1.Y*vec1.Y + vec1.Z*vec1.Z) * sqrt(pow(vec2.X,2) + pow(vec2.Y,2) + pow(vec2.Z,2))
    ));
    return angle*180.0f/core::PI;
}

u32 CRemontee::CompressionOrSupport (const core::vector3df& pylmoins1,const core::vector3df& pyl,const core::vector3df& pylplus1)
{
    core::vector3df v1=pylmoins1-pyl;
    core::vector3df v2=pylplus1-pyl;

    v1.normalize();
    v2.normalize();

    core::vector3df test=v1+v2;

    //printf("TEST vector %f %f %f\n",test.X,test.Y,test.Z);

    if(test.Y<=0) {
        //Compression
        return 1;
    } else {
        //support
        return -1;
    }
}

core::stringc CRemontee::GetName() {
    return remonteeName;
}

void CRemontee::SetName(core::stringc name) {
    remonteeName=name;
}

//Methode a surcharger pour chaque RM
core::stringc CRemontee::GetID() {
    return "RM";
}

//Methode a surcharger pour chaque RM
void CRemontee::SetID(core::stringc name) {

}

void CRemontee::PlaceVehicules()
{
}

CRemontee::~CRemontee()
{

}
