Community Forum

WheelRollingResistence....

Forum Overview >> Farming Simulator 2011

CategoryFarming Simulator 2011
Created12.03.2012 10:05


Peter Edliner (Unknown) 12.03.2012 10:07
Hello,

Could someone maby tell me what the wheel rolling resistence is and where and in which script i can find them?
And are there other resistences too?

Thanks in advance

Ludovic Fritz (mrludo40) 15.03.2012 16:40
hello,
I do not know if this is what you seek




CustomForces = {};

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

function CustomForces:load(xmlFile)

if self.isServer then
self.customForces = {};
local i=0;
while true do
local forceKey = string.format("vehicle.customForces.customForce(%d)", i);
if not hasXMLProperty(xmlFile, forceKey .. "#node") then
break;
end;
local force = {};

local node = getXMLInt(xmlFile, forceKey .. "#node");
force.node = self.components[node].node;
local x,y,z = Utils.getVectorFromString(getXMLString(xmlFile, forceKey .. "#position"));
force.pos = {};
force.pos.x = x;
force.pos.y = y;
force.pos.z = z;
x,y,z = Utils.getVectorFromString(getXMLString(xmlFile, forceKey .. "#positionRev"));
if x ~= nil then
force.revPos = {};
force.revPos.x = x;
force.revPos.y = y;
force.revPos.z = z;
end;
force.force = Utils.getNoNil(getXMLFloat(xmlFile, forceKey .. "#force"), 25);
force.forceRev = Utils.getNoNil(getXMLFloat(xmlFile, forceKey .. "#forceRev"), 25);

local wheelIndex = getXMLInt(xmlFile, forceKey .. "#wheel");
if wheelIndex ~= nil then
force.wheel = self.wheels[wheelIndex];
force.onMinAngle = Utils.getNoNil(getXMLBool(xmlFile, forceKey .. "#onMinAngle"), false);
end;

local speed = getXMLFloat(xmlFile, forceKey .. "#maxSpeed");
local speedRev = getXMLFloat(xmlFile, forceKey .. "#maxSpeedRev");
if speed ~= nil then
force.speed = speed;
force.speedRev = speedRev;
end;

table.insert(self.customForces, force);
i = i + 1;
end;
end;
end;

function CustomForces:delete()
end;

function CustomForces:readStream(streamId, connection)
end;

function CustomForces:writeStream(streamId, connection)
end;

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

function CustomForces:keyEvent(unicode, sym, modifier, isDown)
end;

function CustomForces:update(dt)
if self.isServer then
if self:getIsActive() then
for _, customForce in pairs(self.customForces) do
local forcing = customForce.force;
local speed = customForce.speed;
local pos = customForce.pos;
if self.movingDirection < 0 then
if customForce.revPos ~= nil then
pos = customForce.revPos;
end;
if customForce.speedRev ~= nil then
speed = customForce.speedRev;
end;
if customForce.forceRev ~= nil then
forcing = customForce.forceRev;
end;
end;

if customForce.wheel ~= nil then
local wheel = customForce.wheel;
local force = customForce.force;
local maxAngle = wheel.rotMax;
if customForce.onMinAngle then
maxAngle = wheel.rotMin;
if wheel.steeringAngle > 0 then
force = 0;
end;
else
if wheel.steeringAngle < 0 then
force = 0;
end;
end;
forcing = force * (wheel.steeringAngle / maxAngle);
end;

if speed ~= nil then
forcing = forcing * math.abs(math.min((self.lastSpeed*3600 / speed), 1));
end;

local worldX,worldY,worldZ = localDirectionToWorld(customForce.node, 0, -forcing*dt/1000, 0);
if Vehicle.debugRendering then
local x,y,z = localToWorld(customForce.node, pos.x, pos.y, pos.z);
drawDebugPoint(x, y, z, 1,0,0,1);
drawDebugLine(x, y, z, 1,0,0, x+(worldX*2), y+(worldY*2), z+(worldZ*2), 1,0,0);
end;

addForce(customForce.node, worldX, worldY, worldZ, pos.x, pos.y, pos.z, true);
end;
end;
end;
end;

function CustomForces:updateTick(dt)
end;

function CustomForces:draw()
end;

Jan-hendrik Pfitzner (Unknown) 10.04.2012 07:15
lateralStiffness works for "motorized"

Add it to <wheels> in the .xml


Note: Log in to post. Create a new account here.