update
This commit is contained in:
@@ -131,7 +131,6 @@ function Differential:forwardStep(torque, inertia)
|
||||
self.steerLock
|
||||
)
|
||||
|
||||
-- Аккерман
|
||||
local wheelbase = 2.05
|
||||
local trackWidth = 1.124
|
||||
local radius = wheelbase / math.tan(math.rad(self.steerAngle))
|
||||
|
||||
@@ -11,6 +11,8 @@ require('/koptilnya/libs/entity.txt')
|
||||
|
||||
local Wheel = class('Wheel', PowertrainComponent)
|
||||
|
||||
local DEBUG = false
|
||||
|
||||
function Wheel:initialize(vehicle, name, config)
|
||||
PowertrainComponent.initialize(self, vehicle, name, config)
|
||||
|
||||
@@ -30,7 +32,6 @@ function Wheel:initialize(vehicle, name, config)
|
||||
}
|
||||
|
||||
self.rot = 0
|
||||
self.offset = config.Offset or 0
|
||||
|
||||
self.entity = config.Entity or NULL_ENTITY
|
||||
|
||||
@@ -49,28 +50,35 @@ function Wheel:initialize(vehicle, name, config)
|
||||
|
||||
self.holo = self:createHolo(self.entity)
|
||||
|
||||
if DEBUG then
|
||||
self.debugHoloF:setPos(self.entity:getPos())
|
||||
self.debugHoloR:setPos(self.entity:getPos())
|
||||
self.debugHoloU:setPos(self.entity:getPos())
|
||||
|
||||
self.debugHoloF:setParent(self.entity)
|
||||
self.debugHoloR:setParent(self.entity)
|
||||
self.debugHoloU:setParent(self.entity)
|
||||
end
|
||||
|
||||
if not config.Radius then
|
||||
self.customWheel.radius = self:getEntityRadius()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local right = self.entity:getRight():getRotated(Angle(0, 90, 0))
|
||||
local offsetRight = self.entity:getRight():rotateAroundAxis(self.entity:getUp(), self.offset)
|
||||
if DEBUG then
|
||||
self.debugHoloF = holograms.create(Vector(), Angle(), 'models/sprops/rectangles_thin/size_0/rect_1_5x48x1_5.mdl')
|
||||
self.debugHoloR = holograms.create(Vector(), Angle(), 'models/sprops/rectangles_thin/size_0/rect_1_5x48x1_5.mdl')
|
||||
self.debugHoloU = holograms.create(Vector(), Angle(), 'models/sprops/rectangles_thin/size_0/rect_1_5x48x1_5.mdl')
|
||||
|
||||
self.dir = right:dot(offsetRight)
|
||||
self.debugHoloF:setMaterial('models/debug/debugwhite')
|
||||
self.debugHoloR:setMaterial('models/debug/debugwhite')
|
||||
self.debugHoloU:setMaterial('models/debug/debugwhite')
|
||||
|
||||
self.debugHolo1 = holograms.create(
|
||||
Vector(),
|
||||
Angle(),
|
||||
'models/sprops/geometry/sphere_3.mdl'
|
||||
)
|
||||
|
||||
self.debugHolo2 = holograms.create(
|
||||
Vector(),
|
||||
Angle(),
|
||||
'models/sprops/geometry/sphere_3.mdl'
|
||||
)
|
||||
self.debugHoloF:setColor(Color(255, 0, 0))
|
||||
self.debugHoloR:setColor(Color(0, 255, 0))
|
||||
self.debugHoloU:setColor(Color(0, 0, 255))
|
||||
end
|
||||
|
||||
self.steerVelocity = 0
|
||||
end
|
||||
@@ -90,13 +98,12 @@ function Wheel:createHolo(entity)
|
||||
|
||||
local holo = holograms.create(
|
||||
entity:getPos(),
|
||||
entity:getAngles() + Angle(0, self.offset, 0),
|
||||
entity:getAngles(),
|
||||
self.CONFIG.Model or ''
|
||||
)
|
||||
|
||||
holo:setParent(entity)
|
||||
|
||||
-- holo:setColor(Color(255,255,255,110))
|
||||
entity:setColor(Color(0,0,0,0))
|
||||
|
||||
return holo
|
||||
@@ -121,9 +128,9 @@ function Wheel:forwardStep(torque, inertia)
|
||||
return 0
|
||||
end
|
||||
|
||||
-- self.customWheel.steerAngle = self.vehicle.steer * self.steerLock
|
||||
--self.customWheel.inertia = inertia
|
||||
--self.customWheel:setInertia(inertia)
|
||||
-- print(inertia)
|
||||
-- self.customWheel:setInertia(inertia)
|
||||
|
||||
self.customWheel.motorTorque = torque
|
||||
self.customWheel.brakeTorque = math.max(self.brakePower * self.vehicle.brake, self.handbrakePower * self.vehicle.handbrake)
|
||||
|
||||
@@ -131,8 +138,6 @@ function Wheel:forwardStep(torque, inertia)
|
||||
|
||||
self.angularVelocity = self.customWheel.angularVelocity
|
||||
|
||||
self.debugHolo1:setPos(self.entity:localToWorld(Vector(0, 0, -self.entity:getModelRadius())))
|
||||
|
||||
if self.customWheel.hasHit and isValid(self.vehicle.basePhysObject) then
|
||||
local surfaceForceVector = self.customWheel.right * self.customWheel.sideFriction.force + self.customWheel.forward * self.customWheel.forwardFriction.force
|
||||
|
||||
@@ -140,30 +145,21 @@ function Wheel:forwardStep(torque, inertia)
|
||||
end
|
||||
|
||||
if isValid(self.holo) then
|
||||
if DEBUG then
|
||||
self.debugHoloF:setAngles(self.customWheel.forward:getAngle())
|
||||
self.debugHoloR:setAngles(self.customWheel.right:getAngle())
|
||||
self.debugHoloU:setAngles(self.customWheel.up:getAngle())
|
||||
end
|
||||
|
||||
local spinAxis = self.customWheel.up:cross(self.customWheel.forward):getNormalized()
|
||||
local entityAngles = self.entity:getAngles()
|
||||
|
||||
self.debugHolo2:setPos(self.entity:localToWorld(self.customWheel.up * math.sin(timer.curtime()) * 20))
|
||||
self.rot = self.rot + self.angularVelocity * TICK_INTERVAL
|
||||
|
||||
local rotatedForwardAngle = self.customWheel.forward:getAngle() + Angle(0, 90, 0)
|
||||
local steerRotated = entityAngles:rotateAroundAxis(self.customWheel.up, nil, math.rad(-self.customWheel.steerAngle) + self.customWheel.toeAngle)
|
||||
local camberRotated = steerRotated:rotateAroundAxis(self.customWheel.forward, nil, -self.customWheel.camberAngle)
|
||||
local angularVelocityRotated = camberRotated:rotateAroundAxis(self.customWheel.right, nil, self.rot)
|
||||
|
||||
|
||||
-- self.holo:setAngles(rotatedForwardAngle)
|
||||
|
||||
|
||||
-- local ang = up:getAngle()
|
||||
-- self.holo:setAngles(self.customWheel.forward:getAngle())
|
||||
|
||||
-- self.holo:setAngles(self.holo:getAngles():rotateAroundAxis(self.customWheel.right, 0))
|
||||
-- self.holo:setAngles(self.holo:getAngles():rotateAroundAxis(self.customWheel.right, nil, self.angularVelocity * TICK_INTERVAL))
|
||||
|
||||
|
||||
self.holo:setAngles(self.holo:getAngles():rotateAroundAxis(self.customWheel.right, nil, self.angularVelocity * TICK_INTERVAL))
|
||||
|
||||
-- local steerAngle = self.entity:localToWorldAngles(Angle(0, self.offset - self.customWheel.steerAngle, 0) + self.rotationAxle * self.rot)
|
||||
-- local angle = steerAngle
|
||||
|
||||
-- self.holo:setAngles(angle)
|
||||
self.holo:setAngles(angularVelocityRotated)
|
||||
end
|
||||
|
||||
return self.customWheel.counterTorque
|
||||
|
||||
Reference in New Issue
Block a user