

tueren = {}

function tueren.prerequisitesPresent(specializations)
    return true;
end;

function tueren:load(xmlFile)        
	   self.gearShifter1 = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.gearShifter1#index"));
	-- Anfang workLights
	
	local rotationPartNodeworkLights = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.workLights#index"));
    if rotationPartNodeworkLights ~= nil then
        self.rotationPartworkLights = {};
        self.rotationPartworkLights.node = rotationPartNodeworkLights;

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

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

        self.rotationPartworkLights.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.workLights#rotTime"), 2)*1000;
        self.rotationPartworkLights.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.workLights#touchRotLimit"), 10));
    end;
	
	-- Ende rotationPartworkLights
	
	
	
	-- Anfang Left
	
	local rotationPartNodeleft = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.left#index"));
    if rotationPartNodeleft ~= nil then
        self.rotationPartleft = {};
        self.rotationPartleft.node = rotationPartNodeleft;

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

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

        self.rotationPartleft.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.left#rotTime"), 2)*1000;
        self.rotationPartleft.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.left#touchRotLimit"), 10));
    end;
	
	-- Ende forward
	
	
		-- Anfang forward
	
	local rotationPartNodeforward = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.forward#index"));
    if rotationPartNodeforward ~= nil then
        self.rotationPartforward = {};
        self.rotationPartforward.node = rotationPartNodeforward;

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

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

        self.rotationPartforward.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.forward#rotTime"), 2)*1000;
        self.rotationPartforward.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.forward#touchRotLimit"), 10));
    end;
	
	-- Ende center
	
	
	-- Anfang 	back
	
	local rotationPartNodeback = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.back#index"));
    if rotationPartNodeback~= nil then
        self.rotationPartback = {};
        self.rotationPartback.node = rotationPartNodeback;

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

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

        self.rotationPartback.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.back#rotTime"), 2)*1000;
        self.rotationPartback.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.back#touchRotLimit"), 10));
    end;
	
	-- Ende Left
	-- Anfang 	center
	
	local rotationPartNodecenter = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.center#index"));
    if rotationPartNodecenter~= nil then
        self.rotationPartcenter = {};
        self.rotationPartcenter.node = rotationPartNodecenter;

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

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

        self.rotationPartcenter.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.center#rotTime"), 2)*1000;
        self.rotationPartcenter.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.center#touchRotLimit"), 10));
    end;
	
	-- Ende Left
	
	
	-- Anfang Right
	
	local rotationPartNoderight = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.right#index"));
    if rotationPartNoderight ~= nil then
        self.rotationPartright = {};
        self.rotationPartright.node = rotationPartNoderight;

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

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

        self.rotationPartright.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.right#rotTime"), 2)*1000;
        self.rotationPartright.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.right#touchRotLimit"), 10));
    end;

	-- Ende Left
	
	-- Anfang Animation workLights
	
	local rotationPartNodeaworkLights = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.aworkLights#index"));
    if rotationPartNodeaworkLights ~= nil then
        self.rotationPartaworkLights = {};
        self.rotationPartaworkLights.node = rotationPartNodeaworkLights;

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

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

        self.rotationPartaworkLights.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.aworkLights#rotTime"), 2)*1000;
        self.rotationPartaworkLights.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.aworkLights#touchRotLimit"), 10));
    end;
	
	-- Ende Animation workLights
	
	
	
	
	
	
	-- Anfang Animation Left
	
	local rotationPartNodealeft = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.aleft#index"));
    if rotationPartNodealeft ~= nil then
        self.rotationPartaleft = {};
        self.rotationPartaleft.node = rotationPartNodealeft;

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

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

        self.rotationPartaleft.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.aleft#rotTime"), 2)*1000;
        self.rotationPartaleft.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.aleft#touchRotLimit"), 10));
    end;
	
	-- Ende Animation Right
	
	
	-- Anfang Animation forward
	
	local rotationPartNodeaforward = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.aforward#index"));
    if rotationPartNodeaforward ~= nil then
        self.rotationPartaforward = {};
        self.rotationPartaforward.node = rotationPartNodeaforward;

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

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

        self.rotationPartaforward.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.aforward#rotTime"), 2)*1000;
        self.rotationPartaforward.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.aforward#touchRotLimit"), 10));
    end;
	
	-- Ende Animation center
	
	
	-- Anfang Animation back
	
	local rotationPartNodeaback = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.aback#index"));
    if rotationPartNodeaback ~= nil then
        self.rotationPartaback = {};
        self.rotationPartaback.node = rotationPartNodeaback;

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

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

        self.rotationPartaback.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.aback#rotTime"), 2)*1000;
        self.rotationPartaback.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.aback#touchRotLimit"), 10));
    end;
	
	-- Ende Animation Right
	
	-- Anfang Animation center
	
	local rotationPartNodeacenter = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.acenter#index"));
    if rotationPartNodeacenter ~= nil then
        self.rotationPartacenter = {};
        self.rotationPartacenter.node = rotationPartNodeacenter;

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

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

        self.rotationPartacenter.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.acenter#rotTime"), 2)*1000;
        self.rotationPartacenter.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.acenter#touchRotLimit"), 10));
    end;
	
	-- Ende Animation Right
	
	
	-- Anfang Animation Right
	
	local rotationPartNodearight = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.aright#index"));
    if rotationPartNodearight ~= nil then
        self.rotationPartaright = {};
        self.rotationPartaright.node = rotationPartNodearight;

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

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

        self.rotationPartaright.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.aright#rotTime"), 2)*1000;
        self.rotationPartaright.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.aright#touchRotLimit"), 10));
    end;

	-- Ende Animation center
	
	
	
		self.controlpath = Utils.getFilename("help.dds", self.baseDirectory);
    self.helpPoxX = 0.87;
    self.helpPoxY = 0.4;
    self.helpWidth = 0.12;
    self.helpHeight = 0.46;
    self.helpOverlay = Overlay:new("help", self.controlpath, self.helpPoxX, self.helpPoxY, self.helpWidth, self.helpHeight);
    self.bcActive = false;
	
	
	
	
	
	
end;
      
function tueren:delete()    
end;

function tueren:mouseEvent(posX, posY, isDown, isUp, button)
end;
	  
function tueren:keyEvent(unicode, sym, modifier, isDown)
		
		
		if isDown and sym == Input.KEY_KP_0 then
		self.bcActive = not self.bcActive;
	end;
	
	-- Anfang workLights
	
	if isDown and sym == Input.KEY_l then 
		self.rotationMaxworkLights = not self.rotationMaxworkLights;
		self.rotationMaxaworkLights = not self.rotationMaxaworkLights;
	end;
	
	-- Ende workLights
	
	
	-- Anfang Left

	
	-- Ende Right
	
	-- Anfang Info
	
	if isDown and sym == Input.KEY_9 then
		self.helpPanel = not self.helpPanel;
	end;
	
	-- Ende Info
	
end;

function tueren:update(dt)   
	
		
if self.inrange or self.isEntered then
	if InputBinding.hasEvent (InputBinding.left) then
		self.rotationMaxleft = not self.rotationMaxleft;
		self.rotationMaxaleft = not self.rotationMaxaleft;
	end;
		end;
	-- Ende Left
	
	
	-- Anfang forward
	
if self.inrange or self.isEntered then
	if InputBinding.hasEvent (InputBinding.forward) then
		self.rotationMaxforward = not self.rotationMaxforward;
		self.rotationMaxaforward = not self.rotationMaxaforward;
	end;
		end;
	-- Ende forward
	
	
	
	-- Anfang back
	
if self.inrange or self.isEntered then
	if InputBinding.hasEvent (InputBinding.back) then
		self.rotationMaxback = not self.rotationMaxback;
		self.rotationMaxaback = not self.rotationMaxaback;
	end;
		end;
	-- Ende back
	
	-- Anfang center
	
if self.inrange or self.isEntered then
	if InputBinding.hasEvent (InputBinding.center) then
		self.rotationMaxcenter = not self.rotationMaxcenter;
		self.rotationMaxacenter = not self.rotationMaxacenter;
	end;
		end;
	-- Ende center
	
	
	-- Anfang Right
	
if self.inrange or self.isEntered then
	if InputBinding.hasEvent (InputBinding.right) then 
		self.rotationMaxright = not self.rotationMaxright;
		self.rotationMaxaright = not self.rotationMaxaright;
	end;
		end;
	
	
	
	
	-- Anfang workLights
	
	if self.rotationPartworkLights ~= nil then
		local x, y, z = getRotation(self.rotationPartworkLights.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartworkLights.maxRot, self.rotationPartworkLights.minRot, 3, self.rotationPartworkLights.rotTime, dt, not self.rotationMaxworkLights);
		setRotation(self.rotationPartworkLights.node, unpack(newRot));
	end;
	
	-- Ende workLights
	
	
	
	
	
	
	
	-- Anfang Left
	
	if self.rotationPartleft ~= nil then
		local x, y, z = getRotation(self.rotationPartleft.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartleft.maxRot, self.rotationPartleft.minRot, 3, self.rotationPartleft.rotTime, dt, not self.rotationMaxleft);
		setRotation(self.rotationPartleft.node, unpack(newRot));
	end;
	
	-- Ende center
	
	
	
	-- Anfang forward 
	
	if self.rotationPartforward  ~= nil then
		local x, y, z = getRotation(self.rotationPartforward .node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartforward.maxRot, self.rotationPartforward.minRot, 3, self.rotationPartforward.rotTime, dt, not self.rotationMaxforward);
		setRotation(self.rotationPartforward .node, unpack(newRot));
	end;
	
	-- Ende center 
	
	-- Anfang back 
	
	if self.rotationPartback  ~= nil then
		local x, y, z = getRotation(self.rotationPartback .node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartback.maxRot, self.rotationPartback.minRot, 3, self.rotationPartback.rotTime, dt, not self.rotationMaxback);
		setRotation(self.rotationPartback .node, unpack(newRot));
	end;
	
	-- Ende center 
	
	-- Anfang center 
	
	if self.rotationPartcenter  ~= nil then
		local x, y, z = getRotation(self.rotationPartcenter .node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartcenter.maxRot, self.rotationPartcenter.minRot, 3, self.rotationPartcenter.rotTime, dt, not self.rotationMaxcenter);
		setRotation(self.rotationPartcenter .node, unpack(newRot));
	end;
	
	-- Ende back 
	
	
	
	
	-- Anfang Right
	
	if self.rotationPartright ~= nil then
		local x, y, z = getRotation(self.rotationPartright.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartright.maxRot, self.rotationPartright.minRot, 3, self.rotationPartright.rotTime, dt, not self.rotationMaxright);
		setRotation(self.rotationPartright.node, unpack(newRot));
   end;

	-- Ende back
	
	-- Anfang Animation workLights
	
	if self.rotationPartaworkLights ~= nil then
		local x, y, z = getRotation(self.rotationPartaworkLights.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartaworkLights.maxRot, self.rotationPartaworkLights.minRot, 3, self.rotationPartaworkLights.rotTime, dt, not self.rotationMaxaworkLights);
		setRotation(self.rotationPartaworkLights.node, unpack(newRot));
	end;
	
	-- Ende Animation workLights
	
	
	
	
	
	-- Anfang Animation Left
	
	if self.rotationPartaleft ~= nil then
		local x, y, z = getRotation(self.rotationPartaleft.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartaleft.maxRot, self.rotationPartaleft.minRot, 3, self.rotationPartaleft.rotTime, dt, not self.rotationMaxaleft);
		setRotation(self.rotationPartaleft.node, unpack(newRot));
	end;
	
	-- Ende Animation back
	
	-- Anfang Animation forward 
	
	if self.rotationPartaforward  ~= nil then
		local x, y, z = getRotation(self.rotationPartaforward .node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartaforward .maxRot, self.rotationPartaforward .minRot, 3, self.rotationPartaforward .rotTime, dt, not self.rotationMaxaforward);
		setRotation(self.rotationPartaforward .node, unpack(newRot));
	end;
	
	-- Ende Animation back 
	
	-- Anfang Animation back 
	
	if self.rotationPartaback  ~= nil then
		local x, y, z = getRotation(self.rotationPartaback .node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartaback .maxRot, self.rotationPartaback .minRot, 3, self.rotationPartaback .rotTime, dt, not self.rotationMaxaback);
		setRotation(self.rotationPartaback .node, unpack(newRot));
	end;
	
	-- Ende Animation forward

-- Anfang Animation center 
	
	if self.rotationPartacenter  ~= nil then
		local x, y, z = getRotation(self.rotationPartacenter .node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartacenter .maxRot, self.rotationPartacenter .minRot, 3, self.rotationPartacenter .rotTime, dt, not self.rotationMaxacenter);
		setRotation(self.rotationPartacenter .node, unpack(newRot));
	end;
	
	-- Ende Animation forward


	-- Anfang Animation Right
	
	if self.rotationPartaright ~= nil then
		local x, y, z = getRotation(self.rotationPartaright.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartaright.maxRot, self.rotationPartaright.minRot, 3, self.rotationPartaright.rotTime, dt, not self.rotationMaxaright);
		setRotation(self.rotationPartaright.node, unpack(newRot));
	end;

	-- Ende Animation forward
	
	     local speed = self.lastSpeed*3950;
	if self.gearShifter1 ~= nil then
	if speed >= -0.5 and speed < 0.5 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(-20), Utils.degToRad(0));
								elseif speed >= 0 and speed < 2 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(-16), Utils.degToRad(0));
					elseif speed >= 2 and speed < 4 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(-12), Utils.degToRad(0));
					elseif speed >= 4 and speed < 6 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(-8), Utils.degToRad(0));
					elseif speed >= 6 and speed < 8 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(-4), Utils.degToRad(0));
					elseif speed >= 8 and speed < 10 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(0), Utils.degToRad(0));
					elseif speed >= 10 and speed < 12 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(4), Utils.degToRad(0));
					elseif speed >= 12 and speed < 14 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(8), Utils.degToRad(0));
					elseif speed >= 14 and speed < 16 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(12), Utils.degToRad(0));
					elseif speed >= 16 and speed < 18 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(16), Utils.degToRad(0));
					elseif speed >= 18 and speed < 20 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(20), Utils.degToRad(0));
					elseif speed >= 20 and speed < 22 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(24), Utils.degToRad(0));
					elseif speed >= 22 and speed < 24 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(28), Utils.degToRad(0));
					elseif speed >= 24 and speed < 26 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(32), Utils.degToRad(0));
					elseif speed >= 26 and speed < 28 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(36), Utils.degToRad(0));
					elseif speed >= 28 and speed < 30 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(40), Utils.degToRad(0));
					elseif speed >= 30 and speed < 32 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(44), Utils.degToRad(0));
					elseif speed >= 32 and speed < 34 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(48), Utils.degToRad(0));
					elseif speed >= 34 and speed < 36 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(52), Utils.degToRad(0));
					elseif speed >= 36 and speed < 38 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(56), Utils.degToRad(0));
					elseif speed >= 38 and speed < 40 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(60), Utils.degToRad(0));
					elseif speed >= 40 and speed < 42 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(64), Utils.degToRad(0));
					elseif speed >= 42 and speed < 44 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(68), Utils.degToRad(0));
					elseif speed >= 44 and speed < 46 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(72), Utils.degToRad(0));
					elseif speed >= 46 and speed < 48 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(76), Utils.degToRad(0));
					elseif speed >= 48 and speed < 50 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(80), Utils.degToRad(0));
					elseif speed >= 50 and speed < 52 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(84), Utils.degToRad(0));
					elseif speed >= 52 and speed < 54 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(86), Utils.degToRad(0));
					elseif speed >= 54 and speed < 56 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(92), Utils.degToRad(0));
					elseif speed >= 56 and speed < 58 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(96), Utils.degToRad(0));
					elseif speed >= 58 and speed < 60 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(100), Utils.degToRad(0));
					elseif speed >= 60 and speed < 62 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(104), Utils.degToRad(0));
					elseif speed >= 62 and speed < 64 then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(108), Utils.degToRad(0));
					elseif speed >= 64  then
			setRotation(self.gearShifter1, Utils.degToRad(0), Utils.degToRad(112), Utils.degToRad(0));
		end;
	end;
end;
	
	

function tueren:draw()

	   
	    if self.helpOverlay ~= nil then
		if self.bcActive then
		self.helpOverlay:render();
		end;
	end;

	if self.bcActive then	
		g_currentMission:addExtraPrintText("Key Numpad 0:                                  Menu Off");
	else
		g_currentMission:addExtraPrintText("Key Numpad 0:                                  Menu On");
	end;
	   
	
	
end;


function tueren:updateTick(dt)





if g_currentMission.player ~= nil then
		-- Getting the distance between the player and the implement 
		local nearestDistance = 10.0; --max distance allowed
		local px, py, pz = getWorldTranslation(self.rootNode); 
		local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
		local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);	
		if distance < nearestDistance then
			self.inrange = true; 
		else
			self.inrange = false; 
		end;
	end;
end;



   
