onCameraPreRender
Definition
-- @/lua/ge/extensions/freeroam/bigMapMode.lua:993
local function onCameraPreRender(camData)
if not bigMapActive() then return end
profilerPushEvent("bigmap onCameraPreRender")
if not transitionActive then
local iconRenderer = scenetree.findObjectById(iconRendererId)
if iconRenderer then
local iconInfo = iconRenderer:getIconByName("controllerCrosshair")
if iconInfo then
local camDir = camData.res.rot * yVector
iconInfo.worldPosition = camData.res.pos + camDir * 150
if mouseMoved or uiHasFocus then
iconInfo.color = invisibleColor
else
iconInfo.color = pureWhite
end
end
local iconInfo = iconRenderer:getIconByName("navigationMarker")
if iconInfo then
if showNavigationMarker and core_groundMarkers.currentlyHasTarget() then
local resolutionFactor = 800 / M.getVerticalResolution()
local camQuat = camData.res.rot
local camUp = camQuat * upVector
local camToCluster = core_groundMarkers.endWP[1] - camData.res.pos
local camToClusterLeft = camUp:cross(camToCluster):normalized()
local camToUpperPoint = quatFromAxisAngle(camToClusterLeft, (resolutionFactor * 0.015 * core_camera.getFovRad())):__mul(camToCluster)
iconInfo.worldPosition = camData.res.pos + camToUpperPoint
iconInfo.color = pureWhite
else
iconInfo.color = invisibleColor
end
end
end
else
-- Snap the camera to a straight line in part of the path to make it more stable
if camPath then
if transitionActive == 1 then
if transitionTime < camPath.markers[3].time then
local lineP1P3 = camPath.markers[3].pos - camPath.markers[1].pos
local camVec = camData.res.pos - camPath.markers[1].pos
local dotProduct = lineP1P3:dot(camVec)
camData.res.pos = camPath.markers[1].pos + (lineP1P3:normalized() * (dotProduct / lineP1P3:length()))
end
elseif transitionActive == 2 then
if transitionTime > camPath.markers[2].time then
local lineP2P4 = camPath.markers[4].pos - camPath.markers[2].pos
local camVec = camData.res.pos - camPath.markers[2].pos
local dotProduct = lineP2P4:dot(camVec)
camData.res.pos = camPath.markers[2].pos + (lineP2P4:normalized() * (dotProduct / lineP2P4:length()))
end
end
end
end
-- Calculate the alpha based on the type and progress of transition
local alphaGoal
if transitionActive == 1 then
alphaGoal = (transitionProgress > 0.5) and 1 or 0
elseif transitionActive == 2 then
alphaGoal = 0
else
alphaGoal = 1
end
local navRouteAlpha = groundMarkerAlphaSmoother:getWithRateUncapped(alphaGoal, camData.dtReal, 0.85)
local simplifiedPathLength = simplifiedPath and tableSize(simplifiedPath)
if simplifiedPathLength and simplifiedPathLength > 1 then
local lineWidth = (camHeightAboveTerrain * camData.res.fov) / 20000
local h, s, v = RGBtoHSV(unpack(core_groundMarkers.color)) -- groundMarkerColor
local r, g, b = HSVtoRGB(h, s, 1)
local color = ColorF(r, g, b, navRouteAlpha)
for index = 1, routeAnimCounter do
local pos1 = simplifiedPath[index]
local pos2 = simplifiedPath[index+1]
local b = camData.res.pos * 0.8
local newPos1 = pos1 * 0.2; newPos1:setAdd(b)
local newPos2 = pos2 * 0.2; newPos2:setAdd(b)
debugDrawer:drawCylinder(newPos1, newPos2, lineWidth/2, color)
end
-- speed up the animation for short paths
local routeLengthMultiplier = 1
if simplifiedPathDistance < 500 then
routeLengthMultiplier = 2
end
local animCounterStep = (camData.dtReal) * simplifiedPathLength * routeLengthMultiplier * routeAnimSpeedFactor
routeAnimCounter = math.min(simplifiedPathLength - 1, routeAnimCounter + animCounterStep)
end
-- display mission route preview
if routePreview and #routePreview > 1 then
local lineWidth = (camHeightAboveTerrain * camData.res.fov) / 20000
local h, s, v = RGBtoHSV(unpack(core_groundMarkers.color or {0.1, 0.25, 0.5})) -- groundMarkerColor
local r, g, b = HSVtoRGB(h, 0.3, 1) -- routePreviewCol
local color = ColorF(r, g, b, navRouteAlpha * 0.7)
for index = 1, #routePreview-1 do
local pos1 = routePreview[index]
local pos2 = routePreview[index+1]
local b = camData.res.pos * 0.85
local newPos1 = pos1 * 0.15; newPos1:setAdd(b)
local newPos2 = pos2 * 0.15; newPos2:setAdd(b)
debugDrawer:drawCylinder(newPos1, newPos2, lineWidth/6, color)
end
end
profilerPopEvent("bigmap onCameraPreRender")
end
Callers