--
-- LemkenGigant1400
-- Specialization for LemkenGigant1400
--
-- @author  Felix S. - Outlaw
-- @date  10/01/09
--
-- Copyright (C) Outlaw, All Rights Reserved.

LemkenGigant1400 = {};

function LemkenGigant1400.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(Trailer, specializations);
end;

function LemkenGigant1400:load(xmlFile)

	   hornSoundFile = Utils.getFilename("work.wav", self.baseDirectory);
    self.hornSoundId = createSample("workSound");
    loadSample(self.hornSoundId, hornSoundFile, false);
    self.hornPlaying = false;
	
	self.keys = {};
    local i=0;
    while true do
        local baseName = string.format("vehicle.keys.input(%d)", i);
        local inputName = getXMLString(xmlFile, baseName.. "#name");
        if inputName == nil then
            break;
        end;
        local inputKey = getXMLString(xmlFile, baseName.. "#key");
        if Input[inputKey] == nil then
            print("Error: invalid key '" .. inputKey .. "'  for input event '" .. inputName .. "'");
            break;
        end;
        self.keys[inputName] = Input[inputKey];
        i = i+1;
    end;
	
	
	
	self.backlights = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.backlights#index"));
	setVisibility(self.backlights, false);
	
	
	self.leftRollerNode  = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.roller#Left"));
	self.rightRollerNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.roller#Right"));
	self.rollerRotationScale = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.roller#rotScale"), 1);
	
		local translationPartkuppNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPartkupp#index"));
    if translationPartkuppNode ~= nil then
        self.translationPartkupp = {};
        self.translationPartkupp.node = translationPartkuppNode;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPartkupp#minTrans"));
        self.translationPartkupp.minTrans = {};
        self.translationPartkupp.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPartkupp.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPartkupp.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPartkupp#maxTrans"));
        self.translationPartkupp.maxTrans = {};
        self.translationPartkupp.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPartkupp.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPartkupp.maxTrans[3] = Utils.getNoNil(z, 0);

        self.translationPartkupp.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPartkupp#transTime"), 2)*1000;
   
    end;
	
	
	
   	local translationPartNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPart#index"));
    if translationPartNode ~= nil then
        self.translationPart = {};
        self.translationPart.node = translationPartNode;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart#minTrans"));
        self.translationPart.minTrans = {};
        self.translationPart.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart#maxTrans"));
        self.translationPart.maxTrans = {};
        self.translationPart.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart.maxTrans[3] = Utils.getNoNil(z, 0);
        self.translationPart.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart#transTime"), 2)*1000;
		self.translationPart.touchTransLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart#touchTransLimit"), 10));
    end;
	
	
	local translationPart3Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPart3#index"));
    if translationPart3Node ~= nil then
        self.translationPart3 = {};
        self.translationPart3.node = translationPart3Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart3#minTrans"));
        self.translationPart3.minTrans = {};
        self.translationPart3.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart3.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart3.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart3#maxTrans"));
        self.translationPart3.maxTrans = {};
        self.translationPart3.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart3.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart3.maxTrans[3] = Utils.getNoNil(z, 0);
        self.translationPart3.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart3#transTime"), 2)*1000;
        self.translationPart3.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart3#touchTransLimit"), 10);
    end;
	
		local RotStNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.RotSt#index"));
    if RotStNode ~= nil then
        self.RotSt = {};
        self.RotSt.node = RotStNode;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.RotSt#minRot"));
        self.RotSt.minRot = {};
        self.RotSt.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.RotSt.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.RotSt.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.RotSt#maxRot"));
        self.RotSt.maxRot = {};
        self.RotSt.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.RotSt.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.RotSt.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.RotSt.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.RotSt#rotTime"), 2)*1000;
        self.RotSt.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.RotSt#touchRotLimit"), 10));
    end;
	
	
	local translationPart2Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPart2#index"));
    if translationPart2Node ~= nil then
        self.translationPart2 = {};
        self.translationPart2.node = translationPart2Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart2#minTrans"));
        self.translationPart2.minTrans = {};
        self.translationPart2.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart2.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart2.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart2#maxTrans"));
        self.translationPart2.maxTrans = {};
        self.translationPart2.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart2.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart2.maxTrans[3] = Utils.getNoNil(z, 0);
        self.translationPart2.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart2#transTime"), 2)*1000;
        self.translationPart2.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart2#touchTransLimit"), 10);
    end;
	
	
	    local numRotationParts = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.rotationParts#count"), 0);
    self.rotationParts = {};
    for i=1, numRotationParts do
      local partnamei = string.format("vehicle.rotationParts.part" .. "%d", i);
      self.rotationParts[i] = {};
      self.rotationParts[i].index = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, partnamei .. "#index"));
      local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, partnamei .. "#minRot"));
      self.rotationParts[i].minRot = {};
      self.rotationParts[i].minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
      self.rotationParts[i].minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
      self.rotationParts[i].minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
      x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, partnamei .. "#maxRot"));
      self.rotationParts[i].maxRot = {};
      self.rotationParts[i].maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
      self.rotationParts[i].maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
      self.rotationParts[i].maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
      self.rotationParts[i].rotTime = Utils.getNoNil(getXMLString(xmlFile,  partnamei .. "#rotSpeed"), 2)*1000;
    end;
	
	    local numRotParts = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.RotParts#count"), 0);
    self.RotParts = {};
    for i=1, numRotParts do
      local partnamei = string.format("vehicle.RotParts.part" .. "%d", i);
      self.RotParts[i] = {};
      self.RotParts[i].index = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, partnamei .. "#index"));
      local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, partnamei .. "#minRot"));
      self.RotParts[i].minRot = {};
      self.RotParts[i].minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
      self.RotParts[i].minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
      self.RotParts[i].minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
      x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, partnamei .. "#maxRot"));
      self.RotParts[i].maxRot = {};
      self.RotParts[i].maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
      self.RotParts[i].maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
      self.RotParts[i].maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
      self.RotParts[i].rotTime = Utils.getNoNil(getXMLString(xmlFile,  partnamei .. "#rotSpeed"), 2)*1000;
    end;
	
		local numSpinnerParts = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.SpinnerParts#count"), 0);
    self.SpinnerParts = {};
    for i=1, numSpinnerParts do
		local partnamei = string.format("vehicle.SpinnerParts.part" .. "%d", i);
		self.SpinnerParts[i] = {};
		self.SpinnerParts[i].index = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, partnamei .. "#index"));
		self.SpinnerParts[i].Scale = Utils.getNoNil(getXMLInt(xmlFile, partnamei .. "#rotScale"), 10);
    end;
	
				local RotCheck1Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.RotCheck1#index"));
    if RotCheck1Node ~= nil then
        self.RotCheck1 = {};
        self.RotCheck1.node = RotCheck1Node;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.RotCheck1#minRot"));
        self.RotCheck1.minRot = {};
        self.RotCheck1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.RotCheck1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.RotCheck1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.RotCheck1#maxRot"));
        self.RotCheck1.maxRot = {};
        self.RotCheck1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.RotCheck1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.RotCheck1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.RotCheck1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.RotCheck1#rotTime"), 2)*1000;
    end;
	
				local RotCheck2Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.RotCheck2#index"));
    if RotCheck2Node ~= nil then
        self.RotCheck2 = {};
        self.RotCheck2.node = RotCheck2Node;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.RotCheck2#minRot"));
        self.RotCheck2.minRot = {};
        self.RotCheck2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.RotCheck2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.RotCheck2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.RotCheck2#maxRot"));
        self.RotCheck2.maxRot = {};
        self.RotCheck2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.RotCheck2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.RotCheck2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.RotCheck2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.RotCheck2#rotTime"), 2)*1000;
    end;
	
		local translationPart4Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPart4#index"));
	    if translationPart4Node ~= nil then
        self.translationPart4 = {};
        self.translationPart4.node = translationPart4Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart4#minTrans"));
        self.translationPart4.minTrans = {};
        self.translationPart4.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart4.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart4.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart4#maxTrans"));
        self.translationPart4.maxTrans = {};
        self.translationPart4.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart4.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart4.maxTrans[3] = Utils.getNoNil(z, 0);
        self.translationPart4.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart4#transTime"), 2)*1000;
        self.translationPart4.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart4#touchTransLimit"), 10);
    end;
	
	
			local translationPart5Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPart5#index"));
    if translationPart5Node ~= nil then
        self.translationPart5 = {};
        self.translationPart5.node = translationPart5Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart5#minTrans"));
        self.translationPart5.minTrans = {};
        self.translationPart5.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart5.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart5.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart5#maxTrans"));
        self.translationPart5.maxTrans = {};
        self.translationPart5.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart5.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart5.maxTrans[3] = Utils.getNoNil(z, 0);
        self.translationPart5.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart5#transTime"), 2)*1000;
        self.translationPart5.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart5#touchTransLimit"), 10);
    end;
	
	
	
			    local numRotParts2 = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.RotParts2#count"), 0);
    self.RotParts2 = {};
    for i=1, numRotParts2 do
      local partnamei = string.format("vehicle.RotParts2.part" .. "%d", i);
      self.RotParts2[i] = {};
      self.RotParts2[i].index = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, partnamei .. "#index"));
      local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, partnamei .. "#minRot"));
      self.RotParts2[i].minRot = {};
      self.RotParts2[i].minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
      self.RotParts2[i].minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
      self.RotParts2[i].minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
      x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, partnamei .. "#maxRot"));
      self.RotParts2[i].maxRot = {};
      self.RotParts2[i].maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
      self.RotParts2[i].maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
      self.RotParts2[i].maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
      self.RotParts2[i].rotTime = Utils.getNoNil(getXMLString(xmlFile,  partnamei .. "#rotSpeed"), 2)*1000;
    end;
	
	
				local RotCheck3Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.RotCheck3#index"));
    if RotCheck3Node ~= nil then
        self.RotCheck3 = {};
        self.RotCheck3.node = RotCheck3Node;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.RotCheck3#minRot"));
        self.RotCheck3.minRot = {};
        self.RotCheck3.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.RotCheck3.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.RotCheck3.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.RotCheck3#maxRot"));
        self.RotCheck3.maxRot = {};
        self.RotCheck3.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.RotCheck3.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.RotCheck3.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.RotCheck3.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.RotCheck3#rotTime"), 2)*1000;
    end;
	
	
			local translationPart6Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPart6#index"));
    if translationPart6Node ~= nil then
        self.translationPart6 = {};
        self.translationPart6.node = translationPart6Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart6#minTrans"));
        self.translationPart6.minTrans = {};
        self.translationPart6.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart6.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart6.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart6#maxTrans"));
        self.translationPart6.maxTrans = {};
        self.translationPart6.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart6.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart6.maxTrans[3] = Utils.getNoNil(z, 0);
        self.translationPart6.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart6#transTime"), 2)*1000;
        self.translationPart6.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart6#touchTransLimit"), 10);
    end;
	
			local translationPart7Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPart7#index"));
    if translationPart7Node ~= nil then
        self.translationPart7 = {};
        self.translationPart7.node = translationPart7Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart7#minTrans"));
        self.translationPart7.minTrans = {};
        self.translationPart7.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart7.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart7.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart7#maxTrans"));
        self.translationPart7.maxTrans = {};
        self.translationPart7.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart7.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart7.maxTrans[3] = Utils.getNoNil(z, 0);
        self.translationPart7.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart7#transTime"), 2)*1000;
        self.translationPart7.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart7#touchTransLimit"), 10);
    end;
	
				local translationPart8Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translationPart8#index"));
    if translationPart8Node ~= nil then
        self.translationPart8 = {};
        self.translationPart8.node = translationPart8Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart8#minTrans"));
        self.translationPart8.minTrans = {};
        self.translationPart8.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart8.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart8.minTrans[3] = Utils.getNoNil(z, 0);
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart8#maxTrans"));
        self.translationPart8.maxTrans = {};
        self.translationPart8.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart8.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart8.maxTrans[3] = Utils.getNoNil(z, 0);
        self.translationPart8.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart8#transTime"), 2)*1000;
        self.translationPart8.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart8#touchTransLimit"), 10);
    end;
	
	

    
    self.rundumleuchten = {};
    self.rundumleuchten.rotNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rundumleuchten#rotNode"));
    self.rundumleuchten.light = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rundumleuchten#light"));
    self.rundumleuchten.source = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rundumleuchten#lightsource"));
    self.rundumleuchten.speed = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.rundumleuchten#rotSpeed"), 1)/1000;

	
	
	self.rotationSpeed = 0;
	self.rotationSpeedDownRate = 0;
	self.lastMovingDirection = 0;
	self.rundumleuchtenAn = false;
	self.trsp = false;
	self.trsp2 = false;
	self.trsp_c2 = false;
	self.trsp_out = false;
	self.check1 = false; 
	self.check2 = false; 
	self.keycheck_k = false; 
	self.work_out = false; 
	self.trsp_c = false; 
	self.st = false; 
	self.work = false;
	self.isActiveParticle = false;
	self.on = false; 
end;

function LemkenGigant1400:delete()

end;

function LemkenGigant1400:mouseEvent(posX, posY, isDown, isUp, button)
end;

function LemkenGigant1400:keyEvent(unicode, sym, modifier, isDown)

	
	 
	if isDown and sym==self.keys.transport and self.on == false then
		self.keycheck_k = not self.keycheck_k;

		if self.trsp_out == false then
			self.trsp = not self.trsp;
			self.trsp_c = true;
			self.rundumleuchtenAn = false; 
			setVisibility(self.rundumleuchten.light, self.rundumleuchtenAn);
		else
			self.work_out = false; 
			self.trsp2 = not self.trsp2;
			self.trsp_c2 = true;
		end; 
	end; 
	
	
	
	if isDown and sym==self.keys.senken and self.trsp_out == true then
 		self.work = not self.work;
		self.work_out = true; 
	end; 
		
		
    if isDown and sym==self.keys.rundum and self.trsp_out == false and self.trsp_c == false and self.trsp_c2 == false then
        self.rundumleuchtenAn = not self.rundumleuchtenAn;
        setVisibility(self.rundumleuchten.light, self.rundumleuchtenAn);
    end;
end;

function LemkenGigant1400:update(dt)
   	if self.attacherVehicle then
				
			self.st = true;
			
			
				if self.backlightsActive then
			setVisibility(self.backlights, self.backlightsActive);
		else
			setVisibility(self.backlights, self.backlightsActive, false);
		end;
		
		
		if self.attacherVehicle.lightsActive then
			self.backlightsActive = true;
		else
			self.backlightsActive = false;
		end;

	 
		
			 
			 
			 
			 
			
				if self.trsp2 ~= nil and self.on == false and self.trsp_c2 == true then

					for i=1, table.getn(self.RotParts) do
						local rot = {getRotation(self.RotParts[i].index)};
						local newRot = Utils.getMovedLimitedValues(rot, self.RotParts[i].maxRot, self.RotParts[i].minRot, 3, self.RotParts[i].rotTime, dt,   self.trsp2);
						setRotation(self.RotParts[i].index, unpack(newRot));
					end; 
					
					local x, y, z = getTranslation(self.translationPart6.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart6.maxTrans, self.translationPart6.minTrans, 3, self.translationPart6.transTime, dt,  self.trsp2);
					setTranslation(self.translationPart6.node, unpack(newTrans));
					
						local x, y, z = getTranslation(self.translationPart7.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart7.maxTrans, self.translationPart7.minTrans, 3, self.translationPart7.transTime, dt,  self.trsp2);
					setTranslation(self.translationPart7.node, unpack(newTrans));
					
					local x, y, z = getTranslation(self.translationPart5.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart5.maxTrans, self.translationPart5.minTrans, 3, self.translationPart5.transTime, dt, self.trsp2);
					setTranslation(self.translationPart5.node, unpack(newTrans));

					local x, y, z = getTranslation(self.translationPart4.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart4.maxTrans, self.translationPart4.minTrans, 3, self.translationPart4.transTime, dt,  self.trsp2);
					setTranslation(self.translationPart4.node, unpack(newTrans));
				
					local x, y, z = getRotation(self.RotCheck2.node);
					local rot = {x,y,z};
					local newRot = Utils.getMovedLimitedValues(rot, self.RotCheck2.maxRot, self.RotCheck2.minRot, 3, self.RotCheck2.rotTime, dt,  self.trsp2);
				
					local x, y, z = getRotation(self.RotCheck2.node);
					local minRot = self.RotCheck2.minRot;
					if math.abs(x-minRot[1]) < 0.0001 then
						self.check2 = true; 
					end;
				end; 
				
				
				
				if self.check2 == true then 
					self.trsp_c2 = false;
					for i=1, table.getn(self.RotParts2) do
						local rot = {getRotation(self.RotParts2[i].index)};
						local newRot = Utils.getMovedLimitedValues(rot, self.RotParts2[i].maxRot, self.RotParts2[i].minRot, 3, self.RotParts2[i].rotTime, dt,  self.trsp2);
						setRotation(self.RotParts2[i].index, unpack(newRot));
					end;
						
					local x, y, z = getRotation(self.RotCheck3.node);
					local rot = {x,y,z};
					local newRot = Utils.getMovedLimitedValues(rot, self.RotCheck3.maxRot, self.RotCheck3.minRot, 3, self.RotCheck3.rotTime, dt,  self.trsp2);

					local x, y, z = getRotation(self.RotCheck3.node);
					local minRot = self.RotCheck3.minRot;
					if math.abs(z-minRot[3]) < 0.0001 then
						self.trsp_out = false;
						self.check2 = false; 
						self.work_out = false; 
						self.trsp_c = false; 
						self.trsp_c2 = false; 
						self.trsp2 = not self.trsp2;
					end;
				end; 	
				
				
				
			
				
				if self.trsp ~= nil and self.on == false and self.trsp_c == true then
					for i=1, table.getn(self.RotParts2) do
						local rot = {getRotation(self.RotParts2[i].index)};
						local newRot = Utils.getMovedLimitedValues(rot, self.RotParts2[i].maxRot, self.RotParts2[i].minRot, 3, self.RotParts2[i].rotTime, dt,  not self.trsp);
						setRotation(self.RotParts2[i].index, unpack(newRot));
					end;
						
					local x, y, z = getRotation(self.RotCheck3.node);
					local rot = {x,y,z};
					local newRot = Utils.getMovedLimitedValues(rot, self.RotCheck3.maxRot, self.RotCheck3.minRot, 3, self.RotCheck3.rotTime, dt, not self.trsp);

					local x, y, z = getRotation(self.RotCheck3.node);
					local minRot = self.RotCheck3.maxRot;
					if math.abs(z-minRot[3]) < 0.0001 then
						self.check1 = true; 
					end;
					
					local x, y, z = getRotation(self.RotCheck3.node);
					local minRot = self.RotCheck3.minRot;
					if math.abs(z-minRot[3]) < 0.0001 then
						self.trsp_out = false;
						self.check2 = false; 
						self.work_out = false; 
						self.trsp_c = false; 
						self.trsp_c2 = false; 
					end;
				end; 
				
				
				
				
				if self.check1 ~= false then 
					self.trsp_c = false;
					local x, y, z = getTranslation(self.translationPart5.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart5.maxTrans, self.translationPart5.minTrans, 3, self.translationPart5.transTime, dt, not self.trsp);
					setTranslation(self.translationPart5.node, unpack(newTrans));
					
					local x, y, z = getTranslation(self.translationPart6.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart6.maxTrans, self.translationPart6.minTrans, 3, self.translationPart6.transTime, dt, not self.trsp);
					setTranslation(self.translationPart6.node, unpack(newTrans));
					
					local x, y, z = getTranslation(self.translationPart7.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart7.maxTrans, self.translationPart7.minTrans, 3, self.translationPart7.transTime, dt, not self.trsp);
					setTranslation(self.translationPart7.node, unpack(newTrans));
					
					
					
					for i=1, table.getn(self.RotParts) do
						local rot = {getRotation(self.RotParts[i].index)};
						local newRot = Utils.getMovedLimitedValues(rot, self.RotParts[i].maxRot, self.RotParts[i].minRot, 3, self.RotParts[i].rotTime, dt, not self.trsp);
						setRotation(self.RotParts[i].index, unpack(newRot));
					end; 
				
					local x, y, z = getTranslation(self.translationPart4.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart4.maxTrans, self.translationPart4.minTrans, 3, self.translationPart4.transTime, dt, not self.trsp);
					setTranslation(self.translationPart4.node, unpack(newTrans));
				
					local x, y, z = getRotation(self.RotCheck2.node);
					local rot = {x,y,z};
					local newRot = Utils.getMovedLimitedValues(rot, self.RotCheck2.maxRot, self.RotCheck2.minRot, 3, self.RotCheck2.rotTime, dt, not self.trsp);
					
					local x, y, z = getRotation(self.RotCheck2.node);
					local minRot = self.RotCheck2.maxRot;
					if math.abs(x-minRot[1]) < 0.0001 then
						self.check1 = false; 
						self.trsp_out = true; 
						self.work_out = true; 
						self.trsp = not self.trsp;
						self.rundumleuchtenAn = false; 
						setVisibility(self.rundumleuchten.light, self.rundumleuchtenAn);
					end;
				end; 
				
				
				
				
				
				
				
				if self.on == true then 
					if self.attacherVehicle.lastSpeed*3600 > 2 then
				
						if not self.workSoundRunning then
							 playSample(self.hornSoundId, 0, 1, 0);
            self.hornPlaying = true;
							self.workSoundRunning = true;
						end;
					end;
					if self.attacherVehicle.lastSpeed*3600 < 2 then
					
						if self.workSoundRunning then
							stopSample(self.workSound, 0, 1.6, 0);
							self.workSoundRunning = false;
					self.hornPlaying = false;
						end;
					end; 
				else
				
				end; 
				
				
				
			
					
					
				
				
				if self.on ~= false then
						self.rotationSpeed = self.attacherVehicle.lastSpeed * self.attacherVehicle.movingDirection;
					self.rotationSpeedDownRate = math.abs(self.rotationSpeed * 0.02);
					self.lastMovingDirection = self.attacherVehicle.movingDirection;
				if self.lastMovingDirection == 1 then
						self.rotationSpeed = self.rotationSpeed - self.rotationSpeedDownRate;
						if self.rotationSpeed <= 0 then
							self.rotationSpeed = 0;
						end;
					elseif self.lastMovingDirection == -1 then
						self.rotationSpeed = self.rotationSpeed + self.rotationSpeedDownRate;
						if self.rotationSpeed >= 0 then
							self.rotationSpeed = 0;
						end;
					end;		
				else	
					 stopSample(self.hornSoundId);
            self.hornPlaying = false;
					self.workSoundRunning = false;
					
					
				end; 
				
				
				if self.on == true then 
					for i=1, table.getn(self.cuttingAreas) do
						local x,y,z = getWorldTranslation(self.cuttingAreas[i].start);
						local x1,y1,z1 = getWorldTranslation(self.cuttingAreas[i].width);
						local x2,y2,z2 = getWorldTranslation(self.cuttingAreas[i].height);
						Utils.updateCultivatorArea(x, z, x1, z1, x2, z2); 
						
					end; 
					for i=1, table.getn(self.SpinnerParts) do
						rotate(self.SpinnerParts[i].index , self.SpinnerParts[i].Scale * self.rotationSpeed ,0,0);
					end;
				end; 	
				
				
				
				
				if self.work ~= nil and self.trsp_out == true and self.work_out == true then
					local x, y, z = getRotation(self.RotCheck1.node);
					local rot = {x,y,z};
					local newRot = Utils.getMovedLimitedValues(rot, self.RotCheck1.maxRot, self.RotCheck1.minRot, 3, self.RotCheck1.rotTime, dt, not self.work);

					for i=1, table.getn(self.rotationParts) do
						local rot = {getRotation(self.rotationParts[i].index)};
						local newRot = Utils.getMovedLimitedValues(rot, self.rotationParts[i].maxRot, self.rotationParts[i].minRot, 3, self.rotationParts[i].rotTime, dt, not self.work);
						setRotation(self.rotationParts[i].index, unpack(newRot));
					end; 	

					local x, y, z = getTranslation(self.translationPart.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart.maxTrans, self.translationPart.minTrans, 3, self.translationPart.transTime, dt, not self.work);
					setTranslation(self.translationPart.node, unpack(newTrans));
					local x, y, z = getTranslation(self.translationPart2.node);
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart2.maxTrans, self.translationPart2.minTrans, 3, self.translationPart2.transTime, dt, not self.work);
					setTranslation(self.translationPart2.node, unpack(newTrans));
					local x, y, z = getTranslation(self.translationPart3.node);			
					local trans = {x,y,z};
					local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart3.maxTrans, self.translationPart3.minTrans, 3, self.translationPart3.transTime, dt, not self.work);
					setTranslation(self.translationPart3.node, unpack(newTrans))
					
					local x, y, z = getRotation(self.RotCheck1.node);
					local minRot = self.RotCheck1.maxRot;
					if math.abs(x-minRot[1]) < 0.0001 then
						self.on = true; 
					end;
					local x, y, z = getRotation(self.RotCheck1.node);
					local minRot = self.RotCheck1.minRot;
					if math.abs(x-minRot[1]) < 0.0001 then
						self.trsp_out = true; 
						self.on = false; 
					end;
				end; 
				
				
				
				
				if self.rundumleuchtenAn ~= false then
					rotate(self.rundumleuchten.rotNode, 0, dt*self.rundumleuchten.speed, 0);
				end;
				
				
				if self.trsp_out == true then
					self.rotationSpeed2 = self.attacherVehicle.lastSpeed * self.attacherVehicle.movingDirection;
					rotate(self.leftRollerNode,   self.rollerRotationScale * self.rotationSpeed2 ,0,0);
					rotate(self.rightRollerNode,  self.rollerRotationScale * self.rotationSpeed2 ,0,0);	
				end; 
			
				
				
			end;
	
	
	if self.st ~= nil then
		local x, y, z = getTranslation(self.translationPart8.node);			
		local trans = {x,y,z};
		local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart8.maxTrans, self.translationPart8.minTrans, 3, self.translationPart8.transTime, dt, not self.st);
		setTranslation(self.translationPart8.node, unpack(newTrans))
	end; 	

	
	
	if self.attacherVehicle == nil then
		self.hornPlaying = false;
		self.trsp = false;
		self.work = false; 
		stopSample(self.workSound);
		self.rundumleuchtenAn = false;
		self.st = false; 
	if self.backlightsActive then
		setVisibility(self.backlights, false);
	end;

end; 
	
end;

function LemkenGigant1400:draw()
	if self.attacherVehicle then
		if self.keycheck_k == false then
			g_currentMission:addExtraPrintText("Taste "..string.upper(string.char(self.keys.transport))..": Lemken Gigant 1400 "..g_i18n:getText("LG1400_4"));
			if self.trsp_out == false then 
				if self.rundumleuchtenAn ~= false  then
					g_currentMission:addExtraPrintText("Taste "..string.upper(string.char(self.keys.rundum))..": Lemken Gigant 1400 "..g_i18n:getText("LG1400_2"));
				else
					g_currentMission:addExtraPrintText("Taste "..string.upper(string.char(self.keys.rundum))..": Lemken Gigant 1400 "..g_i18n:getText("LG1400_1"));
				end; 
			end; 	
			else
			if self.trsp_out == false then 
				g_currentMission:addExtraPrintText("Taste "..string.upper(string.char(self.keys.transport))..": Lemken Gigant 1400 "..g_i18n:getText("LG1400_3"));
			else
				if self.on == false then 
					g_currentMission:addExtraPrintText("Taste "..string.upper(string.char(self.keys.transport))..": Lemken Gigant 1400 "..g_i18n:getText("LG1400_3"));
					g_currentMission:addExtraPrintText("Taste "..string.upper(string.char(self.keys.senken))..": Lemken Gigant 1400 "..g_i18n:getText("LG1400_5"));
				else
					g_currentMission:addExtraPrintText("Taste "..string.upper(string.char(self.keys.senken))..": Lemken Gigant 1400 "..g_i18n:getText("LG1400_6"));
				end; 
			end; 
		end; 
	end;
end;











function LemkenGigant1400:delete()
  delete(self.hornSoundId);
end;