--by xyzspain attachable for fixpack and all packers variopal = {}; function variopal.prerequisitesPresent(specializations) Vehicle.registerJointType("frontloader"); return SpecializationUtil.hasSpecialization(Trailer, specializations); end; function variopal:load(xmlFile) self.aiTerrainDetailChannel1 = g_currentMission.sowingChannel; self.aiTerrainDetailChannel2 = g_currentMission.cultivatorChannel; self.safeMode = true -- 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.drumNode1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.drum#index1")); self.drumRotationScale = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.drum#rotationScale"), 1); self.groundCheck = {}; self.groundCheck = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.groundCheck#index")); 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)); self.rotation3.rotTime = self.rotation1.rotTime; 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)); self.rotation4.rotTime = self.rotation1.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)); self.rotation5.rotTime = self.rotation1.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)); self.rotation6.rotTime = self.rotation1.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)); self.rotation7.rotTime = self.rotation1.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 = self.rotation1.rotTime; 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.rotation1.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)); self.rotation10.rotTime = self.rotation1.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)); self.rotation11.rotTime = self.rotation1.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)); self.rotation12.rotTime = self.rotation1.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)); self.rotation13.rotTime = self.rotation1.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)); self.rotation14.rotTime = self.rotation1.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)); self.rotation15.rotTime = self.rotation1.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)); self.rotation16.rotTime = self.rotation1.rotTime; end; local rotationNode17 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation17#index")); if rotationNode17 ~= nil then self.rotation17 = {}; self.rotation17.node = rotationNode17; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation17#minRot")); self.rotation17.minRot = {}; self.rotation17.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation17.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation17.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation17#maxRot")); self.rotation17.maxRot = {}; self.rotation17.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation17.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation17.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation17.rotTime = self.rotation1.rotTime; end; local rotationNode18 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation18#index")); if rotationNode18 ~= nil then self.rotation18 = {}; self.rotation18.node = rotationNode18; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation18#minRot")); self.rotation18.minRot = {}; self.rotation18.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation18.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation18.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation18#maxRot")); self.rotation18.maxRot = {}; self.rotation18.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation18.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation18.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation18.rotTime = self.rotation1.rotTime; end; local rotationNode19 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation19#index")); if rotationNode19 ~= nil then self.rotation19 = {}; self.rotation19.node = rotationNode19; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation19#minRot")); self.rotation19.minRot = {}; self.rotation19.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation19.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation19.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation19#maxRot")); self.rotation19.maxRot = {}; self.rotation19.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation19.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation19.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation19.rotTime = self.rotation1.rotTime; end; local rotationNode20 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation20#index")); if rotationNode20 ~= nil then self.rotation20 = {}; self.rotation20.node = rotationNode20; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation20#minRot")); self.rotation20.minRot = {}; self.rotation20.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation20.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation20.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation20#maxRot")); self.rotation20.maxRot = {}; self.rotation20.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation20.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation20.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation20.rotTime = self.rotation1.rotTime; end; local rotationNode21 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation21#index")); if rotationNode21 ~= nil then self.rotation21 = {}; self.rotation21.node = rotationNode21; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation21#minRot")); self.rotation21.minRot = {}; self.rotation21.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation21.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation21.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation21#maxRot")); self.rotation21.maxRot = {}; self.rotation21.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation21.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation21.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation21.rotTime = self.rotation1.rotTime; end; local rotationNode22 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation22#index")); if rotationNode22 ~= nil then self.rotation22 = {}; self.rotation22.node = rotationNode22; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation22#minRot")); self.rotation22.minRot = {}; self.rotation22.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation22.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation22.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation22#maxRot")); self.rotation22.maxRot = {}; self.rotation22.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation22.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation22.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation22.rotTime = self.rotation1.rotTime; end; local rotationNode23 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation23#index")); if rotationNode23 ~= nil then self.rotation23 = {}; self.rotation23.node = rotationNode23; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation23#minRot")); self.rotation23.minRot = {}; self.rotation23.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation23.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation23.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation23#maxRot")); self.rotation23.maxRot = {}; self.rotation23.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotation23.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotation23.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotation23.rotTime = self.rotation1.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 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.controlpath = Utils.getFilename("variopal.jpg", self.baseDirectory); self.hudvariopalPoxX = 0.01; self.hudvariopalPoxY = 1-0.204; self.hudvariopalWidth = 0.240; self.hudvariopalHeight = 0.240; self.hudvariopalPoxX = 0.75; self.hudvariopalPoxY = 0.60 self.hudvariopalOverlay = Overlay:new("hudvariopal", self.controlpath, self.hudvariopalPoxX, self.hudvariopalPoxY, self.hudvariopalWidth, self.hudvariopalHeight); self.bcActive = false; end; function variopal:delete() end; function variopal:mouseEvent(posX, posY, isDown, isUp, button) end; function variopal:keyEvent(unicode, sym, modifier, isDown) if isDown and sym == 48 then -- Key: 0 self.bcActive = not self.bcActive; end; if sym == Input.KEY_KP_1 then self.rotation10max= isDown; self.rotation11max= isDown; self.rotation12max= isDown; self.rotation13max= isDown; self.rotation14max= isDown; self.rotation15max= isDown; self.rotation16max= isDown; self.rotation17max= isDown; self.rotation18max= isDown; self.rotation19max= isDown; self.rotation20max= isDown; self.rotation21max= isDown; self.rotation22max= isDown; self.rotation23max= isDown; end; if sym == Input.KEY_KP_3 then self.rotation10min= isDown; self.rotation11min= isDown; self.rotation12min= isDown; self.rotation13min= isDown; self.rotation14min= isDown; self.rotation15min= isDown; self.rotation16min= isDown; self.rotation17min= isDown; self.rotation18min= isDown; self.rotation19min= isDown; self.rotation20min= isDown; self.rotation21min= isDown; self.rotation22min= isDown; self.rotation23min= isDown; end; if isDown and sym == Input.KEY_b then self.rotation3Max = not self.rotation3Max ; self.rotation8Max = not self.rotation8Max ; end; if sym == Input.KEY_KP_8 then self.translation1Max = isDown; end; if sym == Input.KEY_KP_2 then self.translation1Min = isDown; end; end; function variopal: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 -- chapuza para hacer girar ruedas al voltear if self.rotation3Max then setVisibility(self.rueda3,false); setVisibility(self.rueda31,true); if self.drumNode1 ~= nil then rotate(self.drumNode1, self.drumRotationScale * self.attacherVehicle.lastSpeed * self.attacherVehicle.movingDirection, 0, 0); end; else setVisibility(self.rueda3,true); setVisibility(self.rueda31,false); end; end; --play areas y sonido 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) <0.8) 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); Utils.updatePloughArea(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; --rotaciones y translaciones 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.rotation3Max ~= nil then local x, y, z = getRotation(self.rotation3.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation3.maxRot, self.rotation3.minRot, 3, self.rotation3.rotTime, dt, not self.rotation3Max); setRotation(self.rotation3.node, unpack(newRot)); end; if self.rotation4Max ~= nil then local x, y, z = getRotation(self.rotation4.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation4.maxRot, self.rotation4.minRot, 3, self.rotation4.rotTime, dt, not self.rotation4Max); setRotation(self.rotation4.node, unpack(newRot)); end; if self.rotation5Max ~= nil then local x, y, z = getRotation(self.rotation5.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation5.maxRot, self.rotation5.minRot, 3, self.rotation5.rotTime, dt, not self.rotation5Max); setRotation(self.rotation5.node, unpack(newRot)); end; if self.rotation6Max ~= nil then local x, y, z = getRotation(self.rotation6.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation6.maxRot, self.rotation6.minRot, 3, self.rotation6.rotTime, dt, not self.rotation6Max); setRotation(self.rotation6.node, unpack(newRot)); end; if self.rotation7Max ~= nil then local x, y, z = getRotation(self.rotation7.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation7.maxRot, self.rotation7.minRot, 3, self.rotation7.rotTime, dt, not self.rotation7Max); setRotation(self.rotation7.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; local doRotate = self.rotation10max or self.rotation10min if self.rotation10 ~= nil and doRotate then local x, y, z = getRotation(self.rotation10.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation10.maxRot, self.rotation10.minRot, 3, self.rotation10.rotTime, dt, not self.rotation10max); setRotation(self.rotation10.node, unpack(newRot)); end; local doRotate = self.rotation11max or self.rotation11min if self.rotation11 ~= nil and doRotate then local x, y, z = getRotation(self.rotation11.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation11.maxRot, self.rotation11.minRot, 3, self.rotation11.rotTime, dt, not self.rotation11max); setRotation(self.rotation11.node, unpack(newRot)); end; local doRotate = self.rotation12max or self.rotation12min if self.rotation12 ~= nil and doRotate then local x, y, z = getRotation(self.rotation12.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation12.maxRot, self.rotation12.minRot, 3, self.rotation12.rotTime, dt, not self.rotation12max); setRotation(self.rotation12.node, unpack(newRot)); end; local doRotate = self.rotation13max or self.rotation13min if self.rotation13 ~= nil and doRotate then local x, y, z = getRotation(self.rotation13.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation13.maxRot, self.rotation13.minRot, 3, self.rotation13.rotTime, dt, not self.rotation13max); setRotation(self.rotation13.node, unpack(newRot)); end; local doRotate = self.rotation14max or self.rotation14min if self.rotation14 ~= nil and doRotate then local x, y, z = getRotation(self.rotation14.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation14.maxRot, self.rotation14.minRot, 3, self.rotation14.rotTime, dt, not self.rotation14max); setRotation(self.rotation14.node, unpack(newRot)); end; local doRotate = self.rotation15max or self.rotation15min if self.rotation15 ~= nil and doRotate then local x, y, z = getRotation(self.rotation15.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation15.maxRot, self.rotation15.minRot, 3, self.rotation15.rotTime, dt, not self.rotation15max); setRotation(self.rotation15.node, unpack(newRot)); end; local doRotate = self.rotation16max or self.rotation16min if self.rotation16 ~= nil and doRotate then local x, y, z = getRotation(self.rotation16.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation16.maxRot, self.rotation16.minRot, 3, self.rotation16.rotTime, dt, not self.rotation16max); setRotation(self.rotation16.node, unpack(newRot)); end; local doRotate = self.rotation17max or self.rotation17min if self.rotation17 ~= nil and doRotate then local x, y, z = getRotation(self.rotation17.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation17.maxRot, self.rotation17.minRot, 3, self.rotation17.rotTime, dt, not self.rotation17max); setRotation(self.rotation17.node, unpack(newRot)); end; local doRotate = self.rotation18max or self.rotation18min if self.rotation18 ~= nil and doRotate then local x, y, z = getRotation(self.rotation18.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation18.maxRot, self.rotation18.minRot, 3, self.rotation18.rotTime, dt, not self.rotation18max); setRotation(self.rotation18.node, unpack(newRot)); end; local doRotate = self.rotation19max or self.rotation19min if self.rotation19 ~= nil and doRotate then local x, y, z = getRotation(self.rotation19.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation19.maxRot, self.rotation19.minRot, 3, self.rotation19.rotTime, dt, not self.rotation19max); setRotation(self.rotation19.node, unpack(newRot)); end; local doRotate = self.rotation20max or self.rotation20min if self.rotation20 ~= nil and doRotate then local x, y, z = getRotation(self.rotation20.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation20.maxRot, self.rotation20.minRot, 3, self.rotation20.rotTime, dt, not self.rotation20max); setRotation(self.rotation20.node, unpack(newRot)); end; local doRotate = self.rotation21max or self.rotation21min if self.rotation21 ~= nil and doRotate then local x, y, z = getRotation(self.rotation21.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation21.maxRot, self.rotation21.minRot, 3, self.rotation21.rotTime, dt, not self.rotation21max); setRotation(self.rotation21.node, unpack(newRot)); end; local doRotate = self.rotation22max or self.rotation22min if self.rotation22 ~= nil and doRotate then local x, y, z = getRotation(self.rotation22.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation22.maxRot, self.rotation22.minRot, 3, self.rotation22.rotTime, dt, not self.rotation22max); setRotation(self.rotation22.node, unpack(newRot)); end; local doRotate = self.rotation23max or self.rotation23min if self.rotation23 ~= nil and doRotate then local x, y, z = getRotation(self.rotation23.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotation23.maxRot, self.rotation23.minRot, 3, self.rotation23.rotTime, dt, not self.rotation23max); setRotation(self.rotation23.node, unpack(newRot)); 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.translation2Max ~= nil 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.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; -- juntas local joint = self.componentJoints[1]; setJointFrame(joint.jointIndex, 0,joint.jointNode); self:setCilindroDirection(); end; function variopal:draw() if self.hudvariopalOverlay ~= nil then if self.bcActive then self.hudvariopalOverlay: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 variopal:onAttach() -- self.fixAttacher = true; self.rotation4Max = true; self.rotation5Max = true; self.translation2Max= true; end; function variopal:onDetach() -- local joint = self.saveJoint; -- joint.minRot = self.rotationCopy; -- joint.maxRotLimit = self.maxRotJoint; self.rotation4Max = false; self.rotation5Max = false; self.translation2Max= false; if self.workSoundRunning then print("end"); stopSample(self.workSound, 0, 1.6, 0); self.workSoundRunning = false; end; end; function variopal:onLeave() end; function variopal: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; function variopal:validateAttacherJoint(implement, jointDesc, dt) return true; end;