VARITITAN1 = {}; function VARITITAN1.prerequisitesPresent(specializations) return SpecializationUtil.hasSpecialization(Trailer, specializations); end; function VARITITAN1:load(xmlFile) -- chapuza para hacer girar ruedas al voltear self.rueda3 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rueda3#index")); self.rueda31 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rueda31#index")); self.rueda9 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rueda9#index")); self.rueda91 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rueda91#index")); self.drumNode1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.drum#index1")); self.drumNode2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.drum#index2")); self.drumRotationScale = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.drum#rotationScale"), 1); self.safeMode = true self.setCilindroDirection = SpecializationUtil.callSpecializationsFunction("setCilindroDirection"); local cilindrosCount = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.cilindros#count"), 0); self.cilindros = {}; for i=1, cilindrosCount do local cilindroName = string.format("vehicle.cilindros.cilindro%d", i); self.cilindros[i] = {}; self.cilindros[i].node = Utils.indexToObject(self.components, getXMLString(xmlFile, cilindroName .. "#index")); self.cilindros[i].part = Utils.indexToObject(self.components, getXMLString(xmlFile, cilindroName .. "#part")); self.cilindros[i].cilindroFixpoint = Utils.indexToObject(self.components, getXMLString(xmlFile, cilindroName .. "#cilindroFixpoint")); self.cilindros[i].fixPoint = Utils.indexToObject(self.components, getXMLString(xmlFile, cilindroName .. "#fixpoint")); local ax, ay, az = getWorldTranslation(self.cilindros[i].part); local bx, by, bz = getWorldTranslation(self.cilindros[i].cilindroFixpoint); self.cilindros[i].partDistance = Utils.vector3Length(ax-bx, ay-by, az-bz); end; local rotationNode1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation1#index")); if rotationNode1 ~= nil then self.rotation1 = {}; self.rotation1.node = rotationNode1; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation1#minRot")); self.rotation1.minRot = {}; self.rotation1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation1#maxRot")); self.rotation1.maxRot = {}; self.rotation1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation1#rotTime"), 2)*1000; end; local rotationNode2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation2#index")); if rotationNode2 ~= nil then self.rotation2 = {}; self.rotation2.node = rotationNode2; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation2#minRot")); self.rotation2.minRot = {}; self.rotation2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation2#maxRot")); self.rotation2.maxRot = {}; self.rotation2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation2.rotTime = self.rotation1.rotTime; end; local rotationNode3 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation3#index")); if rotationNode3 ~= nil then self.rotation3 = {}; self.rotation3.node = rotationNode3; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation3#minRot")); self.rotation3.minRot = {}; self.rotation3.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation3.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation3.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation3#maxRot")); self.rotation3.maxRot = {}; self.rotation3.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation3.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation3.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation3#transpRot")); self.rotation3.transpRot = {}; self.rotation3.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation3.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation3.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation3.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation3#rotTime"), 2)*1000; end; local rotationNode4 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation4#index")); if rotationNode4 ~= nil then self.rotation4 = {}; self.rotation4.node = rotationNode4; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation4#minRot")); self.rotation4.minRot = {}; self.rotation4.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation4.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation4.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation4#maxRot")); self.rotation4.maxRot = {}; self.rotation4.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation4.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation4.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation4#transpRot")); self.rotation4.transpRot = {}; self.rotation4.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation4.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation4.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation4.rotTime = self.rotation3.rotTime; end; local rotationNode5 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation5#index")); if rotationNode5 ~= nil then self.rotation5 = {}; self.rotation5.node = rotationNode5; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation5#minRot")); self.rotation5.minRot = {}; self.rotation5.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation5.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation5.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation5#maxRot")); self.rotation5.maxRot = {}; self.rotation5.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation5.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation5.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation5#transpRot")); self.rotation5.transpRot = {}; self.rotation5.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation5.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation5.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation5.rotTime = self.rotation3.rotTime; end; local rotationNode6 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation6#index")); if rotationNode6 ~= nil then self.rotation6 = {}; self.rotation6.node = rotationNode6; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation6#minRot")); self.rotation6.minRot = {}; self.rotation6.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation6.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation6.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation6#maxRot")); self.rotation6.maxRot = {}; self.rotation6.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation6.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation6.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation6#transpRot")); self.rotation6.transpRot = {}; self.rotation6.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation6.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation6.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation6.rotTime = self.rotation3.rotTime; end; local rotationNode7 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation7#index")); if rotationNode7 ~= nil then self.rotation7 = {}; self.rotation7.node = rotationNode7; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation7#minRot")); self.rotation7.minRot = {}; self.rotation7.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation7.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation7.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation7#maxRot")); self.rotation7.maxRot = {}; self.rotation7.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation7.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation7.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation7#transpRot")); self.rotation7.transpRot = {}; self.rotation7.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation7.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation7.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation7.rotTime = self.rotation3.rotTime; end; local rotationNode8 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation8#index")); if rotationNode8 ~= nil then self.rotation8 = {}; self.rotation8.node = rotationNode8; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation8#minRot")); self.rotation8.minRot = {}; self.rotation8.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation8.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation8.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation8#maxRot")); self.rotation8.maxRot = {}; self.rotation8.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation8.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation8.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation8.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation8#rotTime"), 2)*1000; end; local rotationNode9 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation9#index")); if rotationNode9 ~= nil then self.rotation9 = {}; self.rotation9.node = rotationNode9; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation9#minRot")); self.rotation9.minRot = {}; self.rotation9.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation9.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation9.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation9#maxRot")); self.rotation9.maxRot = {}; self.rotation9.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation9.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation9.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation9.rotTime = self.rotation8.rotTime; end; local rotationNode10 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation10#index")); if rotationNode10 ~= nil then self.rotation10 = {}; self.rotation10.node = rotationNode10; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation10#minRot")); self.rotation10.minRot = {}; self.rotation10.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation10.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation10.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation10#maxRot")); self.rotation10.maxRot = {}; self.rotation10.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation10.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation10.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation10#transpRot")); self.rotation10.transpRot = {}; self.rotation10.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation10.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation10.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation10.rotTime = self.rotation3.rotTime; end; local rotationNode11 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation11#index")); if rotationNode11 ~= nil then self.rotation11 = {}; self.rotation11.node = rotationNode11; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation11#minRot")); self.rotation11.minRot = {}; self.rotation11.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation11.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation11.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation11#maxRot")); self.rotation11.maxRot = {}; self.rotation11.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation11.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation11.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation11#transpRot")); self.rotation11.transpRot = {}; self.rotation11.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation11.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation11.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation11.rotTime = self.rotation3.rotTime; end; local rotationNode12 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation12#index")); if rotationNode12 ~= nil then self.rotation12 = {}; self.rotation12.node = rotationNode12; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation12#minRot")); self.rotation12.minRot = {}; self.rotation12.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation12.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation12.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation12#maxRot")); self.rotation12.maxRot = {}; self.rotation12.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation12.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation12.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation12#transpRot")); self.rotation12.transpRot = {}; self.rotation12.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation12.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation12.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation12.rotTime = self.rotation3.rotTime; end; local rotationNode13 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation13#index")); if rotationNode13 ~= nil then self.rotation13 = {}; self.rotation13.node = rotationNode13; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation13#minRot")); self.rotation13.minRot = {}; self.rotation13.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation13.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation13.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation13#maxRot")); self.rotation13.maxRot = {}; self.rotation13.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation13.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation13.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation13#transpRot")); self.rotation13.transpRot = {}; self.rotation13.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation13.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation13.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation13.rotTime = self.rotation3.rotTime; end; local rotationNode14 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation14#index")); if rotationNode14 ~= nil then self.rotation14 = {}; self.rotation14.node = rotationNode14; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation14#minRot")); self.rotation14.minRot = {}; self.rotation14.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation14.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation14.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation14#maxRot")); self.rotation14.maxRot = {}; self.rotation14.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation14.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation14.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation14#transpRot")); self.rotation14.transpRot = {}; self.rotation14.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation14.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation14.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation14.rotTime = self.rotation3.rotTime; end; local rotationNode15 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation15#index")); if rotationNode15 ~= nil then self.rotation15 = {}; self.rotation15.node = rotationNode15; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation15#minRot")); self.rotation15.minRot = {}; self.rotation15.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation15.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation15.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation15#maxRot")); self.rotation15.maxRot = {}; self.rotation15.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation15.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation15.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation15#transpRot")); self.rotation15.transpRot = {}; self.rotation15.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation15.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation15.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation15.rotTime = self.rotation3.rotTime; end; local rotationNode16 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation16#index")); if rotationNode16 ~= nil then self.rotation16 = {}; self.rotation16.node = rotationNode16; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation16#minRot")); self.rotation16.minRot = {}; self.rotation16.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation16.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation16.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation16#maxRot")); self.rotation16.maxRot = {}; self.rotation16.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation16.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation16.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation16#transpRot")); self.rotation16.transpRot = {}; self.rotation16.transpRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation16.transpRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation16.transpRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation16.rotTime = self.rotation3.rotTime; end; local translationNode1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translation1#index")); if translationNode1 ~= nil then self.translation1 = {}; self.translation1.node = translationNode1; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation1#minTrans")); self.translation1.minTrans = {}; self.translation1.minTrans[1] = Utils.getNoNil(x, 0); self.translation1.minTrans[2] = Utils.getNoNil(y, 0); self.translation1.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation1#maxTrans")); self.translation1.maxTrans = {}; self.translation1.maxTrans[1] = Utils.getNoNil(x, 0); self.translation1.maxTrans[2] = Utils.getNoNil(y, 0); self.translation1.maxTrans[3] = Utils.getNoNil(z, 0); self.translation1.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation1#transTime"), 2)*1000; end; local translationNode2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translation2#index")); if translationNode2 ~= nil then self.translation2 = {}; self.translation2.node = translationNode2; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation2#minTrans")); self.translation2.minTrans = {}; self.translation2.minTrans[1] = Utils.getNoNil(x, 0); self.translation2.minTrans[2] = Utils.getNoNil(y, 0); self.translation2.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation2#maxTrans")); self.translation2.maxTrans = {}; self.translation2.maxTrans[1] = Utils.getNoNil(x, 0); self.translation2.maxTrans[2] = Utils.getNoNil(y, 0); self.translation2.maxTrans[3] = Utils.getNoNil(z, 0); self.translation2.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation2#transTime"), 2)*1000; end; local translationNode3 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translation3#index")); if translationNode3 ~= nil then self.translation3 = {}; self.translation3.node = translationNode3; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation3#minTrans")); self.translation3.minTrans = {}; self.translation3.minTrans[1] = Utils.getNoNil(x, 0); self.translation3.minTrans[2] = Utils.getNoNil(y, 0); self.translation3.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation3#maxTrans")); self.translation3.maxTrans = {}; self.translation3.maxTrans[1] = Utils.getNoNil(x, 0); self.translation3.maxTrans[2] = Utils.getNoNil(y, 0); self.translation3.maxTrans[3] = Utils.getNoNil(z, 0); self.translation3.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation3#transTime"), 2)*1000; end; local translationNode4 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translation4#index")); if translationNode4 ~= nil then self.translation4 = {}; self.translation4.node = translationNode4; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation4#minTrans")); self.translation4.minTrans = {}; self.translation4.minTrans[1] = Utils.getNoNil(x, 0); self.translation4.minTrans[2] = Utils.getNoNil(y, 0); self.translation4.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation4#maxTrans")); self.translation4.maxTrans = {}; self.translation4.maxTrans[1] = Utils.getNoNil(x, 0); self.translation4.maxTrans[2] = Utils.getNoNil(y, 0); self.translation4.maxTrans[3] = Utils.getNoNil(z, 0); self.translation4.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation4#transTime"), 2)*1000; end; local translationNode5 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translation5#index")); if translationNode5 ~= nil then self.translation5 = {}; self.translation5.node = translationNode5; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation5#minTrans")); self.translation5.minTrans = {}; self.translation5.minTrans[1] = Utils.getNoNil(x, 0); self.translation5.minTrans[2] = Utils.getNoNil(y, 0); self.translation5.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation5#maxTrans")); self.translation5.maxTrans = {}; self.translation5.maxTrans[1] = Utils.getNoNil(x, 0); self.translation5.maxTrans[2] = Utils.getNoNil(y, 0); self.translation5.maxTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation5#transpTrans")); self.translation5.transpTrans = {}; self.translation5.transpTrans[1] = Utils.getNoNil(x, 0); self.translation5.transpTrans[2] = Utils.getNoNil(y, 0); self.translation5.transpTrans[3] = Utils.getNoNil(z, 0); self.translation5.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation5#transTime"), 2)*1000; end; local translationNode6 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translation6#index")); if translationNode6 ~= nil then self.translation6 = {}; self.translation6.node = translationNode6; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation6#minTrans")); self.translation6.minTrans = {}; self.translation6.minTrans[1] = Utils.getNoNil(x, 0); self.translation6.minTrans[2] = Utils.getNoNil(y, 0); self.translation6.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation6#maxTrans")); self.translation6.maxTrans = {}; self.translation6.maxTrans[1] = Utils.getNoNil(x, 0); self.translation6.maxTrans[2] = Utils.getNoNil(y, 0); self.translation6.maxTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation6#transpTrans")); self.translation6.transpTrans = {}; self.translation6.transpTrans[1] = Utils.getNoNil(x, 0); self.translation6.transpTrans[2] = Utils.getNoNil(y, 0); self.translation6.transpTrans[3] = Utils.getNoNil(z, 0); self.translation6.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation6#transTime"), 2)*1000; end; local translationNode7 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translation7#index")); if translationNode7 ~= nil then self.translation7 = {}; self.translation7.node = translationNode7; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation7#minTrans")); self.translation7.minTrans = {}; self.translation7.minTrans[1] = Utils.getNoNil(x, 0); self.translation7.minTrans[2] = Utils.getNoNil(y, 0); self.translation7.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation7#maxTrans")); self.translation7.maxTrans = {}; self.translation7.maxTrans[1] = Utils.getNoNil(x, 0); self.translation7.maxTrans[2] = Utils.getNoNil(y, 0); self.translation7.maxTrans[3] = Utils.getNoNil(z, 0); self.translation7.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation7#transTime"), 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.components, 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 numRotParts1 = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.RotParts1#count"), 0); self.RotParts1 = {}; for i=1, numRotParts1 do local partnamei = string.format("vehicle.RotParts1.part" .. "%d", i); self.RotParts1[i] = {}; self.RotParts1[i].index = Utils.indexToObject(self.components, getXMLString(xmlFile, partnamei .. "#index")); local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, partnamei .. "#minRot")); self.RotParts1[i].minRot = {}; self.RotParts1[i].minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.RotParts1[i].minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.RotParts1[i].minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, partnamei .. "#maxRot")); self.RotParts1[i].maxRot = {}; self.RotParts1[i].maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.RotParts1[i].maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.RotParts1[i].maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.RotParts1[i].rotTime = Utils.getNoNil(getXMLString(xmlFile, partnamei .. "#rotSpeed"), 2)*1000; 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.components, 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 workSound = getXMLString(xmlFile, "vehicle.workSound#file"); if workSound ~= nil and workSound ~= "" then workSound = Utils.getFilename(workSound, self.baseDirectory); self.workSound = createSample("workSound"); self.workSoundEnabled = false; loadSample(self.workSound, workSound, false); self.workSoundPitchOffset = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.workSound#pitchOffset"), 1); self.workSoundVolume = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.workSound#volume"), 1); end; self.rundumleuchtenAnz = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.rundumleuchten#count"),0); self.rundumleuchtenAn = false; self.rundumleuchten = {}; for i=1, self.rundumleuchtenAnz do local objname = string.format("vehicle.rundumleuchten.light" .. "%d",i); self.rundumleuchten[i] = {}; self.rundumleuchten[i].rotNode = Utils.indexToObject(self.components, getXMLString(xmlFile, objname .. "#rotNode")); self.rundumleuchten[i].light = Utils.indexToObject(self.components, getXMLString(xmlFile, objname .. "#light")); self.rundumleuchten[i].source = Utils.indexToObject(self.components, getXMLString(xmlFile, objname .. "#lightsource")); self.rundumleuchten[i].speed = Utils.getNoNil(getXMLInt(xmlFile, objname .. "#rotSpeed"), 1)/1000; self.rundumleuchten[i].emit = Utils.getNoNil(getXMLBool(xmlFile, objname .. "#emitLight"), true); if not self.rundumleuchten[i].emit and self.rundumleuchten[i].source ~= nil then setVisibility(self.rundumleuchten[i].source, false); end; end; self.worklight = {}; self.worklight[1] = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.worklight.light1#index")); self.worklight[2] = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.worklight.light2#index")); self.worklight[3] = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.worklight.light3#index")); self.worklight[4] = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.worklight.light4#index")); self.groundCheck = {}; self.groundCheck = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.groundCheck#index")); self.lastSpeed = 0; self.work = getVisibility(self.worklight[1]) self.controlpath = Utils.getFilename("lemken.jpg", self.baseDirectory); self.hudlemkenPoxX = 0.01; self.hudlemkenPoxY = 1-0.204; self.hudlemkenWidth = 0.240; self.hudlemkenHeight = 0.240; self.hudlemkenPoxX = 0.75; self.hudlemkenPoxY = 0.60 self.hudlemkenOverlay = Overlay:new("hudlemken", self.controlpath, self.hudlemkenPoxX, self.hudlemkenPoxY, self.hudlemkenWidth, self.hudlemkenHeight); self.bcActive = false; end; function VARITITAN1:delete() end; function VARITITAN1:mouseEvent(posX, posY, isDown, isUp, button) end; function VARITITAN1:keyEvent(unicode, sym, modifier, isDown) if isDown and sym == 48 then -- Key: 0 self.bcActive = not self.bcActive; end; if isDown and sym == Input.KEY_n and not self.max then self.transport = not self.transport; end; if isDown and sym == Input.KEY_v then self.rotation8Max = not self.rotation8Max; self.rotation9Max = not self.rotation9Max; end; if isDown and sym == Input.KEY_b and not self.max then self.isDown = not self.isDown ; end; if isDown and sym == Input.KEY_l then self.work = not self.work; setVisibility(self.worklight[1], self.work); setVisibility(self.worklight[2], self.work); setVisibility(self.worklight[3], self.work); setVisibility(self.worklight[4], self.work); end; if isDown and sym == Input.KEY_m and self.rotation8Max then self.max = not self.max ; end; if sym == Input.KEY_KP_3 then self.translation1Max = isDown; self.translation2Max = isDown; end; if sym == Input.KEY_KP_1 then self.translation1Min = isDown; self.translation2Min = isDown; end; if isDown and sym == Input.KEY_r then self.rundumleuchtenAn = not self.rundumleuchtenAn; for i=1, self.rundumleuchtenAnz do setVisibility(self.rundumleuchten[i].light, self.rundumleuchtenAn); end; end; end; function VARITITAN1:update(dt) if self.fixAttacher then local implement = self.attacherVehicle:getImplementByObject(self); if implement ~= nil then local joint = self.attacherVehicle.attacherJoints[implement.jointDescIndex]; self.saveJoint = self.attacherVehicle.attacherJoints[implement.jointDescIndex]; self.maxRotJoint = joint.maxRotLimit; self.attacherJointIndex = implement.jointDescIndex; self.rotationCopy = joint.minRot; joint.minRot = {Utils.degToRad(2),0,0}; joint.maxRotLimit = {0, 0, 0}; setJointRotationLimit(joint.jointIndex, 2, true, 0, 0); end; self.fixAttacher = false; end; if self.attacherVehicle then local x,y,z = getWorldTranslation(self.groundCheck); local terrainHeight = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x, 0, z); local gC = y-terrainHeight; -- if (math.min(gC) <1.05) then -- self.go = true; -- end; if self.max and not self.transport then self.rotParts1 =true; self.rotParts2 =true; self.translation3Max =true; self.translation4Max = true; self.translation7Max = true; else self.rotParts2 =false; self.translation3Max =false; self.translation4Max = false; self.rotParts1 =false; self.translation7Max = false; end; if self.max and self.transport then self.rotParts =true; self.rotParts2 =true; self.translation3Max =true; self.translation4Max = true; self.translation7Max = true; else self.rotParts2 =false; self.translation3Max =false; self.translation4Max = false; self.rotParts =false; self.translation7Max = false; end; if (math.min(gC) <0.8) then if (not self.rotation9Max) then if table.getn(self.cuttingAreas) > 0 then local x,y,z = getWorldTranslation(self.cuttingAreas[1].start); local x1,y1,z1 = getWorldTranslation(self.cuttingAreas[1].width); local x2,y2,z2 = getWorldTranslation(self.cuttingAreas[1].height); if self.safeMode then Plough.updateSafeArea(x, z, x1, z1, x2, z2) else Utils.updatePloughrArea(x, z, x1, z1, x2, z2); end; if self.attacherVehicle.lastSpeed*3600 > 2 then if not self.workSoundRunning then print("start"); playSample(self.workSound, 0, 1.6, 0); self.workSoundRunning = true; end; end; if self.attacherVehicle.lastSpeed*3600 < 2 then if self.workSoundRunning then print("end"); stopSample(self.workSound, 0, 1.6, 0); self.workSoundRunning = false; end; end; end; else if self.workSoundRunning then print("end"); stopSample(self.workSound, 0, 1.6, 0); self.workSoundRunning = false; end; end; end; if self.attacherVehicle then -- chapuza para hacer girar ruedas al voltear if (not self.rotation9Max) then if self.drumNode1 ~= nil then rotate(self.drumNode1, self.drumRotationScale * self.attacherVehicle.lastSpeed * self.attacherVehicle.movingDirection, 0, 0); end; if self.drumNode2 ~= nil then rotate(self.drumNode2, self.drumRotationScale * self.attacherVehicle.lastSpeed * self.attacherVehicle.movingDirection, 0, 0); end; end; end; if self.transport then if self.rotation3 ~= nil then local x, y, z = getRotation(self.rotation3.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation3.minRot, self.rotation3.transpRot, 3, self.rotation3.rotTime, dt, self.isDown); setRotation(self.rotation3.node, unpack(newRot)); setVisibility(self.rueda3,true); setVisibility(self.rueda31,false); setVisibility(self.rueda9,true); setVisibility(self.rueda91,false); end; if self.rotation4 ~= nil then local x, y, z = getRotation(self.rotation4.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation4.minRot, self.rotation4.transpRot, 3, self.rotation4.rotTime, dt, self.isDown); setRotation(self.rotation4.node, unpack(newRot)); end; if self.rotation5 ~= nil then local x, y, z = getRotation(self.rotation5.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation5.minRot, self.rotation5.transpRot, 3, self.rotation5.rotTime, dt, self.isDown); setRotation(self.rotation5.node, unpack(newRot)); end; if self.rotation6 ~= nil then local x, y, z = getRotation(self.rotation6.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation6.minRot, self.rotation6.transpRot, 3, self.rotation6.rotTime, dt, self.isDown); setRotation(self.rotation6.node, unpack(newRot)); end; if self.rotation7 ~= nil then local x, y, z = getRotation(self.rotation7.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation7.minRot, self.rotation7.transpRot, 3, self.rotation7.rotTime, dt, self.isDown); setRotation(self.rotation7.node, unpack(newRot)); end; if self.rotation10 ~= nil then local x, y, z = getRotation(self.rotation10.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation10.minRot, self.rotation10.transpRot, 3, self.rotation10.rotTime, dt, self.isDown); setRotation(self.rotation10.node, unpack(newRot)); end; if self.rotation11 ~= nil then local x, y, z = getRotation(self.rotation11.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation11.minRot, self.rotation11.transpRot, 3, self.rotation11.rotTime, dt, self.isDown); setRotation(self.rotation11.node, unpack(newRot)); end; if self.rotation12 ~= nil then local x, y, z = getRotation(self.rotation12.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation12.minRot, self.rotation12.transpRot, 3, self.rotation12.rotTime, dt, self.isDown); setRotation(self.rotation12.node, unpack(newRot)); end; if self.rotation13 ~= nil then local x, y, z = getRotation(self.rotation13.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation13.minRot, self.rotation13.transpRot, 3, self.rotation13.rotTime, dt, self.isDown); setRotation(self.rotation13.node, unpack(newRot)); end; if self.rotation14 ~= nil then local x, y, z = getRotation(self.rotation14.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation14.minRot, self.rotation14.transpRot, 3, self.rotation14.rotTime, dt, self.isDown); setRotation(self.rotation14.node, unpack(newRot)); end; if self.rotation15 ~= nil then local x, y, z = getRotation(self.rotation15.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation15.minRot, self.rotation15.transpRot, 3, self.rotation15.rotTime, dt, self.isDown); setRotation(self.rotation15.node, unpack(newRot)); end; if self.rotation16 ~= nil then local x, y, z = getRotation(self.rotation16.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation16.minRot, self.rotation16.transpRot, 3, self.rotation16.rotTime, dt, self.isDown); setRotation(self.rotation16.node, unpack(newRot)); end; if self.translation5 ~= nil then local x, y, z = getTranslation(self.translation5.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation5.minTrans, self.translation5.transpTrans, 3, self.translation5.transTime, dt, self.isDown); setTranslation(self.translation5.node, unpack(newTrans)); end; if self.translation6 ~= nil then local x, y, z = getTranslation(self.translation6.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation6.minTrans, self.translation6.transpTrans, 3, self.translation6.transTime, dt, self.isDown); setTranslation(self.translation6.node, unpack(newTrans)); end; else if self.rotation3 ~= nil then local x, y, z = getRotation(self.rotation3.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation3.transpRot, self.rotation3.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation3.node, unpack(newRot)); setVisibility(self.rueda31,true); setVisibility(self.rueda3,false); setVisibility(self.rueda91,true); setVisibility(self.rueda9,false); end; if self.rotation4 ~= nil then local x, y, z = getRotation(self.rotation4.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation4.transpRot, self.rotation4.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation4.node, unpack(newRot)); end; if self.rotation5 ~= nil then local x, y, z = getRotation(self.rotation5.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation5.transpRot, self.rotation5.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation5.node, unpack(newRot)); end; if self.rotation6 ~= nil then local x, y, z = getRotation(self.rotation6.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation6.transpRot, self.rotation6.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation6.node, unpack(newRot)); end; if self.rotation7 ~= nil then local x, y, z = getRotation(self.rotation7.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation7.transpRot, self.rotation7.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation7.node, unpack(newRot)); end; if self.rotation10 ~= nil then local x, y, z = getRotation(self.rotation10.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation10.transpRot, self.rotation10.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation10.node, unpack(newRot)); end; if self.rotation11 ~= nil then local x, y, z = getRotation(self.rotation11.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation11.transpRot, self.rotation11.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation11.node, unpack(newRot)); end; if self.rotation12 ~= nil then local x, y, z = getRotation(self.rotation12.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation12.transpRot, self.rotation12.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation12.node, unpack(newRot)); end; if self.rotation13 ~= nil then local x, y, z = getRotation(self.rotation13.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation13.transpRot, self.rotation13.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation13.node, unpack(newRot)); end; if self.rotation14 ~= nil then local x, y, z = getRotation(self.rotation14.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation14.transpRot, self.rotation14.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation14.node, unpack(newRot)); end; if self.rotation15 ~= nil then local x, y, z = getRotation(self.rotation15.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation15.transpRot, self.rotation15.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation15.node, unpack(newRot)); end; if self.rotation16 ~= nil then local x, y, z = getRotation(self.rotation16.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation16.transpRot, self.rotation16.maxRot, 3, 3*1000, dt, not self.isDown); setRotation(self.rotation16.node, unpack(newRot)); end; if self.translation5 ~= nil then local x, y, z = getTranslation(self.translation5.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation5.transpTrans, self.translation5.maxTrans, 3, self.translation5.transTime, dt, not self.isDown); setTranslation(self.translation5.node, unpack(newTrans)); end; if self.translation6 ~= nil then local x, y, z = getTranslation(self.translation6.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation6.transpTrans, self.translation6.maxTrans, 3, self.translation6.transTime, dt,not self.isDown); setTranslation(self.translation6.node, unpack(newTrans)); end; end; local doTranslate = self.translation1Max or self.translation1Min if self.translation1 ~= nil and doTranslate then local x, y, z = getTranslation(self.translation1.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation1.maxTrans, self.translation1.minTrans, 3, self.translation1.transTime, dt, not self.translation1Max); setTranslation(self.translation1.node, unpack(newTrans)); end; if self.translation2 ~= nil and doTranslate then local x, y, z = getTranslation(self.translation2.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation2.maxTrans, self.translation2.minTrans, 3, self.translation2.transTime, dt, not self.translation2Max); setTranslation(self.translation2.node, unpack(newTrans)); end; if self.rotation1Max ~= nil then local x, y, z = getRotation(self.rotation1.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation1.maxRot, self.rotation1.minRot, 3, self.rotation1.rotTime, dt, not self.rotation1Max); setRotation(self.rotation1.node, unpack(newRot)); end; if self.rotation2Max ~= nil then local x, y, z = getRotation(self.rotation2.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation2.maxRot, self.rotation2.minRot, 3, self.rotation2.rotTime, dt, not self.rotation2Max); setRotation(self.rotation2.node, unpack(newRot)); end; if self.rotation8Max ~= nil then local x, y, z = getRotation(self.rotation8.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation8.maxRot, self.rotation8.minRot, 3, self.rotation8.rotTime, dt, not self.rotation8Max); setRotation(self.rotation8.node, unpack(newRot)); end; if self.rotation9Max ~= nil then local x, y, z = getRotation(self.rotation9.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation9.maxRot, self.rotation9.minRot, 3, self.rotation9.rotTime, dt, not self.rotation9Max); setRotation(self.rotation9.node, unpack(newRot)); end; if self.rotParts ~= nil 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, not self.rotParts); setRotation(self.RotParts[i].index, unpack(newRot)); end; end; if self.rotParts1 ~= nil then for i=1, table.getn(self.RotParts1) do local rot = {getRotation(self.RotParts1[i].index)}; local newRot = Utils.getMovedLimitedValues(rot, self.RotParts1[i].maxRot, self.RotParts1[i].minRot, 3, self.RotParts1[i].rotTime, dt, not self.rotParts1); setRotation(self.RotParts1[i].index, unpack(newRot)); end; end; if self.rotParts2 ~= nil 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.rotParts2); setRotation(self.RotParts2[i].index, unpack(newRot)); end; end; if self.translation3Max ~= nil then local x, y, z = getTranslation(self.translation3.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation3.maxTrans, self.translation3.minTrans, 3, self.translation3.transTime, dt, not self.translation3Max); setTranslation(self.translation3.node, unpack(newTrans)); end; if self.translation4Max ~= nil then local x, y, z = getTranslation(self.translation4.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation4.maxTrans, self.translation4.minTrans, 3, self.translation4.transTime, dt, not self.translation4Max); setTranslation(self.translation4.node, unpack(newTrans)); end; if self.translation7Max ~= nil then local x, y, z = getTranslation(self.translation7.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation7.maxTrans, self.translation7.minTrans, 3, self.translation7.transTime, dt, not self.translation7Max); setTranslation(self.translation7.node, unpack(newTrans)); end; if self.rundumleuchtenAn then for i=1, self.rundumleuchtenAnz do rotate(self.rundumleuchten[i].rotNode, 0, dt*self.rundumleuchten[i].speed, 0); end; end; local joint = self.componentJoints[3]; setJointFrame(joint.jointIndex, 0,joint.jointNode); local joint = self.componentJoints[4]; setJointFrame(joint.jointIndex, 0,joint.jointNode); local joint = self.componentJoints[5]; setJointFrame(joint.jointIndex, 0,joint.jointNode); local joint = self.componentJoints[6]; setJointFrame(joint.jointIndex, 0,joint.jointNode); local joint = self.componentJoints[7]; setJointFrame(joint.jointIndex, 0,joint.jointNode); local joint = self.componentJoints[8]; setJointFrame(joint.jointIndex, 0,joint.jointNode); local joint = self.componentJoints[9]; setJointFrame(joint.jointIndex, 0,joint.jointNode); self:setCilindroDirection(); end; function VARITITAN1:draw() if self.hudlemkenOverlay ~= nil then if self.bcActive then self.hudlemkenOverlay:render(); end; end; if self.bcActive then g_currentMission:addExtraPrintText("play 0: memu ON"); else g_currentMission:addExtraPrintText("play 0: memu Off"); end; end; function VARITITAN1:onAttach() self.fixAttacher = true; self.rotation1Max = true; self.rotation2Max = true; self.rotation8Max = true; self.rotation9Max = true; end; function VARITITAN1:onDetach() local joint = self.saveJoint; joint.minRot = self.rotationCopy; joint.maxRotLimit = self.maxRotJoint; self.rotation1Max = false; self.rotation2Max = false; self.rundumleuchtenAn = false; for i=1, self.rundumleuchtenAnz do setVisibility(self.rundumleuchten[i].light, self.rundumleuchtenAn); end; if self.workSoundRunning then print("end"); stopSample(self.workSound, 0, 1.6, 0); self.workSoundRunning = false; end; setVisibility(self.worklight[1], false); setVisibility(self.worklight[2], false); setVisibility(self.worklight[3], false); setVisibility(self.worklight[4], false); end; function VARITITAN1:onLeave() end; function VARITITAN1:setCilindroDirection() for i=1, table.getn(self.cilindros) do local ax, ay, az = getWorldTranslation(self.cilindros[i].node); local bx, by, bz = getWorldTranslation(self.cilindros[i].fixPoint); local x, y, z = worldDirectionToLocal(getParent(self.cilindros[i].node), bx-ax, by-ay, bz-az); setDirection(self.cilindros[i].node, x, y, z, 0, 1, 0); if self.cilindros[i].part ~= nil then local distance = Utils.vector3Length(ax-bx, ay-by, az-bz); setTranslation(self.cilindros[i].part,0 ,0 ,distance-self.cilindros[i].partDistance); end; end; end;