vec3
Definition
-- @/lua/common/mathlib.lua:49
function vec3(x, y, z)
if rawequal(y, nil) then
if rawequal(x, nil) then
return newLuaVec3xyz(0, 0, 0)
else
if rawequal(x.xyz, nil) then
return newLuaVec3xyz(x.x or x[1], x.y or x[2], x.z or x[3])
else
return newLuaVec3xyz(x:xyz())
end
end
else
return newLuaVec3xyz(x, y, z or 0)
end
end
Callers
@/lua/ge/extensions/freeroam/dragRace.lua
local nodePos = vehicle:getNodePosition(axisNodes[1])
local wheelNodePos = vehicle:getPosition() + vec3(nodePos.x, nodePos.y, nodePos.z)
--local wheelNodePosToTrigger = vec3(wheelNodePos - trigger:getPosition())
local wheelNodePos = vehicle:getPosition() + vec3(nodePos.x, nodePos.y, nodePos.z)
--local wheelNodePosToTrigger = vec3(wheelNodePos - trigger:getPosition())
-- We need actual distance from starting line and not the center
-- We need actual distance from starting line and not the center
local dot = vec3(nodePos.x, nodePos.y, nodePos.z):dot(vehicle:getDirectionVector():normalized())
maxFwd = math.max(dot, maxFwd)
local centerPoint = vehicle:getPosition() + maxFwd * vehicle:getDirectionVector():normalized()
local centerPointToTrigger = vec3(centerPoint - trigger:getPosition())
centerPointToTrigger.z = 0
@/lua/ge/extensions/editor/dragRaceEditor/strips.lua
if im.Button("Focus Camera") then
local pos = vec3(selectedWaypoint.transform.position.x, selectedWaypoint.transform.position.y, selectedWaypoint.transform.position.z)
editor.fitViewToSelectionSmooth(pos)
if im.Button("Focus Camera") then
local pos = vec3(lane.boundary.transform.position.x, lane.boundary.transform.position.y, lane.boundary.transform.position.z)
editor.fitViewToSelectionSmooth(pos)
-- Draw strip preview
debugDrawer:drawTextAdvanced(vec3(0, 0, 0), String("Strip: " .. strip.name), constants.CONSTANTS.COLORS.WHITE, true, false, constants.CONSTANTS.COLORS.BLACK)
local pos = vec3(waypoint.transform.position.x, waypoint.transform.position.y, waypoint.transform.position.z)
local rot = quat(waypoint.transform.rotation.x, waypoint.transform.rotation.y, waypoint.transform.rotation.z, waypoint.transform.rotation.w)
local pos = vec3(boundary.transform.position.x, boundary.transform.position.y, boundary.transform.position.z)
local rot = quat(boundary.transform.rotation.x, boundary.transform.rotation.y, boundary.transform.rotation.z, boundary.transform.rotation.w)
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
local newPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
waypoint.transform.position = {x = newPos.x, y = newPos.y, z = newPos.z}
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local sclVec = vec3(worldEditorCppApi.getAxisGizmoScale())
waypoint.transform.scale = {x = sclVec.x, y = sclVec.y, z = sclVec.z}
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
local newPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
boundary.transform.position = {x = newPos.x, y = newPos.y, z = newPos.z}
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local sclVec = vec3(worldEditorCppApi.getAxisGizmoScale())
boundary.transform.scale = {x = sclVec.x, y = sclVec.y, z = sclVec.z}
for i, waypoint in ipairs(lane.waypoints) do
local pos = vec3(waypoint.transform.position.x, waypoint.transform.position.y, waypoint.transform.position.z)
local isSelected = i == selectedWaypointIndex
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
if lane.boundary then
local pos = vec3(lane.boundary.transform.position.x, lane.boundary.transform.position.y, lane.boundary.transform.position.z)
local rot = quat(lane.boundary.transform.rotation.x, lane.boundary.transform.rotation.y, lane.boundary.transform.rotation.z, lane.boundary.transform.rotation.w)
local rot = quat(lane.boundary.transform.rotation.x, lane.boundary.transform.rotation.y, lane.boundary.transform.rotation.z, lane.boundary.transform.rotation.w)
local scl = vec3(lane.boundary.transform.scale.x, lane.boundary.transform.scale.y, lane.boundary.transform.scale.z)
local isSelected = selectedBoundaryIndex == i
-- Calculate box axes from rotation and scale
local x = rot * vec3(scl.x, 0, 0)
local y = rot * vec3(0, scl.y, 0)
local x = rot * vec3(scl.x, 0, 0)
local y = rot * vec3(0, scl.y, 0)
local z = rot * vec3(0, 0, scl.z)
local y = rot * vec3(0, scl.y, 0)
local z = rot * vec3(0, 0, scl.z)
local sclSum = (x + y + z)
@/lua/ge/extensions/gameplay/rally/recce/drivelineRecording.lua
return PointList():createPoint(
vec3(obj.pos),
quat(obj.quat),
@/lua/vehicle/extensions/straightLine.lua
end
targetPosOffset = vec3(0, 1, 0)
print("Targetpos: " .. dumps(baseTargetPos))
local myPos = obj:getPosition()
local targetPos = baseTargetPos + vec3((myPos.x - 20) * targetPosOffset.x, (myPos.y - 20) * targetPosOffset.y, (myPos.z - 20) * targetPosOffset.z)
local distanceVector = targetPos - myPos
@/lua/ge/extensions/flowgraph/nodes/scene/spawnTSStatic.lua
local pos = self.pinIn.position.value or {0,0,0}
pos = vec3(pos[1],pos[2],pos[3])
object:setPosition(pos)
local scl = self.pinIn.scale.value or {1,1,1}
scl = vec3(scl[1],scl[2],scl[3])
object:setScale(scl)
local off = self.pinIn.offset.value or {10,0,0}
off = vec3(off)
pos = self.pinIn.position.value or {0,0,0}
pos = vec3(pos)
pos = pos + off
pos = vec3(pos[1],pos[2],pos[3])
object:setPosition(pos)
@/lua/ge/extensions/editor/missionEditor.lua
-- teleport vehicle
spawn.safeTeleport(playerVehicle,vec3(shownMission.startTrigger.pos), quat(shownMission.startTrigger.rot))
local cameraPosition = core_camera.getPosition()
local position = core_camera.getQuat() * vec3(0, 15, 0)
local beforeCam = position + cameraPosition
@/lua/ge/extensions/editor/barriersEditor.lua
local objects = {}
local center = vec3()
for i = 0, scenetreeObject:size() - 1 do
obj = Sim.upcast(obj)
local pos = vec3(obj:getPosition())
pos = pos + quat(obj:getRotation())*vec3(0,0,0.5)
local pos = vec3(obj:getPosition())
pos = pos + quat(obj:getRotation())*vec3(0,0,0.5)
table.insert(objects,pos)
local camPos = core_camera.getPosition()
local rayDir = vec3(getCameraMouseRay().dir):normalized()
local minNodeDist = math.huge
@/lua/ge/extensions/flowgraph/nodes/scene/raceLineParking.lua
local scale = 35
local centerOffset = vec3(140,20)
local tlCenter = im.ImVec2(0,0)
local rot = quat(self.pinIn.rotation.value)
local xn, yn = rot * vec3(1,0,0), rot * vec3(0,-1,0)
--
local rot = quat(self.pinIn.rotation.value)
local xn, yn = rot * vec3(1,0,0), rot * vec3(0,-1,0)
--
--
local diff = pos - vec3(self.pinIn.position.value)
return vec3(diff:dot(xn)*scale+centerOffset.x+tlCenter.x, diff:dot(yn)*scale + centerOffset.y+tlCenter.y, 0)
local diff = pos - vec3(self.pinIn.position.value)
return vec3(diff:dot(xn)*scale+centerOffset.x+tlCenter.x, diff:dot(yn)*scale + centerOffset.y+tlCenter.y, 0)
end
-- draw U-shape
local x, y = rot * vec3(self.pinIn.scale.value[1],0,0), rot * vec3(0,self.pinIn.scale.value[2],0)
local pos = vec3(self.pinIn.position.value)
-- draw U-shape
local x, y = rot * vec3(self.pinIn.scale.value[1],0,0), rot * vec3(0,self.pinIn.scale.value[2],0)
local pos = vec3(self.pinIn.position.value)
local x, y = rot * vec3(self.pinIn.scale.value[1],0,0), rot * vec3(0,self.pinIn.scale.value[2],0)
local pos = vec3(self.pinIn.position.value)
local clr
local ob = veh:getSpawnWorldOOBB()
local vPos = vec3(map.objects[veh:getId()].pos)
--self:drawLine(self:worldLineToMapLine({vPos, pos + vec3(0,10,0)}))
local vPos = vec3(map.objects[veh:getId()].pos)
--self:drawLine(self:worldLineToMapLine({vPos, pos + vec3(0,10,0)}))
self:drawLine(self:worldLineToMapLine({vec3(ob:getPoint(0)) , vec3(ob:getPoint(3)) , vec3(ob:getPoint(7)) , vec3(ob:getPoint(4)), vec3(ob:getPoint(0))}), nil, 2)
--self:drawLine(self:worldLineToMapLine({vPos, pos + vec3(0,10,0)}))
self:drawLine(self:worldLineToMapLine({vec3(ob:getPoint(0)) , vec3(ob:getPoint(3)) , vec3(ob:getPoint(7)) , vec3(ob:getPoint(4)), vec3(ob:getPoint(0))}), nil, 2)
local wCenter, w1, w2 = self:getVehicleFrontwheelsCenterPosition(veh, vec3())
--self:drawLine(self:worldLineToMapLine({vPos, pos + vec3(0,10,0)}))
self:drawLine(self:worldLineToMapLine({vec3(ob:getPoint(0)) , vec3(ob:getPoint(3)) , vec3(ob:getPoint(7)) , vec3(ob:getPoint(4)), vec3(ob:getPoint(0))}), nil, 2)
local wCenter, w1, w2 = self:getVehicleFrontwheelsCenterPosition(veh, vec3())
--self:drawLine(self:worldLineToMapLine({vPos, pos + vec3(0,10,0)}))
self:drawLine(self:worldLineToMapLine({vec3(ob:getPoint(0)) , vec3(ob:getPoint(3)) , vec3(ob:getPoint(7)) , vec3(ob:getPoint(4)), vec3(ob:getPoint(0))}), nil, 2)
local wCenter, w1, w2 = self:getVehicleFrontwheelsCenterPosition(veh, vec3())
--self:drawLine(self:worldLineToMapLine({vPos, pos + vec3(0,10,0)}))
self:drawLine(self:worldLineToMapLine({vec3(ob:getPoint(0)) , vec3(ob:getPoint(3)) , vec3(ob:getPoint(7)) , vec3(ob:getPoint(4)), vec3(ob:getPoint(0))}), nil, 2)
local wCenter, w1, w2 = self:getVehicleFrontwheelsCenterPosition(veh, vec3())
--self:drawLine(self:worldLineToMapLine({vPos, pos + vec3(0,10,0)}))
self:drawLine(self:worldLineToMapLine({vec3(ob:getPoint(0)) , vec3(ob:getPoint(3)) , vec3(ob:getPoint(7)) , vec3(ob:getPoint(4)), vec3(ob:getPoint(0))}), nil, 2)
local wCenter, w1, w2 = self:getVehicleFrontwheelsCenterPosition(veh, vec3())
self:drawLine(self:worldLineToMapLine({vec3(ob:getPoint(0)) , vec3(ob:getPoint(3)) , vec3(ob:getPoint(7)) , vec3(ob:getPoint(4)), vec3(ob:getPoint(0))}), nil, 2)
local wCenter, w1, w2 = self:getVehicleFrontwheelsCenterPosition(veh, vec3())
self:drawLine(self:worldLineToMapLine({w1,w2}), nil, 3)
for i = 0, 24 do
local off = quatFromEuler(0,0,math.pi*i/12) * vec3(rad, 0,0)
table.insert(list,vec3(140,150)+vec3(tlCenter.x, tlCenter.y)+off)
local off = quatFromEuler(0,0,math.pi*i/12) * vec3(rad, 0,0)
table.insert(list,vec3(140,150)+vec3(tlCenter.x, tlCenter.y)+off)
end
local off = quatFromEuler(0,0,math.pi*i/12) * vec3(rad, 0,0)
table.insert(list,vec3(140,150)+vec3(tlCenter.x, tlCenter.y)+off)
end
tr = quat(tr[1],tr[2],tr[3],tr[4])
local yVec = tr*vec3(0,1,0)
local tpos = vec3(self.pinIn.position.value or {0,0,0})
local yVec = tr*vec3(0,1,0)
local tpos = vec3(self.pinIn.position.value or {0,0,0})
local fwd = veh:getDirectionVector():normalized()
local zVec,yVec,xVec = tr*vec3(0,0,1), tr*vec3(0,1,0), tr*vec3(1,0,0)
local fwdAligned = fwd:projectToOriginPlane(zVec):normalized()
local fwd = veh:getDirectionVector():normalized()
local zVec,yVec,xVec = tr*vec3(0,0,1), tr*vec3(0,1,0), tr*vec3(1,0,0)
local fwdAligned = fwd:projectToOriginPlane(zVec):normalized()
local fwd = veh:getDirectionVector():normalized()
local zVec,yVec,xVec = tr*vec3(0,0,1), tr*vec3(0,1,0), tr*vec3(1,0,0)
local fwdAligned = fwd:projectToOriginPlane(zVec):normalized()
local forward = map.objects[vehicle:getID()].dirVec
forward = vec3(forward.x, forward.y, forward.z)
-- We need to identify all vehicle wheels and then calculate the distance from the start line for each wheel
local nodePos = vehicle:getNodePosition(axisNodes[1])
nodePos = vec3(nodePos.x, nodePos.y, nodePos.z)
table.insert(wheels,{wheelNodePos = vehicle:getPosition() + nodePos, distance = -nodePos:dot(forward)})
-- Point inbetween both wheels is calculated so that we can get a somewhat accurate distance measurement
return vec3((wheel1.x + wheel2.x)/2, (wheel1.y + wheel2.y)/2, (wheel1.z + wheel2.z)/2), vec3(wheel1), vec3(wheel2)
end
-- Point inbetween both wheels is calculated so that we can get a somewhat accurate distance measurement
return vec3((wheel1.x + wheel2.x)/2, (wheel1.y + wheel2.y)/2, (wheel1.z + wheel2.z)/2), vec3(wheel1), vec3(wheel2)
end
-- Point inbetween both wheels is calculated so that we can get a somewhat accurate distance measurement
return vec3((wheel1.x + wheel2.x)/2, (wheel1.y + wheel2.y)/2, (wheel1.z + wheel2.z)/2), vec3(wheel1), vec3(wheel2)
end
local rot = quat(self.pinIn.rotation.value)
local x, y, z = rot * vec3(self.pinIn.scale.value[1],0,0), rot * vec3(0,self.pinIn.scale.value[2],0), rot * vec3(0,0,1)
local pos = vec3(self.pinIn.position.value)
local rot = quat(self.pinIn.rotation.value)
local x, y, z = rot * vec3(self.pinIn.scale.value[1],0,0), rot * vec3(0,self.pinIn.scale.value[2],0), rot * vec3(0,0,1)
local pos = vec3(self.pinIn.position.value)
local rot = quat(self.pinIn.rotation.value)
local x, y, z = rot * vec3(self.pinIn.scale.value[1],0,0), rot * vec3(0,self.pinIn.scale.value[2],0), rot * vec3(0,0,1)
local pos = vec3(self.pinIn.position.value)
local x, y, z = rot * vec3(self.pinIn.scale.value[1],0,0), rot * vec3(0,self.pinIn.scale.value[2],0), rot * vec3(0,0,1)
local pos = vec3(self.pinIn.position.value)
debugDrawer:drawTriSolid(
vec3(pos + x + z),
vec3(pos + x ),
vec3(pos + x + z),
vec3(pos + x ),
vec3(pos - x ),
vec3(pos + x ),
vec3(pos - x ),
color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255))
debugDrawer:drawTriSolid(
vec3(pos - x ),
vec3(pos - x + z),
vec3(pos - x ),
vec3(pos - x + z),
vec3(pos + x + z),
vec3(pos - x + z),
vec3(pos + x + z),
color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255))
debugDrawer:drawTriSolid(
vec3(pos + x + z),
vec3(pos - x ),
vec3(pos + x + z),
vec3(pos - x ),
vec3(pos + x ),
vec3(pos - x ),
vec3(pos + x ),
color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255))
debugDrawer:drawTriSolid(
vec3(pos - x ),
vec3(pos + x + z),
vec3(pos - x ),
vec3(pos + x + z),
vec3(pos - x + z),
vec3(pos + x + z),
vec3(pos - x + z),
color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255))
debugDrawer:drawTriSolid(
vec3(pos - x + z),
vec3(pos - x - y),
vec3(pos - x + z),
vec3(pos - x - y),
vec3(pos - x ),
vec3(pos - x - y),
vec3(pos - x ),
color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255))
debugDrawer:drawTriSolid(
vec3(pos - x + z),
vec3(pos - x ),
vec3(pos - x + z),
vec3(pos - x ),
vec3(pos - x - y),
vec3(pos - x ),
vec3(pos - x - y),
color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255))
debugDrawer:drawTriSolid(
vec3(pos + x + z),
vec3(pos + x - y),
vec3(pos + x + z),
vec3(pos + x - y),
vec3(pos + x ),
vec3(pos + x - y),
vec3(pos + x ),
color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255))
debugDrawer:drawTriSolid(
vec3(pos + x + z),
vec3(pos + x ),
vec3(pos + x + z),
vec3(pos + x ),
vec3(pos + x - y),
vec3(pos + x ),
vec3(pos + x - y),
color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255))
@/lua/ge/extensions/editor/sitesEditor/zones.lua
local centroid = vec3(0, 0, 0)
for _, vertex in ipairs(self.currentVertices) do
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
local q = quatFromDir(quatFromEuler(0, math.pi / 2, 0) * self.currentPlane.normal, vec3(0, 0, 1))
rotation = QuatF(q.x, q.y, q.z, q.w)
function C:beginDrag()
self._prevGizmoPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
if self.currentPlane then
self.beginDragRotation = deepcopy(quatFromDir(quatFromEuler(0, math.pi / 2, 0) * self.currentPlane.normal, vec3(0, 0, 1)))
end
-- update/save our gizmo matrix
local posOffset = (vec3(editor.getAxisGizmoTransform():getColumn(3)) - self._prevGizmoPos) / 2
end
debugDrawer:drawLine((vertex.pos + posOffset + vec3(0, 0, -1000)), (vertex.pos + posOffset + vec3(0, 0, 1000)), ColorF(0, 0, 1, 1))
end
end
debugDrawer:drawLine((vertex.pos + posOffset + vec3(0, 0, -1000)), (vertex.pos + posOffset + vec3(0, 0, 1000)), ColorF(0, 0, 1, 1))
end
if self.currentPlane then
self.currentPlane.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
end
if tableSize(self.currentVertices) > 1 then
local centroid = vec3(0, 0, 0)
for _, vertex in ipairs(self.currentVertices) do
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
self.currentPlane.normal = quat(rotation) * vec3(0, 0, 1)
else
else
self.currentPlane.normal = self.beginDragRotation * quat(rotation) * vec3(0, 0, 1)
end
self._prevGizmoPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
end
function C:dropToTerrain(pos)
local p = vec3(pos)
if core_terrain then
end
zone:drawFence((pos), pos + vec3(1000, 0, 0), ColorI(255, 128, 128, 128))
local prof = hptimer()
@/lua/common/tech/pcdLib.lua
self.viewpoint = '0 0 0 1 0 0 0' -- pos.x pos.y pos.z rot.w rot.x rot.y rot.z
self.pos = vec3(0, 0, 0)
self.rotQuat = quat(0, 0, 0, 1)
@/lua/ge/extensions/editor/tech/roadArchitect/staticMeshMgr.lua
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local camRotAngle = 0.0
@/lua/vehicle/powertrain/shaft.lua
local wheel = powertrain.wheels[device.connectedWheel]
local hubNode1 = vec3(v.data.nodes[wheel.node1].pos)
local hubNode2 = vec3(v.data.nodes[wheel.node2].pos)
local hubNode1 = vec3(v.data.nodes[wheel.node1].pos)
local hubNode2 = vec3(v.data.nodes[wheel.node2].pos)
local n = v.data.nodes[nid]
local distanceToAxis = vec3(n.pos):distanceToLine(hubNode1, hubNode2)
axisInertia = axisInertia + (n.nodeWeight * (distanceToAxis * distanceToAxis))
@/lua/ge/extensions/flowgraph/nodes/scene/camera/procedural/procDirectPath.lua
-- some helper values.
local fwd = vec3(self.pinIn.to.value) - vec3(self.pinIn.from.value)
fwd.z = 0
-- some helper values.
local fwd = vec3(self.pinIn.to.value) - vec3(self.pinIn.from.value)
fwd.z = 0
local fq = quatFromEuler(math.pi / 4, 0, 0) * quatFromDir(fwd)
local d = fq * vec3(0, -12, 0)
local from = deepcopy(m)
from.pos = vec3(deepcopy(self.pinIn.from.value)) + d
from.rot = fq
local from2 = deepcopy(m)
from2.pos = vec3(deepcopy(self.pinIn.from.value)) + d * 1.25
from2.rot = fq
local mid = deepcopy(m)
mid.pos = (vec3(self.pinIn.from.value)) + vec3(0, 0, 180) + d * 3
local mid = deepcopy(m)
mid.pos = (vec3(self.pinIn.from.value)) + vec3(0, 0, 180) + d * 3
-- some helper vectors to get the correct rotation
local tt = (vec3(deepcopy(self.pinIn.to.value)) - mid.pos):normalized()
local tx = tt:cross(vec3(0, 0, 1))
local tt = (vec3(deepcopy(self.pinIn.to.value)) - mid.pos):normalized()
local tx = tt:cross(vec3(0, 0, 1))
local tu = tx:cross(tt)
local back = deepcopy(m)
back.pos = vec3(deepcopy(self.pinIn.from.value)) + d * 5 + vec3(0, 0, 90)
back.rot = fq
local back = deepcopy(m)
back.pos = vec3(deepcopy(self.pinIn.from.value)) + d * 5 + vec3(0, 0, 90)
back.rot = fq
local back2 = deepcopy(m)
back2.pos = vec3(deepcopy(self.pinIn.from.value)) + d
back2.rot = fq
@/lua/ge/extensions/flowgraph/nodes/gameplay/rally/rallyDebugNode.lua
local pinPos = vec3(self.pinIn.pos.value)
-- dump(pinPos)
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veView.lua
local vecUp = vec3(0, 0, 1)
ortho = im.BoolPtr(data.ortho or false),
dragOffset = data.dragOffset or vec3(0,0,0),
--control = ImguiRenderViewControl.getOrCreate(wndName),
local function _drawgrid(size, rot, gridOrigin, width)
local p1 = vec3(0,0,-size)
local p2 = vec3(0,0,size)
local p1 = vec3(0,0,-size)
local p2 = vec3(0,0,size)
local col = ColorF(0.3,0.3,0.3,1)
local delta = vec3(0, 0, 0)
local gridSize = 5 -- meters
if view.mode == 'left' then
view.rot = quatFromDir(vec3(-1,0,0), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(0, -delta.x, delta.y)
end
end
view.dragOffset = view.dragOffset + vec3(delta.z, 0, 0)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(10, 0, 0)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'right' then
view.rot = quatFromDir(vec3(1,0,0), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(0, delta.x, delta.y)
end
end
view.dragOffset = view.dragOffset + vec3(delta.z, 0, 0)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(-3, 0, 0)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'front' then
view.rot = quatFromDir(vec3(0,1,0), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(-delta.x, 0, delta.y)
end
end
view.dragOffset = view.dragOffset + vec3(0, delta.z, 0)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(0, -3, 0)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'back' then
view.rot = quatFromDir(vec3(0,-1,0), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(delta.x, 0, delta.y)
end
end
view.dragOffset = view.dragOffset + vec3(0, delta.z, 0)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(0, 6, 0)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'top' then
view.rot = quatFromDir(vec3(0,0,-1), vec3(1,0,0))
if view.mouseDragging0 and view.lastMouseDragPos then
elseif view.mode == 'top' then
view.rot = quatFromDir(vec3(0,0,-1), vec3(1,0,0))
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(delta.x, -delta.y, 0)
end
end
view.dragOffset = view.dragOffset + vec3(0, 0, delta.z)
if focusObj then
local fwd = focusObj:getDirectionVector()
view.pos = focusPos + focusRot * vec3(0, 0, 5)
view.rot = quatFromDir(vec3(0,0,-1), fwd)
view.pos = focusPos + focusRot * vec3(0, 0, 5)
view.rot = quatFromDir(vec3(0,0,-1), fwd)
--view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'bottom' then
view.rot = quatFromDir(vec3(0,0,1), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(delta.x, delta.y, 0)
end
end
view.dragOffset = view.dragOffset + vec3(0, 0, delta.z)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(0.01, 0.01, -5)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
local txt = dumps{'type: ', view.mode, 'view.pos: ', view.pos}
debugDrawer:drawTextAdvanced((vec3(0,20,0)), "PLEASE DISABLE AMBIENT OCCLUSION", ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
debugDrawer:drawTextAdvanced((vec3(0,40,0)), txt, ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
debugDrawer:drawTextAdvanced((vec3(0,20,0)), "PLEASE DISABLE AMBIENT OCCLUSION", ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
debugDrawer:drawTextAdvanced((vec3(0,40,0)), txt, ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:clearTargetRenderViews()
view.mode = 'left'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'right'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'front'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'back'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'top'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'bottom'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
@/lua/ge/extensions/career/modules/delivery/precisionParking.lua
local targetRot = targetParkingSpot.rot
local targetDir = targetRot * vec3(0, 1, 0) -- Forward direction of target
local bbCenter = vehicleBB:getCenter()
local alignedOffset = (bbCenter - targetPos):projectToOriginPlane(vec3(0, 0, 1))
local xVec = targetRot * vec3(1, 0, 0) -- Right direction
local yVec = targetRot * vec3(0, 1, 0) -- Forward direction
local xVec = targetRot * vec3(1, 0, 0) -- Right direction
local yVec = targetRot * vec3(0, 1, 0) -- Forward direction
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veGeneralData.lua
local data = {}
data.heading = vec3(obj:getDirectionVector())
data.pos = vec3(obj:getPosition())
data.heading = vec3(obj:getDirectionVector())
data.pos = vec3(obj:getPosition())
data.vel = vec3(obj:getVelocity())
data.pos = vec3(obj:getPosition())
data.vel = vec3(obj:getVelocity())
data.rot = vec3(obj:getRotation())
data.vel = vec3(obj:getVelocity())
data.rot = vec3(obj:getRotation())
data.roll, data.pitch, data.yaw = obj:getRollPitchYaw()
@/lua/vehicle/main.lua
-- debug rendering
local focusPos = vec3(0, 0, 0)
function onDebugDraw(x, y, z)
@/lua/ge/extensions/core/vehicleActivePooling.lua
-- activates or deactivates vehicles with respect to their distance to the target position and max distance
local vehPos = vec3()
function VehPool:activateByDistanceTo(pos, dist)
@/lua/common/lpack.lua
elseif c == 252 then -- vec3
return vec3(bufDec:decode(), bufDec:decode(), bufDec:decode())
elseif c == 251 then -- quat
else
bufTmp:put("vec3(", v.x, ",", v.y, ",", v.z, ")")
end
z, c, seridx = peekDec[c](seridx)
return vec3(x, y, z), c, seridx
end
@/lua/vehicle/extensions/tech/platooning.lua
-- Local road data/other vehicle data.
local lastVelPlayer = vec3(0, 0) -- An initial (default) starting value for the player vehicle velocity.
local lastPos, lastVel = {}, {} -- Initialise tables to store the last-known position and velocity data, for all other vehicles in the simulator.
-- Player vehicle state.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0,0), vec3(0, 0) -- The player vehicle orthogonal frame.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0,0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0,0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local fwd, right = vec3(0,0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local vehLength = 0
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local vehLength = 0
local posB, velB, accB = obj:getObjectCenterPosition(k), vec3(0, 0, 0), vec3(0, 0, 0)
velB = v.vel
local posB, velB, accB = obj:getObjectCenterPosition(k), vec3(0, 0, 0), vec3(0, 0, 0)
velB = v.vel
@/lua/ge/extensions/flowgraph/nodes/scene/spawnPrefab.lua
function C:createObject()
local pos = vec3(0,0,0)
if self.pinIn.pos.value then
if self.pinIn.pos.value then
pos = vec3(self.pinIn.pos.value)
end
@/lua/ge/extensions/flowgraph/nodes/debug/debugText.lua
function C:work()
local pos = vec3(self.pinIn.pos.value)
local clr = ColorF(1,1,1,1)
@/lua/ge/extensions/core/multiSpawn.lua
local vecUp = vec3(0, 0, 1)
local vecY = vec3(0, 1, 0)
local vecUp = vec3(0, 0, 1)
local vecY = vec3(0, 1, 0)
local baseRot = (p2 - p1):normalized()
rot = vec3(baseRot)
@/lua/ge/extensions/flowgraph/modules/vehicleModule.lua
for _,d in pairs(off) do
table.insert(data.couplerOffset, {v = vec3(d), n = _, tag = tag})
data.couplerTags[tag] = true
@/lua/common/jbeam/sections/camera.lua
local camNodeID = jbeamUtils.addNodeWithOptions(vehicle, vec3(icam.x, icam.y, icam.z), NORMALTYPE, icam)
local refNode = vehicle.nodes[vehicle.refNodes[0].ref]
cr.pos = nPos - vec3(refNode.pos) -- calculate out the refnode
cr.pos.x = - cr.pos.x -- invert X and Y axis for some reason?!
cr.fov = icam.fov
cr.rot = vec3(0, 180, 0) -- look forward by default
table.insert(vehicle.cameras.relative, cr)
if vehicle.refNodes and vehicle.refNodes[0] and vehicle.refNodes[0].ref and vehicle.nodes[vehicle.refNodes[0].ref] then
local refNodePos = vec3(vehicle.nodes[vehicle.refNodes[0].ref].pos)
for _, cr in pairs(vehicle.cameras.relative) do
cr.pos = vec3(cr)
cr.x, cr.y, cr.z = nil, nil, nil
if cr.rot == nil then
cr.rot = vec3()
else
else
cr.rot = vec3(cr.rot)
end
-- rotation is 180 dg off? O_o
cr.rot = cr.rot + vec3(0, 180, 0)
end
@/lua/ge/extensions/ui/apps/minimap/topomap.lua
log("I", "", string.format("Test heights: origin=%.1f, (100,0)=%.1f, (0,100)=%.1f",
core_terrain.getTerrainHeight(vec3(0,0,0)) or 0,
core_terrain.getTerrainHeight(vec3(100,0,0)) or 0,
core_terrain.getTerrainHeight(vec3(0,0,0)) or 0,
core_terrain.getTerrainHeight(vec3(100,0,0)) or 0,
core_terrain.getTerrainHeight(vec3(0,100,0)) or 0))
core_terrain.getTerrainHeight(vec3(100,0,0)) or 0,
core_terrain.getTerrainHeight(vec3(0,100,0)) or 0))
-- Scan terrain height at each grid point
local scanPos = vec3()
local terrain = core_terrain.getTerrain()
local p1, p2 = vec3(), vec3()
M.drawContours = function(td, width, height, scale, camPos, worldToMapXYZ)
local p1, p2 = vec3(), vec3()
M.drawContours = function(td, width, height, scale, camPos, worldToMapXYZ)
for i in contourQt:queryNotNested(camPos.x-radius, camPos.y-radius, camPos.x+radius, camPos.y+radius) do
--local p1, p2 = vec3(), vec3()
--for i = 1, #contourSegments do
for i in contourQt:queryNotNested(camPos.x-radius, camPos.y-radius, camPos.x+radius, camPos.y+radius) do
--local p1, p2 = vec3(), vec3()
--for i = 1, #contourSegments do
@/lua/ge/extensions/flowgraph/nodes/debug/debugSphere.lua
end
debugDrawer:drawSphere(vec3(self.pinIn.pos.value), self.pinIn.radius.value or 0.25, color)
end
@/lua/vehicle/extensions/tech/wheelForces.lua
local wheelData = {}
local tmpVectorSum = vec3()
data.rimBeamsNode2 = {}
data.rimBeamsNode1VectorSum = vec3()
data.rimBeamsNode2VectorSum = vec3()
data.rimBeamsNode1VectorSum = vec3()
data.rimBeamsNode2VectorSum = vec3()
data.rimBeamsNode1SmootherX = newTemporalSmoothing(15, 15)
data.sidewallBeamsNode2 = {}
data.sidewallBeamsNode1VectorSum = vec3()
data.sidewallBeamsNode2VectorSum = vec3()
data.sidewallBeamsNode1VectorSum = vec3()
data.sidewallBeamsNode2VectorSum = vec3()
data.sidewallBeamsNode1SmootherX = newTemporalSmoothing(15, 15)
data.suspensionBeamsNode2 = {}
data.suspensionBeamsNode2VectorSum = vec3()
data.suspensionBeamsNode1VectorSum = vec3()
data.suspensionBeamsNode2VectorSum = vec3()
data.suspensionBeamsNode1VectorSum = vec3()
data.suspensionBeamsNode1SmootherX = newTemporalSmoothing(15, 15)
data.treadNodes = {}
data.treadNodesVectorSum = vec3()
data.treadNodesSmootherX = newTemporalSmoothing(15, 15)
@/lua/ge/extensions/editor/crawlEditor/waypoints.lua
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
local q = quatFromDir(node.normal, vec3(0,0,1))
rotation = QuatF(q.x, q.y, q.z, q.w)
if node.hasNormal and node.normal then
self.beginDragRotation = deepcopy(quatFromDir(node.normal, vec3(0,0,1)))
end
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
node.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Rotate then
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
local newNormal = quat(rotation)*vec3(0,1,0)
node:setNormal(newNormal)
else
local newNormal = self.beginDragRotation * quat(rotation)*vec3(0,1,0)
node:setNormal(newNormal)
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local sclVec = vec3(worldEditorCppApi.getAxisGizmoScale())
local scl = 1
local txt = "Add manual Pathnode (Click to place)"
debugDrawer:drawTextAdvanced(vec3(self.mouseInfo.rayCast.pos), String(txt), ColorF(1,1,1,1), true, false, ColorI(0,0,0,255))
if selectedPathnode then
debugDrawer:drawTextAdvanced(vec3(10, 10, 0), String("Selected Pathnode: " .. selectedPathnode.name .. " " .. selectedPathnode.id), ColorF(1, 1, 1, 1), false, false, ColorI(0, 0, 0, 255))
else
else
debugDrawer:drawTextAdvanced(vec3(10, 10, 0), String("No pathnode selected"), ColorF(1, 1, 1, 1), false, false, ColorI(0, 0, 0, 255))
end
editor.history:commitAction("Change Pathnode Position",
{index = index, old = pathnode.pos, new = vec3(pathnodePosition[0], pathnodePosition[1], pathnodePosition[2]), field = 'pos', self = self},
setFieldUndo, setFieldRedo)
editor.history:commitAction("Drop Pathnode to Ground",
{index = index, old = pathnode.pos, self = self, new = vec3(pathnodePosition[0], pathnodePosition[1], core_terrain.getTerrainHeight(pathnode.pos)), field = 'pos'},
setFieldUndo, setFieldRedo)
local tbl = {self.fields[name][0],self.fields[name][1],self.fields[name][2]}
fields.values[name] = vec3(tbl)
end
@/lua/ge/extensions/career/modules/vehicleDeletionService.lua
local vehPos = vec3()
local camPos = vec3()
local vehPos = vec3()
local camPos = vec3()
local camDir = vec3()
local camPos = vec3()
local camDir = vec3()
local function onUpdate()
@/lua/common/json-ast.lua
if type(node.posX) == 'number' and type(node.posY) == 'number' and type(node.posZ) == 'number' then
node.pos = vec3(node.posX, node.posY, node.posZ)
node.posX = nil
@/lua/ge/extensions/gameplay/statisticModules/watchJturn.lua
local triggered = false
local vdir = vec3(0,0,0)
local backingdir = vec3(0,0,0)
local vdir = vec3(0,0,0)
local backingdir = vec3(0,0,0)
local velocity = vec3(0,0,0)
local backingdir = vec3(0,0,0)
local velocity = vec3(0,0,0)
-- local vpos = vec3(0,0,0) --debug
local velocity = vec3(0,0,0)
-- local vpos = vec3(0,0,0) --debug
local lastBack = 0
@/lua/ge/extensions/career/modules/inventory.lua
local xVec, yVec, zVec = vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)
local xVec, yVec, zVec = vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)
local xVec, yVec, zVec = vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)
local resolution = vec3(500, 281, 0)
local fov = 50
-- default placement is in front of the dealership, facing it
spawn.safeTeleport(getPlayerVehicle(0), vec3(838.51,-522.42,165.75))
gameplay_walk.setRot(vec3(-1,-1,0), vec3(0,0,1))
spawn.safeTeleport(getPlayerVehicle(0), vec3(838.51,-522.42,165.75))
gameplay_walk.setRot(vec3(-1,-1,0), vec3(0,0,1))
else
spawn.safeTeleport(getPlayerVehicle(0), vec3(838.51,-522.42,165.75))
gameplay_walk.setRot(vec3(-1,-1,0), vec3(0,0,1))
else
local model, config = "covet","vehicles/covet/covet_tutorial.pc"
local pos, rot = vec3(-24.026,609.157,75.112), quatFromDir(vec3(1,0,0))
local options = {config = config, licenseText = "TUTORIAL", vehicleName = "TutorialVehicle", pos = pos, rot = rot}
local model, config = "covet","vehicles/covet/covet_tutorial.pc"
local pos, rot = vec3(-24.026,609.157,75.112), quatFromDir(vec3(1,0,0))
local options = {config = config, licenseText = "TUTORIAL", vehicleName = "TutorialVehicle", pos = pos, rot = rot}
-- move walking character into position
spawn.safeTeleport(getPlayerVehicle(0), vec3(-20.746, 598.736, 75.112))
gameplay_walk.setRot(vec3(0,1,0), vec3(0,0,1))
spawn.safeTeleport(getPlayerVehicle(0), vec3(-20.746, 598.736, 75.112))
gameplay_walk.setRot(vec3(0,1,0), vec3(0,0,1))
end
spawn.safeTeleport(getPlayerVehicle(0), vec3(-20.746, 598.736, 75.112))
gameplay_walk.setRot(vec3(0,1,0), vec3(0,0,1))
end
local vehPos = veh:getPosition()
local zoneExtents = vec3(zone.aabb.xMax - zone.aabb.xMin, zone.aabb.yMax - zone.aabb.yMin, zone.aabb.zMax - zone.aabb.zMin)
zoneExtents.z = math.min(zoneExtents.z, 10000)
@/lua/ge/extensions/editor/veMain.lua
if vEditor.vehicle then
vEditor.vehiclePos = vec3()
end
@/lua/ge/extensions/gameplay/traffic/vehicle.lua
local tickTime = 0.25
local tempPos, tempDirVec, roadPos = vec3(), vec3(), vec3()
local tickTime = 0.25
local tempPos, tempDirVec, roadPos = vec3(), vec3(), vec3()
local tickTime = 0.25
local tempPos, tempDirVec, roadPos = vec3(), vec3(), vec3()
-- const vectors --
local vecUp = vec3(0, 0, 1)
self.pos, self.targetPos, self.dirVec, self.vel, self.driveVec = vec3(), vec3(), vec3(), vec3(), vec3()
self.damage = 0
self.pos, self.targetPos, self.dirVec, self.vel, self.driveVec = vec3(), vec3(), vec3(), vec3(), vec3()
self.damage = 0
self.pos, self.targetPos, self.dirVec, self.vel, self.driveVec = vec3(), vec3(), vec3(), vec3(), vec3()
self.damage = 0
self.pos, self.targetPos, self.dirVec, self.vel, self.driveVec = vec3(), vec3(), vec3(), vec3(), vec3()
self.damage = 0
self.pos, self.targetPos, self.dirVec, self.vel, self.driveVec = vec3(), vec3(), vec3(), vec3(), vec3()
self.damage = 0
if self.isPerson then -- special check if the vehicle is a person
local center = vec3(be:getObjectOOBBCenterXYZ(id)) -- for accuracy
validCollision = self.pos:z0():squaredDistance(center:z0()) < square(veh.width * 0.6) or coll.count >= 3 -- jumping on car, or multiple hits
@/lua/ge/extensions/util/trackBuilder/basicBorders.lua
crossPoints = {
{ point = vec3( 0, 0, -1 ), uv = 0.25 },
{ point = vec3(-1.1, 0, -0.4), uv = 0.52 },
{ point = vec3( 0, 0, -1 ), uv = 0.25 },
{ point = vec3(-1.1, 0, -0.4), uv = 0.52 },
{ point = vec3(-1.1, 0, 0.5 ), uv = 0.71 },
{ point = vec3(-1.1, 0, -0.4), uv = 0.52 },
{ point = vec3(-1.1, 0, 0.5 ), uv = 0.71 },
{ point = vec3(-0.95, 0, 0.6 ), uv = 0.75 },
{ point = vec3(-1.1, 0, 0.5 ), uv = 0.71 },
{ point = vec3(-0.95, 0, 0.6 ), uv = 0.75 },
{ point = vec3(-0.725, 0, 0.5 ), uv = 0.80 },
{ point = vec3(-0.95, 0, 0.6 ), uv = 0.75 },
{ point = vec3(-0.725, 0, 0.5 ), uv = 0.80 },
{ point = vec3(-0.5, 0, 0.2 ), uv = 0.88 },
{ point = vec3(-0.725, 0, 0.5 ), uv = 0.80 },
{ point = vec3(-0.5, 0, 0.2 ), uv = 0.88 },
{ point = vec3( 0, 0, 0 ), uv = 1 }
{ point = vec3(-0.5, 0, 0.2 ), uv = 0.88 },
{ point = vec3( 0, 0, 0 ), uv = 1 }
},
crossPoints = {
{ point = vec3(math.cos(-1.0*math.pi/2 )*0.5, 0, -0.5+math.sin(-1.0*math.pi/2 )*0.5), uv = 0.5 },
{ point = vec3(math.cos(-1.4*math.pi/2 )*0.5, 0, -0.5+math.sin(-1.4*math.pi/2 )*0.5), uv = 0.6 },
{ point = vec3(math.cos(-1.0*math.pi/2 )*0.5, 0, -0.5+math.sin(-1.0*math.pi/2 )*0.5), uv = 0.5 },
{ point = vec3(math.cos(-1.4*math.pi/2 )*0.5, 0, -0.5+math.sin(-1.4*math.pi/2 )*0.5), uv = 0.6 },
{ point = vec3(math.cos(-1.8*math.pi/2 )*0.5, 0, -0.5+math.sin(-1.8*math.pi/2 )*0.5), uv = 0.7 },
{ point = vec3(math.cos(-1.4*math.pi/2 )*0.5, 0, -0.5+math.sin(-1.4*math.pi/2 )*0.5), uv = 0.6 },
{ point = vec3(math.cos(-1.8*math.pi/2 )*0.5, 0, -0.5+math.sin(-1.8*math.pi/2 )*0.5), uv = 0.7 },
{ point = vec3(math.cos(-2.2*math.pi/2 )*0.5, 0, -0.5+math.sin(-2.2*math.pi/2 )*0.5), uv = 0.8 },
{ point = vec3(math.cos(-1.8*math.pi/2 )*0.5, 0, -0.5+math.sin(-1.8*math.pi/2 )*0.5), uv = 0.7 },
{ point = vec3(math.cos(-2.2*math.pi/2 )*0.5, 0, -0.5+math.sin(-2.2*math.pi/2 )*0.5), uv = 0.8 },
{ point = vec3(math.cos(-2.6*math.pi/2 )*0.5, 0, -0.5+math.sin(-2.6*math.pi/2 )*0.5), uv = 0.9 },
{ point = vec3(math.cos(-2.2*math.pi/2 )*0.5, 0, -0.5+math.sin(-2.2*math.pi/2 )*0.5), uv = 0.8 },
{ point = vec3(math.cos(-2.6*math.pi/2 )*0.5, 0, -0.5+math.sin(-2.6*math.pi/2 )*0.5), uv = 0.9 },
{ point = vec3(math.cos(-3.0*math.pi/2 )*0.5, 0, -0.5+math.sin(-3.0*math.pi/2 )*0.5), uv = 1.0 },
{ point = vec3(math.cos(-2.6*math.pi/2 )*0.5, 0, -0.5+math.sin(-2.6*math.pi/2 )*0.5), uv = 0.9 },
{ point = vec3(math.cos(-3.0*math.pi/2 )*0.5, 0, -0.5+math.sin(-3.0*math.pi/2 )*0.5), uv = 1.0 },
},
crossPoints = {
{ point = vec3(0, 0, -1), uv = 00 },
{ point = vec3(-0.02,0, -0.98), uv = 0.02 },
{ point = vec3(0, 0, -1), uv = 00 },
{ point = vec3(-0.02,0, -0.98), uv = 0.02 },
{ point = vec3(-0.02,0, -0.96), uv = 0.04 },
{ point = vec3(-0.02,0, -0.98), uv = 0.02 },
{ point = vec3(-0.02,0, -0.96), uv = 0.04 },
{ point = vec3(-0.02,0, -0.04), uv = 0.96 },
{ point = vec3(-0.02,0, -0.96), uv = 0.04 },
{ point = vec3(-0.02,0, -0.04), uv = 0.96 },
{ point = vec3(-0.02,0,-0.02), uv = 0.98},
{ point = vec3(-0.02,0, -0.04), uv = 0.96 },
{ point = vec3(-0.02,0,-0.02), uv = 0.98},
{ point = vec3(0, 0, 0), uv = 1.0 },
{ point = vec3(-0.02,0,-0.02), uv = 0.98},
{ point = vec3(0, 0, 0), uv = 1.0 },
},
crossPoints = {
{ point = vec3( 0, 0, -1 ), uv = 0.001},
{ point = vec3(-15, 0, -1 ), uv = 0.002},
{ point = vec3( 0, 0, -1 ), uv = 0.001},
{ point = vec3(-15, 0, -1 ), uv = 0.002},
{ point = vec3(-15, 0, 1.3 ), uv = 0.005},
{ point = vec3(-15, 0, -1 ), uv = 0.002},
{ point = vec3(-15, 0, 1.3 ), uv = 0.005},
{ point = vec3(-14, 0, 1.3 ), uv = 0.01 },
{ point = vec3(-15, 0, 1.3 ), uv = 0.005},
{ point = vec3(-14, 0, 1.3 ), uv = 0.01 },
{ point = vec3(-14, 0, 0.0 ), uv = 0.13 },
{ point = vec3(-14, 0, 1.3 ), uv = 0.01 },
{ point = vec3(-14, 0, 0.0 ), uv = 0.13 },
{ point = vec3(-1.54, 0, 0.0 ), uv = 0.87 },
{ point = vec3(-14, 0, 0.0 ), uv = 0.13 },
{ point = vec3(-1.54, 0, 0.0 ), uv = 0.87 },
{ point = vec3(-1.5, 0, 0.07), uv = 0.92 },
{ point = vec3(-1.54, 0, 0.0 ), uv = 0.87 },
{ point = vec3(-1.5, 0, 0.07), uv = 0.92 },
{ point = vec3(-0.04, 0, 0.04), uv = 0.98 },
{ point = vec3(-1.5, 0, 0.07), uv = 0.92 },
{ point = vec3(-0.04, 0, 0.04), uv = 0.98 },
{ point = vec3( 0, 0, 0 ), uv = 1 }
{ point = vec3(-0.04, 0, 0.04), uv = 0.98 },
{ point = vec3( 0, 0, 0 ), uv = 1 }
},
crossPoints = {
{ point = vec3(0,0,-1), uv = 0.5 },
{ point = vec3(-0.5,0,-1), uv = 0.6, sharp = true},
{ point = vec3(0,0,-1), uv = 0.5 },
{ point = vec3(-0.5,0,-1), uv = 0.6, sharp = true},
{ point = vec3(-1,0,-0.66), uv = 0.7, sharp = true },
{ point = vec3(-0.5,0,-1), uv = 0.6, sharp = true},
{ point = vec3(-1,0,-0.66), uv = 0.7, sharp = true },
{ point = vec3(-1,0,0.33), uv = 0.8, sharp = true },
{ point = vec3(-1,0,-0.66), uv = 0.7, sharp = true },
{ point = vec3(-1,0,0.33), uv = 0.8, sharp = true },
{ point = vec3(-0.5,0,0.33), uv = 0.9, sharp = true },
{ point = vec3(-1,0,0.33), uv = 0.8, sharp = true },
{ point = vec3(-0.5,0,0.33), uv = 0.9, sharp = true },
{ point = vec3(0,0,0), uv = 1 },
{ point = vec3(-0.5,0,0.33), uv = 0.9, sharp = true },
{ point = vec3(0,0,0), uv = 1 },
},
crossPoints = {
{ point = vec3(0 ,0,-1), uv = 0 },
{ point = vec3(-1,0,-1), uv = 0.2, sharp = true },
{ point = vec3(0 ,0,-1), uv = 0 },
{ point = vec3(-1,0,-1), uv = 0.2, sharp = true },
{ point = vec3(-2,0,-0.33), uv = 0.4, sharp = true },
{ point = vec3(-1,0,-1), uv = 0.2, sharp = true },
{ point = vec3(-2,0,-0.33), uv = 0.4, sharp = true },
{ point = vec3(-2,0,0.66), uv = 0.6, sharp = true },
{ point = vec3(-2,0,-0.33), uv = 0.4, sharp = true },
{ point = vec3(-2,0,0.66), uv = 0.6, sharp = true },
{ point = vec3(-1,0,0.66), uv = 0.8, sharp = true },
{ point = vec3(-2,0,0.66), uv = 0.6, sharp = true },
{ point = vec3(-1,0,0.66), uv = 0.8, sharp = true },
{ point = vec3(0,0,0), uv = 1 },
{ point = vec3(-1,0,0.66), uv = 0.8, sharp = true },
{ point = vec3(0,0,0), uv = 1 },
},
crossPoints = {
{ point = vec3(0 , 0, -1), uv = 0 },
{ point = vec3(-3 , 0, -1), uv = 0.4 },
{ point = vec3(0 , 0, -1), uv = 0 },
{ point = vec3(-3 , 0, -1), uv = 0.4 },
{ point = vec3(-3 , 0, 0), uv = 1-6/12 , sharp = true},
{ point = vec3(-3 , 0, -1), uv = 0.4 },
{ point = vec3(-3 , 0, 0), uv = 1-6/12 , sharp = true},
{ point = vec3(-2.5, 0, 0.5-0.66*0.66*0.5), uv = 1-5/12 },
{ point = vec3(-3 , 0, 0), uv = 1-6/12 , sharp = true},
{ point = vec3(-2.5, 0, 0.5-0.66*0.66*0.5), uv = 1-5/12 },
{ point = vec3(-2 , 0, 0.5-0.33*0.33*0.5), uv = 1-4/12 },
{ point = vec3(-2.5, 0, 0.5-0.66*0.66*0.5), uv = 1-5/12 },
{ point = vec3(-2 , 0, 0.5-0.33*0.33*0.5), uv = 1-4/12 },
{ point = vec3(-1.5, 0, 0.5), uv = 1-3/12 },
{ point = vec3(-2 , 0, 0.5-0.33*0.33*0.5), uv = 1-4/12 },
{ point = vec3(-1.5, 0, 0.5), uv = 1-3/12 },
{ point = vec3(-1 , 0, 0.5-0.33*0.33*0.5), uv = 1-2/12 },
{ point = vec3(-1.5, 0, 0.5), uv = 1-3/12 },
{ point = vec3(-1 , 0, 0.5-0.33*0.33*0.5), uv = 1-2/12 },
{ point = vec3(-0.5, 0, 0.5-0.66*0.66*0.5), uv = 1-1/12 },
{ point = vec3(-1 , 0, 0.5-0.33*0.33*0.5), uv = 1-2/12 },
{ point = vec3(-0.5, 0, 0.5-0.66*0.66*0.5), uv = 1-1/12 },
{ point = vec3(0 , 0, 0), uv = 1 },
{ point = vec3(-0.5, 0, 0.5-0.66*0.66*0.5), uv = 1-1/12 },
{ point = vec3(0 , 0, 0), uv = 1 },
},
crossPoints = {
{ point = vec3(0 , 0, -1), uv = 0 },
{ point = vec3(-1.5 , 0, -1), uv = 0.4 },
{ point = vec3(0 , 0, -1), uv = 0 },
{ point = vec3(-1.5 , 0, -1), uv = 0.4 },
{ point = vec3(-1.5 , 0, 0), uv = 1-6/12 , sharp = true},
{ point = vec3(-1.5 , 0, -1), uv = 0.4 },
{ point = vec3(-1.5 , 0, 0), uv = 1-6/12 , sharp = true},
{ point = vec3(-1.25, 0, 1.5-0.66*0.66*1.5), uv = 1-5/12 },
{ point = vec3(-1.5 , 0, 0), uv = 1-6/12 , sharp = true},
{ point = vec3(-1.25, 0, 1.5-0.66*0.66*1.5), uv = 1-5/12 },
{ point = vec3(-1 , 0, 1.5-0.33*0.33*1.5), uv = 1-4/12 },
{ point = vec3(-1.25, 0, 1.5-0.66*0.66*1.5), uv = 1-5/12 },
{ point = vec3(-1 , 0, 1.5-0.33*0.33*1.5), uv = 1-4/12 },
{ point = vec3(-0.75, 0, 1.5), uv = 1-3/12 },
{ point = vec3(-1 , 0, 1.5-0.33*0.33*1.5), uv = 1-4/12 },
{ point = vec3(-0.75, 0, 1.5), uv = 1-3/12 },
{ point = vec3(-0.5 , 0, 1.5-0.33*0.33*1.5), uv = 1-2/12 },
{ point = vec3(-0.75, 0, 1.5), uv = 1-3/12 },
{ point = vec3(-0.5 , 0, 1.5-0.33*0.33*1.5), uv = 1-2/12 },
{ point = vec3(-0.25, 0, 1.5-0.66*0.66*1.5), uv = 1-1/12 },
{ point = vec3(-0.5 , 0, 1.5-0.33*0.33*1.5), uv = 1-2/12 },
{ point = vec3(-0.25, 0, 1.5-0.66*0.66*1.5), uv = 1-1/12 },
{ point = vec3(0 , 0, 0), uv = 1 },
{ point = vec3(-0.25, 0, 1.5-0.66*0.66*1.5), uv = 1-1/12 },
{ point = vec3(0 , 0, 0), uv = 1 },
},
crossPoints = {
{ point = vec3(math.cos(-0.00 * math.pi )*-0.20, 0, 0.5+math.sin(-0.00 * math.pi )*-0.20), uv = 0.8 },
{ point = vec3(math.cos(-0.25 * math.pi )*-0.20, 0, 0.5+math.sin(-0.25 * math.pi )*-0.20), uv = 0.85 },
{ point = vec3(math.cos(-0.00 * math.pi )*-0.20, 0, 0.5+math.sin(-0.00 * math.pi )*-0.20), uv = 0.8 },
{ point = vec3(math.cos(-0.25 * math.pi )*-0.20, 0, 0.5+math.sin(-0.25 * math.pi )*-0.20), uv = 0.85 },
{ point = vec3(math.cos(-0.50 * math.pi )*-0.20, 0, 0.5+math.sin(-0.50 * math.pi )*-0.20), uv = 0.9 },
{ point = vec3(math.cos(-0.25 * math.pi )*-0.20, 0, 0.5+math.sin(-0.25 * math.pi )*-0.20), uv = 0.85 },
{ point = vec3(math.cos(-0.50 * math.pi )*-0.20, 0, 0.5+math.sin(-0.50 * math.pi )*-0.20), uv = 0.9 },
{ point = vec3(math.cos(-0.75 * math.pi )*-0.20, 0, 0.5+math.sin(-0.75 * math.pi )*-0.20), uv = 0.95 },
{ point = vec3(math.cos(-0.50 * math.pi )*-0.20, 0, 0.5+math.sin(-0.50 * math.pi )*-0.20), uv = 0.9 },
{ point = vec3(math.cos(-0.75 * math.pi )*-0.20, 0, 0.5+math.sin(-0.75 * math.pi )*-0.20), uv = 0.95 },
{ point = vec3(math.cos(-1.00 * math.pi )*-0.20, 0, 0.5+math.sin(-1.00 * math.pi )*-0.20), uv = 1.0 },
{ point = vec3(math.cos(-0.75 * math.pi )*-0.20, 0, 0.5+math.sin(-0.75 * math.pi )*-0.20), uv = 0.95 },
{ point = vec3(math.cos(-1.00 * math.pi )*-0.20, 0, 0.5+math.sin(-1.00 * math.pi )*-0.20), uv = 1.0 },
{ point = vec3(math.cos(-1.25 * math.pi )*-0.20, 0, 0.5+math.sin(-1.25 * math.pi )*-0.20), uv = 1.05 },
{ point = vec3(math.cos(-1.00 * math.pi )*-0.20, 0, 0.5+math.sin(-1.00 * math.pi )*-0.20), uv = 1.0 },
{ point = vec3(math.cos(-1.25 * math.pi )*-0.20, 0, 0.5+math.sin(-1.25 * math.pi )*-0.20), uv = 1.05 },
{ point = vec3(math.cos(-1.50 * math.pi )*-0.20, 0, 0.5+math.sin(-1.50 * math.pi )*-0.20), uv = 1.1 },
{ point = vec3(math.cos(-1.25 * math.pi )*-0.20, 0, 0.5+math.sin(-1.25 * math.pi )*-0.20), uv = 1.05 },
{ point = vec3(math.cos(-1.50 * math.pi )*-0.20, 0, 0.5+math.sin(-1.50 * math.pi )*-0.20), uv = 1.1 },
{ point = vec3(math.cos(-1.75 * math.pi )*-0.20, 0, 0.5+math.sin(-1.75 * math.pi )*-0.20), uv = 1.15 },
{ point = vec3(math.cos(-1.50 * math.pi )*-0.20, 0, 0.5+math.sin(-1.50 * math.pi )*-0.20), uv = 1.1 },
{ point = vec3(math.cos(-1.75 * math.pi )*-0.20, 0, 0.5+math.sin(-1.75 * math.pi )*-0.20), uv = 1.15 },
{ point = vec3(math.cos(-0.00 * math.pi )*-0.20, 0, 0.5+math.sin(-0.00 * math.pi )*-0.20), uv = 1.2 },
{ point = vec3(math.cos(-1.75 * math.pi )*-0.20, 0, 0.5+math.sin(-1.75 * math.pi )*-0.20), uv = 1.15 },
{ point = vec3(math.cos(-0.00 * math.pi )*-0.20, 0, 0.5+math.sin(-0.00 * math.pi )*-0.20), uv = 1.2 },
{ point = vec3( 0, 0,-1), uv = 0.7 },
{ point = vec3( 0, 0, 0), uv = 1 }
{ point = vec3( 0, 0,-1), uv = 0.7 },
{ point = vec3( 0, 0, 0), uv = 1 }
},
crossPoints = {
{ point = vec3( 0, 0,-1), uv = 0 },
{ point = vec3( 0, 0, 0), uv = 1 }
{ point = vec3( 0, 0,-1), uv = 0 },
{ point = vec3( 0, 0, 0), uv = 1 }
},
a:normalize()
shape.normals[#shape.normals+1] = vec3(-a.z,0,a.x)
-- Actual normal.
local n = vec3(
-(a.z) - (b.z),
if len <=0.00001 then
n = vec3(
-(nextP.z - currentP.z),
else
shape.normals[#shape.normals+1] = vec3(-a.z,0,a.x)
shape.normals[#shape.normals+1] = vec3(-b.z,0,b.x)
shape.normals[#shape.normals+1] = vec3(-a.z,0,a.x)
shape.normals[#shape.normals+1] = vec3(-b.z,0,b.x)
end
a:normalize()
shape.normals[#shape.normals+1] = vec3(-a.z,0,a.x)
end
local pointCount = 0
local tmpVec3 = vec3()
local cappedWidth = 0
p.point.z * point.orientation.nz +
point.position + vec3(0,0,point.zOffset)
)
@/lua/ge/extensions/flowgraph/nodes/environment/planet.lua
local mesh = self:createheightmapMesh(warped, 5,"procheightmapMat")
table.insert(self.objs, self:placeObject("testMesh",mesh, vec3(self.pinIn.position.value), side.quat ))
end
-- local hm = self:heightmapFromPNG(self.pinIn.heightmap.value or "terrain.png",vec3(sLength,sLength, self.pinIn.surfaceHeight.value or 0))
local center = vec3(self.pinIn.position.value[1] or 0, self.pinIn.position.value[2] or 0,self.pinIn.position.value[3] or 0)
local vehPos = veh:getPosition()
local count = 0
local normal = vec3()
--if x > 1 and y > 1 then
local pos = heightmap[y][x]
local d = vec3(pos.x, pos.y, 0):length()/sphereRadius
local h = pos.z
local r = math.atan2(pos.y, pos.x)
local sphereVec = vec3(math.cos(r) * math.sin(d), math.sin(r) * math.sin(d), -math.cos(d)) * (sphereRadius-h)
heightmap[y][x] = {x = sphereVec.x, y = sphereVec.y, z = sphereVec.z, origX = pos.x, origY = pos.y }
local xCount = #heightmap[2]
local corner = vec3(heightmap[2][2])
corner.z = 0
cLength = corner:length()
local sphereCenter = vec3(0,0, -(cLength/math.sqrt(2)))
local pos = heightmap[y][x]
local d = vec3(pos.x,pos.y,0) - sphereCenter
local sphereVec = (d:normalized() * (sphereRadius - (pos.z * surfaceHeight)))
function C:normalFromPoints(p1, p3, p2)
local u = vec3(p2)-vec3(p1)
local v = vec3(p3)-vec3(p1)
function C:normalFromPoints(p1, p3, p2)
local u = vec3(p2)-vec3(p1)
local v = vec3(p3)-vec3(p1)
local u = vec3(p2)-vec3(p1)
local v = vec3(p3)-vec3(p1)
local u = vec3(p2)-vec3(p1)
local v = vec3(p3)-vec3(p1)
name = name or "procObject"
pos = pos or vec3(0,0,0)
rot = rot or quat(0,0,0,0)
pos = vec3(pos)
rot = rot:toTorqueQuat()
proc:setField('rotation', 0, rot.x .. ' ' .. rot.y .. ' ' .. rot.z .. ' ' .. rot.w)
proc.scale = vec3(1, 1, 1)
z = z * (invertColors and 1 or -1)
row[x] = vec3(x,y,z)
end
local centerCoordinates = {}
centerCoordinates.f = vec3(1*size+1,1*size+1)
centerCoordinates.r = vec3(2*size+1,1*size+1)
centerCoordinates.f = vec3(1*size+1,1*size+1)
centerCoordinates.r = vec3(2*size+1,1*size+1)
centerCoordinates.b = vec3(3*size+1,1*size+1)
centerCoordinates.r = vec3(2*size+1,1*size+1)
centerCoordinates.b = vec3(3*size+1,1*size+1)
centerCoordinates.l = vec3(0*size+1,1*size+1)
centerCoordinates.b = vec3(3*size+1,1*size+1)
centerCoordinates.l = vec3(0*size+1,1*size+1)
centerCoordinates.u = vec3(1*size+1,0*size+1)
centerCoordinates.l = vec3(0*size+1,1*size+1)
centerCoordinates.u = vec3(1*size+1,0*size+1)
centerCoordinates.d = vec3(1*size+1,2*size+1)
centerCoordinates.u = vec3(1*size+1,0*size+1)
centerCoordinates.d = vec3(1*size+1,2*size+1)
local hm = M.heightmapFromPNG("terrain.png",vec3(500,500,30))
hm = M.warpSphere(250, hm)
local mesh = M.createheightmapMesh(hm, 10,"procheightmapMat")
local obj = M.placeObject("testMesh",mesh, vec3(400,300,1000) )
end
@/lua/ge/extensions/gameplay/rally/driveline/drivelineRoute.lua
local posCache = vec3()
function C:recalculate()
local txtPos = vec3(point.pos)
txtPos.z = txtPos.z + zOffset
clr = rainbowColor(#routeToDraw.path, i, 1)
pos = vec3(point.pos)
pos.z = pos.z + zOffset
if i > 1 then
local pos2 = vec3(routeToDraw.path[i-1].pos)
pos2.z = pos2.z + zOffset
-- local txtPos = vec3(point.pos)
-- txtPos.z = txtPos.z + zOffset
for i, point in ipairs(self.route.path) do
local pos = vec3(point.pos)
-- debugDrawer:drawSphere(pos, 1, clrShort)
if i > 1 then
local pos2 = vec3(self.route.path[i-1].pos)
local dist = pos:distance(pos2)
@/lua/ge/extensions/gameplay/police.lua
local vecY = vec3(0, 1, 0)
local tempPos, tempFwd, tempFwd2, tempUp, tempRight = vec3(), vec3(), vec3(), vec3(), vec3()
local vecY = vec3(0, 1, 0)
local tempPos, tempFwd, tempFwd2, tempUp, tempRight = vec3(), vec3(), vec3(), vec3(), vec3()
local vecY = vec3(0, 1, 0)
local tempPos, tempFwd, tempFwd2, tempUp, tempRight = vec3(), vec3(), vec3(), vec3(), vec3()
local vecY = vec3(0, 1, 0)
local tempPos, tempFwd, tempFwd2, tempUp, tempRight = vec3(), vec3(), vec3(), vec3(), vec3()
local vecY = vec3(0, 1, 0)
local tempPos, tempFwd, tempFwd2, tempUp, tempRight = vec3(), vec3(), vec3(), vec3(), vec3()
local vecY = vec3(0, 1, 0)
local tempPos, tempFwd, tempFwd2, tempUp, tempRight = vec3(), vec3(), vec3(), vec3(), vec3()
tempPos:setAddXYZ(x, y, z) -- offset adjustment
table.insert(transforms, {pos = vec3(tempPos), rot = quat(newQuat)})
end
pursuit.roadblockPos = vec3(spawnData.pos)
pursuit.roadblockNear = false
@/lua/vehicle/controller/tech/mesh.lua
-- Properties which are updated regularly.
local currentPos = vec3(0, 0, 0)
local currentDir = vec3(0, 0, 0)
local currentPos = vec3(0, 0, 0)
local currentDir = vec3(0, 0, 0)
@/lua/ge/extensions/gameplay/discover/discover_037.lua
local vehs = {
{ vec3(-821.7966309,903.6448364,75.53855133), quat(3.139752468e-06,-1.053478079e-05,0.4958757203,0.8683934995), "unicycle", "vehicles/unicycle/with_mesh.pc" },
{ vec3(-810.0274048,909.8909912,75.03192139), quat(-0.001089688493,-0.003704504967,0.9999047143,-0.01325336309), "fullsize", "vehicles/fullsize/limo_official.pc" },
{ vec3(-821.7966309,903.6448364,75.53855133), quat(3.139752468e-06,-1.053478079e-05,0.4958757203,0.8683934995), "unicycle", "vehicles/unicycle/with_mesh.pc" },
{ vec3(-810.0274048,909.8909912,75.03192139), quat(-0.001089688493,-0.003704504967,0.9999047143,-0.01325336309), "fullsize", "vehicles/fullsize/limo_official.pc" },
}
})
freeroam_bigMapMode.setNavFocus(vec3(835.908,-522.544,165.363))
end
{ vec3(-393.538208,85.07393646,100.4414902), quat(0.003996261011,0.001331355885,-0.8466762199,0.5320917552), "hopper", "vehicles/hopper/sport_A.pc" },
{ vec3(-392.4162598,79.27086639,100.084465), quat(-0.0007308341831,-0.004185617448,0.9826823809,-0.1852492502), "fullsize", "vehicles/fullsize/lowrider.pc" },
{ vec3(-393.538208,85.07393646,100.4414902), quat(0.003996261011,0.001331355885,-0.8466762199,0.5320917552), "hopper", "vehicles/hopper/sport_A.pc" },
{ vec3(-392.4162598,79.27086639,100.084465), quat(-0.0007308341831,-0.004185617448,0.9826823809,-0.1852492502), "fullsize", "vehicles/fullsize/lowrider.pc" },
{ vec3(-460.0043945,110.3837967,99.99999237), quat(0,-0,1,-0), "large_cannon", "vehicles/large_cannon/standard.pc" },
{ vec3(-471.0322876,111.5633316,99.99999237), quat(5.743762875e-07,-5.464591496e-06,1.715435881e-07,1), "large_roller", "vehicles/large_roller/standard.pc" },
{ vec3(-460.0043945,110.3837967,99.99999237), quat(0,-0,1,-0), "large_cannon", "vehicles/large_cannon/standard.pc" },
{ vec3(-471.0322876,111.5633316,99.99999237), quat(5.743762875e-07,-5.464591496e-06,1.715435881e-07,1), "large_roller", "vehicles/large_roller/standard.pc" },
{ vec3(-439,-15.95985031,100), quat(1.525190219e-07,-1.723923542e-07,-0.7071049957,0.7071085666), "large_hamster_wheel", "vehicles/large_hamster_wheel/standard.pc" },
{ vec3(-471.0322876,111.5633316,99.99999237), quat(5.743762875e-07,-5.464591496e-06,1.715435881e-07,1), "large_roller", "vehicles/large_roller/standard.pc" },
{ vec3(-439,-15.95985031,100), quat(1.525190219e-07,-1.723923542e-07,-0.7071049957,0.7071085666), "large_hamster_wheel", "vehicles/large_hamster_wheel/standard.pc" },
{ vec3(-448,43.99998856,99.99998474), quat(-2.854423109e-06,-1.182347615e-06,0.9238819276,-0.38267765), "large_spinner", "vehicles/large_spinner/flail.pc" },
{ vec3(-460,32,100), quat(-0,0,0.9238795164,-0.3826834713), "large_spinner", "vehicles/large_spinner/base.pc", true },
{ vec3(-470,12.08457279,110.9995651), quat(0.5001355236,0.5010345638,0.4986913531,0.5001357399), "large_spinner", "vehicles/large_spinner/base.pc", true },
{ vec3(-460,32,100), quat(-0,0,0.9238795164,-0.3826834713), "large_spinner", "vehicles/large_spinner/base.pc", true },
{ vec3(-470,12.08457279,110.9995651), quat(0.5001355236,0.5010345638,0.4986913531,0.5001357399), "large_spinner", "vehicles/large_spinner/base.pc", true },
{ vec3(-439,68,100), quat(1.950982245e-06,1.950980785e-06,0.7071070457,0.7071065166), "spikestrip", "vehicles/spikestrip/flexr_dual.pc" },
{ vec3(-439,79,100), quat(1.950982245e-06,1.950980785e-06,0.7071070457,0.7071065166), "spikestrip", "vehicles/spikestrip/flexr_dual.pc" },
{ vec3(-439,68,100), quat(1.950982245e-06,1.950980785e-06,0.7071070457,0.7071065166), "spikestrip", "vehicles/spikestrip/flexr_dual.pc" },
{ vec3(-439,79,100), quat(1.950982245e-06,1.950980785e-06,0.7071070457,0.7071065166), "spikestrip", "vehicles/spikestrip/flexr_dual.pc" },
{ vec3(-422.999939,73.00011444,99.99913025), quat(-5.571546525e-05,-6.816663433e-05,0.9999999956,3.381670454e-05), "trampoline", "vehicles/trampoline/anchor.pc" },
{ vec3(-432,88.00015259,105.9998169), quat(0.4999864969,-0.5000118257,0.4999867948,0.5000148819), "large_spinner", "vehicles/large_spinner/small_dual.pc", true },
local vehs = {
{vec3(1082.018188,427.2434998,114.7162094), quat(-0.02628606277,-0.04700933289,-0.007957618196,0.998516821), "pickup", "vehicles/pickup/deserttruck_crawler_A.pc" },
{vec3(1100,584,160), quat(0,0,0,1), "pressure_ball", "vehicles/pressule_ball/helium.pc.pc" },
{vec3(1100,584,160), quat(0,0,0,1), "pigeon", "vehicles/pigeon/base.pc.pc" },
{vec3(1100,584,160), quat(0,0,0,1), "pressure_ball", "vehicles/pressule_ball/helium.pc.pc" },
{vec3(1100,584,160), quat(0,0,0,1), "pigeon", "vehicles/pigeon/base.pc.pc" },
}
end
local windVec = vec3(25+random()*10,0,0)
v:queueLuaCommand('obj:setWind('..string.format('%6f, %6f, %6f', windVec.x, windVec.y, windVec.z)..')')
local randomPos = function()
return vec3(startX - random()*len/2,520 + random()*height,130 + random()*100)
end
local veh = core_vehicles.spawnNewVehicle(model, options)
local windVec = vec3(25+random()*10,0,0)
veh:queueLuaCommand('obj:setWind('..string.format('%6f, %6f, %6f', windVec.x, windVec.y, windVec.z)..')')
veh:setClusterPosRelRot(veh:getRefNodeId(), randomPos.x, randomPos.y, randomPos.z,0,0,0,1)
local windVec = vec3(25+random()*10,0,0)
veh:queueLuaCommand('obj:setWind('..string.format('%6f, %6f, %6f', windVec.x, windVec.y, windVec.z)..')')
for _, veh in ipairs(setupVehs) do
--spawn.safeTeleport(veh, vec3(randomPos), quat(0,0,0,1), nil, nil, nil, nil, false)
--veh:setClusterPosRelRot(veh:getRefNodeId(), randomPos.x, randomPos.y, randomPos.z,0,0,0,1)
veh:resetBrokenFlexMesh()
local windVec = vec3(25+random()*10,0,0)
veh:queueLuaCommand('obj:setWind('..string.format('%6f, %6f, %6f', windVec.x, windVec.y, windVec.z)..')')
local vehs = {
{ vec3(208.9507599,-58.5039711,100.1960449), quat(0.001559768738,0.0007141662238,-0.3119492118,0.9500972299), "fullsize", "vehicles/fullsize/limo_derby.pc" },
{ vec3(215.3587799,-65.03526306,100.1957703), quat(0.001210500138,0.001256510898,-0.6362022006,0.7715203924), "fullsize", "vehicles/fullsize/limo_derby.pc" },
{ vec3(208.9507599,-58.5039711,100.1960449), quat(0.001559768738,0.0007141662238,-0.3119492118,0.9500972299), "fullsize", "vehicles/fullsize/limo_derby.pc" },
{ vec3(215.3587799,-65.03526306,100.1957703), quat(0.001210500138,0.001256510898,-0.6362022006,0.7715203924), "fullsize", "vehicles/fullsize/limo_derby.pc" },
{ vec3(225.7114563,-69.6268158,100.1959534), quat(0.001570248627,0.0007085807929,-0.3077276251,0.9514729324), "fullsize", "vehicles/fullsize/limo_derby.pc" },
{ vec3(215.3587799,-65.03526306,100.1957703), quat(0.001210500138,0.001256510898,-0.6362022006,0.7715203924), "fullsize", "vehicles/fullsize/limo_derby.pc" },
{ vec3(225.7114563,-69.6268158,100.1959534), quat(0.001570248627,0.0007085807929,-0.3077276251,0.9514729324), "fullsize", "vehicles/fullsize/limo_derby.pc" },
{ vec3(229.7160492,-79.54701996,100.1958771), quat(0.001717891903,0.0002193109397,-0.01340812524,0.9999086073), "fullsize", "vehicles/fullsize/limo_derby.pc" }
{ vec3(225.7114563,-69.6268158,100.1959534), quat(0.001570248627,0.0007085807929,-0.3077276251,0.9514729324), "fullsize", "vehicles/fullsize/limo_derby.pc" },
{ vec3(229.7160492,-79.54701996,100.1958771), quat(0.001717891903,0.0002193109397,-0.01340812524,0.9999086073), "fullsize", "vehicles/fullsize/limo_derby.pc" }
}
{
vec3(363.9958191,-197.4786835,77.9961319), quat(-0.0005543338439,0.003372357637,0.4714414284,0.8818907526), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(360.7849731,-200.7636414,78.07813263), quat(0.006742560331,-0.01062271526,0.8806311428,-0.4736353936), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
vec3(363.9958191,-197.4786835,77.9961319), quat(-0.0005543338439,0.003372357637,0.4714414284,0.8818907526), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(360.7849731,-200.7636414,78.07813263), quat(0.006742560331,-0.01062271526,0.8806311428,-0.4736353936), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(367.0430603,-202.0362091,77.98976135), quat(-0.003238036801,0.0005231049422,0.4730052569,0.8810534992), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(360.7849731,-200.7636414,78.07813263), quat(0.006742560331,-0.01062271526,0.8806311428,-0.4736353936), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(367.0430603,-202.0362091,77.98976135), quat(-0.003238036801,0.0005231049422,0.4730052569,0.8810534992), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(364.9580688,-196.6944122,78.97259521), quat(-0.0001914897888,0.01949516246,-0.2922635234,0.9561390772), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(367.0430603,-202.0362091,77.98976135), quat(-0.003238036801,0.0005231049422,0.4730052569,0.8810534992), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(364.9580688,-196.6944122,78.97259521), quat(-0.0001914897888,0.01949516246,-0.2922635234,0.9561390772), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(363.5989685,-203.0787506,79.24938965), quat(0.00445194461,-0.01197569268,0.9570844328,0.2895274624), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(364.9580688,-196.6944122,78.97259521), quat(-0.0001914897888,0.01949516246,-0.2922635234,0.9561390772), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(363.5989685,-203.0787506,79.24938965), quat(0.00445194461,-0.01197569268,0.9570844328,0.2895274624), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(360.1609802,-199.8941803,79.29812622), quat(-0.03122464289,0.1275293849,-0.2935328995,0.9468894944), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(363.5989685,-203.0787506,79.24938965), quat(0.00445194461,-0.01197569268,0.9570844328,0.2895274624), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
{ vec3(360.1609802,-199.8941803,79.29812622), quat(-0.03122464289,0.1275293849,-0.2935328995,0.9468894944), "fullsize", "vehicles/fullsize/limo_luxe.pc" },
}
}
local avgPosition = vec3(0,0,0)
local explodeVehicles = {}
-- Create a point at the bottom center in local space (Z is up/down)
local localPoint = vec3(math.random()*0.25-0.125, math.random()*0.25-0.125, -halfExtents.z-0.8)
-- Convert to world space
@/lua/ge/extensions/flowgraph/nodes/environment/setWind.lua
local windVec = vec3()
function C:work()
@/lua/vehicle/extensions/tech/ACC.lua
-- Local road data/other vehicle data.
local lastVelPlayer = vec3(0, 0) -- An initial (default) starting value for the player vehicle velocity.
local lastPos, lastVel = {}, {} -- Initialise tables to store the last-known position and velocity data, for all other vehicles in the simulator.
-- Player vehicle state.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0, 0), vec3(0, 0) -- The player vehicle orthogonal frame.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0, 0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0, 0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local fwd, right = vec3(0, 0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
-- Compute the position, velocity and acceleration of this other vehicle.
local posB, velB, accB = obj:getObjectCenterPosition(k), vec3(0, 0, 0), vec3(0, 0, 0)
if lastPos[k] ~= nil then
-- Compute the position, velocity and acceleration of this other vehicle.
local posB, velB, accB = obj:getObjectCenterPosition(k), vec3(0, 0, 0), vec3(0, 0, 0)
if lastPos[k] ~= nil then
@/lua/ge/extensions/core/vehicleMirrors.lua
-- local userCorrection = vec3()
local showDebug = im.BoolPtr(false)
local camPos = core_camera.getPosition()
-- local camUp = vec3(core_camera.getUp())
local vehPos = veh:getPosition()
local mirrorCamPos = vec3()
for _, m in pairs(vehicleMirrorData) do
for _, m in pairs(vehicleMirrorData) do
local id1 = vec3(veh:getNodePosition(m.id1))
local id2 = vec3(veh:getNodePosition(m.id2))
local id1 = vec3(veh:getNodePosition(m.id1))
local id2 = vec3(veh:getNodePosition(m.id2))
local id3 = vec3(veh:getNodePosition(m.id3))
local id2 = vec3(veh:getNodePosition(m.id2))
local id3 = vec3(veh:getNodePosition(m.id3))
if im.Button("reset") then
m.userCorrection = vec3()
end
for _, m in pairs(vehicleMirrorData) do
m.userCorrection = vec3()
end
@/lua/ge/extensions/gameplay/rally/geometry.lua
local rlcolor = ColorF(0,0,0,0)
local tagPos = vec3()
local vehPos = vec3()
local vehVel = vec3()
local vehPos = vec3()
local vehVel = vec3()
local pacenotes = nil
@/lua/ge/extensions/flowgraph/nodes/gameplay/groundmarkers.lua
if type(target) == 'table' and type(target[1]) == 'number' then
target = vec3(target)
end
@/gameplay/missionTypes/cannon/customNodes/cannonBallDistNode.lua
local endPos = targetPos - vec3(unpack(self.pinIn.camOffsetPos.value))
core_camera.setPosRot(0,
@/lua/ge/extensions/gameplay/race/path.lua
local clr = rainbowColor(#self.aiDetailedPath, i, 1)
debugDrawer:drawSphere(vec3(e.pos), 1, ColorF(clr[1], clr[2], clr[3], 0.6))
if e.wp then
if i > 1 then
--debugDrawer:drawLine(vec3(e.pos), vec3(route.path[i-1].pos), )
debugDrawer:drawSquarePrism(
if i > 1 then
--debugDrawer:drawLine(vec3(e.pos), vec3(route.path[i-1].pos), )
debugDrawer:drawSquarePrism(
debugDrawer:drawSquarePrism(
vec3(e.pos), vec3(self.aiDetailedPath[i-1].pos),
Point2F(2,0.5),
debugDrawer:drawSquarePrism(
vec3(e.pos), vec3(self.aiDetailedPath[i-1].pos),
Point2F(2,0.5),
if not nodePositions then
nodePositions = {vec3(self.pathnodes.objects[self.startNode].pos)}
end
local nodePos = vec3(self.pathnodes.objects[currentSegment.targetNode].pos)
local name_a, name_b, distance = map.findClosestRoad(nodePos)
local info = extensions.scenario_scenarios.getScenario().nodes[cp]
pn.pos = vec3(info.pos)
pn.radius = info.radius
if cp:getField('directionalWaypoint',0) == '1' then
pn:setNormal(quat(cp:getRotation())*vec3(1,0,0))
else
end
pn.pos = vec3(cp:getPosition())
local scl = cp:getScale()
if wp:getField('directionalWaypoint',0) == '1' then
rot = quat(wp:getRotation())*vec3(1,0,0)
end
end
pn.pos = vec3(wp:getPosition())
pn.radius = getSceneWaypointRadius(wp)
if wp:getField('directionalWaypoint',0) == '1' then
rot = quat(wp:getRotation())*vec3(1,0,0)
end
end
pn.pos = vec3(wp:getPosition())
pn.radius = getSceneWaypointRadius(wp)
local rot = quat(spawnObj:getRotation())* quat(0,0,1,0)
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(vec3(spawnObj:getPosition()) + y*1)
local rot = quat(spawnObj:getRotation())* quat(0,0,1,0)
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(vec3(spawnObj:getPosition()) + y*1)
local rot = quat(spawnObj:getRotation())* quat(0,0,1,0)
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(vec3(spawnObj:getPosition()) + y*1)
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(vec3(spawnObj:getPosition()) + y*1)
pos:set(pos.x, pos.y, pos.z)
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(vec3(spawnObj:getPosition()) + y*1)
pos:set(pos.x, pos.y, pos.z)
@/lua/ge/server/commands.lua
camDir.z = 0
local camRot = quatFromDir(camDir, vec3(0,0,1))
local rot = quat(0, 0, 1, 0) * camRot -- vehicles' forward is inverted
camDir.z = 0
local camRot = quatFromDir(camDir, vec3(0,0,1))
camRot = quat(0, 0, 1, 0) * camRot -- vehicles' forward is inverted
@/lua/ge/extensions/flowgraph/nodes/recording/recordCamera.lua
local pos = v.pos or {0,0,0}
pos = vec3(pos[1],pos[2],pos[3])
currentMarker:setPosition(pos)
currentMarker:setPosition(pos)
currentMarker:setScale(vec3(0.1,0.1,0.1))
@/lua/vehicle/hydros.lua
-- Jerk tracking variables
local totalAcceleration = vec3(0,0,0)
local prevTotalAccel = vec3(0,0,0)
local totalAcceleration = vec3(0,0,0)
local prevTotalAccel = vec3(0,0,0)
local poweredWheelIndices = {}
local smoothVelocity = vec3()
@/gameplay/missions/automation_test_track/flowgraph/001-Dam/customNodes/hitTargetNode.lua
if not self.active then
self.pos = vec3()
self.bestPos = vec3()
self.pos = vec3()
self.bestPos = vec3()
self.centerPos = vec3()
self.bestPos = vec3()
self.centerPos = vec3()
local targetBox = target:getObjectBox():getExtents():componentMul(target:getScale())
self.targetPos = self.pinIn.targetPos.value and vec3(self.pinIn.targetPos.value) or target:getPosition()
self.targetRadius = self.pinIn.targetRadius.value or math.max(targetBox.x, targetBox.y, targetBox.z) * 0.5
@/gameplay/missionTypes/cannon/customNodes/cannonPreviewNode.lua
local steps = 800
local g = vec3(0,0,-9.81)
local adjustedG = g * dt
local sphereColor = ColorF(1,1,1,1)
local scaledVel = vec3()
@/lua/ge/extensions/gameplay/markers/crawlMarker.lua
local markerIndexCorrection = { { 3, 4, 2, 1 }, { 1, 2, 4, 3 } }
local vecZero = vec3(0,0,0)
local vecOne = vec3(1,1,1)
local vecZero = vec3(0,0,0)
local vecOne = vec3(1,1,1)
local quatZero = quat(0,0,0,0)
local quatZero = quat(0,0,0,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local lineColorF = ColorF(1,1,1,1)
local iconWorldSize = 20
local tmpVec = vec3()
local maxVisibleDistance = 35
--lineColorF.a = area.iconAlphaSmoother:value()
debugDrawer:drawLine(area.iconPos + vec3(0,0,self.iconOffsetHeight - smootherVal * self.iconOffsetHeight), tmpVec, lineColorF)
end
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/core/cameraModes/transition.lua
self.hidden = true
self.camLastPosRel = vec3(5,5,5)
self.camLastPosAbs = vec3(0,0,0)
self.camLastPosRel = vec3(5,5,5)
self.camLastPosAbs = vec3(0,0,0)
self.camLastFOV = 90
@/lua/ge/extensions/gameplay/discover/discover_038.lua
local spawningOptions = sanitizeVehicleSpawnOptions("unicycle", {config = "vehicles/unicycle/with_mesh.pc"})
spawningOptions.pos = vec3(-806.7416992,-325.3113098,237.535614)
spawningOptions.rot = quat(1.781464772e-06,-1.254244252e-05,0.8572401185,0.5149168662)
@/lua/vehicle/powertrain/electricServo.lua
local wheel = powertrain.wheels[device.connectedRotator]
local hubNode1 = vec3(v.data.nodes[wheel.node1].pos)
local hubNode2 = vec3(v.data.nodes[wheel.node2].pos)
local hubNode1 = vec3(v.data.nodes[wheel.node1].pos)
local hubNode2 = vec3(v.data.nodes[wheel.node2].pos)
local n = v.data.nodes[nid]
local distanceToAxis = vec3(n.pos):distanceToLine(hubNode1, hubNode2)
axisInertia = axisInertia + (n.nodeWeight * (distanceToAxis * distanceToAxis))
@/lua/ge/extensions/editor/toolUtilities/polygon.lua
local polygon = {}
local lastMousePos = vec3()
local selectedNodeIdx = 1
local markupTimer, markupTime = hptimer(), 0.0
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
local markupTimer, markupTime = hptimer(), 0.0
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
local markupTimer, markupTime = hptimer(), 0.0
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
local markupTimer, markupTime = hptimer(), 0.0
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
for i = 1, #polygon do
copy[i] = vec3(polygon[i])
end
if im.IsMouseClicked(0) then
table.insert(polygon, idxLower + 1, vec3(mousePos)) -- Insert the new node at the correct intermediate position.
markupTime = timeUntilTextAppears
if im.IsMouseClicked(0) then
polygon[#polygon + 1] = vec3(mousePos)
selectedNodeIdx = #polygon
@/gameplay/missionTypes/cannon/customNodes/cannonBallTouchdownNode.lua
function C:onNodeReset()
self.lastBallPos = vec3()
self.trackingBall = false
@/lua/ge/extensions/flowgraph/nodes/gameplay/sites/posInZone.lua
local pos = vec3()
@/lua/ge/extensions/util/instancedLineRenderDemo.lua
local masses = {}
local origin = vec3(0, 0, 3)
local simDrawOffset = origin + vec3(0, 10, 0)
local function vec3Random()
return vec3(math.random(), math.random(), math.random())
end
table.insert(masses, {
force = vec3(0, 0, 0),
velocity = vec3Random(1),
local function drawgrid(size, rot, gridOrigin, mode, width)
local p1 = vec3(0,0,-size)
local p2 = vec3(0,0,size)
local p1 = vec3(0,0,-size)
local p2 = vec3(0,0,size)
local col = ColorF(0.3,0.3,0.3,1)
-- draw them all
local offset = vec3(6, 0, 0)
for _, mass in ipairs(masses) do
local gridSize = 5
drawgrid(gridSize, rot, origin + vec3(gridSize * 3, -1, z), false, width)
drawgrid(gridSize, rot, origin + vec3(gridSize * 3, 0, z), true, width)
drawgrid(gridSize, rot, origin + vec3(gridSize * 3, -1, z), false, width)
drawgrid(gridSize, rot, origin + vec3(gridSize * 3, 0, z), true, width)
debugDrawer:drawText(origin + vec3(gridSize * 3, -0.5, z), String('grid line width = ' .. tostring(width)), ColorF(0, 0, 0, 1))
drawgrid(gridSize, rot, origin + vec3(gridSize * 3, 0, z), true, width)
debugDrawer:drawText(origin + vec3(gridSize * 3, -0.5, z), String('grid line width = ' .. tostring(width)), ColorF(0, 0, 0, 1))
end
for i = 0, 2 * math.pi, math.pi / step do
local p = vec3(-i, 0, math.sin(t + i)) + pos
local col = ColorF(math.sin(t + p.x), math.cos(t + p.x), 0, 1)
for i = 0, 10, 1 do
local pos = origin + vec3(-5, 0, i * 0.3)
local elCount = drawSin(t, pos, i, step)
local bgColor = ColorF(1,1,1,0.5)
debugDrawer:drawLineInstance(origin + vec3(-3,0,1), origin + vec3(-3,0,2), 10, ColorF(1,1,0,1), 30, ColorF(0,1,0,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-3,0,2), origin + vec3(-4,0,3), 30, ColorF(0,1,0,1), 20, ColorF(0,0,1,1), bgColor, bgColor, 30)
local bgColor = ColorF(1,1,1,0.5)
debugDrawer:drawLineInstance(origin + vec3(-3,0,1), origin + vec3(-3,0,2), 10, ColorF(1,1,0,1), 30, ColorF(0,1,0,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-3,0,2), origin + vec3(-4,0,3), 30, ColorF(0,1,0,1), 20, ColorF(0,0,1,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-3,0,1), origin + vec3(-3,0,2), 10, ColorF(1,1,0,1), 30, ColorF(0,1,0,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-3,0,2), origin + vec3(-4,0,3), 30, ColorF(0,1,0,1), 20, ColorF(0,0,1,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-4,0,3), origin + vec3(-3,0,4 ), 20, ColorF(0,0,1,1), 30, ColorF(1,0,0,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-3,0,1), origin + vec3(-3,0,2), 10, ColorF(1,1,0,1), 30, ColorF(0,1,0,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-3,0,2), origin + vec3(-4,0,3), 30, ColorF(0,1,0,1), 20, ColorF(0,0,1,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-4,0,3), origin + vec3(-3,0,4 ), 20, ColorF(0,0,1,1), 30, ColorF(1,0,0,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-3,0,2), origin + vec3(-4,0,3), 30, ColorF(0,1,0,1), 20, ColorF(0,0,1,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-4,0,3), origin + vec3(-3,0,4 ), 20, ColorF(0,0,1,1), 30, ColorF(1,0,0,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-3,0,2), origin + vec3(-4,0,3), 30, ColorF(0,1,0,1), 20, ColorF(0,0,1,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-4,0,3), origin + vec3(-3,0,4 ), 20, ColorF(0,0,1,1), 30, ColorF(1,0,0,1), bgColor, bgColor, 30)
debugDrawer:drawLineInstance(origin + vec3(-4,0,4), origin + vec3(-3,0,5), 30, ColorF(0,0,1,1))
debugDrawer:drawLineInstance(origin + vec3(-4,0,5), origin + vec3(-3,0,6), 30, ColorF(0,0,1,1))
debugDrawer:drawLineInstance(origin + vec3(-4,0,4), origin + vec3(-3,0,5), 30, ColorF(0,0,1,1))
debugDrawer:drawLineInstance(origin + vec3(-4,0,5), origin + vec3(-3,0,6), 30, ColorF(0,0,1,1))
debugDrawer:drawLineInstance(origin + vec3(-4,0,4), origin + vec3(-3,0,5), 30, ColorF(0,0,1,1))
debugDrawer:drawLineInstance(origin + vec3(-4,0,5), origin + vec3(-3,0,6), 30, ColorF(0,0,1,1))
end
debugDrawer:drawLineInstance(origin + vec3(-4,0,4), origin + vec3(-3,0,5), 30, ColorF(0,0,1,1))
debugDrawer:drawLineInstance(origin + vec3(-4,0,5), origin + vec3(-3,0,6), 30, ColorF(0,0,1,1))
end
local function drawSignal(pos)
debugDrawer:drawDot(pos + vec3(0,0,-3), 20, ColorF(0,0,0,1))
debugDrawer:drawLineInstance(pos + vec3(0,0,-3), pos + vec3(0,0,0.4), 5, ColorF(0,0,0,1))
debugDrawer:drawDot(pos + vec3(0,0,-3), 20, ColorF(0,0,0,1))
debugDrawer:drawLineInstance(pos + vec3(0,0,-3), pos + vec3(0,0,0.4), 5, ColorF(0,0,0,1))
debugDrawer:drawLineInstance(pos + vec3(0,0,-0.4), pos + vec3(0,0,0.4), 80, ColorF(1,1,1,0.8), 80, ColorF(1,1,1,0.8), ColorF(0,0,0,1), ColorF(0,0,0,1), 30)
debugDrawer:drawDot(pos + vec3(0,0,-3), 20, ColorF(0,0,0,1))
debugDrawer:drawLineInstance(pos + vec3(0,0,-3), pos + vec3(0,0,0.4), 5, ColorF(0,0,0,1))
debugDrawer:drawLineInstance(pos + vec3(0,0,-0.4), pos + vec3(0,0,0.4), 80, ColorF(1,1,1,0.8), 80, ColorF(1,1,1,0.8), ColorF(0,0,0,1), ColorF(0,0,0,1), 30)
debugDrawer:drawLineInstance(pos + vec3(0,0,-3), pos + vec3(0,0,0.4), 5, ColorF(0,0,0,1))
debugDrawer:drawLineInstance(pos + vec3(0,0,-0.4), pos + vec3(0,0,0.4), 80, ColorF(1,1,1,0.8), 80, ColorF(1,1,1,0.8), ColorF(0,0,0,1), ColorF(0,0,0,1), 30)
debugDrawer:drawLineInstance(pos + vec3(0,0,-3), pos + vec3(0,0,0.4), 5, ColorF(0,0,0,1))
debugDrawer:drawLineInstance(pos + vec3(0,0,-0.4), pos + vec3(0,0,0.4), 80, ColorF(1,1,1,0.8), 80, ColorF(1,1,1,0.8), ColorF(0,0,0,1), ColorF(0,0,0,1), 30)
debugDrawer:drawDot(pos + vec3(0,0, 0.4), 56, ColorF(0,0,0,1))
debugDrawer:drawDot(pos + vec3(0,0, 0.4), 50, signalColors[signalMode][1])
debugDrawer:drawDot(pos + vec3(0,0, 0.4), 56, ColorF(0,0,0,1))
debugDrawer:drawDot(pos + vec3(0,0, 0.4), 50, signalColors[signalMode][1])
debugDrawer:drawDot(pos , 56, ColorF(0,0,0,1))
debugDrawer:drawDot(pos , 50, signalColors[signalMode][2], ColorF(0,0,0,1), 1.2)
debugDrawer:drawDot(pos + vec3(0,0,-0.4), 56, ColorF(0,0,0,1))
debugDrawer:drawDot(pos + vec3(0,0,-0.4), 50, signalColors[signalMode][3], ColorF(0,0,0,1), 1.2)
debugDrawer:drawDot(pos + vec3(0,0,-0.4), 56, ColorF(0,0,0,1))
debugDrawer:drawDot(pos + vec3(0,0,-0.4), 50, signalColors[signalMode][3], ColorF(0,0,0,1), 1.2)
useDepth = true
simDrawOffset = simDrawOffset + vec3(5, 0, 0)
updateSim(0)
updateSim(0)
simDrawOffset = simDrawOffset - vec3(5, 0, 0)
--testGrid(dtSim)
signalTimer = signalTimer + dtSim
--drawSignal(origin + vec3(-2,0,3))
--debugDrawer:drawLineInstance(origin + vec3(0, 0, 0), origin + vec3(0, 0, 500), 30, ColorF(1, 0, 1, 1))
end
--debugDrawer:drawLineInstance(origin + vec3(0, 0, 0), origin + vec3(0, 0, 500), 30, ColorF(1, 0, 1, 1))
end
@/lua/ge/extensions/career/modules/playerDriving.lua
local path = { looped = false, manualFov = false}
local startPos = core_camera.getPosition() + vec3(0,0,30)
@/lua/ge/extensions/flowgraph/nodes/ui/imgui/elemental/imBegin.lua
local windowPos
local sPos = vec3(x, y)
if anchor == "TL" then
@/lua/ge/extensions/editor/gen/world.lua
build_radius = 100,
gen_center = vec3(0,0,0),
-- city sector
terrBlock:setPosition(vec3(terrainImpExp.transformPos.x[0], terrainImpExp.transformPos.y[0], terrainImpExp.transformPos.z[0]))
local om = createObject("ProceduralMesh")
om:setPosition(vec3(0,0,0))
om.isMesh = true
if ima == 1 then
ddae[p].front = vec3(0,1,0)
ddae[p].inout = -ddae[p].fr.y
if ima == 2 then
ddae[p].front = vec3(-1,0,0)
ddae[p].inout = -ddae[p].to.x
ddae[p].len = math.abs(ddae[p].fr.z-ddae[p].to.z)
ddae[p].dir = vec3(0,0,1)
end
end
W.ui.gen_center = vec3(apos[1]+L/2,apos[2]+L/2,apos[3])
if desc.prn then
p = p + adesc[desc.prn].pos + vec3(0,0,forHeight(adesc[desc.prn].afloor, desc.floor-1))
end
return p + desc.pos + desc.afloor[ij[1]].pos + vec3(0,0,forHeight(desc.afloor, ij[1]-1))
end
return vec3((p - orig):dot(un), (p - orig):dot(vn), 0)
end
local vup = fortop and vec3(0,0,desc.afloor[ij[1]].h) or vec3(0,0,0)
local u = desc.afloor[ij[1]].awall[ij[2]].u
local vup = fortop and vec3(0,0,desc.afloor[ij[1]].h) or vec3(0,0,0)
local u = desc.afloor[ij[1]].awall[ij[2]].u
local u = desc.afloor[ij[1]].awall[ij[2]].u
local vp = u:cross(vec3(0,0,1))
local d = intersectsRay_Plane(ray.pos, ray.dir,
for i,h in pairs(c) do
tb:setHeightWs(vec3(j,i), h)
end
end
shmap[x][y] = core_terrain.getTerrainHeight(vec3(x,y))
end
for k,f in pairs(dhide) do
f:setPosition(f:getPosition()+vec3(0,0,-100))
editor.updateForestItem(fdata, f:getKey(), f:getPosition(), f:getData(), f:getTransform(), 1, f:getUid())
if U._PRD == 0 and W.ui.injunction then
scenetree.findObject("thePlayer"):setPosition(vec3(0, 0, core_terrain.getTerrainHeight(vec3(0,0))))
end
if U._PRD == 0 and W.ui.injunction then
scenetree.findObject("thePlayer"):setPosition(vec3(0, 0, core_terrain.getTerrainHeight(vec3(0,0))))
end
local mtx = MatrixF(true)
-- mtx:setFromEuler(vec3(math.pi,0,0))
local mrotx = MatrixF(true)
local mrotx = MatrixF(true)
mrotx:setFromEuler(vec3(vang.x, 0, 0))
local mroty = MatrixF(true)
local mroty = MatrixF(true)
mroty:setFromEuler(vec3(0, vang.y, 0))
mtx:setFromEuler(vec3(0, 0, vang.z))
mtx:mul(mrotx)
aforest[#aforest+1] = {dae=sdata.def[tp].dae, type=tp,
p=vec3(d,bot)}
d = d + space
ahole[#ahole+1] = {p=d.p, w=w, list=d.list or {
vec3(0,-0.01),vec3(w,-0.01),vec3(w,h),vec3(0,h)
}}
ahole[#ahole+1] = {p=d.p, w=w, list=d.list or {
vec3(0,-0.01),vec3(w,-0.01),vec3(w,h),vec3(0,h)
}}
ahole[#ahole+1] = {p=d.p, w=w, list=d.list or {
vec3(0,-0.01),vec3(w,-0.01),vec3(w,h),vec3(0,h)
}}
ahole[#ahole+1] = {p=d.p, w=w, list=d.list or {
vec3(0,-0.01),vec3(w,-0.01),vec3(w,h),vec3(0,h)
}}
-- spline wall
local mbody,afpos,invalid = M.frameSpline({vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},ahole,ap,adist,astep)
if not mbody then return end
-- spline wall
local mbody,afpos,invalid = M.frameSpline({vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},ahole,ap,adist,astep)
if not mbody then return end
-- spline wall
local mbody,afpos,invalid = M.frameSpline({vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},ahole,ap,adist,astep)
if not mbody then return end
-- spline wall
local mbody,afpos,invalid = M.frameSpline({vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},ahole,ap,adist,astep)
if not mbody then return end
local dae = ddae[d.dae]
local scale = vec3(
ahole[i].w/(dae.to.x-dae.fr.x-margin),1,
for i,d in pairs(afpos) do
aforest[i].pos = (d[1]+d[2])/2 + vec3(0,0,d[3].y)
end
desc.pos + un*pos + U.vturn(ddae[dae].front, -a)*ddae[dae].inout, -- (ax[#ax] + 0)/X + desc.v*0/Y,
vec3(0,0,a), cforest, vec3(1, scale, scalez)) -- un*scale)
pos = pos + ddae[dae].len*scale
desc.pos + un*pos + U.vturn(ddae[dae].front, -a)*ddae[dae].inout, -- (ax[#ax] + 0)/X + desc.v*0/Y,
vec3(0,0,a), cforest, vec3(1, scale, scalez)) -- un*scale)
pos = pos + ddae[dae].len*scale
local newW = desc.u:length() - 2*desc.winleft
scale = vec3(newW/winW,scale,scale)
winW = newW
desc.pos + un * (ax[#ax] + doorW/2 - margin) + vn * doorbot,
vec3(0,0,ang), cforest)
if desc.doorstairs and desc.doorstairs[desc.doorind] then
desc.pos + un * (ax[#ax] + doorW/2 - margin) + vn * (doorbot-default.doorbot),
vec3(0,0,ang-math.pi/2), cforest
)
arc[#arc+1] = {
vec3(ax[#ax-1], desc.doorbot,0),
vec3(ax[#ax], desc.doorbot,0),
vec3(ax[#ax-1], desc.doorbot,0),
vec3(ax[#ax], desc.doorbot,0),
vec3(ax[#ax], desc.doorbot + doorH - margin,0),
vec3(ax[#ax], desc.doorbot,0),
vec3(ax[#ax], desc.doorbot + doorH - margin,0),
vec3(ax[#ax-1], desc.doorbot + doorH - margin,0),
vec3(ax[#ax], desc.doorbot + doorH - margin,0),
vec3(ax[#ax-1], desc.doorbot + doorH - margin,0),
}
desc.pos + desc.u*(ax[#ax] + winw/2 - margin + ds)/X + desc.v*(winbotc+dz)/Y,
vec3(0,0,ang), cforest, scale, wi) -- dscale[desc.win])
if cedit.fscope == 1 and editkey and wi == editkey then -- not out.editkey then
arc[#arc+1] = {
vec3(ax[#ax-1]+ds+dw, wb + margin,0),
vec3(ax[#ax]+ds-dw,wb + margin,0),
vec3(ax[#ax-1]+ds+dw, wb + margin,0),
vec3(ax[#ax]+ds-dw,wb + margin,0),
vec3(ax[#ax]+ds-dw,wb + margin + winh - 2*margin,0),
vec3(ax[#ax]+ds-dw,wb + margin,0),
vec3(ax[#ax]+ds-dw,wb + margin + winh - 2*margin,0),
vec3(ax[#ax-1]+ds+dw,wb + margin + winh - 2*margin,0),
vec3(ax[#ax]+ds-dw,wb + margin + winh - 2*margin,0),
vec3(ax[#ax-1]+ds+dw,wb + margin + winh - 2*margin,0),
}
local w,h = U.rcWH(b.base)
local scale = vec3((w+0*margin)/doorW, 1, (h+0*margin)/doorH)
scale.x = (w+2*margin*scale.x)/doorW
+ vn*math.min(b.base[1].y,b.base[2].y),
vec3(0,0,ang), cforest, scale)
end
end
local pos = U.proj2D(desc.pos) + vec3(0,0,hfr) + unorm*margin
pos.z = bdesc.pos.z + hfr
local ckey = to(desc, desc.pilaster.dae,
pos, vec3(0,0,ang), cforest,
vec3(1,1,scale)
pos, vec3(0,0,ang), cforest,
vec3(1,1,scale)
)
margin = -(ddae[desc.pilaster.dae].to.x - ddae[desc.pilaster.dae].fr.x)/2
pos = U.proj2D(desc.pos) + vec3(0,0,hfr) + desc.u + unorm*margin
pos.z = bdesc.pos.z + hfr
pos,
vec3(0,0,ang), cforest, vec3(1,1,scale)
)
pos,
vec3(0,0,ang), cforest, vec3(1,1,scale)
)
-- place pillars
local dpos = vec3(
(ddae[desc.pillar.dae].to.x - ddae[desc.pillar.dae].fr.x)/2,
end
local vn = vec3(-desc.u.y,desc.u.x):normalized()
local scale = desc.pillar.down/(ddae[desc.pillar.dae].to.z - ddae[desc.pillar.dae].fr.z)
desc.pos + (marginLeft + (i-1)*step)*desc.u:normalized()
- vec3(0,0,desc.pillar.down) - vn*(desc.pillar.inout or 0), -- dpos, -- + vec3(0,2,0),-- + un * (ax[#ax] + doorW/2 - margin) + vn * doorbot,
vec3(0,0,ang), cforest, vec3(1,1,scale))
desc.pos + (marginLeft + (i-1)*step)*desc.u:normalized()
- vec3(0,0,desc.pillar.down) - vn*(desc.pillar.inout or 0), -- dpos, -- + vec3(0,2,0),-- + un * (ax[#ax] + doorW/2 - margin) + vn * doorbot,
vec3(0,0,ang), cforest, vec3(1,1,scale))
- vec3(0,0,desc.pillar.down) - vn*(desc.pillar.inout or 0), -- dpos, -- + vec3(0,2,0),-- + un * (ax[#ax] + doorW/2 - margin) + vn * doorbot,
vec3(0,0,ang), cforest, vec3(1,1,scale))
end
- vec3(0,0,desc.pillar.down) - vn*(desc.pillar.inout or 0), -- dpos, -- + vec3(0,2,0),-- + un * (ax[#ax] + doorW/2 - margin) + vn * doorbot,
vec3(0,0,ang), cforest, vec3(1,1,scale))
end
local wpos = dforest[key].item:getPosition()
to(desc, desc.balcony.dae, wpos + vec3(0,0,desc.balcony.bottom or 0), vec3(0,0,-ang),
nil, scale)
local wpos = dforest[key].item:getPosition()
to(desc, desc.balcony.dae, wpos + vec3(0,0,desc.balcony.bottom or 0), vec3(0,0,-ang),
nil, scale)
lo('??^^^^^^^^^^^^^^_____________ border:'..tostring(m.front)..':'..adesc[cedit.mesh].id,nil,2) --..':'..tostring(desc[tp].daecorner)..' a:'..a..':'..tostring(desc.ij[2]))
local shift = alod[1].pos or vec3(0,0,0)
local am = {alod[1].list[1].m}
M.flipSide(am[1].faces, am[1].normals)
local ref = vec3(0,0,0)
local scale = math.sin(math.pi/4)/math.sin(math.pi/4 + desc[tp].skew)
local a = desc[tp].skew
local ang = U.vang(vec3(1,1,0),U.proj2D(v),true)
a = ang>0 and a or -a
a = ang>0 and a or -a
if U.toLine(U.proj2D(v),{vec3(0,0),vec3(1,1)}) > small_dist then
local x,y = U.lineCross(U.proj2D(v),U.proj2D(v)+(ang<0 and vec3(1,0) or vec3(0,1)),vec3(0,0),vec3(1,1))
a = ang>0 and a or -a
if U.toLine(U.proj2D(v),{vec3(0,0),vec3(1,1)}) > small_dist then
local x,y = U.lineCross(U.proj2D(v),U.proj2D(v)+(ang<0 and vec3(1,0) or vec3(0,1)),vec3(0,0),vec3(1,1))
if U.toLine(U.proj2D(v),{vec3(0,0),vec3(1,1)}) > small_dist then
local x,y = U.lineCross(U.proj2D(v),U.proj2D(v)+(ang<0 and vec3(1,0) or vec3(0,1)),vec3(0,0),vec3(1,1))
ref = vec3(x,y)
if U.toLine(U.proj2D(v),{vec3(0,0),vec3(1,1)}) > small_dist then
local x,y = U.lineCross(U.proj2D(v),U.proj2D(v)+(ang<0 and vec3(1,0) or vec3(0,1)),vec3(0,0),vec3(1,1))
ref = vec3(x,y)
if U.toLine(U.proj2D(v),{vec3(0,0),vec3(1,1)}) > small_dist then
local x,y = U.lineCross(U.proj2D(v),U.proj2D(v)+(ang<0 and vec3(1,0) or vec3(0,1)),vec3(0,0),vec3(1,1))
ref = vec3(x,y)
if U.toLine(U.proj2D(v),{vec3(0,0),vec3(1,1)}) > small_dist then
local x,y = U.lineCross(U.proj2D(v),U.proj2D(v)+(ang<0 and vec3(1,0) or vec3(0,1)),vec3(0,0),vec3(1,1))
ref = vec3(x,y)
local x,y = U.lineCross(U.proj2D(v),U.proj2D(v)+(ang<0 and vec3(1,0) or vec3(0,1)),vec3(0,0),vec3(1,1))
ref = vec3(x,y)
am[1].verts[i] = ref*scale + U.vturn(v-ref, a)
else
am[1].verts[i] = U.proj2D(am[1].verts[i])*scale + vec3(0,0,am[1].verts[i].z)
end
for i,n in pairs(am[1].normals) do
local ang = U.vang(vec3(1,1,0),n)
local da = ang < 0 and desc[tp].skew or -desc[tp].skew
local key = to(desc, desc[tp].daecorner,
pos, vec3(0,0,a), cforest)
lo('?? if_CORNER:'..tostring(key)..':'..fout..':'..desc[tp].daecorner)
local key = to(desc, desc[tp].daecorner,
pos, vec3(0,0,a), cforest)
-- if cedit.forest then
-- FIRESTAIRS
local ang = U.vang(desc.u,vec3(1,0,0),true)
if desc.firestairs and desc.firestairs.yes then
to(desc, desc.firestairs.dae, pos,
vec3(0,0,ang), cforest, scale)
end
if desc.ij[1] < #bdesc.afloor then
to(desc, desc.firestairs.daestairs, pos+vec3(0,0,desc.v:length()),
vec3(0,0,ang), cforest, vec3(scalestairs,1,scalestairs))
to(desc, desc.firestairs.daestairs, pos+vec3(0,0,desc.v:length()),
vec3(0,0,ang), cforest, vec3(scalestairs,1,scalestairs))
end
to(desc, desc.firestairs.daestairs, pos+vec3(0,0,desc.v:length()),
vec3(0,0,ang), cforest, vec3(scalestairs,1,scalestairs))
end
local list = M.fillSegment(
pos + vec3(0,0,ddae[daecap].len+bdesc.pos.z),
pos + vec3(0,0,desc.pos.z + desc.v:length()), ddae[dae], ang, true)
pos + vec3(0,0,ddae[daecap].len+bdesc.pos.z),
pos + vec3(0,0,desc.pos.z + desc.v:length()), ddae[dae], ang, true)
if list then
end
to(desc, daecap, pos+vec3(0,0,-ddae[daecap].fr.z+bdesc.pos.z),
vec3(0,0,ang), cforest)
to(desc, daecap, pos+vec3(0,0,-ddae[daecap].fr.z+bdesc.pos.z),
vec3(0,0,ang), cforest)
end
end
local dpos = vec3(0,0,0)
local gmargin = bdesc.afloor[#bdesc.afloor].top.margin
to(desc, desc.stringcourse.daecorner,
pos, vec3(0,0,a+math.pi), cforest)
end
mbody,mh,ae,apath,albl = M.rcPave({
vec3(0,0,0),
vec3(desc.u:length(),0,0),
vec3(0,0,0),
vec3(desc.u:length(),0,0),
vec3(desc.u:length(),desc.v:length(),0),
vec3(desc.u:length(),0,0),
vec3(desc.u:length(),desc.v:length(),0),
vec3(0,desc.v:length(),0),
vec3(desc.u:length(),desc.v:length(),0),
vec3(0,desc.v:length(),0),
}, arc, {uvref,scale}) --, desc.ij[2]==2 and true or false) -- {arc[1],arc[2],arc[3],arc[4],arc[5],arc[6]}) -- arc)
if dir == 0 then
v2 = v1 + (v1 - base[i]):cross(vec3(0,0,1))
end
local x, y = U.lineCross(v1, v2, a, b)
local v = vec3(x, y, 0)
if dbg then lo('?? a_b:'..j..':'..tostring(a)..':'..tostring(b)..':'..tostring(x)..':'..tostring(y)) end
for _,v in pairs(b1) do
out.avedit[#out.avedit + 1] = v + vec3(0,0,1)
end
for i,b in pairs(cbase) do
base[#base+1] = vec3(b.x,b.y)
end
W.atParent = function(desc)
if not desc.prn then return vec3(0,0,0) end
return adesc[desc.prn].pos + vec3(0,0,forHeight(adesc[desc.prn].afloor,desc.floor-1))
if not desc.prn then return vec3(0,0,0) end
return adesc[desc.prn].pos + vec3(0,0,forHeight(adesc[desc.prn].afloor,desc.floor-1))
end
if (cedit.fscope ~= 1 or cedit.forest==d.key) and d.pos then
out.avedit[#out.avedit + 1] = d.pos+vec3(0,0,H) -- dforest[d.key].item:getPosition()
afspline[#afspline+1] = d.key
for i,b in pairs(desc.aspline[ij[1]][ij[2]].base) do
out.dyell[ij[1]][i] = {b+vec3(0,0,H),b+vec3(0,0,H+desc.afloor[ij[1]].h)}
end
for i,b in pairs(desc.aspline[ij[1]][ij[2]].base) do
out.dyell[ij[1]][i] = {b+vec3(0,0,H),b+vec3(0,0,H+desc.afloor[ij[1]].h)}
end
local h = ddae[forestMeshName].to.z - ddae[forestMeshName].fr.z
out.avedit[#out.avedit + 1] = dforest[key].item:getPosition() + vec3(0,0,h)
end
local h = ddae[d].to.z - ddae[d].fr.z
out.avedit[#out.avedit + 1] = dforest[key].item:getPosition() + vec3(0,0,h)
end
local ps, u = desc.pos+desc.afloor[ij[1]].pos+base[ij[2]]+vec3(0,0,(w.pos-desc.pos).z), U.mod(ij[2]+1,base)-base[ij[2]]
local inspline = false
if w.df[w.win] then
local vn = w.u:cross(vec3(0,0,1)):normalized()
for _,key in ipairs(w.df[w.win]) do
if cedit.fscope ~= 1 or key == cedit.forest then
out.avedit[#out.avedit + 1] = dforest[key].item:getPosition() + vec3(0,0,h) + vn*math.abs(ddae[forestMeshName].fr.y)
end
if cedit.fscope ~= 1 or key == cedit.forest then
out.avedit[#out.avedit + 1] = dforest[key].item:getPosition() + vec3(0,0,h)
end
local daedata = ddae[forestMeshName]
local w = vec3(w.u.y, -w.u.x):normalized()
out.aforest[#out.aforest] = out.aforest[#out.aforest] + w*math.abs(daedata.fr.x-daedata.to.x)/2 -- + daePath[forestMeshName]
if #U.index(cedit.aforest, d.key)>0 then
out.avedit[#out.avedit + 1] = d.pos+vec3(0,0,H) -- dforest[d.key].item:getPosition()
end
for _,p in pairs(base) do
pth[#pth+1] = adesc[cedit.mesh].pos + floor.pos + p + vec3(0,0,h+(child.fat or 0)) + posplus
end
end
pth[#pth+1] = adesc[cedit.mesh].pos + floor.pos + base[1] + vec3(0,0,h+(child.fat or 0)) + posplus
out.fmtop = {pth}
for _,p in pairs(base) do
pth[#pth+1] = adesc[cedit.mesh].pos + floor.pos + p + vec3(0,0,h+(floor.top.fat or 0)) + posplus
end
end
pth[#pth+1] = adesc[cedit.mesh].pos + floor.pos + base[1] + vec3(0,0,h+(floor.top.fat or 0)) + posplus
out.fmtop = {pth}
for _,key in ipairs(desc.df[desc.roofborder[1]]) do
out.avedit[#out.avedit + 1] = dforest[key].item:getPosition() + vec3(0,0,0.1)
end
if v1:length() == 0 then
v1 = v2:cross(vec3(0,0,1))
end
if v2:length() == 0 then
v2 = v1:cross(vec3(0,0,1))
end
local u = base[ifirst % #base + 1] - ps
local v = (base[(ifirst + 2) % #base + 1] - ps)/2 + vec3(0,0,tip/1)
local function roofPlate(p, u, v, h, mskip, fskip)
v = v + vec3(0, 0, h)
-- build grid
u = floor.awall[1].u:normalized()*u:length()
local v = vec3(-u.y, u.x)
floor.base = {floor.base[1]}
an = {vec3(0,0,1)}
for i=1,#av,4 do
-- lift ridge vertices
av[i+2] = av[i+2] + vec3(0,0,desctop.tip)
av[i+3] = av[i+3] + vec3(0,0,desctop.tip)
av[i+2] = av[i+2] + vec3(0,0,desctop.tip)
av[i+3] = av[i+3] + vec3(0,0,desctop.tip)
-- set uvs for plates
local ibase = apair[1][1]
local cp = floor.base[ibase] + vec3(0,0,h)
local dh = U.linePlaneHit({cp, cp+vec3(0,0,1)}, {
local cp = floor.base[ibase] + vec3(0,0,h)
local dh = U.linePlaneHit({cp, cp+vec3(0,0,1)}, {
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[2]+vec3(0,0,h)},
local dh = U.linePlaneHit({cp, cp+vec3(0,0,1)}, {
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[2]+vec3(0,0,h)},
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[6]+vec3(0,0,h)}})
local dh = U.linePlaneHit({cp, cp+vec3(0,0,1)}, {
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[2]+vec3(0,0,h)},
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[6]+vec3(0,0,h)}})
local dh = U.linePlaneHit({cp, cp+vec3(0,0,1)}, {
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[2]+vec3(0,0,h)},
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[6]+vec3(0,0,h)}})
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[2]+vec3(0,0,h)},
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[6]+vec3(0,0,h)}})
--TODO:
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[2]+vec3(0,0,h)},
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[6]+vec3(0,0,h)}})
--TODO:
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[2]+vec3(0,0,h)},
{av[1]+vec3(0,0,h), av[3]+vec3(0,0,h), av[6]+vec3(0,0,h)}})
--TODO:
for i=1,#av do
av[i] = av[i] + desc.pos + floor.pos + vec3(0,0,h-dh)
end
if not tip then tip = tipDefualt(floor) end
local top = center + tip*vec3(0,0,1)
local vtip = center + 1*tip*vec3(0,0,1) + vec3(0,0,h) --+ pos
local top = center + tip*vec3(0,0,1)
local vtip = center + 1*tip*vec3(0,0,1) + vec3(0,0,h) --+ pos
av, af, an, auv = {vtip + pos},{},{},{} -- 1st av is tip!
local top = center + tip*vec3(0,0,1)
local vtip = center + 1*tip*vec3(0,0,1) + vec3(0,0,h) --+ pos
av, af, an, auv = {vtip + pos},{},{},{} -- 1st av is tip!
av[#av + 1] = base[i] + pos + vec3(0,0,h)
local sign = 1 -- (i == 1 or i == 4) and -1 or 1
local d = U.toLine(center, {base[i], U.mod(i+1,base)})
auv[#auv + 1] = {u = side - math.sqrt(((center-base[i]):length())^2-d^2), v = -vec3(d,tip):length()}
auv[#auv + 1] = {u = 0, v = 0}
if desctop.mat == 'm_roof_slates_ochre_bat' then -- or desctop.mat == 'm_roof_slates_rounded_bat' then
local w = (center-base[i]+vec3(0,0,tip)):normalized()
local u = w:cross(vec3(0,0,1)):normalized()
local w = (center-base[i]+vec3(0,0,tip)):normalized()
local u = w:cross(vec3(0,0,1)):normalized()
local v = u:cross(w)
}
am[#am+1] = M.forBeam(poly,(base[i]-center+vec3(0,0,tip)):length()-ridgeMargin,true,desctop.mat,w)
end
lo('?? idh:'..idh..':'..tostring(sbase[idh]))
local d1 = intersectsRay_Plane(sbase[idh], vec3(0,0,1), top, (top-U.mod(idh,base)):cross(U.mod(idh+1,base)-U.mod(idh,base)))
local d2 = intersectsRay_Plane(sbase[idh], vec3(0,0,1), top, (top-U.mod(idh,base)):cross(U.mod(idh-1,base)-U.mod(idh,base)))
local d1 = intersectsRay_Plane(sbase[idh], vec3(0,0,1), top, (top-U.mod(idh,base)):cross(U.mod(idh+1,base)-U.mod(idh,base)))
local d2 = intersectsRay_Plane(sbase[idh], vec3(0,0,1), top, (top-U.mod(idh,base)):cross(U.mod(idh-1,base)-U.mod(idh,base)))
local dh = math.min(d1,d2)
local hpre = forHeight(desc.afloor, ifloor-1)
av[k] = av[k] - vec3(0,0,dh) -- vec3(0,0,dh + hpre) --+ floor.pos --s-h-0.1)
end
local hpre = forHeight(desc.afloor, ifloor-1)
av[k] = av[k] - vec3(0,0,dh) -- vec3(0,0,dh + hpre) --+ floor.pos --s-h-0.1)
end
for i=1,#m.verts do
m.verts[i] = m.verts[i] + pos + vec3(0,0,h-dh+desctop.fat)
end
local u = (U.mod(ifirst+1,base)-U.mod(ifirst,base)):normalized()
local v = vec3(-u.y, u.x, 0)
av,af,auv,an = {},{},{},{} --{vec3(0,0,1)}
local v = vec3(-u.y, u.x, 0)
av,af,auv,an = {},{},{},{} --{vec3(0,0,1)}
-- get normal and shift
an = {u:cross(av[i]+vec3(0,0,dh)-U.mod(ifirst,base)):normalized()}
dfit = margin*dh/d
end
av[i] = av[i] + vec3(0,0,dh)
sbase[i] = sbase[i] + vec3(0,0,sdh)
av[i] = av[i] + vec3(0,0,dh)
sbase[i] = sbase[i] + vec3(0,0,sdh)
else
for i=1,#av do
av[i] = av[i] + desc.pos + floor.pos + vec3(0,0,h-dfit)
sbase[i] = sbase[i] + desc.pos + floor.pos + vec3(0,0,h)
av[i] = av[i] + desc.pos + floor.pos + vec3(0,0,h-dfit)
sbase[i] = sbase[i] + desc.pos + floor.pos + vec3(0,0,h)
if i > 1 then
p = U.polyStraighten({
sbase[i-1] - vec3(0,0,asdh[i-1]),
sbase[i] - vec3(0,0,asdh[i]),
sbase[i-1] - vec3(0,0,asdh[i-1]),
sbase[i] - vec3(0,0,asdh[i]),
sbase[i],
p = U.polyStraighten({
sbase[#av] - vec3(0,0,asdh[#av]),
sbase[1] - vec3(0,0,asdh[1]),
sbase[#av] - vec3(0,0,asdh[#av]),
sbase[1] - vec3(0,0,asdh[1]),
sbase[1],
for i=1,#av do
av[i] = av[i] + desc.pos + floor.pos + vec3(0,0,h)
end
for i=1,#d.av do
d.av[i] = d.av[i] + desc.pos + floor.pos + vec3(0,0,h)
sdata[n].av[i] = sdata[n].av[i] + desc.pos + floor.pos + vec3(0,0,h)
d.av[i] = d.av[i] + desc.pos + floor.pos + vec3(0,0,h)
sdata[n].av[i] = sdata[n].av[i] + desc.pos + floor.pos + vec3(0,0,h)
end
end
d.r = math.abs((d.av[1]-d.av[3]):dot((d.av[1]-d.av[4]):cross(vec3(0,0,1)):normalized()))
local ctip = tip * d.r/7.
for k=2,#d.av,3 do
d.av[k] = d.av[k] + vec3(0,0,ctip)
if n == 1 and k == 2 then
local ic = apair[1][1]
dh = intersectsRay_Plane(sdata[n].av[1], vec3(0,0,1),
d.av[2], (d.av[2]-d.av[1]):cross(d.av[4]-d.av[1]))
sdata[n].av[k] = sdata[n].av[k] + vec3(0,0,ctip-dh)
local ind = k == 2 and U.mod(apair[(n+1)/2][1]-1+ifirst-1,#cbase) or U.mod(apair[(n+1)/2][2]-1+ifirst-1,#cbase)
for i=1,#d.av do
d.av[i] = d.av[i] - vec3(0,0,dh) + pp
end
if not floor.top.ridge.on then
av,af,an,auv = {},{},{vec3(0,0,1)},{}
local arc = coverUp(base)
local u = (base[2]-base[1]):normalized()
local v = vec3(-u.y, u.x, 0)
local ref = base[1]
U.dump(av, '?? paved:')
an = {vec3(0,0,1)}
end
for i=1,#av do
av[i] = av[i] + desc.pos + floor.pos + vec3(0,0,h)
end
for i,_ in pairs(av) do
av[i] = av[i] + prn.pos + vec3(0,0,H)
end
--- a
local an = {u:cross(vec3(0,0,1)):normalized()}
local ang = math.atan2(-an[1].y, an[1].x) - math.pi/2
for j = 1,n do
local itemkey = to(desctop, rbdae, p, vec3(0,yng,ang), cforest, scale)
p = p + (l - dl)*u
--- a
local an = {u:cross(vec3(0,0,1)):normalized()}
local ang = math.atan2(-an[1].y, an[1].x) - math.pi/2
for j = 1,n do
local itemkey = to(desctop, rbdae, p, vec3(bng,0,ang), cforest, scale)
p = p + (l - dl)*u
local dz = aforest[fi].type == 'win' and -ddae[wall.win].fr.z*(aforest[fi].scale and aforest[fi].scale.z or 1) or 0
local ang = 0*math.pi + U.vang(d[2]-d[1],vec3(1,0,0),true)
-- lo('?? for_ff:'.._..':'..tostring(desc.aspline[i][k]))
-- local key = to(desc.aspline[i][k], aforest[fi].dae,
aforest[fi].pos+vec3(0,0,dz+cheight),
vec3(0,0,ang), nil, aforest[fi].scale)
aforest[fi].pos+vec3(0,0,dz+cheight),
vec3(0,0,ang), nil, aforest[fi].scale)
if aforest[fi].update then
end
-- local key = to(desc.aspline[i][k], aforest[fi].dae, (d[1]+d[2])/2+vec3(0,0,d[3].y+dz+cheight), vec3(0,0,ang))
if cedit.aforest and #U.index(cedit.aforest,aforest[fi].key)>0 then
end
-- local key = to(desc.aspline[i][k], aforest[fi].dae, (d[1]+d[2])/2+vec3(0,0,d[3].y+dz+cheight), vec3(0,0,ang))
if cedit.aforest and #U.index(cedit.aforest,aforest[fi].key)>0 then
w.ij = {i,j}
w.v = vec3(0, 0, f.h)
w.pos = p + vec3(0, 0, cheight) -- p changes for walls
w.v = vec3(0, 0, f.h)
w.pos = p + vec3(0, 0, cheight) -- p changes for walls
local spillarInout = w.pillar and w.pillar.inout or nil
prn = prn or adesc[desc.prn]
w.pos = w.pos + vec3(0, 0, forHeight(prn.afloor, desc.floor-1))
end
-- end
w.v = vec3(0, 0, H/spany)
if j > 1 then
for ie,v in pairs(rc) do
rc[ie] = rc[ie] - vec3(ds,f.h,0) -- (U.mod(j+1,f.base) - f.base[j]):normalized()*ds
end
we.arcext[#we.arcext+1] = rc
local vn = -we.u:cross(vec3(0,0,1)):normalized()
local dw = 0.2
if k < spany then
w.pos = w.pos + vec3(0,0,H/spany)
end
-- lo('?? postWU2:'..#am..':'..#av..':'..tostring(dirty))
-- wallUp(p + vec3(0, 0, cheight), w, 'o_wall_'..i..'_'..j)
-- wallUp(f.base[j] + vec3(0, 0, cheight), w, 'w'..i..j)
-- wallUp(p + vec3(0, 0, cheight), w, 'o_wall_'..i..'_'..j)
-- wallUp(f.base[j] + vec3(0, 0, cheight), w, 'w'..i..j)
-- if intopchange then
-- for j=#asi,1,-1 do
subdata.verts[#subdata.verts+1] = subdata.verts[asi[j]] + vec3(0,0,desctop.fat)
asi[#asi+1] = #subdata.verts
for i=1,#mdata.verts do
mdata.verts[i] = mdata.verts[i] + vec3(0,0,desctop.fat)
end
local u = (base[2]-base[1]):normalized()
local v = vec3(-u.y, u.x, 0)
local ref = base[1]
local av,af,auv = polyPave(f.botext or f.base,
(prn and prn.pos or vec3(0,0,0))+desc.pos+f.pos
+vec3(0,0,(hprn + cheight + 0.01)))
(prn and prn.pos or vec3(0,0,0))+desc.pos+f.pos
+vec3(0,0,(hprn + cheight + 0.01)))
--[[
]]
local an = {vec3(0,0,1)}
local mdatabot = {
if #f.top.border.shape == 0 then
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
if #f.top.border.shape == 0 then
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
if #f.top.border.shape == 0 then
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
if #f.top.border.shape == 0 then
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
if #f.top.border.shape == 0 then
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
if #f.top.border.shape == 0 then
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
end
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
end
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
end
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
end
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
end
f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(1, 1), vec3(0, 1), vec3(0, 0)} --, vec3(0, 1.5)}
-- f.top.border.shape = {vec3(0, 0), vec3(1, 0), vec3(0.8, 0.5), vec3(1, 1), vec3(0, 1)} --, vec3(0, 1.5)}
end
local iseq
local cp = vec3(1,0)
local upre = f.awall[#base].u
local upre = f.awall[#base].u
local dp = vec3(0,0,0)
if desc.prn then
if desc.prn then
dp = prn.pos + vec3(0, 0, forHeight(prn.afloor, desc.floor-1))
end
local u = f.awall[k].u:normalized()
local w = vec3(u.y,-u.x)
local ifr,ito,step = 1,#f.top.border.shape,1
-- lo('??++++ ang:'..ang..' w:'..tostring(U.vturn(w,-U.vang(upre,u)/2)),true)
avert[#avert+1] = base[k] + desc.pos + f.pos + vec3(0,0,forHeight(desc.afloor, f.ij[1]))
--base2world(desc, {i,k}) --base[k]
--base2world(desc, {i,k}) --base[k]
+ (f.top.border.height*(c.y-0.5)+f.top.border.dz)*vec3(0,0,1)
+ (f.top.border.width*(c.x-0.5)+f.top.border.dy)*U.vturn(w,-U.vang(upre,u,true)/2)+dp
local u = f.awall[k].u:normalized()
local w = vec3(u.y,-u.x)
local ifr,ito,step = 1,#f.top.border.shape,1
-- lo('??++++ ang:'..ang..' w:'..tostring(U.vturn(w,-U.vang(upre,u)/2)),true)
avert[#avert+1] = base[k] + desc.pos + f.pos + vec3(0,0,forHeight(desc.afloor, f.ij[1]))
+ (f.top.border.height*(c.y-0.5)+f.top.border.dz)*vec3(0,0,1)
avert[#avert+1] = base[k] + desc.pos + f.pos + vec3(0,0,forHeight(desc.afloor, f.ij[1]))
+ (f.top.border.height*(c.y-0.5)+f.top.border.dz)*vec3(0,0,1)
+ (f.top.border.width*(c.x-0.5)+f.top.border.dy)*U.vturn(w,-U.vang(upre,u)/2)+dp
+ (f.top.border.width*(c.x-0.5)+f.top.border.dy)*U.vturn(w,-U.vang(upre,u)/2)+dp
-- + f.top.border.height*(c.y-0.5)*vec3(0,0,1)
-- + f.top.border.width*(c.x-0.5)*U.vturn(w,-U.vang(upre,u)/2)
local u = desc.afloor[list[i][1]].awall[list[i][2]].u
local ang = U.vang(u, vec3(1,0,0), true)+math.pi/2
-- U.dump(list[i],'?? toCorner.in_STEM:'..i..tostring(base2world(desc, list[i]))..':'..list[i].dae)
base2world(desc, list[i]),
vec3(0,0,ang), cforest, vec3(1,1,scale))
end
base2world(desc, list[i]),
vec3(0,0,ang), cforest, vec3(1,1,scale))
end
base2world(desc, ij),
vec3(0,0,0), cforest, vec3(1,1,scale))
end
base2world(desc, ij),
vec3(0,0,0), cforest, vec3(1,1,scale))
end
base2world(desc,s.list[ci]),
vec3(0,0,0), nil, vec3(1,1,scale))
]]
base2world(desc,s.list[ci]),
vec3(0,0,0), nil, vec3(1,1,scale))
]]
ij = {floorn, j},
u = base[j % #base + 1] - base[j], v = vec3(0, 0, h),
mat = wdesc.mat, uv = {0, 0, 1, 1},
local function shape2base(nm)
local base = {vec3(0,0,0)}
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
local base = {vec3(0,0,0)}
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
if false then
local base = {vec3(0,0,0)}
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
if false then
-- if true then return end
if not center then center = vec3(0,0) end
-- clean folder
if istemplate then
p = vec3(0,0,0)
else
local y = center.y + math.random(2*R) - R
p = vec3(x, y)
local z = tb and core_terrain.getTerrainHeight(p) or 0
local function buildingGen(p, base, intest)
-- p = vec3(0,0,0)
-- if test(p) then return end
base = {
vec3(0, 0, 0),
vec3(-len, 0, 0),
vec3(0, 0, 0),
vec3(-len, 0, 0),
vec3(-len, -w, 0),
vec3(-len, 0, 0),
vec3(-len, -w, 0),
vec3(0, -w, 0),
vec3(-len, -w, 0),
vec3(0, -w, 0),
}
base = out.cshape and shape2base(out.cshape) or {
vec3(0, 0, 0),
vec3(-12, 0, 0),
vec3(0, 0, 0),
vec3(-12, 0, 0),
vec3(-12, -8, 0),
vec3(-12, 0, 0),
vec3(-12, -8, 0),
vec3(0, -8, 0),
vec3(-12, -8, 0),
vec3(0, -8, 0),
}
base = {
vec3(0, 0, 0),
vec3(-12, 0, 0),
vec3(0, 0, 0),
vec3(-12, 0, 0),
vec3(-12, -8, 0),
vec3(-12, 0, 0),
vec3(-12, -8, 0),
vec3(0, -8, 0),
vec3(-12, -8, 0),
vec3(0, -8, 0),
}
base = {
4*vec3(1,0,0),
4*vec3(0,1,0),
4*vec3(1,0,0),
4*vec3(0,1,0),
4*vec3(-1,0,0),
4*vec3(0,1,0),
4*vec3(-1,0,0),
4*vec3(0,-1,0),
4*vec3(-1,0,0),
4*vec3(0,-1,0),
}
base = {
vec3(-0.5,0,0),
vec3(1,0,0),
vec3(-0.5,0,0),
vec3(1,0,0),
vec3(1,2,0),
vec3(1,0,0),
vec3(1,2,0),
vec3(3,4,0),
vec3(1,2,0),
vec3(3,4,0),
vec3(5,4,0),
vec3(5,7,0),
vec3(5,4,0),
vec3(5,7,0),
vec3(3,6,0),
vec3(0,3,0),
vec3(3,6,0),
vec3(0,3,0),
}
base = {
-- vec3(-6.884427697,-8,0),
vec3(0,0,0),
-- vec3(-6.884427697,-8,0),
vec3(0,0,0),
vec3(-6.884426951,-4.768371582e-07,0),
vec3(0,0,0),
vec3(-6.884426951,-4.768371582e-07,0),
-- vec3(-6.884427697,-8,0),
vec3(-6.884426951,-4.768371582e-07,0),
-- vec3(-6.884427697,-8,0),
vec3(-6.884426198,4.08,0),
-- vec3(-6.884427697,-8,0),
vec3(-6.884426198,4.08,0),
vec3(-11.99999925,4.08,0),
vec3(-6.884426198,4.08,0),
vec3(-11.99999925,4.08,0),
vec3(-12,-8,0),
vec3(-11.99999925,4.08,0),
vec3(-12,-8,0),
vec3(0,-8,0),
vec3(-12,-8,0),
vec3(0,-8,0),
}
-- local windae = 1
local u,v = cbase[j % #cbase + 1] - cbase[j],vec3(0, 0, h)
local mwin = daewin
local dim = (base[1] - base[math.floor(#base/2)+1]):length()
afloor[#afloor + 1] = {base = U.clone(cbase), h = ch, pos = vec3(0,0,0),
awall = awall,
h = wall.v:length()
pos = wall.pos + u/2 + h/2*U.vturn(u:normalized(), -math.pi/2) + vec3(0,0,h/2)
-- render
local resX = math.floor(resY*w/h)
local defaultRes = vec3(resX, resY, 0)
local stamp = U.stamp(ij,true)
-- lo('?? for_DIR:'..tostring(wall.u)..':'..tostring(wall.v)..':'..tostring(dir))
local q = quatFromDir(dir, vec3(0,0,1))
local rot = QuatF(q.x,q.y,q.z,q.w)
local rot = QuatF(q.x,q.y,q.z,q.w)
-- rot = quatFromDir(vec3(-1,0,0), vec3(0,0,1))
local mat = rot:getMatrix()
local rot = QuatF(q.x,q.y,q.z,q.w)
-- rot = quatFromDir(vec3(-1,0,0), vec3(0,0,1))
local mat = rot:getMatrix()
local topfloor = desc.afloor[#desc.afloor]
dlod = houseUp({pos = desc.pos + vec3(0,0,0), afloor = afloor, isbox=true, basement = {yes = false}})
local dirname = editor.getLevelPath()..'bat/'
local u = (floor.base[2]-floor.base[1]):normalized()
local v = -u:cross(vec3(0,0,1))
for i,uv in pairs(mesh.uvs) do
local v = w.v:normalized()
local cds = vec3(-ds.x,ds.y,ds.z)
if isrel then
if isrel then
cds = vec3(-ds.x,ds.y,ds.z)
cds = u*cds.x+v*cds.y
lo('??__________________ to_MM:',true)
matMove(vec3(0,0),true)
end
local cvHit1,cvHit2 = nil,nil
local bpos = floor.pos + adesc[cedit.mesh].pos + vec3(0, 0, aint[1][1].z) -- basic outer position
for j,v in pairs(floor.base) do
-- local x,y = U.lineCross(base[aint[2][2]], base[aint[2][2] % #base + 1], base[cut[1][1]], base[cut[1][1]] + (aint[1][1] - aint[2][1]))
cut[#cut + 1] = {aint[2][2], vec3(x, y, 0), false}
-- cut[#cut + 1] = {aint[2][2], aint[2][1] - bpos, false}
lo('?? for_f:'..tostring(itm.visibility)..':'..tostring(itm:getData()))
-- itm:setPosition(vec3(0,0,0))
-- editor.removeForestItem(fdata, itm) -- dforest[key].item)
local f = itm
f:setPosition(f:getPosition() + vec3(0,0,-1))
editor.updateForestItem(fdata, f:getKey(), f:getPosition(), f:getData(), f:getTransform(), 1, f:getUid())
desc.afloor[ij[1]].base[ij[2]] + desc.pos + desc.afloor[ij[1]].pos,
(base[ij[2] % #base + 1] - base[ij[2]]):cross(vec3(0,0,1)))
return ray.pos + d*ray.dir
local i = floor.ij[1]
local p = base2world(desc,{i,1})+vec3(0,0,floor.h)
local phit = U.ray2plane(ray,p,vec3(0,0,1))
local p = base2world(desc,{i,1})+vec3(0,0,floor.h)
local phit = U.ray2plane(ray,p,vec3(0,0,1))
-- lo('>> ray2rc:'..i..':'..tostring(ray.dir)..':'..#floor.top.achild)
for _,b in pairs(base) do
cbase[#cbase+1] = base2world(desc,{i,1},b)+vec3(0,0,floor.h)
end
local ray = getCameraMouseRay()
local vn = vec3(0, 0, 1)
local h = forHeight(desc.afloor, ifloor)
local h = forHeight(desc.afloor, ifloor)
local d = intersectsRay_Plane(ray.pos, ray.dir, vec3(0, 0, h), vn)
local p = ray.pos + d*ray.dir - desc.pos - floor.pos
local u,v = cedit.cval['AltZ'][1],cedit.cval['AltZ'][2]
local bpos = desc.pos + desc.afloor[cij[1]].pos + vec3(0,0,forHeight(desc.afloor, cij[1]))
if cedit.cval['AltZ'][3] == nil then
if base then
local p = base2world(desc,{i,1})+vec3(0,0,f.h)
local phit = U.ray2plane(ray,p,vec3(0,0,1))
local p = base2world(desc,{i,1})+vec3(0,0,f.h)
local phit = U.ray2plane(ray,p,vec3(0,0,1))
-- U.dump(desctop.base,'??^^^^^^^^^^^^^^^^^^^^^ ifHit:'..tostring(desctop.shape)..':'..tostring(phit)..':'..tostring(p))
for _,b in pairs(base) do
cbase[#cbase+1] = base2world(desc,{i,1},b)+vec3(0,0,f.h)
end
end
-- U.ray2plane(ray,p,vec3(0,0,1))
end
for j,w in pairs(f.awall) do
-- local phit = U.ray2plane(ray,p,vec3(0,0,1))
d = intersectsRay_Triangle(ray.pos, ray.dir,
base2world(desc, {i,j}),
base2world(desc, {i}, f.base[j] + vec3(0,0,f.h)),
base2world(desc, {i,j+1}))
base2world(desc, {i,j+1}),
base2world(desc, {i}, f.base[j] + vec3(0,0,f.h)),
base2world(desc, {i}, U.mod(j+1,f.base) + vec3(0,0,f.h)))
base2world(desc, {i}, f.base[j] + vec3(0,0,f.h)),
base2world(desc, {i}, U.mod(j+1,f.base) + vec3(0,0,f.h)))
-- lo('?? if_wall_HIT2:'..j..':'..d,true)
-- local id, om = meshUp(amesh)
-- om:setPosition(vec3(0, 0, 3))
-- center for going around
ccenter = adesc[id].pos + vec3(-ext.x, -ext.y, ext.z)/2
lo('??+++++ CENTER:'..tostring(ccenter))
-- cam frame
local cx, cz = camDir:cross(vec3(0,0,1)):normalized(), camDir
local cy = cz:cross(cx)
-- local wall = floor.awall[cij[2]]
-- local u, v = wall.u:normalized(), wall.u:cross(vec3(0,0,1)):normalized()
-- projections to view plane
-- edges projections in cam coords
local upcam = vec3(up:dot(cx), up:dot(cy), 0):normalized()
local vpcam = vec3(vp:dot(cx), vp:dot(cy), 0):normalized()
local upcam = vec3(up:dot(cx), up:dot(cy), 0):normalized()
local vpcam = vec3(vp:dot(cx), vp:dot(cy), 0):normalized()
local mcam = vec3(dwin[1], dwin[2], 0)
local vpcam = vec3(vp:dot(cx), vp:dot(cy), 0):normalized()
local mcam = vec3(dwin[1], dwin[2], 0)
if mcam:length() == 0 then
va = v
vn = vec3(0,0,1)
isperp = true
for k,b in pairs(s.base) do
-- lo('?? if_NODE:'..k..':'..tostring(b+vec3(0,0,s.box.minExtents.z))..':'..tostring(b+vec3(0,0,s.box.maxExtents.z)))
if U.angDistVert(b+vec3(0,0,s.box.minExtents.z),b+vec3(0,0,s.box.maxExtents.z)) then
for k,b in pairs(s.base) do
-- lo('?? if_NODE:'..k..':'..tostring(b+vec3(0,0,s.box.minExtents.z))..':'..tostring(b+vec3(0,0,s.box.maxExtents.z)))
if U.angDistVert(b+vec3(0,0,s.box.minExtents.z),b+vec3(0,0,s.box.maxExtents.z)) then
-- lo('?? if_NODE:'..k..':'..tostring(b+vec3(0,0,s.box.minExtents.z))..':'..tostring(b+vec3(0,0,s.box.maxExtents.z)))
if U.angDistVert(b+vec3(0,0,s.box.minExtents.z),b+vec3(0,0,s.box.maxExtents.z)) then
lo('?? drag_SNODE:'..k)
-- lo('?? if_NODE:'..k..':'..tostring(b+vec3(0,0,s.box.minExtents.z))..':'..tostring(b+vec3(0,0,s.box.maxExtents.z)))
if U.angDistVert(b+vec3(0,0,s.box.minExtents.z),b+vec3(0,0,s.box.maxExtents.z)) then
lo('?? drag_SNODE:'..k)
local p = rayCast.pos
local d = intersectsRay_Plane(ray.pos, ray.dir, p, vec3(0,0,1))
lo('?? dragStart:'..tostring(p)..':'..tostring(d))
-- get mouse shift
local d = intersectsRay_Plane(ray.pos, ray.dir, cedit.cval['DragPos'].pos, vec3(0,0,1))
local dp = ray.pos + d*ray.dir - cedit.cval['DragPos'].pos
local dp = ray.pos + d*ray.dir - cedit.cval['DragPos'].pos
-- dp = vec3(1,0,0)
lo('?? for_DRAG_POS:'..tostring(dp)) --p-cedit.cval['DragPos'].pos)) --..tostring(ray.dir)..':'..tostring(cedit.cval['DragPos'].pos)..'/'..tostring(p))
-- move node
s.base[k] = cedit.cval['DragPos'].node + dp --vec3(1,0,0)
-- s.base[k] = s.base[k]+dp --vec3(1,0,0)
s.base[k] = cedit.cval['DragPos'].node + dp --vec3(1,0,0)
-- s.base[k] = s.base[k]+dp --vec3(1,0,0)
s.dirty = true
if not cedit.cval['DragPos'] then
cedit.cval['DragPos'] = {cpos = rayCast.pos, s = vec3(0,0)}
lo('?? rcp:'..tostring(rayCast.pos))
local x,y = U.proj2D(vp):length(),-vp.z
cedit.cval['DragPos'].s = cedit.cval['DragPos'].s + vec3(x,y)
lo('?? mdrag.spline_ds:'..d..':'..tostring(cedit.cval['DragPos'].s)..':'..cedit.forest) --..':'..rayCast.object.name) --..tostring(p-cedit.cval['DragPos'].mouse))
lo('?? mdrag.spline_ds:'..d..':'..tostring(cedit.cval['DragPos'].s)..':'..cedit.forest) --..':'..rayCast.object.name) --..tostring(p-cedit.cval['DragPos'].mouse))
-- cedit.cval['DragPos'].s = vec3(0,-0.2)
local ds = cedit.cval['DragPos'].s
local ds = cedit.cval['DragPos'].s
-- ds = vec3(0,-0.2)
-- U.dump(desc.aspline[ij[1]][ij[2]].aforest, '?? AF:')
d.p = cedit.cval['DragPos'].fpos + ds
-- d.p = d.p + vec3(0,-0.2)
d.update = true
local p = base2world(desc, ij)
local d = intersectsRay_Plane(ray.pos, ray.dir, p, vec3(0,0,1))
local t = ray.pos + d*ray.dir
-- local w = floor.awall[incorner[1].ij[2]]
local mdir,cmouse,isperp = mouseDir(w.u:normalized(),w.u:cross(vec3(0,0,1)):normalized())
if isperp == false then
local x,y = U.lineCross(base[ind],base[ind]+v,base[j],U.mod(j+1,base))
local d = (vec3(x,y)-base[ind]):length()
-- lo('?? for_D:'..j..' b1:'..tostring(base[j])..' b2:'..tostring(U.mod(j+1,base))..' x:'..tostring(x)..'y:'..tostring(y)..':'..tostring(base[ind])..' d:'..tostring(d))
imi = j
vmi = vec3(x,y)
end
local x,y = U.lineCross(base[ind],base[ind]+v, base[imi],U.mod(imi+1,base))
local v = vec3(x,y)
local ihit
if not cedit.cval['DragPos'].pairend then
local d = intersectsRay_Plane(ray.pos, ray.dir, p, vec3(0,0,1))
local t = ray.pos + d*ray.dir
end
-- db = vec3(0,1,0)
-- lo('?? for_db:'..tostring(db), true)
-- for k,e in pairs(out.acorner) do
-- db = vec3(0.1,0,0)
local base = desc.afloor[e.ij[1]].base
U.mod(s.to-1,base),U.mod(s.to-1,base)+u2)
-- local vc = vec3(x,y)
base[s.to] = vec3(x,y)
-- local vc = vec3(x,y)
base[s.to] = vec3(x,y)
baseOn(desc.afloor[s.floor])
lo('?? Z_dragging:'..tostring(ds)) --..':'..tostring(cameraMouseRayCast(true).object.name), true)
adesc[cedit.mesh].pos = cedit.cval['DragPos'].pos + ds:dot(vec3(0,0,1))*vec3(0,0,1)
houseUp(adesc[cedit.mesh], cedit.mesh, true)
lo('?? Z_dragging:'..tostring(ds)) --..':'..tostring(cameraMouseRayCast(true).object.name), true)
adesc[cedit.mesh].pos = cedit.cval['DragPos'].pos + ds:dot(vec3(0,0,1))*vec3(0,0,1)
houseUp(adesc[cedit.mesh], cedit.mesh, true)
local a,b = smouse,cameraMouseRayCast(false).pos
local u,v = U.proj2D(b-a),vec3(0,0,(b-a).z)
local reg = {a,a+u,b,b-u}
if not adesc[cedit.mesh].prn then
adesc[cedit.mesh].pos = cedit.cval['DragPos'].pos + vec3(-2,0,0)
indrag = false
local shift = U.proj2D(rayCast.pos - smouse)
-- shift = vec3(3,6,0) --
local side = forSide()
local c2 = cameraMouseRayCast(true).pos --rayCast.pos
local vz = (c2-c1):dot(vec3(0,0,1))*vec3(0,0,1)
local vh = c2 - (c1 + vz)
local c2 = cameraMouseRayCast(true).pos --rayCast.pos
local vz = (c2-c1):dot(vec3(0,0,1))*vec3(0,0,1)
local vh = c2 - (c1 + vz)
local center = U.boxMark(dmesh[cmesh].obj, out)
local d = intersectsRay_Plane(core_camera.getPosition(), dirhit, center, vec3(0,0,1))
cedit.cval['Drag'] = {
end
local cterrain = intersectsRay_Plane(core_camera.getPosition(), dirhit, cedit.cval['Drag'].center, vec3(0,0,1))
local dv = cterrain * dirhit - cedit.cval['Drag'].terrain
-- lo('?? mark2:'..tostring(dirhit)..':'..tostring(rayCast.normal))
-- local vx = core_camera.getForward():cross(vec3(0,0,1))
-- local vy = vx:cross(core_camera.getForward())
local vx = dirface:cross(vec3(0,0,1)):normalized()
if dirface:cross(vec3(0,0,1)):length() < 0.001 then
local vx = dirface:cross(vec3(0,0,1)):normalized()
if dirface:cross(vec3(0,0,1)):length() < 0.001 then
vx = (rayCast.pos - ccenter):normalized()
-- local vx = dirobj:cross(vec3(0,0,1)):normalized()
-- local vz = dirobj:cross(vx)
end
core_camera.setRotation(0, quatFromDir(newdir, vec3(0,0,1)))
-- lo('?? around:'..tostring(indrag))
center = base2world(desc, {1, 1}, center)
-- out.apoint = {center + vec3(0,0,1.5)}
local floor = desc.afloor[cij[1]]
local wall = desc.afloor[cij[1]].awall[cedit.cval['DragRot'].imap[pe]]
local u,v = wall.u:normalized(), wall.u:cross(vec3(0,0,1)):normalized()
local dpos, cmouse, isperp = mouseDir(u, v)
-- lo('?? for_PARALL:', true)
-- dpos = vec3(1,0,0)
-- _dbdrag = true
-- = U.mod(ij[2]+1,base) - base[ij[2]]
base[U.mod(ij[2]+1,#base)] = vec3(x,y,0) -- U.mod(ij[2]+1,base) + dpos
-- lo('?? fB:'..ij[2])
-- lo('?? FOREST_moving:'..tostring(ds)..':'..tostring(smouse), true)
-- ds = vec3(0,0,0)
if dforest[cedit.forest] and dforest[cedit.forest].type == 'win' and cij then
if wall then
local u, v = wall.u:normalized(), wall.u:cross(vec3(0,0,1)):normalized()
-- lo('?? for_dpos:'..tostring(dpos),true)
-- dpos = vec3(0,0,0)
if dpos ~= nil then
-- ami = a
local s = closestLinePoints(base[k], U.mod(k+1,base), a, a+vec3(0,0,1))
bmi = base[k] + (U.mod(k+1,base) - base[k])*s
ami = a
local s = closestLinePoints(floorpre.base[k], U.mod(k+1,floorpre.base), a, a+vec3(0,0,1))
bmi = floorpre.base[k] + (U.mod(k+1,floorpre.base) - floorpre.base[k])*s
lo('?? HIT_edge:'..dmi, true)
local s = closestLinePoints(floorpre.base[imi], U.mod(imi+1,floorpre.base), a, a+vec3(0,0,1))
-- lo('?? for_s:'..imi..':'..s)
rc[#rc+1] = world2wall(out.ahole[i], cw)
-- rc[#rc+1] = vec3((out.ahole[i] - orig):dot(un), (out.ahole[i] - orig):dot(vn), 0)
end
-- lo('?? for_p:'..tostring(cw.pos)..':'..tostring(p)..':'..tostring(cw.u)..':'..tostring(cw.v))
-- lo('?? for_p2:'..tostring(vec3(p.x*cw.u:normalized(), p.y*cw.v:normalized(),0)))
out.ahole[#out.ahole+1] = cw.pos + p.x*cw.u:normalized() + p.y*cw.v:normalized()
lo('?? to_SEED:'..tostring(rayCast.pos))
N.circleSeed(W.ui.node_n, vec3(rayCast.pos.x, rayCast.pos.y), W.ui.node_r)
N.pathsUp()
-- local id, om = meshUp(amesh)
-- om:setPosition(vec3(0, 0, 3))
for _,z in pairs({ob.minExtents.z, ob.maxExtents.z}) do
out.avedit[#out.avedit+1] = vec3(x, y, z)
end
if out.frame ~= nil then
ccenter = vec3(0,0,0)
for i = 0,1 do
if dmi < near_dist then
local s = closestLinePoints(floorpre.base[imi], U.mod(imi+1,floorpre.base), a, a+vec3(0,0,1))
-- lo('?? for_s:'..imi..':'..s)
--[[
b = base2world(desc, {cij[1]-1,1}, b) + vec3(0,0,1)
out.apoint = {b, base2world(desc, {2, 1})}
local ray = getCameraMouseRay()
local vn = vec3(0, 0, 1)
local h = forHeight(adesc[cedit.mesh].afloor)
local h = forHeight(adesc[cedit.mesh].afloor)
local d = intersectsRay_Plane(ray.pos, ray.dir, vec3(0, 0, h), vn)
local p = ray.pos + d*ray.dir - adesc[cedit.mesh].pos - lastFloor.pos
--!! intopsplit = false
-- out.avedit = {vec3(0, 0, 6)}
-- U.dump(out.avedit, '<< mup:'..#out.avedit)
--(mdata.verts[mdata.faces[face].v+1] - mdata.verts[mdata.faces[face].v+2]):cross(mdata.verts[mdata.faces[face].v+2] - mdata.verts[mdata.faces[face].v+3])}
dir = vec3(-dir.y, dir.x):normalized()
lo('?? orig:'..tostring(pos)..':'..tostring(dir))
local u = (floor.base[2] - floor.base[1]):normalized()
local v = u:cross(vec3(0,0,1)):normalized()
local cmouse, dpos
local vn = vec3(0,0,1)
local ray = getCameraMouseRay()
out.avedit = {
cmouse + (u + v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (u - v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (u + v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (u - v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (-u - v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (u - v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (-u - v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (-u + v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (-u - v)*0.2,-- + vec3(0,0,floor.top.tip),
cmouse + (-u + v)*0.2,-- + vec3(0,0,floor.top.tip),
}
local v1,v2 = U.proj2D(floor.base[j] + adesc[cedit.mesh].pos), U.proj2D(floor.base[j % #floor.base + 1] + adesc[cedit.mesh].pos)
local x,y = U.lineCross(v1, v2, cmouse, cmouse + dpos:cross(vec3(0,0,1)))
if math.abs((v1 - vec3(x,y,0)):length() + (v2 - vec3(x,y,0)):length() - (v1-v2):length()) < 0.01 then
local x,y = U.lineCross(v1, v2, cmouse, cmouse + dpos:cross(vec3(0,0,1)))
if math.abs((v1 - vec3(x,y,0)):length() + (v2 - vec3(x,y,0)):length() - (v1-v2):length()) < 0.01 then
aint[#aint + 1] = {vec3(x, y, cedit.cval['AltMove'][1]+adesc[cedit.mesh].pos.z+0.1), j}
local x,y = U.lineCross(v1, v2, cmouse, cmouse + dpos:cross(vec3(0,0,1)))
if math.abs((v1 - vec3(x,y,0)):length() + (v2 - vec3(x,y,0)):length() - (v1-v2):length()) < 0.01 then
aint[#aint + 1] = {vec3(x, y, cedit.cval['AltMove'][1]+adesc[cedit.mesh].pos.z+0.1), j}
if math.abs((v1 - vec3(x,y,0)):length() + (v2 - vec3(x,y,0)):length() - (v1-v2):length()) < 0.01 then
aint[#aint + 1] = {vec3(x, y, cedit.cval['AltMove'][1]+adesc[cedit.mesh].pos.z+0.1), j}
end
for i=1,#base do
local dir = dpos:cross(vec3(0,0,1)):normalized()
local d = U.toLine(base[i], {lmouse, lmouse+dir})
for i=1,#base do
local dir = dpos:cross(vec3(0,0,1)):normalized()
local d = U.toLine(mbase[i], {lmouse, lmouse+dir})
-- lo('?? pre_hit:'..tostring(pos)..':'..tostring(cmouse))
aint = U.polyCross(base, lmouse, dpos:cross(vec3(0,0,1)))
-- U.dump(aint, '?? wspl: pos:'..tostring(pos)..' cm:'..tostring(cmouse)..':'..#out.wsplit)
end
out.wsplit[i] = aint[i][2] + pos + vec3(0,0,cedit.cval['AltMove'][1]+adesc[cedit.mesh].pos.z+0.01)
end
if W.ui.dbg == nil then
-- local pleft,pright = U.polyCross(floor.base, cmouse, dpos:cross(vec3(0,0,1)))
-- lo('?? LR:'..tostring(pleft)..':'..tostring(pright))
-- lo('?? va:'..tostring(U.proj2D(v))..':'..tostring(U.proj2D(rayCast.pos)))
local a,b = v+vec3(0,0,H),v+vec3(0,0,H+desc.afloor[i].h)
rayCast = cameraMouseRayCast(false)
-- lo('?? va:'..tostring(U.proj2D(v))..':'..tostring(U.proj2D(rayCast.pos)))
local a,b = v+vec3(0,0,H),v+vec3(0,0,H+desc.afloor[i].h)
rayCast = cameraMouseRayCast(false)
out.asplit = {{line={
vec3(rayCast.pos.x,rayCast.pos.y,box.minExtents.z),
vec3(rayCast.pos.x,rayCast.pos.y,box.maxExtents.z)}}}
vec3(rayCast.pos.x,rayCast.pos.y,box.minExtents.z),
vec3(rayCast.pos.x,rayCast.pos.y,box.maxExtents.z)}}}
end
p = p + (d + u)*un
out.asplit[#out.asplit+1] = {ij = ij, u = d+u, line = {p, p + vec3(0,0,desc.afloor[ij[1] ].h)}}
]]
local m = dmesh[cmesh].data[1]
local center = vec3(0,0,0)
for _,v in pairs(dmesh[cmesh].apick) do
else
local center,n = vec3(0,0,0),0
local amesh = dmesh[cmesh].data
for _,w in pairs(floor.awall) do
set(w, 'v', vec3(0,0,floor.h))
w.v = vec3(0,0,floor.h)
set(w, 'v', vec3(0,0,floor.h))
w.v = vec3(0,0,floor.h)
end
if base ~= nil then
local vn = (base[ij[2] % #base + 1] - base[ij[2]]):cross(vec3(0,0,1)):normalized()
local dv = vn * 0.02 * dir
center = base2world(desc, {cij[1], 1}, center)
-- out.apoint = {center + vec3(0,0,6)}
U.dump(base, '?? to_AROUND:'..scope..':'..cij[1]..':'..tostring(center))
-- turn camera in direction of dirnew
core_camera.setRotation(0, quatFromDir(dirnew, vec3(0,0,1)))
local vp = -dir*(core_camera.getPosition() - center):cross(vec3(0,0,1)):normalized()
local posnew = center +
core_camera.setPosition(0, newpos)
core_camera.setRotation(0, quatFromDir(newdir, vec3(0,0,1)))
]]
if false then
local direction = vec3(core_camera.getForward())
local startPoint = vec3(core_camera.getPosition())
local direction = vec3(core_camera.getForward())
local startPoint = vec3(core_camera.getPosition())
lo('?? RA:'..tostring(direction)..':'..tostring(startPoint))
-- local newPos = U.vturn(U.proj2D(startPoint - direction), 0.05) + vec3(0, 0, startPoint.z)
-- core_camera.setRotation(0, vec3(0,0,math.pi/4))
-- core_camera.setRotation(0, quatFromDir(vec3(0, -10, -1),vec3(0,0,1)))
-- core_camera.setRotation(0, vec3(0,0,math.pi/4))
-- core_camera.setRotation(0, quatFromDir(vec3(0, -10, -1),vec3(0,0,1)))
core_camera.setRotation(0, quatFromDir(vec3(0, -10, 4), vec3(0,0,1)))
-- core_camera.setRotation(0, vec3(0,0,math.pi/4))
-- core_camera.setRotation(0, quatFromDir(vec3(0, -10, -1),vec3(0,0,1)))
core_camera.setRotation(0, quatFromDir(vec3(0, -10, 4), vec3(0,0,1)))
-- core_camera.setRotation(0, quatFromDir(vec3(0, -10, -1),vec3(0,0,1)))
core_camera.setRotation(0, quatFromDir(vec3(0, -10, 4), vec3(0,0,1)))
end
-- core_camera.setRotation(0, quatFromDir(vec3(0, -10, -1),vec3(0,0,1)))
core_camera.setRotation(0, quatFromDir(vec3(0, -10, 4), vec3(0,0,1)))
end
if string.find(cmd, 'building') then
local desc = buildingGen(vec3(math.random(10),math.random(10)))
lo('?? created:'..#adesc..':'..tostring(cedit.mesh)..':'..tostring(desc.id)) --..':'..adesc[1].id)
out.R.up()
-- out.R.move(vec3(0,0.2,3.5))
-- io.flush(setfile)
local r = 0.01*math.sqrt((rayCast.pos-core_camera.getPosition()):length())
debugDrawer:drawSphere(rayCast.pos + vec3(0,0,0.25), r*4, ColorF(0.3,1,0.2,.6), false)
Render.path({rayCast.pos, rayCast.pos + vec3(0,0,0.2)}, color(0,255,255,255), 3)
debugDrawer:drawSphere(rayCast.pos + vec3(0,0,0.25), r*4, ColorF(0.3,1,0.2,.6), false)
Render.path({rayCast.pos, rayCast.pos + vec3(0,0,0.2)}, color(0,255,255,255), 3)
end
base2world(desc, {ij[1], ij[2]+1})}) do
if ray2segment(ray, p, p+vec3(0,0,floor.h)) < 0.01 then
-- lo('?? edge_CLOSE:')
if w.u:cross(w.v):dot(ray.dir) < 0 then
ishit = {ij={ij[1],U.mod(ij[2]+k-1,#floor.base)}, line={p, p+vec3(0,0,floor.h)}}
break
out.acorner[#out.acorner + 1] = {ij = ij,
line = {p, p + vec3(0,0,desc.afloor[ij[1]].h)}}
end
local campos = core_camera.getPosition()
local s = closestLinePoints(p, p + vec3(0,0,floor.h), campos, campos + ray.dir)
local ps = p + vec3(0,0,floor.h*s)
local s = closestLinePoints(p, p + vec3(0,0,floor.h), campos, campos + ray.dir)
local ps = p + vec3(0,0,floor.h*s)
if editor.keyModifiers.ctrl then
if U.vang(ray.dir, ps - core_camera.getPosition()) < 0.01 then
-- if rayCast.pos:distanceToLine(p, p + vec3(0,0,1))/(core_camera.getPosition() - rayCast.pos):length() < 0.02 then
-- U.dump(aedit[id].desc.ij, '?? for_CORNER:'..id)
ij = ij,
line = {p, p + vec3(0,0,H)}}
-- line = {p, p + vec3(0,0,forHeight(desc.afloor))}}
line = {p, p + vec3(0,0,H)}}
-- line = {p, p + vec3(0,0,forHeight(desc.afloor))}}
incorner = true
end
if rayCast.pos:distanceToLine(p, p + vec3(0,0,1)) < 0.2 then
-- lo('?? close:')
-- lo('?? close:')
-- out.apath = {{p, p + vec3(0,0,forHeight(desc.afloor))}}
-- out.invertedge = {{p, p + vec3(0,0,forHeight(desc.afloor))}}
-- out.apath = {{p, p + vec3(0,0,forHeight(desc.afloor))}}
-- out.invertedge = {{p, p + vec3(0,0,forHeight(desc.afloor))}}
end
local ray = getCameraMouseRay()
local lift = vec3(0,0,0)
if otype == 'lid' then
istop = true
lift = vec3(0,0,floor.h)
break
istop = true
lift = vec3(0,0,floor.h)
end
--[[
if floor.awall[j].u:cross(vec3(0,0,1)):dot(ray.dir) < 0 then
out.aedge.e[#out.aedge.e+1] =
out.aedge.e[#out.aedge.e+1] =
base2world(desc, {ij[1],j}) + (istop and vec3(0,0,floor.h) or vec3(0,0,0))
jma = j
out.aedge.e[#out.aedge.e+1] =
base2world(desc, {ij[1],j}) + (istop and vec3(0,0,floor.h) or vec3(0,0,0))
jma = j
local c = U.polyCenter(base)
c = c + base2world(desc, {ifloor, 1}) - base[1] + vec3(0,0,floor.h)
--[[
--[[
local c = vec3(0,0,0)
local s = 0
s = s + ds
-- c = c + base2world(desc, {ifloor, j}) + vec3(0,0,floor.h)
end
end
c = c/s + vec3(0,0,floor.h)
]]
-- local pm = base2world(desc, base[aside[cij[1]][1]]) + base2world(desc, U.mod(aside[cij[1]][3]+1,base))
out.middle = {line = {pm, pm + vec3(0,0,desc.afloor[cij[1]].h)}, ij = cij}
elseif scope == 'floor' and U._PRD == 0 then
local pm = base2world(desc,cij, base[jp] + u*(base[cij[2]]-base[jp]):dot(u) + u*p/2)
out.middle = {line = {pm, pm + vec3(0,0,desc.afloor[cij[1]].h)}, ij = cij}
-- lo('?? PM2:'..tostring(pm)..':'..mi..':'..ma..':'..tostring(u)..':'..cij[2], true)
-- local pm = base2world(desc, base[aside[cij[1] ][1] ]) + base2world(desc, U.mod(aside[cij[1] ][3]+1,base))
out.middle = {line = {pm, pm + vec3(0,0,desc.afloor[cij[1] ].h)}, ij = cij}
-- U.dump(aside, '?? for_side:'..cij[1]..':'..#aside[cij[1] ]..':'..tostring(pm))
floor.achild[#floor.achild+1] = deepcopy(dnew)
floor.achild[#floor.achild].pos = posnew -- floor.achild[#floor.achild].pos + vec3(4,0,0)
-- update by-reference object
if axis then
Render.circle(axis + vec3(0,0,0.01), 0.6, color(255,255,255,255), 2)
-- Render.circle(axis + vec3(0,0,0.01), 0.41, color(255,255,255,255))
Render.circle(axis + vec3(0,0,0.01), 0.6, color(255,255,255,255), 2)
-- Render.circle(axis + vec3(0,0,0.01), 0.41, color(255,255,255,255))
Render.path({axis, axis + vec3(0,0,0.5)}, color(255,255,255,200), 2)
-- Render.circle(axis + vec3(0,0,0.01), 0.41, color(255,255,255,255))
Render.path({axis, axis + vec3(0,0,0.5)}, color(255,255,255,200), 2)
-- debugDrawer:drawLine(axis, axis + vec3(0,0,0.5), ColorF(1,1,1,0.6))
Render.path({axis, axis + vec3(0,0,0.5)}, color(255,255,255,200), 2)
-- debugDrawer:drawLine(axis, axis + vec3(0,0,0.5), ColorF(1,1,1,0.6))
end
--TODO: for direction
s.ahole[#s.ahole+1] = {p=start-vec3(0,H,0), w=av[2].x-av[1].x, list=av, dae = daePath.win[1]}
end
-- TODO: get long direction
w.storefront.adir[#w.storefront.adir+1] = vec3(0,1,0)
]]
if not toemu[k] then toemu[k] = {} end
if not toemu[k][ic] then toemu[k][ic] = vec3(0,0,0) end
toemu[k][ic] = toemu[k][ic] + v*val
end
table.insert(asbase[i], mi, vec3(0,0,0))
end
local y = math.random(L) - L/2
local p = vec3(x, y)
local z = tb and core_terrain.getTerrainHeight(p) or 0
local R = W.ui.build_radius
local center = vec3(0,0)
W.building4test(W.ui.build_pattern, R, center, true)
local mrotx = MatrixF(true)
mrotx:setFromEuler(vec3(vang.x, 0, 0))
local mroty = MatrixF(true)
local mroty = MatrixF(true)
mroty:setFromEuler(vec3(0, vang.y, 0))
mtx:setFromEuler(vec3(0, 0, vang.z))
mroty:setFromEuler(vec3(0, vang.y, 0))
mtx:setFromEuler(vec3(0, 0, vang.z))
mtx:mul(mrotx)
local y = center.y + math.random(2*R) - R
local p = vec3(x, y)
dpos[id][#dpos[id]+1] = p
local vang = vec3(0,0,rot)
local mrotx = MatrixF(true)
mrotx:setFromEuler(vec3(vang.x, 0, 0))
local mroty = MatrixF(true)
local mroty = MatrixF(true)
mroty:setFromEuler(vec3(0, vang.y, 0))
mtx:setFromEuler(vec3(0, 0, vang.z))
mroty:setFromEuler(vec3(0, vang.y, 0))
mtx:setFromEuler(vec3(0, 0, vang.z))
mtx:mul(mrotx)
local base = {}
local pos = vec3(d.coords[1][1],d.coords[1][2],0)
for k=1,#d.coords-1 do
for k=1,#d.coords-1 do
local p = vec3(d.coords[k][1],d.coords[k][2],0) - pos
base[#base+1] = p
end
-- pos = vec3(0,0,0)
pos.z = core_terrain.getTerrainHeight(U.proj2D(pos))
elseif key == 'node_n' then
N.circleSeed(val, vec3(x, y), W.ui.node_r)
N.pathsUp()
elseif key == 'node_r' then
N.circleSeed(W.ui.node_n, vec3(x, y), val)
N.pathsUp()
-- new floor child
local dnew = {afloor = {}, pos = vec3(0,0,0), prn = desc.id, floor = floor.ij[1]}
local child = deepcopy(floor)
if false and U._PRD == 0 then
matMove(vec3(0,0,0), true)
else
else
matMove(vec3(val,0,0), true)
end
-- incontrol = true
matMove(vec3(0,-val,0),true)
-- return
u = floorpre.awall[j].u,
v = vec3(0,0,floor.h),
df = {},
local w,h = U.rcWH(b.base)
local scale = vec3(doorW/w, 1, doorH/h)
-- U.dump('?? scale:'..tostring(scale))
local base,frame = cedit.cval['DragPos'].hole,cedit.cval['DragPos'].frame
-- local irc = U.inRC(base[1] + val*vec3(1,0,0), {out.inhole.arc[6]})
-- U.dump(out.inhole.arc[6], '?? if_RC:'..tostring(irc)..':'..tostring(base[1]))
for i = 1,#base do
local ind = U.inRC(base[i] + val*vec3(1,0,0), out.inhole.arc)
if ind and ind ~= #out.inhole.arc - #out.inhole.achild + cur then
local rc = {
vec3(0,0,0),
vec3(w.u:length(),0,0),
vec3(0,0,0),
vec3(w.u:length(),0,0),
vec3(w.u:length(),w.v:length(),0),
vec3(w.u:length(),0,0),
vec3(w.u:length(),w.v:length(),0),
vec3(0,w.v:length(),0)}
vec3(w.u:length(),w.v:length(),0),
vec3(0,w.v:length(),0)}
if not U.inRC(base[i] + val*vec3(1,0,0), {rc}) then
vec3(0,w.v:length(),0)}
if not U.inRC(base[i] + val*vec3(1,0,0), {rc}) then
rollback = true
for i = 1,#base do
ahole[cur].base[i] = base[i] + val*vec3(1,0,0)
end
for i = 1,#base do
local ind = U.inRC(base[i] + val*vec3(0,1,0), out.inhole.arc)
if ind and ind ~= #out.inhole.arc - #out.inhole.achild + cur then
local rc = {
vec3(0,0,0),
vec3(w.u:length(),0,0),
vec3(0,0,0),
vec3(w.u:length(),0,0),
vec3(w.u:length(),w.v:length(),0),
vec3(w.u:length(),0,0),
vec3(w.u:length(),w.v:length(),0),
vec3(0,w.v:length(),0)}
vec3(w.u:length(),w.v:length(),0),
vec3(0,w.v:length(),0)}
local p = base[i] + val*vec3(0,1,0)
vec3(0,w.v:length(),0)}
local p = base[i] + val*vec3(0,1,0)
if not U.inRC(base[i] + val*vec3(0,1,0), {rc}) then
local p = base[i] + val*vec3(0,1,0)
if not U.inRC(base[i] + val*vec3(0,1,0), {rc}) then
rollback = true
for i = 1,#base do
ahole[cur].base[i] = base[i] + val*vec3(0,1,0)
end
forBuilding(desc, function(w, ij)
w.df[w.balcony.dae].scale = vec3(val,1,1)
end)
d.update = true
d.p = cedit.cval['DragPos'].dpos[i] + val*vec3(1,0) --(val-cedit.cval['DragPos'].val)*vec3(0,1)
if #cedit.aforest == 0 then
d.update = true
d.p = cedit.cval['DragPos'].dpos[i] + val*vec3(1,0) --(val-cedit.cval['DragPos'].val)*vec3(0,1)
if #cedit.aforest == 0 then
d.update = true
d.p = cedit.cval['DragPos'].dpos[i] + val*vec3(0,1) --(val-cedit.cval['DragPos'].val)*vec3(0,1)
-- out._dbgcheck = true
d.update = true
d.p = cedit.cval['DragPos'].dpos[i] + val*vec3(0,1) --(val-cedit.cval['DragPos'].val)*vec3(0,1)
-- out._dbgcheck = true
d.update = true
-- d.p = d.p + 0.18*vec3(2,1)
-- if true then return end
lo('??^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to_UPD:'..d.key..':'..tostring(incontrol))
-- d.p = cedit.cval['DragPos'].p + 1*(val-cedit.cval['DragPos'].val)*vec3(1.5,1) -- d.p + 0.2*vec3(1,1)
d.p = cedit.cval['DragPos'].p + (val-cedit.cval['DragPos'].val)*vec3(1,0)
lo('??^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to_UPD:'..d.key..':'..tostring(incontrol))
-- d.p = cedit.cval['DragPos'].p + 1*(val-cedit.cval['DragPos'].val)*vec3(1.5,1) -- d.p + 0.2*vec3(1,1)
d.p = cedit.cval['DragPos'].p + (val-cedit.cval['DragPos'].val)*vec3(1,0)
-- d.p = cedit.cval['DragPos'].p + 1*(val-cedit.cval['DragPos'].val)*vec3(1.5,1) -- d.p + 0.2*vec3(1,1)
d.p = cedit.cval['DragPos'].p + (val-cedit.cval['DragPos'].val)*vec3(1,0)
break
@/lua/console/resave-pcs.lua
BeamEngine:deleteAllObjects()
BeamEngine:spawnObject(1, "vehicles/" .. vdir .. "/", nil, vec3(0,3,0))
local be = BeamEngine:getSlot(0)
@/lua/ge/extensions/editor/util/editorElementHelper.lua
elem.drawColor = displayOptions.drawColor or {1,0.25,0,0.5}
elem.defaultPos = valueOptions.defaultPos or vec3()
elem.defaultRot = valueOptions.defaultRot or quat(0,0,0,1)
elem.oneDimScale = valueOptions.oneDimScale or false
elem.defaultScl = valueOptions.defaultScl or (elem.oneDimScale and 1 or vec3(1,1,1))
if valueOptions.hasPos == nil and valueOptions.defaultPos then valueOptions.hasPos = true end
local function boolSetContainer(e, ctd) if ctd[e.fieldName] == nil then e.ptr[0] = e.defaultValue else e.ptr[0] = ctd[e.fieldName] end end
local function transformSetContainer(e, ctd) e.transform:set(vec3(ctd[e.fieldNamePos] or e.defaultPos), quat(ctd[e.fieldNameRot] or e.defaultRot), e.oneDimScale and (ctd[e.fieldNameScl] or e.defaultScl) or (vec3(ctd[e.fieldNameScl] or e.defaultScl))) end
local function modelConfigSetContainer(e, ctd) e.mc.model = ctd[e.fieldNameModel] or e.defaultModel e.mc.config = ctd[e.fieldNameConfig] or e.defaultConfig e.mc.configPath = ctd[e.fieldNameConfigPath] or e.defaultConfigPath ui_flowgraph_editor.vehicleSelectorRefresh(e.mc) end
local function boolSetContainer(e, ctd) if ctd[e.fieldName] == nil then e.ptr[0] = e.defaultValue else e.ptr[0] = ctd[e.fieldName] end end
local function transformSetContainer(e, ctd) e.transform:set(vec3(ctd[e.fieldNamePos] or e.defaultPos), quat(ctd[e.fieldNameRot] or e.defaultRot), e.oneDimScale and (ctd[e.fieldNameScl] or e.defaultScl) or (vec3(ctd[e.fieldNameScl] or e.defaultScl))) end
local function modelConfigSetContainer(e, ctd) e.mc.model = ctd[e.fieldNameModel] or e.defaultModel e.mc.config = ctd[e.fieldNameConfig] or e.defaultConfig e.mc.configPath = ctd[e.fieldNameConfigPath] or e.defaultConfigPath ui_flowgraph_editor.vehicleSelectorRefresh(e.mc) end
--if not e.drawMode == 'hidden' then
debugDrawer:drawTextAdvanced(vec3(e.transform.pos), String(e.label), whiteColorF, true, false, blackColorI)
--end
elseif e.drawMode == 'halfBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)/2
elseif e.drawMode == 'halfBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)/2
elseif e.drawMode == 'halfBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)/2
elseif e.drawMode == 'fullBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)
elseif e.drawMode == 'fullBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)
elseif e.drawMode == 'fullBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)
if editor.uiIconImageButton(editor.icons.undo, imVec24x24) then
e.transform:set(vec3(e.defaultPos), quat(e.defaultRot), e.oneDimScale and (e.defaultScl) or (vec3(e.defaultScl)))
ctd[e.fieldNamePos] = e.hasPos and (e.transform.pos:toTable())
if editor.uiIconImageButton(editor.icons.undo, imVec24x24) then
e.transform:set(vec3(e.defaultPos), quat(e.defaultRot), e.oneDimScale and (e.defaultScl) or (vec3(e.defaultScl)))
ctd[e.fieldNamePos] = e.hasPos and (e.transform.pos:toTable())
self.mouseInfo.ray = getCameraMouseRay()
self.mouseInfo.rayDir = vec3(self.mouseInfo.ray.dir)
self.mouseInfo.rayCast = cameraMouseRayCast()
self.mouseInfo.hold = false
self.mouseInfo._downPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._downNormal = vec3(self.mouseInfo.rayCast.normal)
self.mouseInfo._downPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._downNormal = vec3(self.mouseInfo.rayCast.normal)
end
if self.mouseInfo.hold then
self.mouseInfo._holdPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._holdNormal = vec3(self.mouseInfo.rayCast.normal)
self.mouseInfo._holdPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._holdNormal = vec3(self.mouseInfo.rayCast.normal)
end
if self.mouseInfo.up then
self.mouseInfo._upPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._upNormal = vec3(self.mouseInfo.rayCast.normal)
self.mouseInfo._upPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._upNormal = vec3(self.mouseInfo.rayCast.normal)
end
if self.mouseInfo.closestElementsHovered and self.mouseInfo.valid then
debugDrawer:drawTextAdvanced(vec3(self.mouseInfo.rayCast.pos), String("Click to Edit: " .. self.mouseInfo.closestElementsHovered.label), ColorF(1,1,1,1),true, false, ColorI(0,128,0,255))
if self.mouseInfo.down then
debugDrawer:drawSphere(e.transform.pos, radius, ColorF(e.drawColor[1], e.drawColor[2], e.drawColor[3], e.drawColor[4]))
local normal = e.transform.rot * vec3(0,1,0)
debugDrawer:drawSquarePrism(
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
debugDrawer:drawTriSolid(
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos-yn/2 ),
vec3(pos-xn/2 ),
vec3(pos-yn/2 ),
blackColor)
debugDrawer:drawTriSolid(
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos-yn/2 ),
vec3(pos+xn/2 ),
vec3(pos-yn/2 ),
blackColor)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/ui/liveryEditor/camera.lua
local ORTHOGRAPHIC_VIEWS = {
front = vec3(180, 0, 0),
back = vec3(0, 0, 0),
front = vec3(180, 0, 0),
back = vec3(0, 0, 0),
left = vec3(-90, 0, 0),
back = vec3(0, 0, 0),
left = vec3(-90, 0, 0),
right = vec3(90, 0, 0),
left = vec3(-90, 0, 0),
right = vec3(90, 0, 0),
topfront = vec3(180, -90, 0),
right = vec3(90, 0, 0),
topfront = vec3(180, -90, 0),
topleft = vec3(-90, -90, 0),
topfront = vec3(180, -90, 0),
topleft = vec3(-90, -90, 0),
topright = vec3(90, -90, 0),
topleft = vec3(-90, -90, 0),
topright = vec3(90, -90, 0),
topback = vec3(0, -90, 0),
topright = vec3(90, -90, 0),
topback = vec3(0, -90, 0),
default = vec3(145, -5, 0)
}
core_camera.setFOV(0, 45)
core_camera.setOffset(0, vec3(0, 0, 2 / idealDistance))
@/lua/ge/extensions/editor/tech/roadArchitect/geometry.lua
local twoPi, halfPi, deg2Rad = pi * 2.0, pi * 0.5, pi / 180.0
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tgt_2D, tmpLat = vec3(0, 0), vec3(0, 0)
local twoPi, halfPi, deg2Rad = pi * 2.0, pi * 0.5, pi / 180.0
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tgt_2D, tmpLat = vec3(0, 0), vec3(0, 0)
local twoPi, halfPi, deg2Rad = pi * 2.0, pi * 0.5, pi / 180.0
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tgt_2D, tmpLat = vec3(0, 0), vec3(0, 0)
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tgt_2D, tmpLat = vec3(0, 0), vec3(0, 0)
local pStart_2D, pMid_2D, pEnd_2D = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tgt_2D, tmpLat = vec3(0, 0), vec3(0, 0)
local pStart_2D, pMid_2D, pEnd_2D = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tgt_2D, tmpLat = vec3(0, 0), vec3(0, 0)
local pStart_2D, pMid_2D, pEnd_2D = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local vertical = vec3(0, 0, 1)
local tgt_2D, tmpLat = vec3(0, 0), vec3(0, 0)
local pStart_2D, pMid_2D, pEnd_2D = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local vertical = vec3(0, 0, 1)
local tgt_2D, tmpLat = vec3(0, 0), vec3(0, 0)
local pStart_2D, pMid_2D, pEnd_2D = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local vertical = vec3(0, 0, 1)
local pStart_2D, pMid_2D, pEnd_2D = vec3(0, 0), vec3(0, 0), vec3(0, 0)
local vertical = vec3(0, 0, 1)
local oneThird, twoThirds = 0.3333333333333333333333333333, 0.666666666666666666666666666667
local a, b, c = v2:distance(v1), v2:distance(v0), v1:distance(v0)
local center = vec3((a * v0.x + b * v1.x + c * v2.x), (a * v0.y + b * v1.y + c * v2.y), 0.0) / (a + b + c)
return center, center:distanceToLineSegment(v0, v1)
return {
p = vec3(pos.x, pos.y, pos.z),
isLocked = n.isLocked,
local poly1 = poly[1]
local pDisc = { vec3(poly1.p.x, poly1.p.y, 0) }
local ctr = 2
local pLastIdx = max(1, lastIdx - 1)
local pPrev = vec3(pDisc[pLastIdx].x, pDisc[pLastIdx].y, 0)
local pStart_3D = vec3(pDisc[lastIdx].x, pDisc[lastIdx].y, 0)
local pPrev = vec3(pDisc[pLastIdx].x, pDisc[pLastIdx].y, 0)
local pStart_3D = vec3(pDisc[lastIdx].x, pDisc[lastIdx].y, 0)
pStart_2D:set(pStart_3D.x, pStart_3D.y, 0.0)
pStart_2D:set(pStart_3D.x, pStart_3D.y, 0.0)
local i1, i2, i3, i4 = pPrev, pStart_2D, vec3(u1_2D.x, u1_2D.y, 0), vec3(u2_2D.x, u2_2D.y, 0)
pStart_2D:set(pStart_3D.x, pStart_3D.y, 0.0)
local i1, i2, i3, i4 = pPrev, pStart_2D, vec3(u1_2D.x, u1_2D.y, 0), vec3(u2_2D.x, u2_2D.y, 0)
local pClo1 = {}
i1 = vec3(pIm.x, pIm.y, 0)
i2 = vec3(pDisc[ctr - 1].x, pDisc[ctr - 1].y, 0)
i1 = vec3(pIm.x, pIm.y, 0)
i2 = vec3(pDisc[ctr - 1].x, pDisc[ctr - 1].y, 0)
i3 = vec3(pArc[1].x, pArc[1].y, 0)
i2 = vec3(pDisc[ctr - 1].x, pDisc[ctr - 1].y, 0)
i3 = vec3(pArc[1].x, pArc[1].y, 0)
i4 = vec3(pArc[2].x, pArc[2].y, 0)
i3 = vec3(pArc[1].x, pArc[1].y, 0)
i4 = vec3(pArc[2].x, pArc[2].y, 0)
i2i3 = i3 - i2
local pArcLen = #pArc
i1 = vec3(pArc[pArcLen - 1].x, pArc[pArcLen - 1].y, 0)
i2 = vec3(pArc[pArcLen].x, pArc[pArcLen].y, 0)
i1 = vec3(pArc[pArcLen - 1].x, pArc[pArcLen - 1].y, 0)
i2 = vec3(pArc[pArcLen].x, pArc[pArcLen].y, 0)
i3 = vec3(p3_2D.x, p3_2D.y, 0)
i2 = vec3(pArc[pArcLen].x, pArc[pArcLen].y, 0)
i3 = vec3(p3_2D.x, p3_2D.y, 0)
i4 = vec3(pIp.x, pIp.y, 0)
i3 = vec3(p3_2D.x, p3_2D.y, 0)
i4 = vec3(pIp.x, pIp.y, 0)
i2i3 = i3 - i2
local nLast = poly[#poly]
local i1 = vec3(pDisc[ctr - 2].x, pDisc[ctr - 2].y, 0)
local i2 = vec3(pDisc[ctrLast].x, pDisc[ctrLast].y, 0)
local i1 = vec3(pDisc[ctr - 2].x, pDisc[ctr - 2].y, 0)
local i2 = vec3(pDisc[ctrLast].x, pDisc[ctrLast].y, 0)
local i3 = vec3(nLast.p.x, nLast.p.y, 0)
local i2 = vec3(pDisc[ctrLast].x, pDisc[ctrLast].y, 0)
local i3 = vec3(nLast.p.x, nLast.p.y, 0)
local i4 = i3
rdk = {}
rdk[6] = vec3(0, 0)
end
rdk = {}
rdk[6] = vec3(0, 0)
end
@/lua/ge/extensions/editor/dynamicDecals/layerTypes/decal.lua
if widgets.draw({decalScale.x, decalScale.y, decalScale.z}, api.propertiesMap["decalScale"], guiId) then
api.setDecalScale(vec3(api.propertiesMap["decalScale"].value[1], 1.0, api.propertiesMap["decalScale"].value[3]))
end
@/lua/ge/extensions/core/sounds.lua
local lastCameraForward = nil
local cameraForward = vec3()
local vecDown3F = vec3(0,0,-1)
local cameraForward = vec3()
local vecDown3F = vec3(0,0,-1)
local frameFlag = true
local frameFlag = true
local camPos = vec3()
local vehVelocity = vec3()
local camPos = vec3()
local vehVelocity = vec3()
local insideModifier = settings.getValue('AudioInsideModifier')
end
lastCamPos = lastCamPos or vec3()
lastCameraForward = lastCameraForward or vec3()
lastCamPos = lastCamPos or vec3()
lastCameraForward = lastCameraForward or vec3()
lastCamPos:set(camPos)
@/lua/ge/extensions/ui/apps/minimap/route.lua
for i = 1, routeMaxLength do
routePath[i] = vec3()
end
@/lua/ge/client/postFx/dof.lua
local camPos = vec3(core_camera.getPosition())
if sceneObject and not Engine.sceneGetCameraFrustum():isBoxOutside(sceneObject:getWorldBox()) then
local vehPos = vec3(veh:getPosition())
-- Calculate distance between camera and vehicle
-- Fallback to center raycast if vehicle is not in view
local direction = vec3(core_camera.getForward())
local farDist = tonumber(TorqueScriptLua.getVar("$Param::FarDist"))
local hitPos = vec3(tonumber(resultArgs[2]), tonumber(resultArgs[3]), tonumber(resultArgs[4]))
return (hitPos - camPos):length()
@/lua/ge/extensions/flowgraph/nodes/scene/camera/setCameraPosition.lua
function C:init()
self.position = vec3(0,0,0)
self.mode = 'custom'
local cameraPosition = core_camera.getPosition()
self.position = vec3(cameraPosition)
reason = "Got values from Camera"
if self.mode == 'from Pin' then
self.position = vec3(self.pinIn.pos.value)
end
function C:_onDeserialized(nodeData)
self.position = nodeData.ppos and vec3(nodeData.ppos[1], nodeData.ppos[2], nodeData.ppos[3]) or vec3({0,0,0})
self.mode = nodeData.mode or 'custom'
function C:_onDeserialized(nodeData)
self.position = nodeData.ppos and vec3(nodeData.ppos[1], nodeData.ppos[2], nodeData.ppos[3]) or vec3({0,0,0})
self.mode = nodeData.mode or 'custom'
@/lua/vehicle/jbeam/stage2.lua
if type(beam.precompressionRange) == 'number' then
local bL = vec3(node1pos):distance(node2pos)
beam.beamPrecompression = max(0, (bL + beam.precompressionRange) / (bL + 1e-30))
@/lua/ge/extensions/editor/tech/roadArchitect/overlays.lua
local deg45 = 0.785398163
local vertical = vec3(0, 0, 1)
@/lua/ge/extensions/flowgraph/nodes/util/closestRoad.lua
local pos, projPos = vec3(), vec3()
local pos, projPos = vec3(), vec3()
@/lua/ge/extensions/editor/gen/top.lua
local u = (base[2]-base[1]):normalized()
-- local v = vec3(-u.y, u.x, 0)
local v = -u:cross(w)
local x,y = U.lineCross(a[2],b[2],b[1],c[1])
local vcross = vec3(x,y)
-- W.out.avedit = {vcross}
local xm,ym = U.lineCross(abMid[1],abMid[2],bcMid[1],bcMid[2])
-- W.out.avedit = {vec3(xm,ym)} --{vec3(x,y)} -- {vcross,c[1]} -- {abMid[1],abMid[2]} --vec3(xm,ym)}
local dir = vec3(xm,ym)-vec3(x,y)
local xm,ym = U.lineCross(abMid[1],abMid[2],bcMid[1],bcMid[2])
-- W.out.avedit = {vec3(xm,ym)} --{vec3(x,y)} -- {vcross,c[1]} -- {abMid[1],abMid[2]} --vec3(xm,ym)}
local dir = vec3(xm,ym)-vec3(x,y)
local xm,ym = U.lineCross(abMid[1],abMid[2],bcMid[1],bcMid[2])
-- W.out.avedit = {vec3(xm,ym)} --{vec3(x,y)} -- {vcross,c[1]} -- {abMid[1],abMid[2]} --vec3(xm,ym)}
local dir = vec3(xm,ym)-vec3(x,y)
-- W.out.avedit = {vec3(xm,ym)} --{vec3(x,y)} -- {vcross,c[1]} -- {abMid[1],abMid[2]} --vec3(xm,ym)}
local dir = vec3(xm,ym)-vec3(x,y)
-- W.out.avedit = {vec3(x,y),vec3(xm,ym),vec3(x,y)+dir*rw}
-- W.out.avedit = {vec3(xm,ym)} --{vec3(x,y)} -- {vcross,c[1]} -- {abMid[1],abMid[2]} --vec3(xm,ym)}
local dir = vec3(xm,ym)-vec3(x,y)
-- W.out.avedit = {vec3(x,y),vec3(xm,ym),vec3(x,y)+dir*rw}
local dir = vec3(xm,ym)-vec3(x,y)
-- W.out.avedit = {vec3(x,y),vec3(xm,ym),vec3(x,y)+dir*rw}
local av = {b[1],vec3(x,y)+dir*rw,vcross}
local dir = vec3(xm,ym)-vec3(x,y)
-- W.out.avedit = {vec3(x,y),vec3(xm,ym),vec3(x,y)+dir*rw}
local av = {b[1],vec3(x,y)+dir*rw,vcross}
local dir = vec3(xm,ym)-vec3(x,y)
-- W.out.avedit = {vec3(x,y),vec3(xm,ym),vec3(x,y)+dir*rw}
local av = {b[1],vec3(x,y)+dir*rw,vcross}
-- W.out.avedit = {vec3(x,y),vec3(xm,ym),vec3(x,y)+dir*rw}
local av = {b[1],vec3(x,y)+dir*rw,vcross}
-- W.out.avedit = av
-- W.out.avedit = av
-- local av = {b[1],vec3(x,y)+dir:normalized()*rw,vcross}
local aV = {vcross,(b[2]+vcross)/2,b[2]}
for k=2,#d.av,3 do
d.av[k] = d.av[k]+vec3(0,0,1)
end
local apThick = {
vec3(x,y,0),c[1],
(vec3(x,y,0)+b[2])/2, bcMid[2],
vec3(x,y,0),c[1],
(vec3(x,y,0)+b[2])/2, bcMid[2],
b[2],c[2],
for k=2,#base,3 do
base[k] = base[k]+vec3(0,0,1)
end
for k=2,#base,3 do
base[k] = base[k]+vec3(0,0,1)
end
for k=1,#base do
-- base[k] = base[k]+vec3(0,0,0.1)
end
for k=2,#base,3 do
base[k] = base[k]+vec3(0,0,1)
end
base = {
vec3(-0.716707144,0.9078321689,0),
vec3(-12.56234233,-1.010742044,0),
vec3(-0.716707144,0.9078321689,0),
vec3(-12.56234233,-1.010742044,0),
vec3(-11.28329286,-8.907832169,0),
vec3(-12.56234233,-1.010742044,0),
vec3(-11.28329286,-8.907832169,0),
vec3(0.5623423313,-6.989257956,0), }
vec3(-11.28329286,-8.907832169,0),
vec3(0.5623423313,-6.989257956,0), }
base = {
base = {
vec3(-1.937387983,-9.957783447,0),
vec3(-2.063050671,2.041558572,0),
vec3(-1.937387983,-9.957783447,0),
vec3(-2.063050671,2.041558572,0),
vec3(-10.06261202,1.957783447,0),
vec3(-2.063050671,2.041558572,0),
vec3(-10.06261202,1.957783447,0),
vec3(-9.936949329,-10.04155857,0), }
vec3(-10.06261202,1.957783447,0),
vec3(-9.936949329,-10.04155857,0), }
]]
-- W.out.aforest = {}
-- W.out.aforest[#W.out.aforest+1] = c1 + vec3(0,0,8) --W.base2world(W.forDesc(), {3, 1}, c1)
-- W.out.aforest[#W.out.aforest+1] = W.forDesc() and (W.base2world(W.forDesc(), {3, 1}, c2) + vec3(0,0,8)) or nil
-- W.out.aforest[#W.out.aforest+1] = c1 + vec3(0,0,8) --W.base2world(W.forDesc(), {3, 1}, c1)
-- W.out.aforest[#W.out.aforest+1] = W.forDesc() and (W.base2world(W.forDesc(), {3, 1}, c2) + vec3(0,0,8)) or nil
-- lo('?? sF:'..tostring(c1)..':'..tostring(c2), true)
-- local u = (base[2]-base[1]):normalized()
-- local v = vec3(-u.y, u.x, 0)
local u = (U.mod(p[1]+1,base) - base[p[1] ]):normalized()
local v = vec3(-u.y, u.x, 0)
local ref = base[p[1] ]
local u = (base[2]-base[1]):normalized()
local v = vec3(-u.y, u.x, 0)
local ref = base[1]
local u = (base[2]-base[1]):normalized()
local v = vec3(-u.y, u.x, 0)
local ref = base[1]
@/flowgraphEditor/Tower/customNodes/towerNode.lua
self.objects = {}
local lastPos, lastRot = vec3(0,0,200), quatFromEuler(0,0,0)
local q = quat(goal:getRotation())
lastPos = goal:getPosition() + q * vec3(0,4,0)
lastRot = quat(goal:getRotation()) * quatFromEuler(0,0,-math.pi/2)
@/lua/ge/extensions/tech/multiscreen.lua
name = name,
position = vec3(positionX or 0, positionY or 0, positionZ or 0),
rotation = quatFromEuler(rotationX or 0, rotationY or 0, rotationZ or 0),
@/lua/ge/extensions/scenario/raceDebug.lua
end
node.pos = vec3(node.pos)
node.direct = (#path == 1)
@/lua/ge/extensions/editor/objectToSplineEditor.lua
local vecUp = vec3(0, 0, 1)
local objColor = ColorF(1, 1, 0, 0.5)
local edgeCount = guide:getEdgeCount()
local pos1, pos2, dirVec, dirVecUp = vec3(), vec3(), vec3(), vec3()
local points = {}
local edgeCount = guide:getEdgeCount()
local pos1, pos2, dirVec, dirVecUp = vec3(), vec3(), vec3(), vec3()
local points = {}
local edgeCount = guide:getEdgeCount()
local pos1, pos2, dirVec, dirVecUp = vec3(), vec3(), vec3(), vec3()
local points = {}
local edgeCount = guide:getEdgeCount()
local pos1, pos2, dirVec, dirVecUp = vec3(), vec3(), vec3(), vec3()
local points = {}
local posOffset, rotOffset = vec3(0, 0, 0), quat(0, 0, 0, 1)
if params.randomPosOffset and params.randomPosOffset ~= 0 then
local obj = scenetree.findObjectById(objId)
local offset = vec3(0, 0, 0)
@/lua/ge/extensions/ui/apps/minimap/utils.lua
local camFwd, camRight = vec3(), vec3()
local camInverseFwd, camInverseRight = vec3(), vec3()
local camFwd, camRight = vec3(), vec3()
local camInverseFwd, camInverseRight = vec3(), vec3()
local camFwd, camRight = vec3(), vec3()
local camInverseFwd, camInverseRight = vec3(), vec3()
local halfWidthWithOffset = 0
local camFwd, camRight = vec3(), vec3()
local camInverseFwd, camInverseRight = vec3(), vec3()
local halfWidthWithOffset = 0
local function mapToWorld(p)
local cp = vec3(p.x-centerX, -(p.y - centerY),0)
cp = camRotInverse * cp
-- Returns the clamped position and a flag indicating whether clamping happened
local centerLocal, target, fromCenter, dir = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
-- Returns the clamped position and a flag indicating whether clamping happened
local centerLocal, target, fromCenter, dir = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
-- Returns the clamped position and a flag indicating whether clamping happened
local centerLocal, target, fromCenter, dir = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
-- Returns the clamped position and a flag indicating whether clamping happened
local centerLocal, target, fromCenter, dir = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
local centerLocal, target, fromCenter, dir = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
local edge, toP1, cross1, cross2 = vec3(), vec3(), vec3(), vec3()
local centerLocal, target, fromCenter, dir = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
local edge, toP1, cross1, cross2 = vec3(), vec3(), vec3(), vec3()
local centerLocal, target, fromCenter, dir = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
local edge, toP1, cross1, cross2 = vec3(), vec3(), vec3(), vec3()
local centerLocal, target, fromCenter, dir = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
local edge, toP1, cross1, cross2 = vec3(), vec3(), vec3(), vec3()
local corners = {vec3(), vec3(), vec3(), vec3()}
local edge, toP1, cross1, cross2 = vec3(), vec3(), vec3(), vec3()
local function setClampToBounds(pos, inset, maxDistance)
local corners = {vec3(), vec3(), vec3(), vec3()}
local edge, toP1, cross1, cross2 = vec3(), vec3(), vec3(), vec3()
local function setClampToBounds(pos, inset, maxDistance)
local corners = {vec3(), vec3(), vec3(), vec3()}
local edge, toP1, cross1, cross2 = vec3(), vec3(), vec3(), vec3()
local function setClampToBounds(pos, inset, maxDistance)
local corners = {vec3(), vec3(), vec3(), vec3()}
local edge, toP1, cross1, cross2 = vec3(), vec3(), vec3(), vec3()
local function setClampToBounds(pos, inset, maxDistance)
local strikeColor = color(255,255,255,255)
local circlePos = vec3()
local simpleCircle = function(pos, fill, strikeClr, radius)
local linePos1 = vec3()
local linePos2 = vec3()
local linePos1 = vec3()
local linePos2 = vec3()
local simpleLine = function(pos1, pos2, fill, strikeClr)
local buffer = -14
local centerLocal, markerLocal, directionLocal, intersectionLocal = vec3(), vec3(), vec3(), vec3()
local tip, side, side1, side2 = vec3(), vec3(), vec3(), vec3()
local buffer = -14
local centerLocal, markerLocal, directionLocal, intersectionLocal = vec3(), vec3(), vec3(), vec3()
local tip, side, side1, side2 = vec3(), vec3(), vec3(), vec3()
local buffer = -14
local centerLocal, markerLocal, directionLocal, intersectionLocal = vec3(), vec3(), vec3(), vec3()
local tip, side, side1, side2 = vec3(), vec3(), vec3(), vec3()
local buffer = -14
local centerLocal, markerLocal, directionLocal, intersectionLocal = vec3(), vec3(), vec3(), vec3()
local tip, side, side1, side2 = vec3(), vec3(), vec3(), vec3()
local centerLocal, markerLocal, directionLocal, intersectionLocal = vec3(), vec3(), vec3(), vec3()
local tip, side, side1, side2 = vec3(), vec3(), vec3(), vec3()
-- Edge pointer function
local centerLocal, markerLocal, directionLocal, intersectionLocal = vec3(), vec3(), vec3(), vec3()
local tip, side, side1, side2 = vec3(), vec3(), vec3(), vec3()
-- Edge pointer function
local centerLocal, markerLocal, directionLocal, intersectionLocal = vec3(), vec3(), vec3(), vec3()
local tip, side, side1, side2 = vec3(), vec3(), vec3(), vec3()
-- Edge pointer function
local centerLocal, markerLocal, directionLocal, intersectionLocal = vec3(), vec3(), vec3(), vec3()
local tip, side, side1, side2 = vec3(), vec3(), vec3(), vec3()
-- Edge pointer function
local center = vec3()
local simpleLineWithEdgePointer = function(pos1, pos2, fill, strikeClr)
@/lua/ge/extensions/ui/apps/minimap/vehicles.lua
-- Vehicle drawing state variables
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
-- Vehicle drawing state variables
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
-- Vehicle drawing state variables
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
-- Vehicle drawing state variables
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
-- Vehicle drawing state variables
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
local lastDtSim, lastVel = 0, 0
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
local lastDtSim, lastVel = 0, 0
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
local lastDtSim, lastVel = 0, 0
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
local lastDtSim, lastVel = 0, 0
local lastPos, lastPos2, pos, fwd, scl = vec3(), vec3(), vec3(), vec3(), vec3()
local f, bl, br, bc, side = vec3(), vec3(), vec3(), vec3(), vec3()
local lastDtSim, lastVel = 0, 0
local stoppedScale = 0.5
local localUp = vec3(0,0,1)
local localFwd = vec3(0,1,0)
local localUp = vec3(0,0,1)
local localFwd = vec3(0,1,0)
local velSmoother = newTemporalSmoothing(0.25,0.5, nil, 1)
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
-- Apply lookahead offset to camera position for free camera drawing
local adjustedCamPos = vec3(camPos)
if debugSettings.lookaheadEnabled then
local lookaheadValue = debugSettingsData.lookaheadValue[debugSettings.lookaheadValue].value
local lookWithoutZ = vec3(cameraLook.x, cameraLook.y, 0):normalized()
adjustedCamPos = adjustedCamPos - lookWithoutZ * lookaheadValue * scale * height/2
@/lua/ge/extensions/freeroam/facilities.lua
local function getAverageDoorPositionForFacility(facility)
local center, count = vec3(0,0,0), 0
log("E","","Dealership has no doors and thus no position! " .. facility.id)
return vec3()
end
local zones = {}
local pos, radius = vec3(), 5
local zones = getZonesForFacility(facility)
if not aabb.invalid then
pos = vec3((aabb.xMin + aabb.xMax)/2, (aabb.yMin + aabb.yMax)/2, (aabb.zMin + aabb.zMax)/2)
pos.z = core_terrain.getTerrainHeight(pos) or pos.z
local center, count = vec3(0,0,0), 0
for _, pair in ipairs(f.doors or {}) do
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veAdjustableTechCarTuner.lua
-- local nodes = vehData.vdata.nodes
-- local com = vec3()
-- local minExtents, maxExtents = vec3(math.huge, math.huge, math.huge), vec3(-math.huge, -math.huge, -math.huge)
-- local com = vec3()
-- local minExtents, maxExtents = vec3(math.huge, math.huge, math.huge), vec3(-math.huge, -math.huge, -math.huge)
-- local totalMass = 0
-- local com = vec3()
-- local minExtents, maxExtents = vec3(math.huge, math.huge, math.huge), vec3(-math.huge, -math.huge, -math.huge)
-- local totalMass = 0
@/lua/ge/extensions/editor/forestEditor.lua
local function updateCentroid()
selectionCentroid = vec3(0, 0, 0)
local bbox = Box3F()
local bbox = Box3F()
bbox:setExtents(vec3(-1e10 - 1e10, -1e10 - 1e10, -1e10 - 1e10))
bbox:setCenter(vec3(0, 0, 0))
bbox:setExtents(vec3(-1e10 - 1e10, -1e10 - 1e10, -1e10 - 1e10))
bbox:setCenter(vec3(0, 0, 0))
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local and #forestItems == 1 then
editor.setAxisGizmoTransform(forestItems[1]:getTransform(), vec3(1,1,1))
else
mat:setColumn(3, selectionCentroid)
editor.setAxisGizmoTransform(mat, vec3(1,1,1))
end
if not endPoint then
endPoint = startPoint - vec3(0,0,100)
end
end
local res = Engine.castRay((startPoint + vec3(0,0,1)), endPoint, true, false)
if not res then
if not res then
res = Engine.castRay((startPoint + vec3(0,0,100)), (startPoint - vec3(0,0,1000)), true, false)
end
if not res then
res = Engine.castRay((startPoint + vec3(0,0,100)), (startPoint - vec3(0,0,1000)), true, false)
end
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Rotate then
local delta = vec3(worldEditorCppApi.getAxisGizmoTotalRotateOffset())
editor.rotateForestSelection(var.forestData, delta, selectionCentroid, originalTransforms)
for index, obj in ipairs(editor.selection.forestItem) do
local delta = vec3(worldEditorCppApi.getAxisGizmoScaleOffset())
local mul = (delta.x < 0) and -1 or ((delta.y < 0) and -1 or (delta.z < 0 and -1 or 1))
transform:setColumn4F(2, item:getTransform():getColumn4F(2))
transform:setPosition(vec3(posItem.x, posItem.y, posItem.z))
editor.history:commitAction("MoveForestItem",
local transform = MatrixF(true)
transform:setFromEuler(vec3(eulerRotation.x, eulerRotation.y, eulerRotation.z))
transform:setPosition(item:getPosition())
local function drawFrustumRect(frustum)
local topLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
if originNode.isUpdated or targetNode.isUpdated then
local rayCastBegin = castRayDown(lastPos + vec3(0,0,100))
local rayCastEnd = castRayDown(tempTarget + vec3(0,0,100))
local rayCastBegin = castRayDown(lastPos + vec3(0,0,100))
local rayCastEnd = castRayDown(tempTarget + vec3(0,0,100))
if rayCastBegin then
if rayCastBegin then
tempLineBegin = vec3(lastPos.x,lastPos.y,rayCastBegin.pt.z)
end
if rayCastEnd then
tempLineEnd = vec3(tempTarget.x,tempTarget.y,rayCastEnd.pt.z)
end
for _, item in ipairs(newItems) do
local pos = vec3(item:getPosition())
local height = item:getSize().z
pos.z = pos.z + height * 0.5
local rayCastRes = castRayDown(pos, pos - vec3(0,0,height))
if rayCastRes then
local normal = vec3(rayCastRes.norm)
local rot = quat(rotation) * vec3(0,0,1):getRotationTo(normal)
local normal = vec3(rayCastRes.norm)
local rot = quat(rotation) * vec3(0,0,1):getRotationTo(normal)
local trans = QuatF(rot.x, rot.y, rot.z, rot.w):getMatrix()
local topLeft2I = editor.screenToClient(Point2I(mouseDragStartPos.x, mouseDragStartPos.y))
local topLeft = vec3(topLeft2I.x, topLeft2I.y, 0)
local bottomRight = (topLeft + vec3(delta.x, delta.y, 0))
local topLeft = vec3(topLeft2I.x, topLeft2I.y, 0)
local bottomRight = (topLeft + vec3(delta.x, delta.y, 0))
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local and #editor.selection.forestItem == 1 then
editor.setAxisGizmoTransform(editor.selection.forestItem[1]:getTransform(), vec3(1,1,1))
elseif selectionCentroid then
mat:setColumn(3, selectionCentroid)
editor.setAxisGizmoTransform(mat, vec3(1,1,1))
end
@/lua/ge/extensions/gameplay/rally/tools/loopToolbox.lua
if transformSuccess and transform then
objPos = vec3(transform:getColumn(3))
end
if x and y and z then
objPos = vec3(tonumber(x), tonumber(y), tonumber(z))
end
-- if im.Button("Focus on Service Stall") then
-- local center = vec3(stallPos[1], stallPos[2], stallPos[3])
-- local rot = core_camera.getQuat()
-- local rot = core_camera.getQuat()
-- local pos = center + rot * vec3(0, -15, 0)
-- local camRot = quatFromDir(center - pos)
-- if im.Button("Focus on Service Out Trigger") then
-- local center = vec3(outTriggerPos[1], outTriggerPos[2], outTriggerPos[3])
-- local rot = core_camera.getQuat()
-- local rot = core_camera.getQuat()
-- local pos = center + rot * vec3(0, -15, 0)
-- local camRot = quatFromDir(center - pos)
@/lua/common/graphpath.lua
local targetMinCostLink
local tmpVec = vec3()
local nodeToTargetVec = vec3()
local tmpVec = vec3()
local nodeToTargetVec = vec3()
local targetMinCostLink = nil
local nodePos, tmpVec, nodeToTargetVec = vec3(), vec3(), vec3()
local targetMinCostLink = nil
local nodePos, tmpVec, nodeToTargetVec = vec3(), vec3(), vec3()
local targetMinCostLink = nil
local nodePos, tmpVec, nodeToTargetVec = vec3(), vec3(), vec3()
local road = {} -- predessesor of node in the shortest path to node
local curSegDir = vec3(initDir.x, initDir.y, 0)
local inFwdFlow, inBackFlow, inDrivability, inGated = radius[start], 0, 1, false
local nextSegDir = vec3()
local minParent1, queued1, road1, prevPathSet = {}, {}, {}, {} -- only road1 needs to be initialized here
local curSegDir, nextSegDir = vec3(), vec3()
que1:clear()
local minParent1, queued1, road1, prevPathSet = {}, {}, {}, {} -- only road1 needs to be initialized here
local curSegDir, nextSegDir = vec3(), vec3()
que1:clear()
local prevNode = startNode
local prevDir = vec3(initialDir)
local rnd2 = rndDirCoef * 2
@/lua/ge/extensions/c2/panelPlugins/tileManager.lua
local s = inst.size
local scale = vec3(s, s, s)
local template = inst.template
local min = vec3(bb[1], bb[2], bb[3])
local max = vec3(bb[4], bb[5], bb[6])
local min = vec3(bb[1], bb[2], bb[3])
local max = vec3(bb[4], bb[5], bb[6])
local corners = {
vec3(min.x, min.y, min.z),
vec3(max.x, min.y, min.z),
vec3(min.x, min.y, min.z),
vec3(max.x, min.y, min.z),
vec3(max.x, max.y, min.z),
vec3(max.x, min.y, min.z),
vec3(max.x, max.y, min.z),
vec3(min.x, max.y, min.z),
vec3(max.x, max.y, min.z),
vec3(min.x, max.y, min.z),
vec3(min.x, min.y, max.z),
vec3(min.x, max.y, min.z),
vec3(min.x, min.y, max.z),
vec3(max.x, min.y, max.z),
vec3(min.x, min.y, max.z),
vec3(max.x, min.y, max.z),
vec3(max.x, max.y, max.z),
vec3(max.x, min.y, max.z),
vec3(max.x, max.y, max.z),
vec3(min.x, max.y, max.z)
vec3(max.x, max.y, max.z),
vec3(min.x, max.y, max.z)
}
local function drawCube(min, max, color)
local p1 = vec3(min.x, min.y, min.z)
local p2 = vec3(max.x, min.y, min.z)
local p1 = vec3(min.x, min.y, min.z)
local p2 = vec3(max.x, min.y, min.z)
local p3 = vec3(max.x, max.y, min.z)
local p2 = vec3(max.x, min.y, min.z)
local p3 = vec3(max.x, max.y, min.z)
local p4 = vec3(min.x, max.y, min.z)
local p3 = vec3(max.x, max.y, min.z)
local p4 = vec3(min.x, max.y, min.z)
local p5 = vec3(min.x, min.y, max.z)
local p4 = vec3(min.x, max.y, min.z)
local p5 = vec3(min.x, min.y, max.z)
local p6 = vec3(max.x, min.y, max.z)
local p5 = vec3(min.x, min.y, max.z)
local p6 = vec3(max.x, min.y, max.z)
local p7 = vec3(max.x, max.y, max.z)
local p6 = vec3(max.x, min.y, max.z)
local p7 = vec3(max.x, max.y, max.z)
local p8 = vec3(min.x, max.y, max.z)
local p7 = vec3(max.x, max.y, max.z)
local p8 = vec3(min.x, max.y, max.z)
if debugState.drawTileGrid then
local p1 = vec3(worldX, worldY, z)
local p2 = vec3(worldX + tileSize, worldY + tileSize, z + 1000) -- Huge block
local p1 = vec3(worldX, worldY, z)
local p2 = vec3(worldX + tileSize, worldY + tileSize, z + 1000) -- Huge block
if debugState.drawBorders then
local p1 = vec3(worldX, worldY, z)
local p2 = vec3(worldX + tileSize, worldY, z)
local p1 = vec3(worldX, worldY, z)
local p2 = vec3(worldX + tileSize, worldY, z)
local p3 = vec3(worldX + tileSize, worldY + tileSize, z)
local p2 = vec3(worldX + tileSize, worldY, z)
local p3 = vec3(worldX + tileSize, worldY + tileSize, z)
local p4 = vec3(worldX, worldY + tileSize, z)
local p3 = vec3(worldX + tileSize, worldY + tileSize, z)
local p4 = vec3(worldX, worldY + tileSize, z)
if debugState.drawStats then
debugDrawer:drawTextAdvanced(vec3(worldX+tileSize/2, worldY+tileSize/2, z),
String(string.format("Tile %d,%d\nObj: %d\nDec: %d\nMrk: %d\nFor: %d\nAI: %d",
for _, obj in ipairs(data.objects) do
local pos = vec3(worldX + obj.pos[1], worldY + obj.pos[2], obj.pos[3])
debugDrawer:drawSphere(pos + vec3(0,0,2), 1, ColorF(0,0,1,0.5))
local pos = vec3(worldX + obj.pos[1], worldY + obj.pos[2], obj.pos[3])
debugDrawer:drawSphere(pos + vec3(0,0,2), 1, ColorF(0,0,1,0.5))
for _, item in ipairs(data.forestItems) do
local pos = vec3(worldX + item.pos[1], worldY + item.pos[2], item.pos[3])
debugDrawer:drawSphere(pos + vec3(0,0,2), 0.5, ColorF(0,1,0,0.5))
local pos = vec3(worldX + item.pos[1], worldY + item.pos[2], item.pos[3])
debugDrawer:drawSphere(pos + vec3(0,0,2), 0.5, ColorF(0,1,0,0.5))
for _, decal in ipairs(data.decals) do
local pos = vec3(worldX + decal.pos[1], worldY + decal.pos[2], decal.pos[3])
local rot = QuatF(decal.rot[1], decal.rot[2], decal.rot[3], decal.rot[4])
local scale = vec3(decal.scale[1], decal.scale[2], decal.scale[3])
local halfSize = scale.x * 0.5 -- Rough size
local up = rot * vec3(0,0,1)
local right = rot * vec3(1,0,0)
local up = rot * vec3(0,0,1)
local right = rot * vec3(1,0,0)
local fwd = rot * vec3(0,1,0)
local right = rot * vec3(1,0,0)
local fwd = rot * vec3(0,1,0)
-- Convert local to world
local pos = vec3(worldX + node.pos[1], worldY + node.pos[2], node.pos[3])
-- Node sphere
debugDrawer:drawSphere(pos + vec3(0,0,0.5), node.radius or 1, ColorF(1,1,0,0.5))
if link.inPos and link.outPos then
local inPos = vec3(worldX + link.inPos[1], worldY + link.inPos[2], link.inPos[3])
local outPos = vec3(worldX + link.outPos[1], worldY + link.outPos[2], link.outPos[3])
local inPos = vec3(worldX + link.inPos[1], worldY + link.inPos[2], link.inPos[3])
local outPos = vec3(worldX + link.outPos[1], worldY + link.outPos[2], link.outPos[3])
if not debugState.drawAIGraphAdvanced then
debugDrawer:drawLine(inPos + vec3(0,0,0.5), outPos + vec3(0,0,0.5), ColorF(1,1,0,1))
else
if not debugState.drawAIGraphAdvanced then
debugDrawer:drawLine(inPos + vec3(0,0,0.5), outPos + vec3(0,0,0.5), ColorF(1,1,0,1))
else
-- Assume flat normal or use some up
local normal = vec3(0,0,1)
local right1 = edgeDirVec:cross(normal) -- Cross with Up to get Right
local tailPos, tipPos = vec3(), vec3()
for i = 1, laneCount do
local tailPos, tipPos = vec3(), vec3()
for i = 1, laneCount do
tailPos:set(inPos)
tailPos:setAdd2(tailPos, right1 * offset + vec3(0,0,0.5)) -- Offset + height
local p1 = vec3(worldX + n1.pos[1], worldY + n1.pos[2], n1.pos[3] + 0.2)
local p2 = vec3(worldX + n2.pos[1], worldY + n2.pos[2], n2.pos[3] + 0.2)
local p1 = vec3(worldX + n1.pos[1], worldY + n1.pos[2], n1.pos[3] + 0.2)
local p2 = vec3(worldX + n2.pos[1], worldY + n2.pos[2], n2.pos[3] + 0.2)
-- Perpendicular vector (rotate 90 degrees around Z axis)
local perp = vec3(-dir.y, dir.x, 0)
for _, node in ipairs(road.nodes) do
local pos = vec3(worldX + node.pos[1], worldY + node.pos[2], node.pos[3] + 0.2)
local width = node.width or 5
@/lua/ge/extensions/editor/crawlEditor/presets.lua
name = n.name or ("Node " .. i),
pos = vec3(n.position or {0,0,0}),
rot = quat(n.rotation or {0,0,0,1}),
name = n.name or ("Node " .. i),
pos = vec3(n.position or {0,0,0}),
rot = quat(n.rotation or {0,0,0,1}),
@/lua/ge/extensions/gameplay/delivery/delivery.lua
self.sites = sites
self.pickup = {pos = vec3(pickupPos), radius = pickupRadius}
self.locations = self:selectLocations(tag, count)
@/lua/ge/extensions/gameplay/missions/startTrigger.lua
local posDown = location.pos + vec3(0,0,-2)
local posUp = location.pos + vec3(0,0,0.25)
local posDown = location.pos + vec3(0,0,-2)
local posUp = location.pos + vec3(0,0,0.25)
local colorf = ColorF(0.3*color[1], 0.3*color[2], 0.3*color[3], 0.2)
local posUp = location.pos + vec3(0,0,5)
local colorf = ColorF(0.6*color[1], 0.6*color[2], 0.6*color[3], 0.4)
posDown = posUp
local posUp = location.pos + vec3(0,0,5)
local colorf = ColorF(1.0*color[1], 1.0*color[2], 1.0*color[3], 1.0)
local function coordinatesTriggerList(trigger,locations)
table.insert(locations, {type='coordinates', level=trigger.level, pos=vec3(trigger.pos), rot=quat(trigger.rot or {0,0,0,1}), radius=trigger.radius, check=defaultLocationCheck, displayMarker=defaultLocationDisplayMarker})
end
local missionIds = {}
local weightedCenter = vec3()
local sumRadii = 0
weightedCenter = weightedCenter / sumRadii
local newCenter = vec3()
local sumWeights = 0
@/gameplay/missionTypes/scatterPickup/editor.lua
--self:addBool("Has End Zone","hasEndZone",false,nil,{boxText = "If true, challenge ends when player enters this trigger"})
--self:addTransform("End Zone", "endZone", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "fullBox", drawColor = {0,0,1,0.3}})
@/lua/ge/extensions/editor/aiViz.lua
local upVector = vec3(0, 0, 1)
local linkLineColor = ColorF(0, 1, 0, 1)
local linkLineOffset = vec3(0, 0, 0.5)
local tailPos = inNodePos + right1 * offset1
local tipPos = vec3()
for j = 1, k do
local perpendicularDir = linkDir:normalized():cross(upVector)
local p1 = node.pos + perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p2 = node.pos + -perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p1 = node.pos + perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p2 = node.pos + -perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p3 = mapNodes[otherNid].pos + -perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local p2 = node.pos + -perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p3 = mapNodes[otherNid].pos + -perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local p4 = mapNodes[otherNid].pos + perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local p3 = mapNodes[otherNid].pos + -perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local p4 = mapNodes[otherNid].pos + perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local hitDist1 = intersectsRay_Triangle(camPos, rayDir, p1, p2, p3)
@/lua/ge/extensions/editor/audioEventsList.lua
else
sourcePos = vec3(0,0,0)
end
@/lua/ge/extensions/ui/apps/minimap/additionalInfo.lua
local lastLocationName = nil
local camPos = vec3()
local function checkLocationName()
@/lua/ge/spawn.lua
local localVehForward = vec3(0, -1, 0)
local localVehUp = vec3(0, 0, 1)
local localVehForward = vec3(0, -1, 0)
local localVehUp = vec3(0, 0, 1)
local otherBB = otherVeh:getWorldBox()
otherVehAxis1, otherVehAxis2, otherVehAxis3 = vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)
otherBBHalfExtents = otherBB:getExtents() / 2
local otherBB = otherVeh:getWorldBox()
otherVehAxis1, otherVehAxis2, otherVehAxis3 = vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)
otherBBHalfExtents = otherBB:getExtents() / 2
local otherBB = otherVeh:getWorldBox()
otherVehAxis1, otherVehAxis2, otherVehAxis3 = vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)
otherBBHalfExtents = otherBB:getExtents() / 2
end
local newVehicleBBMaxExtents = vec3(halfExtentsX, halfExtentsY, halfExtentsZ):length()
local seed = vec3(math.random(), math.random(), math.random())
local function getVisibilityStatus(intendedPos, testBB)
-- Turn it around if upside down
if vehBB:getAxis(2):dot(vec3(0, 0, 1)) < 0 then
local mat = vehBB:getMatrix()
local halfExtentsX, halfExtentsY, halfExtentsZ = abs(vehBB:getHalfExtents().x), abs(vehBB:getHalfExtents().y), abs(vehBB:getHalfExtents().z)
local downVec = raycastDown and vec3(0,0,-1) or -axis2
-- first raycast straight down
local halfExtents = vehBB:getHalfExtents()
mat:setPosition(vehBB:getCenter() + vec3(0,0,(halfExtents.x + halfExtents.y + halfExtents.z)/3))
newBBHigher:set2(mat, vehBB:getHalfExtents() * 2)
-- Turn it around if upside down
if boundingBox:getAxis(2):dot(vec3(0, 0, 1)) < 0 then
local mat = boundingBox:getMatrix()
local transform0 = veh:getRefNodeMatrix()
local coupler0_offset = couplerOffsetVeh--vec3(0, 3, 0.2)
local coupler1_offset = couplerOffsetTrailer--vec3(0.3, -3.3, 0)
local coupler0_offset = couplerOffsetVeh--vec3(0, 3, 0.2)
local coupler1_offset = couplerOffsetTrailer--vec3(0.3, -3.3, 0)
@/lua/ge/extensions/flowgraph/nodes/mission/ARunForLife.lua
buff = self:getBuffByName("repair")
actualPos = vec3(lanesPos[buff.lane], camPos.y + spawnLine, Z)
self:activateBuff(buff, actualPos)
if coinAvailable then
actualPos = vec3(randomLanePos, camPos.y + spawnLine, Z)
self:activateBuff(self:getBuffByName("coin"), actualPos)
local oobb = veh:getSpawnWorldOOBB()
local oobbCenter = (vec3(oobb:getPoint(0)) + vec3(oobb:getPoint(3)) + vec3(oobb:getPoint(7)) + vec3(oobb:getPoint(4))) / 4
local diff = oobbCenter - veh:getPosition()
local oobb = veh:getSpawnWorldOOBB()
local oobbCenter = (vec3(oobb:getPoint(0)) + vec3(oobb:getPoint(3)) + vec3(oobb:getPoint(7)) + vec3(oobb:getPoint(4))) / 4
local diff = oobbCenter - veh:getPosition()
local oobb = veh:getSpawnWorldOOBB()
local oobbCenter = (vec3(oobb:getPoint(0)) + vec3(oobb:getPoint(3)) + vec3(oobb:getPoint(7)) + vec3(oobb:getPoint(4))) / 4
local diff = oobbCenter - veh:getPosition()
local oobb = veh:getSpawnWorldOOBB()
local oobbCenter = (vec3(oobb:getPoint(0)) + vec3(oobb:getPoint(3)) + vec3(oobb:getPoint(7)) + vec3(oobb:getPoint(4))) / 4
local diff = oobbCenter - veh:getPosition()
local diff = oobbCenter - veh:getPosition()
actualPos = vec3(randomLanePos, camPos.y + spawnLine, Z) - diff
spawn.safeTeleport(veh, vec3(actualPos), rot)
texture = 'art/shapes/arrows/t_arrow_opaque_d.color.png',
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
color = ColorF(1, 0, 0, 1 ),
color = ColorF(1, 0, 0, 1 ),
scale = vec3(1, 1, 4),
fadeStart = 100,
local forwardVec = vec3(0, -1, 0)
local anotherForwardVec = vec3(0, 1, 0)
local forwardVec = vec3(0, -1, 0)
local anotherForwardVec = vec3(0, 1, 0)
local scaleVec = vec3(7, 8, 5)
local anotherForwardVec = vec3(0, 1, 0)
local scaleVec = vec3(7, 8, 5)
local anotherScaleVec = vec3(10, 12, 5)
local scaleVec = vec3(7, 8, 5)
local anotherScaleVec = vec3(10, 12, 5)
local drawPos
drawPos = vec3(propPos.x + t.decal.xOffset, propPos.y + t.decal.yOffset, Z)
color = t.decal.color
data.color = ColorF(unpack(red))
data.position = vec3(plPos.x, camPos.y, Z)
data.forwardVec = anotherForwardVec
@/lua/ge/extensions/flowgraph/nodes/gameplay/rally/trackVehicleDistanceToPos.lua
local veh, vehicleData
-- local wCenter, wPos = vec3(), vec3()
local vehPos, vehRot, vehVel = vec3(), quat(), vec3()
local veh, vehicleData
-- local wCenter, wPos = vec3(), vec3()
local vehPos, vehRot, vehVel = vec3(), quat(), vec3()
-- local wCenter, wPos = vec3(), vec3()
local vehPos, vehRot, vehVel = vec3(), quat(), vec3()
-- local wCenter, wPos = vec3(), vec3()
local vehPos, vehRot, vehVel = vec3(), quat(), vec3()
if type(self.pinIn.pos.value) == "table" and not self.pinIn.pos.value.x then
self.targetPos = vec3(self.pinIn.pos.value)
elseif self.pinIn.pos.value then
@/lua/ge/extensions/editor/vizHelper.lua
local lastPos = vec3()
end
local focusPos = vec3(mouseHit.pos)
--TODO: convert to editor.beginWindow/endWindow api
local norm = vec3(mouseHit.normal)
data.forwardVec = fwd
data.scale = vec3(scale[0], scale[0], scale[0])
data.fadeStart = 2000
@/lua/ge/ge_utils.lua
log('D', logTag,obj:getDeclarationLine())
--obj:delete(1,2,3, vec3(1,2,3), "test")
end
if not vehr then return end
local pos1 = vec3(vehr:getPosition())
local x, y, z = string.match(objPos, "([0-9]*)%s*([0-9]*)%s*([0-9]*)%s*")
objPos = vec3(tonumber(x), tonumber(y), tonumber(z))
end
local x, y, z = string.match(objScale, "([0-9]*)%s*([0-9]*)%s*([0-9]*)%s*")
objScale = vec3(tonumber(x), tonumber(y), tonumber(z))
end
-- Spawn the vehicle on the left of the player vehicle
local dir = vec3(playerVehicle:getDirectionVector()):normalized()
local offset = vec3(-dir.y, dir.x, 0)
local dir = vec3(playerVehicle:getDirectionVector()):normalized()
local offset = vec3(-dir.y, dir.x, 0)
local position = vec3(playerVehicle:getPosition())
local offset = vec3(-dir.y, dir.x, 0)
local position = vec3(playerVehicle:getPosition())
options.pos = position + offset * 5
if commands.isFreeCamera() or not playerVehicle then
local camDir = core_camera.getQuat() * vec3(0,1,0)
camDir.z = 0
else
options.rot = quatFromDir(vec3(playerVehicle:getDirectionVector()):normalized(), vec3(playerVehicle:getDirectionVectorUp()):normalized())
end
else
options.rot = quatFromDir(vec3(playerVehicle:getDirectionVector()):normalized(), vec3(playerVehicle:getDirectionVectorUp()):normalized())
end
res.pt = vec3(res.pt)
res.norm = vec3(res.norm)
res.pt = vec3(res.pt)
res.norm = vec3(res.norm)
return res
local a = vec3(4 + math.sin(castRayTest) * 3,-2+math.cos(castRayTest) * 3,10)
local b = vec3(4 + math.cos(castRayTest) * 3,-2+math.sin(castRayTest) * 3,-10)
local a = vec3(4 + math.sin(castRayTest) * 3,-2+math.cos(castRayTest) * 3,10)
local b = vec3(4 + math.cos(castRayTest) * 3,-2+math.sin(castRayTest) * 3,-10)
castRayDebug(a, b, false, false)
@/lua/ge/extensions/gameplay/crashTest/scenarioManager.lua
sanitizedStep.scriptAiFile = "scriptAi"..id..".track.json"
sanitizedStep.staticCrashTransformPos =vec3(step.staticCrashTransformPos[1], step.staticCrashTransformPos[2], step.staticCrashTransformPos[3])
sanitizedStep.staticCrashTransformScl = vec3(step.staticCrashTransformScl[1], step.staticCrashTransformScl[2], step.staticCrashTransformScl[3])
sanitizedStep.staticCrashTransformPos =vec3(step.staticCrashTransformPos[1], step.staticCrashTransformPos[2], step.staticCrashTransformPos[3])
sanitizedStep.staticCrashTransformScl = vec3(step.staticCrashTransformScl[1], step.staticCrashTransformScl[2], step.staticCrashTransformScl[3])
sanitizedStep.plTargetDestinationPos = vec3(step.plTargetDestinationPos[1], step.plTargetDestinationPos[2], step.plTargetDestinationPos[3])
sanitizedStep.staticCrashTransformScl = vec3(step.staticCrashTransformScl[1], step.staticCrashTransformScl[2], step.staticCrashTransformScl[3])
sanitizedStep.plTargetDestinationPos = vec3(step.plTargetDestinationPos[1], step.plTargetDestinationPos[2], step.plTargetDestinationPos[3])
sanitizedStep.plTargetDestinationScl = vec3(step.plTargetDestinationScl[1], step.plTargetDestinationScl[2], step.plTargetDestinationScl[3])
sanitizedStep.plTargetDestinationPos = vec3(step.plTargetDestinationPos[1], step.plTargetDestinationPos[2], step.plTargetDestinationPos[3])
sanitizedStep.plTargetDestinationScl = vec3(step.plTargetDestinationScl[1], step.plTargetDestinationScl[2], step.plTargetDestinationScl[3])
sanitizedStep.targetVehTargetDestinationPos = vec3(step.targetVehTargetDestinationPos[1], step.targetVehTargetDestinationPos[2], step.targetVehTargetDestinationPos[3])
sanitizedStep.plTargetDestinationScl = vec3(step.plTargetDestinationScl[1], step.plTargetDestinationScl[2], step.plTargetDestinationScl[3])
sanitizedStep.targetVehTargetDestinationPos = vec3(step.targetVehTargetDestinationPos[1], step.targetVehTargetDestinationPos[2], step.targetVehTargetDestinationPos[3])
sanitizedStep.targetVehTargetDestinationScl = vec3(step.targetVehTargetDestinationScl[1], step.targetVehTargetDestinationScl[2], step.targetVehTargetDestinationScl[3])
sanitizedStep.targetVehTargetDestinationPos = vec3(step.targetVehTargetDestinationPos[1], step.targetVehTargetDestinationPos[2], step.targetVehTargetDestinationPos[3])
sanitizedStep.targetVehTargetDestinationScl = vec3(step.targetVehTargetDestinationScl[1], step.targetVehTargetDestinationScl[2], step.targetVehTargetDestinationScl[3])
sanitizedStep.isThereDamageAssessment = step.isThereDamageAssessment
local vecOffset = vec3(0, 0, 2)
local function displayTargetMarkers(displayOnlyCurrentStep)
@/lua/common/jbeam/sections/wheels.lua
-- fix it like this
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
-- fix it like this
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
-- fix it like this
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
-- fix it like this
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
local width = node1_pos:distance(node2_pos)
-- fix it like this
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
local node1_pos = vec3(node1.pos)
local node2_pos = vec3(node2.pos)
@/lua/ge/extensions/flowgraph/nodes/types/transform.lua
local cameraPosition = core_camera.getPosition()
local position = core_camera.getQuat() * vec3(0, 15, 0)
self.position = position + cameraPosition
self.rotation = quat(0,0,0,1)
self.scale = vec3(1,1,1)
self.markerColor = ColorF(1,0,0.5,0.25)
self._beginDragRotation = deepcopy(quat(self.rotation))
self._beginDragScale = vec3(self.scale)
self._beginDragPosition = vec3(self.position)
self._beginDragScale = vec3(self.scale)
self._beginDragPosition = vec3(self.position)
end
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
self.position = vec3(editor.getAxisGizmoTransform():getColumn(3))
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Rotate then
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
self.scale = vec3(self._beginDragScale):componentMul(scl)
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
self.scale = vec3(self._beginDragScale):componentMul(scl)
end
local x, y, z = self.rotation * vec3(1,0,0), self.rotation * vec3(0,1,0), self.rotation * vec3(0,0,1)
--if self.isDragging then
local x, y, z = self.rotation * vec3(1,0,0), self.rotation * vec3(0,1,0), self.rotation * vec3(0,0,1)
--if self.isDragging then
local x, y, z = self.rotation * vec3(1,0,0), self.rotation * vec3(0,1,0), self.rotation * vec3(0,0,1)
--if self.isDragging then
if not obj then return end
self.position = vec3(obj:getPosition())
self.rotation = quat(obj:getRotation())
self.rotation = quat(obj:getRotation())
self.scale = vec3(obj:getScale())
end
local cameraPosition = core_camera.getPosition()
local position = core_camera.getQuat() * vec3(0, 15, 0)
local beforeCam = position + cameraPosition
if im.Button("Position To Camera") then
self.position = vec3(cameraPosition)
self:updateTransform()
if not obj then return end
self.position = vec3(obj:getPosition())
self.rotation = quat(obj:getRotation())
self.rotation = quat(obj:getRotation())
self.scale = vec3(obj:getScale())
self.changed = true
local rot = self.rotation
local x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
x = x + self.position
local rot = self.rotation
local x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
x = x + self.position
local rot = self.rotation
local x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
x = x + self.position
elseif self.displayMode == 'halfBox' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
local scl = (x+y+z)/2
elseif self.displayMode == 'halfBox' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
local scl = (x+y+z)/2
elseif self.displayMode == 'halfBox' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
local scl = (x+y+z)/2
elseif self.displayMode == 'fullBox' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
local scl = (x+y+z)
elseif self.displayMode == 'fullBox' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
local scl = (x+y+z)
elseif self.displayMode == 'fullBox' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
local scl = (x+y+z)
elseif self.displayMode == 'aproxVehicle' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
self:drawAxisBox(((-x-1*y-0.3*z)+self.position),x*2,y*4.2,z*1.8,color(self.markerColor.red*255, self.markerColor.green*255, self.markerColor.blue*255, self.markerColor.alpha*255))
elseif self.displayMode == 'aproxVehicle' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
self:drawAxisBox(((-x-1*y-0.3*z)+self.position),x*2,y*4.2,z*1.8,color(self.markerColor.red*255, self.markerColor.green*255, self.markerColor.blue*255, self.markerColor.alpha*255))
elseif self.displayMode == 'aproxVehicle' then
x, y, z = rot * vec3(self.scale.x,0,0), rot * vec3(0,self.scale.y,0), rot * vec3(0,0,self.scale.z)
self:drawAxisBox(((-x-1*y-0.3*z)+self.position),x*2,y*4.2,z*1.8,color(self.markerColor.red*255, self.markerColor.green*255, self.markerColor.blue*255, self.markerColor.alpha*255))
debugDrawer:drawTriSolid(
vec3(self.position+x/2 ),
vec3(self.position-x/2 ),
vec3(self.position+x/2 ),
vec3(self.position-x/2 ),
vec3(self.position-y/2 ),
vec3(self.position-x/2 ),
vec3(self.position-y/2 ),
color(self.markerColor.red*128, self.markerColor.green*128, self.markerColor.blue*128, self.markerColor.alpha*255))
debugDrawer:drawTriSolid(
vec3(self.position-x/2 ),
vec3(self.position+x/2 ),
vec3(self.position-x/2 ),
vec3(self.position+x/2 ),
vec3(self.position-y/2 ),
vec3(self.position+x/2 ),
vec3(self.position-y/2 ),
color(self.markerColor.red*128, self.markerColor.green*128, self.markerColor.blue*128, self.markerColor.alpha*255))
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
if nodeData.position then
self.position = vec3(nodeData.position[1], nodeData.position[2], nodeData.position[3])
end
if nodeData.scale then
self.scale = vec3(nodeData.scale[1], nodeData.scale[2], nodeData.scale[3])
end
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/vePropTransformer.lua
local zeroVec = vec3(0,0,0)
local arrowHeadVec = vec3(0,0.075,0)
local zeroVec = vec3(0,0,0)
local arrowHeadVec = vec3(0,0.075,0)
pickedProp = nil,
lastPropBaseTranslationGlobal = vec3(),
lastPropBaseRotationGlobal = vec3(),
lastPropBaseTranslationGlobal = vec3(),
lastPropBaseRotationGlobal = vec3(),
lastPropBaseRotationGlobalQuat = quat(),
axisGizmo = {
startPos = vec3()
}
if not prop.baseTranslationGlobalWithNodeTransforms then
prop.baseTranslationGlobalWithNodeTransforms = vec3()
end
local tempVec = vec3()
local qDir = quat(worldMat:toQuatF())
local dirVec = qDir * vec3(0, lightRange, 0)
if im.InputFloat3("baseTranslation", inputBaseTranslation, "%0.3f") then
propObj:setBaseTranslation(vec3(inputBaseTranslation[0], inputBaseTranslation[1], inputBaseTranslation[2]))
end
if im.InputFloat3("baseTranslationGlobal", inputBaseTranslationGlobal, "%0.3f") then
propObj:setBaseTranslationGlobal(vec3(inputBaseTranslationGlobal[0], inputBaseTranslationGlobal[1], inputBaseTranslationGlobal[2]))
end
if im.InputFloat3("baseRotation", inputBaseRotation, "%0.3f", im.InputTextFlags_EnterReturnsTrue) then
local rot = vec3(inputBaseRotation[0] * math.pi / 180.0, inputBaseRotation[1] * math.pi / 180.0, inputBaseRotation[2] * math.pi / 180.0)
propObj:setBaseRotation(rot)
if im.InputFloat3("baseRotationGlobal", inputBaseRotationGlobal, "%0.3f", im.InputTextFlags_EnterReturnsTrue) then
local rot = vec3(inputBaseRotationGlobal[0] * math.pi / 180.0, inputBaseRotationGlobal[1] * math.pi / 180.0, inputBaseRotationGlobal[2] * math.pi / 180.0)
propObj:setBaseRotationGlobal(rot)
@/lua/ge/extensions/flowgraph/nodes/gameplay/toggleWalking.lua
if self.pinIn.enterWalking.value then
local pos = self.pinIn.pos.value and vec3(self.pinIn.pos.value) or nil
local rot = self.pinIn.rot.value and quat(self.pinIn.rot.value) or nil
@/gameplay/missionTypes/evade/customNodes/scatterTrafficAwayNode.lua
if v.isAi then
if (self.pinIn.inverted.value and v.pos:squaredDistance(vec3(self.pinIn.pos.value)) > square(self.pinIn.radius.value))
or (not self.pinIn.inverted.value and v.pos:squaredDistance(vec3(self.pinIn.pos.value)) <= square(self.pinIn.radius.value)) then
if (self.pinIn.inverted.value and v.pos:squaredDistance(vec3(self.pinIn.pos.value)) > square(self.pinIn.radius.value))
or (not self.pinIn.inverted.value and v.pos:squaredDistance(vec3(self.pinIn.pos.value)) <= square(self.pinIn.radius.value)) then
gameplay_traffic.forceTeleport(id)
@/lua/ge/extensions/flowgraph/nodes/gameplay/decalCircle.lua
texture = 'art/shapes/arrows/t_arrow_opaque_d.color.png',
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
color = ColorF(1, 0, 0, 1),
color = ColorF(1, 0, 0, 1),
scale = vec3(1, 1, 1),
fadeStart = 200,
@/lua/ge/extensions/gameplay/drift/stuntZones/donut.lua
local decalCount
local defaultDecalScale = vec3(0.35,0.35,3)
local t, cosX, sinY, x, y, data, invAmount, filledPerc, cooldownPerc
local lastPos = vec3()
local pos = vec3()
local lastPos = vec3()
local pos = vec3()
local color
pos = vec3(x,y,self.data.zoneData.pos.z or 0)
color = gameplay_drift_stuntZones.getDecalColor(cooldownPerc, filledPerc, t)
@/lua/ge/extensions/editor/masterSpline/autoRoadGen.lua
local iStart, iGoal, pt = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
local distVec, dir = vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local iStart, iGoal, pt = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
local distVec, dir = vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local distVec, dir = vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local distVec, dir = vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local distVec, dir = vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
for i = 1, #nodes - 1 do
local startPos, goalPos = vec3(nodes[i]), vec3(nodes[i + 1])
for i = 1, #nodes - 1 do
local startPos, goalPos = vec3(nodes[i]), vec3(nodes[i + 1])
local p = pathNodes[i]
spline.nodes[i], spline.widths[i], spline.nmls[i] = vec3(p), pathWidths[i], vec3(0, 0, 1)
end
local p = pathNodes[i]
spline.nodes[i], spline.widths[i], spline.nmls[i] = vec3(p), pathWidths[i], vec3(0, 0, 1)
end
@/lua/ge/extensions/flowgraph/nodes/scene/singleMarker.lua
local sendTable = {pos = vec3(), radius = 0}
local fieldsChanged = false
self.marker = require("scenario/race_marker").createRaceMarker(true, self.pinIn.markerType.value)
self.marker:setToCheckpoint({pos = vec3(self.position), radius = self.radius, fadeNear = self.pinIn.fadeNearDist.value, fadeFar = self.pinIn.fadeFarDist.value})
self.marker:setMode('default')
@/lua/ge/extensions/editor/tech/roadArchitect/render.lua
local groupPolygonElevVec = vec3(0, 0, 5) -- A vector used when rendering group creation 'fences' (polygons).
local cylRaised = vec3(0, 0, 5.0) -- The length of the cylinder used to render terraform range visualisation spheres.
local random, randomseed = math.random, math.randomseed
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local random, randomseed = math.random, math.randomseed
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local clRaise = vec3(0, 0, 0.01) -- A vector used to raise the road centerline slightly.
local xAxis, yAxis, zAxis = vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) -- The unit axis vectors.
local clRaise = vec3(0, 0, 0.01) -- A vector used to raise the road centerline slightly.
local xAxis, yAxis, zAxis = vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) -- The unit axis vectors.
local downVec, raised = -zAxis, zAxis * 10.0
local clRaise = vec3(0, 0, 0.01) -- A vector used to raise the road centerline slightly.
local xAxis, yAxis, zAxis = vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) -- The unit axis vectors.
local downVec, raised = -zAxis, zAxis * 10.0
local clRaise = vec3(0, 0, 0.01) -- A vector used to raise the road centerline slightly.
local xAxis, yAxis, zAxis = vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) -- The unit axis vectors.
local downVec, raised = -zAxis, zAxis * 10.0
local cp1, cp2 = renderData[1][idx1][idx2], renderData[2][idx1][idx2]
local pStart, p2 = vec3(cp1.x, cp1.y, cp1.z), vec3(cp2.x, cp2.y, cp2.z)
local sTgt = pStart - p2
local cp1, cp2 = renderData[1][idx1][idx2], renderData[2][idx1][idx2]
local pStart, p2 = vec3(cp1.x, cp1.y, cp1.z), vec3(cp2.x, cp2.y, cp2.z)
local sTgt = pStart - p2
local cp1, cp2 = renderData[#renderData][idx1][idx2], renderData[#renderData - 1][idx1][idx2]
local pEnd, p3 = vec3(cp1.x, cp1.y, cp1.z), vec3(cp2.x, cp2.y, cp2.z)
local eTgt = pEnd - p3
local cp1, cp2 = renderData[#renderData][idx1][idx2], renderData[#renderData - 1][idx1][idx2]
local pEnd, p3 = vec3(cp1.x, cp1.y, cp1.z), vec3(cp2.x, cp2.y, cp2.z)
local eTgt = pEnd - p3
@/lua/ge/extensions/editor/camPathEditor.lua
local sqrt = math.sqrt
local xVector = vec3(1, 0, 0)
local yVector = vec3(0, 1, 0)
local xVector = vec3(1, 0, 0)
local yVector = vec3(0, 1, 0)
local zVector = vec3(0, 0, 1)
local yVector = vec3(0, 1, 0)
local zVector = vec3(0, 0, 1)
local target = vec3(0, 0, 0)
if playerVehicle then
-- Transform offset from local space to world space using vehicle direction vectors
local forward = vec3(playerVehicle:getDirectionVector())
local up = vec3(playerVehicle:getDirectionVectorUp())
local forward = vec3(playerVehicle:getDirectionVector())
local up = vec3(playerVehicle:getDirectionVectorUp())
local right = up:cross(forward):normalized() -- Compute right vector using cross product
frustumColorI = trackingFrustumColorI
local target = vec3(0, 0, 0)
if playerVehicle then
-- Transform offset from local space to world space using vehicle direction vectors
local forward = vec3(playerVehicle:getDirectionVector())
local up = vec3(playerVehicle:getDirectionVectorUp())
local forward = vec3(playerVehicle:getDirectionVector())
local up = vec3(playerVehicle:getDirectionVectorUp())
local right = up:cross(forward):normalized() -- Compute right vector using cross product
'pos',
vec3(markerPosition[0], markerPosition[1], markerPosition[2])
)
@/lua/ge/extensions/editor/crawlEditor/input.lua
mouseInfo.ray = getCameraMouseRay()
mouseInfo.rayDir = vec3(mouseInfo.ray.dir)
mouseInfo.rayCast = cameraMouseRayCast()
mouseInfo.hold = false
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._downNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._downNormal = vec3(mouseInfo.rayCast.normal)
end
if mouseInfo.hold then
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._holdNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._holdNormal = vec3(mouseInfo.rayCast.normal)
end
if mouseInfo.up then
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._upNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._upNormal = vec3(mouseInfo.rayCast.normal)
end
@/lua/ge/extensions/gameplay/traffic.lua
-- const vectors --
local vecUp = vec3(0, 0, 1)
local vecY = vec3(0, 1, 0)
local vecUp = vec3(0, 0, 1)
local vecY = vec3(0, 1, 0)
local spawnProcess = {}
local spawnPointPos, spawnPointDirVec = vec3(), vec3()
local tempVec = vec3()
local spawnProcess = {}
local spawnPointPos, spawnPointDirVec = vec3(), vec3()
local tempVec = vec3()
local spawnPointPos, spawnPointDirVec = vec3(), vec3()
local tempVec = vec3()
local vars, focus
focus.mode = 'camera'
focus.pos = vec3()
focus.dirVec = vec3()
focus.pos = vec3()
focus.dirVec = vec3()
focus.dist = 0 -- scales direction vector (looks ahead)
if traffic[id] then
traffic[id].pos = vec3(pos) -- instantly updates the position this frame
traffic[id]._teleport = nil
--if traffic[id] then
--traffic[id].respawn.pos = vec3(0, 0, -1000) -- temporary, prevents conflicts (remove later)
--end
@/lua/ge/extensions/flowgraph/nodes/util/distanceBetween.lua
local zeroVec = vec3()
local posA = vec3()
local posB = vec3()
local posA = vec3()
local posB = vec3()
function C:work()
local pos = vec3()
function C:getPosition(pinInput)
@/lua/ge/extensions/editor/meshSpline/import.lua
local abs = math.abs
local scaleVec = vec3(1, 1, 1)
local meshRot = quat()
local tangent, meshXAxis = vec3(), vec3()
local meshRot = quat()
local tangent, meshXAxis = vec3(), vec3()
comp.obj = Sim.upcast(comp.obj)
local pos = vec3(comp.obj:getPosition())
positions[i], widths[i] = pos, 10.0 -- Use dummy widths.
for _ = 1, #filteredPositions do
table.insert(spline.nmls, vec3(0, 0, 1)) -- Default to global up.
end
@/lua/ge/extensions/flowgraph/nodes/vehicle/groundDistance.lua
local point, offset = vec3(), vec3()
local point, offset = vec3(), vec3()
@/lua/ge/extensions/editor/terrainAndRoadImporter.lua
local abs, sqrt, exp, pi = math.abs, math.sqrt, math.exp, math.pi
local vert = vec3(0, 0, 1.0)
local zOffsetDecal = vert * 10
local tmp1, tmp2, tmp3, tmp4 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tmp1, tmp2, tmp3, tmp4 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tmp1, tmp2, tmp3, tmp4 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local tmp1, tmp2, tmp3, tmp4 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
for i = 1, #jsonFull do
te:worldToGridByPoint2I(vec3(jsonFull[i].x, jsonFull[i].y, jsonFull[i].z), gW, tb)
peaks[i] = vec3(gW.x, gW.y, jsonFull[i].z)
te:worldToGridByPoint2I(vec3(jsonFull[i].x, jsonFull[i].y, jsonFull[i].z), gW, tb)
peaks[i] = vec3(gW.x, gW.y, jsonFull[i].z)
end
-- Update the terrain block.
tb:updateGrid(vec3(0, 0), vec3(xSize, ySize))
end
-- Update the terrain block.
tb:updateGrid(vec3(0, 0), vec3(xSize, ySize))
end
local gMin, gMax = Point2I(0, 0), Point2I(0, 0)
te:worldToGridByPoint2I(vec3(floor(max(tXMin, box.xMin - DOI)), floor(max(tYMin, box.yMin - DOI))), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(min(tXMax, box.xMax + DOI)), ceil(min(tYMax, box.yMax + DOI))), gMax, tb)
te:worldToGridByPoint2I(vec3(floor(max(tXMin, box.xMin - DOI)), floor(max(tYMin, box.yMin - DOI))), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(min(tXMax, box.xMax + DOI)), ceil(min(tYMax, box.yMax + DOI))), gMax, tb)
local bXMin, bXMax, bYMin, bYMax = gMin.x, gMax.x, gMin.y, gMax.y
-- Iterate over the grid bounding box, and add contributions to the road mask.
local pWS = vec3(0, 0)
for x = 0, xSize do
-- Iterate over the grid bounding box, and add contributions to the road mask.
local pWS = vec3(0, 0)
local fixedMask = {}
-- Update the terrain block.
tb:updateGrid(vec3(bXMin, bYMin), vec3(bXMax, bYMax))
end
-- Update the terrain block.
tb:updateGrid(vec3(bXMin, bYMin), vec3(bXMax, bYMax))
end
local gMin, gMax = Point2I(0, 0), Point2I(0, 0)
te:worldToGridByPoint2I(vec3(floor(tXMin), floor(tYMin)), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
te:worldToGridByPoint2I(vec3(floor(tXMin), floor(tYMin)), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
-- Update the terrain block.
tb:updateGrid(vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y))
-- Update the terrain block.
tb:updateGrid(vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y))
local gMin, gMax = Point2I(0, 0), Point2I(0, 0)
te:worldToGridByPoint2I(vec3(floor(tXMin), floor(tYMin)), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
te:worldToGridByPoint2I(vec3(floor(tXMin), floor(tYMin)), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
tmp1:set(d.x, d.y, 0)
nodes[j] = vec3(d.x, d.y, core_terrain.getTerrainHeight(tmp1))
widths[j] = d.width
local gMin, gMax = Point2I(0, 0), Point2I(0, 0)
te:worldToGridByPoint2I(vec3(floor(tXMin), floor(tYMin)), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
te:worldToGridByPoint2I(vec3(floor(tXMin), floor(tYMin)), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
-- Update the terrain block.
tb:updateGrid(vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y))
end
-- Update the terrain block.
tb:updateGrid(vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y))
end
@/gameplay/missionTypes/cannon/customNodes/MarkersNode.lua
local modes = {}
local markerOffset = vec3()
local whiteF = ColorF(1, 1, 1, 1)
@/lua/ge/extensions/util/trackBuilder/basicCenters.lua
crossPoints = {
{ point = vec3( 1, 0, -1 ) },
{ point = vec3( 0.5, 0, -1.1 ) },
{ point = vec3( 1, 0, -1 ) },
{ point = vec3( 0.5, 0, -1.1 ) },
{ point = vec3( 0, 0, -1.15 ) },
{ point = vec3( 0.5, 0, -1.1 ) },
{ point = vec3( 0, 0, -1.15 ) },
{ point = vec3(-0.5, 0, -1.1 ) },
{ point = vec3( 0, 0, -1.15 ) },
{ point = vec3(-0.5, 0, -1.1 ) },
{ point = vec3(-1, 0, -1 ) },
{ point = vec3(-0.5, 0, -1.1 ) },
{ point = vec3(-1, 0, -1 ) },
{ point = vec3(-1, 0, 0 ) },
{ point = vec3(-0.7, 0, -0.15 ) },
{ point = vec3(-1, 0, 0 ) },
{ point = vec3(-0.7, 0, -0.15 ) },
{ point = vec3(-0.3, 0, -0.18 ) },
{ point = vec3(-0.7, 0, -0.15 ) },
{ point = vec3(-0.3, 0, -0.18 ) },
{ point = vec3(0, 0, -0.2 ) },
{ point = vec3(-0.3, 0, -0.18 ) },
{ point = vec3(0, 0, -0.2 ) },
{ point = vec3(0.3, 0, -0.18 ) },
{ point = vec3(0, 0, -0.2 ) },
{ point = vec3(0.3, 0, -0.18 ) },
{ point = vec3(0.7, 0, -0.15 ) },
{ point = vec3(0.3, 0, -0.18 ) },
{ point = vec3(0.7, 0, -0.15 ) },
{ point = vec3(1, 0, 0 ) }
{ point = vec3(0.7, 0, -0.15 ) },
{ point = vec3(1, 0, 0 ) }
},
crossPoints = {
{ point = vec3( 1, 0, -1 ) },
{ point = vec3( 0.5, 0, -1.1 ) },
{ point = vec3( 1, 0, -1 ) },
{ point = vec3( 0.5, 0, -1.1 ) },
{ point = vec3( 0, 0, -1.15 ) },
{ point = vec3( 0.5, 0, -1.1 ) },
{ point = vec3( 0, 0, -1.15 ) },
{ point = vec3(0, 0, -0.2 ) },
{ point = vec3(0.3, 0, -0.18 ) },
{ point = vec3(0, 0, -0.2 ) },
{ point = vec3(0.3, 0, -0.18 ) },
{ point = vec3(0.7, 0, -0.15 ) },
{ point = vec3(0.3, 0, -0.18 ) },
{ point = vec3(0.7, 0, -0.15 ) },
{ point = vec3(1, 0, 0 ) }
{ point = vec3(0.7, 0, -0.15 ) },
{ point = vec3(1, 0, 0 ) }
},
crossPoints = {
{ point = vec3( 1, 0,-1) },
{ point = vec3(-1, 0,-1) },
{ point = vec3( 1, 0,-1) },
{ point = vec3(-1, 0,-1) },
{ point = vec3(-1, 0, 0) },
{ point = vec3(-1, 0,-1) },
{ point = vec3(-1, 0, 0) },
{ point = vec3( 1, 0, 0) },
{ point = vec3(-1, 0, 0) },
{ point = vec3( 1, 0, 0) },
},
crossPoints = {
{ point = vec3( 1, 0,-1 ) },
{ point = vec3( 0, 0,-1.1) },
{ point = vec3( 1, 0,-1 ) },
{ point = vec3( 0, 0,-1.1) },
{ point = vec3(-1, 0,-1 ) },
{ point = vec3( 0, 0,-1.1) },
{ point = vec3(-1, 0,-1 ) },
{ point = vec3(-1, 0, 0 ) },
{ point = vec3(-1, 0,-1 ) },
{ point = vec3(-1, 0, 0 ) },
{ point = vec3( 0, 0,-0.2) },
{ point = vec3(-1, 0, 0 ) },
{ point = vec3( 0, 0,-0.2) },
{ point = vec3( 1, 0, 0 ) }
{ point = vec3( 0, 0,-0.2) },
{ point = vec3( 1, 0, 0 ) }
},
vertices[i] = {}
vertices[i].position = vec3(currentP.point.x * scl, currentP.point.y, currentP.point.z)
vertices[i].sharp = shape.crossPoints[i].sharp or false
a:normalize()
normals[#normals+1] = vec3(-a.z,0,a.x)
-- Actual normal.
local n = vec3(
-(a.z) - (b.z),
if len <=0.00001 then
n = vec3(
-(nextP.z - currentP.z),
else
normals[#normals+1] = vec3(-a.z,0,a.x)
normals[#normals+1] = vec3(-b.z,0,b.x)
normals[#normals+1] = vec3(-a.z,0,a.x)
normals[#normals+1] = vec3(-b.z,0,b.x)
end
a:normalize()
normals[#normals+1] = vec3(-a.z,0,a.x)
local pointCount = 0
local tmpVec3 = vec3()
for pIndex = 1, #segment.points do
p.position.z * point.orientation.nz +
point.position + vec3(0,0,point.zOffset)
)
@/lua/ge/extensions/editor/util/transformUtil.lua
self.pos = vec3(0, 0, 0)
self.rot = quat(0, 0, 0, 1)
self.rot = quat(0, 0, 0, 1)
self.scl = vec3(1, 1, 1)
self:setOneDimensionalScale(self.oneDimensionalScale)
else
self.scl = vec3(1, 1, 1) * (type(self.scl) == 'number' and self.scl or 1)
self.inputScl = im.ArrayFloat(3)
if scl and type(scl) == 'number' then
scl = vec3(1, 1, 1) * (scl or 1)
end
self._temp = {
pos = vec3(self.pos),
rot = quat(self.rot),
rot = quat(self.rot),
scl = self.oneDimensionalScale and self.scl or vec3(self.scl),
moved = false
if txt then
debugDrawer:drawTextAdvanced(vec3(mouseInfo.rayCast.pos), String(txt), ColorF(1, 1, 1, 1), true, false, clr or ColorI(0, 0, 0, 255))
end
function C:helperPositionInFrontOfToCamera()
self:set(vec3(core_camera.getQuat() * vec3(0, 15, 0)) + core_camera.getPosition())
end
function C:helperPositionInFrontOfToCamera()
self:set(vec3(core_camera.getQuat() * vec3(0, 15, 0)) + core_camera.getPosition())
end
if not core_terrain.getTerrain() then return end
self:set(vec3(self.pos.x, self.pos.y, core_terrain.getTerrainHeight(self.pos) or self.pos.z))
end
local terrainNormal = core_terrain.getTerrainSmoothNormal(self.pos)
local fwd = (self.rot * vec3(0,1,0)):projectToOriginPlane(terrainNormal)
self:set(nil, quatFromDir(fwd, terrainNormal))
if im.InputFloat3("##Pos", self.inputPos, "%0." .. editor.getPreference("ui.general.floatDigitCount") .. "f") then
self.pos = vec3(self.inputPos[0], self.inputPos[1], self.inputPos[2])
changed = true
if im.InputFloat3("##Scl", self.inputScl, "%0." .. editor.getPreference("ui.general.floatDigitCount") .. "f") then
self.scl = vec3(self.inputScl[0], self.inputScl[1], self.inputScl[2])
changed = true
if im.InputFloat3(self.objectName .. " Position", self.inputPos, "%0." .. editor.getPreference("ui.general.floatDigitCount") .. "f", im.InputTextFlags_EnterReturnsTrue) then
self.pos = vec3(self.inputPos[0], self.inputPos[1], self.inputPos[2])
changed = true
if im.InputFloat3(self.objectName .. " Scale", self.inputScl, "%0." .. editor.getPreference("ui.general.floatDigitCount") .. "f", im.InputTextFlags_EnterReturnsTrue) then
self.scl = vec3(self.inputScl[0], self.inputScl[1], self.inputScl[2])
changed = true
if im.InputFloat3("Pos", self.inputPos, "%0." .. editor.getPreference("ui.general.floatDigitCount") .. "f", im.InputTextFlags_EnterReturnsTrue) then
self.pos = vec3(self.inputPos[0], self.inputPos[1], self.inputPos[2])
changed = true
if im.InputFloat3("Scl", self.inputScl, "%0." .. editor.getPreference("ui.general.floatDigitCount") .. "f", im.InputTextFlags_EnterReturnsTrue) then
self.scl = vec3(self.inputScl[0], self.inputScl[1], self.inputScl[2])
changed = true
self.isDragging = true
self.beginDragPos = vec3(self.pos)
self.beginDragRot = quat(self.rot)
self.beginDragRot = quat(self.rot)
self.beginDragScl = self.oneDimensionalScale and self.scl or vec3(self.scl)
end
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate and self.allowTranslate then
self.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
self.inputPos[0] = im.Float(self.pos.x)
if self.oneDimensionalScale then
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
if scl.x ~= 1 then
else
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
self.scl = self.beginDragScl:componentMul(scl)
end
local x, y, z = self.rot * vec3(1, 0, 0), self.rot * vec3(0, 1, 0), self.rot * vec3(0, 0, 1)
debugDrawer:drawLine((self.pos - x * 1000), (self.pos + x * 1000), ColorF(0.9, 0, 0, 0.6))
end
local x, y, z = self.rot * vec3(1, 0, 0), self.rot * vec3(0, 1, 0), self.rot * vec3(0, 0, 1)
debugDrawer:drawLine((self.pos - x * 1000), (self.pos + x * 1000), ColorF(0.9, 0, 0, 0.6))
end
local x, y, z = self.rot * vec3(1, 0, 0), self.rot * vec3(0, 1, 0), self.rot * vec3(0, 0, 1)
debugDrawer:drawLine((self.pos - x * 1000), (self.pos + x * 1000), ColorF(0.9, 0, 0, 0.6))
@/lua/ge/extensions/editor/scriptAIEditor.lua
maxMPS = 41.6666666666666666666667,
stdFwd = vec3(0.0, 1.0, 0.0),
stdUp = vec3(0.0, 0.0, 1.0)
stdFwd = vec3(0.0, 1.0, 0.0),
stdUp = vec3(0.0, 0.0, 1.0)
}
local n0 = data[last]
n1.t = nodes[last].t[0] + ((vec3(n1.x, n1.y, n1.z) - vec3(n0.x, n0.y, n0.z)):length() * velInv)
end
local n0 = data[last]
n1.t = nodes[last].t[0] + ((vec3(n1.x, n1.y, n1.z) - vec3(n0.x, n0.y, n0.z)):length() * velInv)
end
local n0, n1 = d[i - 1], d[i]
local timeStamp = n0.t[0] + ((vec3(n1.x[0], n1.y[0], n1.z[0]) - vec3(n0.x[0], n0.y[0], n0.z[0])):length() * velInv)
n1.t = im.FloatPtr(timeStamp)
local n0, n1 = d[i - 1], d[i]
local timeStamp = n0.t[0] + ((vec3(n1.x[0], n1.y[0], n1.z[0]) - vec3(n0.x[0], n0.y[0], n0.z[0])):length() * velInv)
n1.t = im.FloatPtr(timeStamp)
end
nodes[1].dir, nodes[1].up = vec3(consts.stdFwd), vec3(consts.stdUp) -- The first node is special, since it contains the dir and up vectors.
local firstPos = vec3(nodes[1].x, nodes[1].y, nodes[1].z)
end
nodes[1].dir, nodes[1].up = vec3(consts.stdFwd), vec3(consts.stdUp) -- The first node is special, since it contains the dir and up vectors.
local firstPos = vec3(nodes[1].x, nodes[1].y, nodes[1].z)
nodes[1].dir, nodes[1].up = vec3(consts.stdFwd), vec3(consts.stdUp) -- The first node is special, since it contains the dir and up vectors.
local firstPos = vec3(nodes[1].x, nodes[1].y, nodes[1].z)
for i, n in ipairs(nodes) do
if i > 1 then
local pos = vec3(n.x, n.y, n.z)
local dirVec = pos - firstPos
local n = camWinData.nodes[camWinData.selectedNode]
mState.beginDragPos, mState.beginDragRotation = vec3(n.x[0], n.y[0], n.z[0]), quat(n.qx, n.qy, n.qz, n.qw)
end
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
local data = { idx = idx, old = mState.beginDragPos, new = vec3(n.x[0], n.y[0], n.z[0]) }
editor.history:commitAction("Translate Camera Path Node", data, gizmoPosUndo, gizmoPosRedo)
local n1, n2 = poly[a], poly[b]
local p1, p2 = vec3(n1.x[0], n1.y[0], n1.z[0]), vec3(n2.x[0], n2.y[0], n2.z[0])
return (p2 - p1):length() / (n2.t[0] - n1.t[0])
local n1, n2 = poly[a], poly[b]
local p1, p2 = vec3(n1.x[0], n1.y[0], n1.z[0]), vec3(n2.x[0], n2.y[0], n2.z[0])
return (p2 - p1):length() / (n2.t[0] - n1.t[0])
local n = poly[len]
local p1 = vec3(n.x[0], n.y[0], n.z[0])
return p1, p1, 0.0
local n = poly[1]
local p1 = vec3(n.x[0], n.y[0], n.z[0])
return p1, p1, 0.0
local a = (toolWinData.t[0] - t1) / (t2 - t1)
return vec3(n1.x[0], n1.y[0], n1.z[0]), vec3(n2.x[0], n2.y[0], n2.z[0]), a
end
local a = (toolWinData.t[0] - t1) / (t2 - t1)
return vec3(n1.x[0], n1.y[0], n1.z[0]), vec3(n2.x[0], n2.y[0], n2.z[0]), a
end
path.markers[i] = {
pos = vec3(n.x[0], n.y[0], n.z[0]), rot = quat(n.qx, n.qy, n.qz, n.qw),
time = n.t[0],
local midX, midY = (xMin + xMax) * 0.5, (yMin + yMax) * 0.5 -- Midpoint of trajectory patch.
local groundDist = (vec3(midX, midY, 0.0) - vec3(xMax, yMax, 0.0)):length() -- The largest distance from the center of the box to the outside.
local halfFov = core_camera.getFovRad() * 0.5 -- Half the camera field of view (in radians).
local midX, midY = (xMin + xMax) * 0.5, (yMin + yMax) * 0.5 -- Midpoint of trajectory patch.
local groundDist = (vec3(midX, midY, 0.0) - vec3(xMax, yMax, 0.0)):length() -- The largest distance from the center of the box to the outside.
local halfFov = core_camera.getFovRad() * 0.5 -- Half the camera field of view (in radians).
local height = groundDist / tan(halfFov) + zMax + 5.0 -- The height that the camera should be to fit all the trajectory in view.
local rot = quatFromDir(vec3(0, 0, -1))
commands.setFreeCamera()
local n = polyLine[i]
local p = vec3(n.x[0], n.y[0], n.z[0])
local isSufficientlyDistant = true
local pOld = spawnPositions[i]
spawnPositions[ctr] = vec3(pOld.x + 15, pOld.y + 15, pOld.z)
ctr = ctr + 1
local n1, n2 = dn[j - 1], dn[j]
local p1, p2 = vec3(n1.x, n1.y, n1.z), vec3(n2.x, n2.y, n2.z)
debugDrawer:drawLineInstance(p1, p2, 4, color)
local n1, n2 = dn[j - 1], dn[j]
local p1, p2 = vec3(n1.x, n1.y, n1.z), vec3(n2.x, n2.y, n2.z)
debugDrawer:drawLineInstance(p1, p2, 4, color)
local nStart, nEnd = dn[1], dn[numNodes] -- Draw start/end text, if there are at least two nodes.
local pStart, pEnd = vec3(nStart.x, nStart.y, nStart.z), vec3(nEnd.x, nEnd.y, nEnd.z)
debugDrawer:drawTextAdvanced(pStart, "Start", colors.textA, true, false, colors.textB)
local nStart, nEnd = dn[1], dn[numNodes] -- Draw start/end text, if there are at least two nodes.
local pStart, pEnd = vec3(nStart.x, nStart.y, nStart.z), vec3(nEnd.x, nEnd.y, nEnd.z)
debugDrawer:drawTextAdvanced(pStart, "Start", colors.textA, true, false, colors.textB)
local n = dn[j]
local p = vec3(n.x, n.y, n.z)
debugDrawer:drawSphere(p, 0.1 * sqrt(p:distance(camPos)), color)
local dt1, dt2, dt3 = n2.t[0] - n1.t[0], n3.t[0] - n2.t[0], n4.t[0] - n3.t[0] -- The dt between each adjacent pair of nodes.
local p1 = vec3(n1.x[0], n1.y[0], n1.z[0])
local p2 = vec3(n2.x[0], n2.y[0], n2.z[0])
local p1 = vec3(n1.x[0], n1.y[0], n1.z[0])
local p2 = vec3(n2.x[0], n2.y[0], n2.z[0])
local p3 = vec3(n3.x[0], n3.y[0], n3.z[0])
local p2 = vec3(n2.x[0], n2.y[0], n2.z[0])
local p3 = vec3(n3.x[0], n3.y[0], n3.z[0])
local p4 = vec3(n4.x[0], n4.y[0], n4.z[0])
local p3 = vec3(n3.x[0], n3.y[0], n3.z[0])
local p4 = vec3(n4.x[0], n4.y[0], n4.z[0])
if i1 == i2 then -- Edge case: Add a virtual marker at the start for p1, so the cam speed is smoother.
local n0, n1 = poly[iLast], poly[i]
v[iLast] = (vec3(n0.x[0], n0.y[0], n0.z[0]) - vec3(n1.x[0], n1.y[0], n1.z[0])):length() / (n1.t[0] - n0.t[0])
end
local n0, n1 = poly[iLast], poly[i]
v[iLast] = (vec3(n0.x[0], n0.y[0], n0.z[0]) - vec3(n1.x[0], n1.y[0], n1.z[0])):length() / (n1.t[0] - n0.t[0])
end
local n0, n1 = poly[i - 1], poly[i]
local p0, p1 = vec3(n0.x[0], n0.y[0], n0.z[0]), vec3(n1.x[0], n1.y[0], n1.z[0])
local d = (p0 - p1):length()
local n0, n1 = poly[i - 1], poly[i]
local p0, p1 = vec3(n0.x[0], n0.y[0], n0.z[0]), vec3(n1.x[0], n1.y[0], n1.z[0])
local d = (p0 - p1):length()
local n1, n2 = poly[i - 1], poly[i]
local d = (vec3(n2.x[0], n2.y[0], n2.z[0]) - vec3(n1.x[0], n1.y[0], n1.z[0])):length()
total = total + d
local n1, n2 = poly[i - 1], poly[i]
local d = (vec3(n2.x[0], n2.y[0], n2.z[0]) - vec3(n1.x[0], n1.y[0], n1.z[0])):length()
total = total + d
local n1, n2 = poly[i], poly[i + 1]
local d = (vec3(n2.x[0], n2.y[0], n2.z[0]) - vec3(n1.x[0], n1.y[0], n1.z[0])):length()
total = total + d
local n1, n2 = poly[i], poly[i + 1]
local d = (vec3(n2.x[0], n2.y[0], n2.z[0]) - vec3(n1.x[0], n1.y[0], n1.z[0])):length()
total = total + d
local n1, n2 = poly[i], poly[i + 1]
debugDrawer:drawLineInstance(vec3(n1.x[0], n1.y[0], n1.z[0]), vec3(n2.x[0], n2.y[0], n2.z[0]), 12, colors.fField)
end
local n1, n2 = poly[i], poly[i + 1]
debugDrawer:drawLineInstance(vec3(n1.x[0], n1.y[0], n1.z[0]), vec3(n2.x[0], n2.y[0], n2.z[0]), 12, colors.fField)
end
local n = poly[l]
local pLast = vec3(n.x[0], n.y[0], n.z[0])
local len = u - 1
local n = sc[j]
local p = vec3(n.x[0], n.y[0], n.z[0])
local d = minDistBetweenPointAndRay(p, pos, ray.dir)
local n = poly[nClosest]
local p = vec3(n.x[0], n.y[0], n.z[0])
local hitToPointDist = (p - pos):length()
local sqC = Point2F(nDist, nDist)
debugDrawer:drawSquarePrism(p - vec3(0, 0, nDist), p + vec3(0, 0, nDist), sqC, sqC, colors.nGlow)
else
local sqC = Point2F(nDist, nDist)
debugDrawer:drawSquarePrism(p - vec3(0, 0, nDist), p + vec3(0, 0, nDist), sqC, sqC, colors.nGlow)
else
local len = #polyLine
local pOld = vec3(n.x[0], n.y[0], n.z[0])
local translation = pos - pOld
local sqC = Point2F(nDist, nDist)
debugDrawer:drawSquarePrism(pOld - vec3(0, 0, nDist), pOld + vec3(0, 0, nDist), sqC, sqC, colors.nGlow)
else
local sqC = Point2F(nDist, nDist)
debugDrawer:drawSquarePrism(pOld - vec3(0, 0, nDist), pOld + vec3(0, 0, nDist), sqC, sqC, colors.nGlow)
else
local transform = rotation:getMatrix()
transform:setPosition(vec3(n.x[0], n.y[0], n.z[0]))
editor.setAxisGizmoTransform(transform)
local function drawCamTrajPolyline(pn, color)
local pLast = vec3(pn[1].x[0], pn[1].y[0], pn[1].z[0])
local len = #pn - 1
local n1, n2 = poly[j - 1], poly[j]
local p1 = vec3(n1.x[0], n1.y[0], n1.z[0])
local p2 = vec3(n2.x[0], n2.y[0], n2.z[0])
local p1 = vec3(n1.x[0], n1.y[0], n1.z[0])
local p2 = vec3(n2.x[0], n2.y[0], n2.z[0])
debugDrawer:drawLineInstance(p1, p2, 4, color)
local n = poly[j]
local p = vec3(n.x[0], n.y[0], n.z[0])
local dist = (p - camPos):length()
local sqC = Point2F(nDist, nDist)
debugDrawer:drawSquarePrism(p - vec3(0, 0, nDist), p + vec3(0, 0, nDist), sqC, sqC, color)
else
local sqC = Point2F(nDist, nDist)
debugDrawer:drawSquarePrism(p - vec3(0, 0, nDist), p + vec3(0, 0, nDist), sqC, sqC, color)
else
local nStart, nEnd = poly[1], poly[numNodes]
local pStart, pEnd = vec3(nStart.x[0], nStart.y[0], nStart.z[0]), vec3(nEnd.x[0], nEnd.y[0], nEnd.z[0])
debugDrawer:drawTextAdvanced(pStart, "Start", colors.textA, true, false, colors.textB)
local nStart, nEnd = poly[1], poly[numNodes]
local pStart, pEnd = vec3(nStart.x[0], nStart.y[0], nStart.z[0]), vec3(nEnd.x[0], nEnd.y[0], nEnd.z[0])
debugDrawer:drawTextAdvanced(pStart, "Start", colors.textA, true, false, colors.textB)
local n = poly[j]
local p = vec3(n.x[0], n.y[0], n.z[0])
debugDrawer:drawTextAdvanced(p, tostring(j), colors.textA, true, false, colors.textB)
local n1, n2 = poly[j - 1], poly[j]
local p1, p2 = vec3(n1.x[0], n1.y[0], n1.z[0]), vec3(n2.x[0], n2.y[0], n2.z[0])
local lineSegVec = p2 - p1
local n1, n2 = poly[j - 1], poly[j]
local p1, p2 = vec3(n1.x[0], n1.y[0], n1.z[0]), vec3(n2.x[0], n2.y[0], n2.z[0])
local lineSegVec = p2 - p1
local n = poly[j]
local p = vec3(n.x[0], n.y[0], n.z[0])
debugDrawer:drawTextAdvanced(p, tostring(round1(n.v[0] * 3.6)) .. ' kph', colors.textA, true, false, colors.textB)
local n = pn[j]
local p = vec3(n.x[0], n.y[0], n.z[0])
local dist = (p - camPos):length()
local sqC = Point2F(nDist, nDist)
debugDrawer:drawSquarePrism(p - vec3(0, 0, nDist), p + vec3(0, 0, nDist), sqC, sqC, color)
else
local sqC = Point2F(nDist, nDist)
debugDrawer:drawSquarePrism(p - vec3(0, 0, nDist), p + vec3(0, 0, nDist), sqC, sqC, color)
else
end
local pStart, pEnd = vec3(pn[1].x[0], pn[1].y[0], pn[1].z[0]), vec3(pn[numNodes].x[0], pn[numNodes].y[0], pn[numNodes].z[0])
debugDrawer:drawTextAdvanced(pStart, "Start", colors.textA, true, false, colors.textB)
end
local pStart, pEnd = vec3(pn[1].x[0], pn[1].y[0], pn[1].z[0]), vec3(pn[numNodes].x[0], pn[numNodes].y[0], pn[numNodes].z[0])
debugDrawer:drawTextAdvanced(pStart, "Start", colors.textA, true, false, colors.textB)
local n = d[i]
p[i] = vec3(n.x[0], n.y[0], n.z[0])
end
local p1_2d = coords[seg1]
local pn0_2d, pn1_2d, pn2_2d, pn3_2d = coords[seg0] - p1_2d, vec3(0.0, 0.0, 0.0), coords[seg2] - p1_2d, coords[seg3] - p1_2d
local t1, t2 = computeTangents(pn0_2d, pn1_2d, pn2_2d, pn3_2d)
local n1, n2 = d[i - 1], d[i]
local p1, p2 = vec3(n1.x, n1.y, n1.z), vec3(n2.x, n2.y, n2.z)
if (p2 - p1):squaredLength() > 1e-7 then
local n1, n2 = d[i - 1], d[i]
local p1, p2 = vec3(n1.x, n1.y, n1.z), vec3(n2.x, n2.y, n2.z)
if (p2 - p1):squaredLength() > 1e-7 then
local w = c.wA + (t * c.wB) + (t2 * c.wC) + (t3 * c.wD)
local v1 = vec3(xStart + u, yStart + v, zStart + w)
nodes[ctr] = { x = v1.x, y = v1.y, z = v1.z, isLocked = false }
-- Set the dir and up vectors. If they are not provided, compute them from the trajectory.
local dirVec = (vec3(procNodes[2].x[0], procNodes[2].y[0], procNodes[2].z[0]) - vec3(procNodes[1].x[0], procNodes[1].y[0], procNodes[1].z[0]))
dirVec:normalize()
-- Set the dir and up vectors. If they are not provided, compute them from the trajectory.
local dirVec = (vec3(procNodes[2].x[0], procNodes[2].y[0], procNodes[2].z[0]) - vec3(procNodes[1].x[0], procNodes[1].y[0], procNodes[1].z[0]))
dirVec:normalize()
table.clear(cwd.nodes)
local rot = quatFromDir(vec3(0, 0, -1))
rot:normalize()
@/lua/ge/extensions/gameplay/drag/general.lua
-- Initialize vector fields
racer.vehPos = vec3()
racer.vehDirectionVector = vec3()
racer.vehPos = vec3()
racer.vehDirectionVector = vec3()
racer.vehDirectionVectorUp = vec3()
racer.vehDirectionVector = vec3()
racer.vehDirectionVectorUp = vec3()
racer.vehRot = quat()
racer.vehRot = quat()
racer.vehVelocity = vec3()
racer.prevSpeed = 0
local vehicleRot = quatFromDir(forward, up)
local x, y, z = vehicleRot * vec3(1,0,0), vehicleRot * vec3(0,1,0), vehicleRot * vec3(0,0,1)
local center = vehicle:getSpawnWorldOOBB():getCenter()
local vehicleRot = quatFromDir(forward, up)
local x, y, z = vehicleRot * vec3(1,0,0), vehicleRot * vec3(0,1,0), vehicleRot * vec3(0,0,1)
local center = vehicle:getSpawnWorldOOBB():getCenter()
local vehicleRot = quatFromDir(forward, up)
local x, y, z = vehicleRot * vec3(1,0,0), vehicleRot * vec3(0,1,0), vehicleRot * vec3(0,0,1)
local center = vehicle:getSpawnWorldOOBB():getCenter()
local axisNodes = vehicle:getWheelAxisNodes(i)
local nodePos = vec3(vehicle:getNodePosition(axisNodes[1]))
local wheelNodePos = vehiclePos + nodePos
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
wheelsByFrontness[frontness] = wheelsByFrontness[frontness] or {}
local vehicleRot = quatFromDir(forward, up)
local x, y, z = vehicleRot * vec3(1,0,0), vehicleRot * vec3(0,1,0), vehicleRot * vec3(0,0,1)
local frontLeft, frontRight = vehicle:getSpawnWorldOOBB():getPoint(0) - vehiclePos, vehicle:getSpawnWorldOOBB():getPoint(3) - vehiclePos
local vehicleRot = quatFromDir(forward, up)
local x, y, z = vehicleRot * vec3(1,0,0), vehicleRot * vec3(0,1,0), vehicleRot * vec3(0,0,1)
local frontLeft, frontRight = vehicle:getSpawnWorldOOBB():getPoint(0) - vehiclePos, vehicle:getSpawnWorldOOBB():getPoint(3) - vehiclePos
local vehicleRot = quatFromDir(forward, up)
local x, y, z = vehicleRot * vec3(1,0,0), vehicleRot * vec3(0,1,0), vehicleRot * vec3(0,0,1)
local frontLeft, frontRight = vehicle:getSpawnWorldOOBB():getPoint(0) - vehiclePos, vehicle:getSpawnWorldOOBB():getPoint(3) - vehiclePos
local posL = vec3(frontLeft:dot(x), frontLeft:dot(y), frontLeft:dot(z))
local posR = vec3(frontRight:dot(x), frontRight:dot(y), frontRight:dot(z))
local posL = vec3(frontLeft:dot(x), frontLeft:dot(y), frontLeft:dot(z))
local posR = vec3(frontRight:dot(x), frontRight:dot(y), frontRight:dot(z))
maxFrontness = "oobb"
for k, v in pairs(racer.allWheelsOffsets) do
racer.wheelsCenter[k] = {pos = vec3(), wheelCountInv = 1 / #racer.allWheelsOffsets[k]}
racer.beamState[k] = {preStage = false, stage = false}
if stagePos then
local pos = vec3(stagePos)
local poi = {
@/lua/ge/extensions/tech/lidarTest.lua
sensorId = extensions.tech_sensors.createLidar(
vid, 0.0001, vec3(3, 0, 3), vec3(0, -1, 0), 64, 0.47, 2200000, 20, 2 * math.pi, 120,
true, false, false, false, false)
sensorId = extensions.tech_sensors.createLidar(
vid, 0.0001, vec3(3, 0, 3), vec3(0, -1, 0), 64, 0.47, 2200000, 20, 2 * math.pi, 120,
true, false, false, false, false)
assert(extensions.tech_sensors.getLidarIsAnnotated(sensorId) == false, "lidarTest.lua - getLidarIsAnnotated has failed")
assert(extensions.tech_sensors.getLidarSensorPosition(sensorId) == vec3(3, 0, 3), "lidarTest.lua - getLidarSensorPosition has failed")
assert(extensions.tech_sensors.getLidarSensorDirection(sensorId) == vec3(0, -1, 0), "lidarTest.lua - getLidarDirectionPosition has failed")
assert(extensions.tech_sensors.getLidarSensorPosition(sensorId) == vec3(3, 0, 3), "lidarTest.lua - getLidarSensorPosition has failed")
assert(extensions.tech_sensors.getLidarSensorDirection(sensorId) == vec3(0, -1, 0), "lidarTest.lua - getLidarDirectionPosition has failed")
assert(extensions.tech_sensors.getLidarVerticalResolution(sensorId) == 64, "lidarTest.lua - getLidarVerticalResolution has failed")
sensorId = extensions.tech_sensors.createLidar(
vid, 0.0001, vec3(3, 0, 3), vec3(0, -1, 0), 64, 0.47, 2200000, 20, 2 * math.pi, 120,
true, false, false, false, false)
sensorId = extensions.tech_sensors.createLidar(
vid, 0.0001, vec3(3, 0, 3), vec3(0, -1, 0), 64, 0.47, 2200000, 20, 2 * math.pi, 120,
true, false, false, false, false)
@/gameplay/missionTypes/scatterPickup/customNodes/scatterPrefabSetupNode.lua
if option.sink then
object:setPosition(p - vec3(0,0,(math.random()*option.sink[2]-option.sink[1]) + option.sink[1]))
else
if option.scale then
object:setScale((vec3(1,1,1) + vec3():getBluePointInSphere(0.05)) * (math.random()*(option.scale[2]-option.scale[1]) +option.scale[1]))
else
if option.scale then
object:setScale((vec3(1,1,1) + vec3():getBluePointInSphere(0.05)) * (math.random()*(option.scale[2]-option.scale[1]) +option.scale[1]))
else
else
object:setScale(vec3(1,1,1) + vec3():getBluePointInSphere(0.05))
end
else
object:setScale(vec3(1,1,1) + vec3():getBluePointInSphere(0.05))
end
if option.align then
local angle = (math.acos(vec3(0,0,1):dot(point.normal))) / math.pi * 180
if angle <= option.align then
if angle <= option.align then
local fwd = vec3(0,1,0):projectToOriginPlane(point.normal)
local rot = quatFromEuler(0,0,math.random() * 360) * quatFromDir(fwd, point.normal)
@/lua/ge/extensions/flowgraph/nodes/gameplay/vehiclePool/activateByDistance.lua
local pos = vec3()
function C:work()
@/lua/ge/extensions/flowgraph/nodes/gameplay/decalLine.lua
texture = 'art/shapes/arrows/t_arrow_opaque_d.color.png',
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
color = ColorF(1, 0, 0, 1 ),
color = ColorF(1, 0, 0, 1 ),
scale = vec3(1, 1, 1),
fadeStart = 200,
local fwd = vec3()
local t, data, a, b
a, b = vec3(self.pinIn.posA.value) or vec3(0, 0, 0), vec3(self.pinIn.posB.value) or vec3(0, 0, 0)
a, b = vec3(self.pinIn.posA.value) or vec3(0, 0, 0), vec3(self.pinIn.posB.value) or vec3(0, 0, 0)
a, b = vec3(self.pinIn.posA.value) or vec3(0, 0, 0), vec3(self.pinIn.posB.value) or vec3(0, 0, 0)
a, b = vec3(self.pinIn.posA.value) or vec3(0, 0, 0), vec3(self.pinIn.posB.value) or vec3(0, 0, 0)
@/lua/ge/extensions/editor/masterSpline/homologation.lua
local abs, asin, rad, deg = math.abs, math.asin, math.rad, math.deg
local globalUp = vec3(0, 0, 1)
local presetsMap = roadStds.getPresetsMap()
local dists = {}
local ab, bc, rotatedNormal = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local dists = {}
local ab, bc, rotatedNormal = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local dists = {}
local ab, bc, rotatedNormal = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local ab, bc, rotatedNormal = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local p0_2D, p1_2D, p2_2D = vec3(), vec3(), vec3()
local ab, bc, rotatedNormal = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local p0_2D, p1_2D, p2_2D = vec3(), vec3(), vec3()
local ab, bc, rotatedNormal = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local p0_2D, p1_2D, p2_2D = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local p0_2D, p1_2D, p2_2D = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local p0_2D, p1_2D, p2_2D = vec3(), vec3(), vec3()
local tmp1, tmp2, tmp3 = vec3(), vec3(), vec3()
local p0_2D, p1_2D, p2_2D = vec3(), vec3(), vec3()
local tangent = tangents[divIdx]
local tangentHoriz = vec3(tangent.x, tangent.y, 0)
if tangentHoriz:length() < epsilon then
@/lua/ge/extensions/flowgraph/nodes/scene/camera/cameraCircle.lua
local vecUp = vec3(0, 0, 1)
function C:_executionStarted()
function C:onNodeReset()
self.centerPos = vec3()
self.offset = vec3()
self.centerPos = vec3()
self.offset = vec3()
self.camPos = vec3()
self.offset = vec3()
self.camPos = vec3()
self.angle = 0
@/lua/ge/extensions/editor/gen/mesh.lua
local an = {}
an[#an+1] = vec3(-1,-1,0)
an[#an+1] = vec3(1,-1,0)
an[#an+1] = vec3(-1,-1,0)
an[#an+1] = vec3(1,-1,0)
an[#an+1] = vec3(1,1,0)
an[#an+1] = vec3(1,-1,0)
an[#an+1] = vec3(1,1,0)
an[#an+1] = vec3(-1,1,0)
an[#an+1] = vec3(1,1,0)
an[#an+1] = vec3(-1,1,0)
av[#av+1] = vec3(0,0,0)
av[#av+1] = vec3(1,0,0)
av[#av+1] = vec3(0,0,0)
av[#av+1] = vec3(1,0,0)
av[#av+1] = vec3(1,1,0)
av[#av+1] = vec3(1,0,0)
av[#av+1] = vec3(1,1,0)
av[#av+1] = vec3(0,1,0)
av[#av+1] = vec3(1,1,0)
av[#av+1] = vec3(0,1,0)
av[#av+1] = vec3(0,0,5)
av[#av+1] = vec3(1,0,5)
av[#av+1] = vec3(0,0,5)
av[#av+1] = vec3(1,0,5)
av[#av+1] = vec3(1,1,5)
av[#av+1] = vec3(1,0,5)
av[#av+1] = vec3(1,1,5)
av[#av+1] = vec3(0,1,5)
av[#av+1] = vec3(1,1,5)
av[#av+1] = vec3(0,1,5)
local mrotx = MatrixF(true)
mrotx:setFromEuler(vec3(vang.x, 0, 0))
local mroty = MatrixF(true)
local mroty = MatrixF(true)
mroty:setFromEuler(vec3(0, vang.y, 0))
mtx:mul(mrotx)
mtx:mul(mroty)
mtx:setFromEuler(vec3(0, 0, vang.z))
local sc = step/daedesc.len - 1
local dir = daedesc.dir or vec3(1,0,0)
local vscale = vec3(1,1,1) + dir*sc
local dir = daedesc.dir or vec3(1,0,0)
local vscale = vec3(1,1,1) + dir*sc
-- U.dump(daedesc, '?? fillSegment:'..l..':'..tostring(b-a)..':'..daedesc.len..':'..n..' scale:'..scale) --..tostring(M.fdata))
-- if dbg then lo('?? fS_pos:'..tostring(pos)) end
local itm = M.to(daedesc, pos, vec3(0,0,ang+turn), vscale) -- vec3(scale,1,1))
out[#out+1] = itm
-- if dbg then lo('?? fS_pos:'..tostring(pos)) end
local itm = M.to(daedesc, pos, vec3(0,0,ang+turn), vscale) -- vec3(scale,1,1))
out[#out+1] = itm
-- lo('?? forNorm:'..tostring(vn))
local a = U.vang(vn,vec3(0,0,1))
return {round(a*10000), round(U.vang(U.proj2D(vn),vec3(1,0,0),true)*10000)},vn
local a = U.vang(vn,vec3(0,0,1))
return {round(a*10000), round(U.vang(U.proj2D(vn),vec3(1,0,0),true)*10000)},vn
end
local side = U.mod(istart+1,base) - ref
local refuv = vec3(0,0,0)
local sideuv = vec3(side:length(),0,0)
local refuv = vec3(0,0,0)
local sideuv = vec3(side:length(),0,0)
if uvini then
if uvini then
refuv = vec3(uvini[1].u, uvini[1].v)
sideuv = vec3(uvini[2].u-uvini[1].u, uvini[2].v-uvini[1].v)
refuv = vec3(uvini[1].u, uvini[1].v)
sideuv = vec3(uvini[2].u-uvini[1].u, uvini[2].v-uvini[1].v)
end
local uvu = sideuv/side:length()
local uvv = vec3(-uvu.y,uvu.x)
af = af ~= nil and af or {}
pos = pos ~= nil and pos or vec3(0, 0, 0)
if pos == nil then
pos = vec3(0, 0, 0)
end
for i=0,lastMeshInfo.verticesCount*3-1,3 do
av[#av+1] = vec3(verts[i],-verts[i+2],verts[i+1])
end
for i=0,lastMeshInfo.normalsCount*3-1,3 do
an[#an+1] = vec3(normals[i],normals[i+1],normals[i+2])
end
local an,af,auv = {},{},{},{}
-- an = {vec3(0,0,1)}
auv = {{u=0,v=0},{u=1,v=0},{u=0,v=1}}
]]
local pos = vec3(acell[4],acell[8],acell[12])
lo('?? for_mat:'..tostring(pos))
else
av[#av+1] = vec3(aval[j],aval[j+1],aval[j+2])
end
-- local inspect = require("libs/inspect/inspect")
-- local v = vec3(1,2,3)
-- lo('?? if_v:'..tostring(v))
end
-- local pos = floor.awall[1].pos + vec3(0,0,floor.h)
local pos = desc.pos + vec3(0,0,H)
-- local pos = floor.awall[1].pos + vec3(0,0,floor.h)
local pos = desc.pos + vec3(0,0,H)
lo('?? if_POS:'..tostring(floor.pos)..':'..tostring(desc.pos))
ndmesh = deepcopy(ndmesh)
ndmesh = M.toXML({an ={vec3(0,0,1)},av=avt,af=aft,auv=auvt}, ndmesh)
local ray = getCameraMouseRay()
-- local vn = vec3(0,0,1)
-- local d = intersectsRay_Plane(ray.pos, ray.dir, smouse, vn)
for i = 1,#g[1],3 do
-- av[#av + 1] = vec3(g[1][i+1], g[1][i], g[1][i+2])
-- av[#av + 1] = vec3(g[1][i], g[1][i+2], g[1][i+1])
-- av[#av + 1] = vec3(g[1][i+1], g[1][i], g[1][i+2])
-- av[#av + 1] = vec3(g[1][i], g[1][i+2], g[1][i+1])
av[#av + 1] = vec3(g[1][i], g[1][i+1], g[1][i+2])
-- av[#av + 1] = vec3(g[1][i], g[1][i+2], g[1][i+1])
av[#av + 1] = vec3(g[1][i], g[1][i+1], g[1][i+2])
end
for i = 1,#g[2],3 do
-- an[#an + 1] = vec3(g[2][i+1], g[2][i], g[2][i+2])
-- an[#an + 1] = vec3(g[2][i], g[2][i+2], g[2][i+1])
-- an[#an + 1] = vec3(g[2][i+1], g[2][i], g[2][i+2])
-- an[#an + 1] = vec3(g[2][i], g[2][i+2], g[2][i+1])
an[#an + 1] = vec3(g[2][i], g[2][i+1], g[2][i+2])
-- an[#an + 1] = vec3(g[2][i], g[2][i+2], g[2][i+1])
an[#an + 1] = vec3(g[2][i], g[2][i+1], g[2][i+2])
end
end
-- an = {vec3(0, 0, 1)}
if #g > 2 then
for i = 1,#afloat[1],3 do
av[#av + 1] = vec3(afloat[1][i],afloat[1][i+1],afloat[1][i+2])
end
for i = 1,#afloat[2],3 do
an[#an + 1] = vec3(afloat[2][i],afloat[2][i+1],afloat[2][i+2])
end
end
-- an = {vec3(0, 0, 1)}
for i = 1,#afloat[3],2 do
dvi[i] = o
verts[#verts+1] = m.verts[i+1] + vec3(-2,0,0)
end
local center,n = vec3(0,0,0),0
for _,f in pairs(tri) do
end
local center,n = vec3(0,0,0),0
for _,f in pairs(tri) do
end
local center,n = vec3(0,0,0),0
for _,f in pairs(tri) do
end
local center,n = vec3(0,0,0),0
for _,f in pairs(tri) do
-- lo('?? for_loop:'..i..':'..j..':'..tostring(l[j]))
l[j] = l[j] + 0*vec3(0.7,1.)
av[#av+1] = {pos=p, star={}}
for i,p in pairs(av) do
avert[i] = p.pos + vec3(0,0,0.1)
end
-- lo('?? for_NORM:'..tostring(norm))
anorm[#anorm+1] = vec3(0,0,1)
-- an,auv,af = M.zip2(avert, iseq, an, true, af)
end
-- an = {vec3(0,0,1)}
-- an = anorm
-- if dbg then lo('?? for_angg:'..c..':'..d..'>>'..tostring(ang)..' 1:'..tostring(av[b].p-av[a].p)..' 2:'..tostring(av[c].p-av[b].p)) end
-- lo('?? for_ang:'..ang..':'..c..'<'..b..'<'..a..':'..U.vang(av[b].p-av[a].p,vec3(0,-1,0),true))
if ang < ama then
for i,v in pairs(av) do
avert[#avert+1] = v.p + vec3(0,0,0.01)
end
end
-- an = {vec3(0,0,1)}
-- U.dump(avert, '?? preUV:')
local ang = U.vang(av[b].p-av[a].p,av[c].p-av[b].p,true)
lo('?? for_ang:'..ang..':'..c..'<'..b..'<'..a..':'..U.vang(av[b].p-av[a].p,vec3(0,-1,0),true))
if ang > ama then
cid = cid + 1
om:setPosition(vec3(0,0,0))
om.isMesh = true
-- lo('?? cross:'..k..':'..tostring(v)..':'..q)
loop[#loop+1] = vec3(adist[k]+astep[k]*q, s.p.y+p.y)
break
local aloop = {base}
-- {vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},
-- {vec3(1,2), vec3(5,2), vec3(5,6), vec3(1,6)}
local aloop = {base}
-- {vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},
-- {vec3(1,2), vec3(5,2), vec3(5,6), vec3(1,6)}
local aloop = {base}
-- {vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},
-- {vec3(1,2), vec3(5,2), vec3(5,6), vec3(1,6)}
local aloop = {base}
-- {vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},
-- {vec3(1,2), vec3(5,2), vec3(5,6), vec3(1,6)}
-- {vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},
-- {vec3(1,2), vec3(5,2), vec3(5,6), vec3(1,6)}
-- }
-- {vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},
-- {vec3(1,2), vec3(5,2), vec3(5,6), vec3(1,6)}
-- }
-- {vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},
-- {vec3(1,2), vec3(5,2), vec3(5,6), vec3(1,6)}
-- }
-- {vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},
-- {vec3(1,2), vec3(5,2), vec3(5,6), vec3(1,6)}
-- }
}
local mbody,pmi,pma,aseq,invalid = M.framePave(aloop, vec3(0,-1), astep)
if not mbody then return end
local z = mbody.verts[v.ind].y
mbody.verts[v.ind] = vec3(n.x, n.y, z)
else
else
mbody.normals[i] = vec3(0,0,1)
-- U.dump(aseq, '!! ERR_WRONG_LOOP:'..i..':'..#aseq)
local s = U.v2stamp((av[aface[i+1].v]-av[aface[i].v]):cross(av[aface[i+2].v]-av[aface[i].v]):normalized(),2)
U.dump(aface[i], '?? for_face:'..i..':'..s) --..':'..U.v2stamp(vec3(1.122421432,2,3)))
if not dnorm[s] then dnorm[s] = {} end
end
-- U.out.aset[1] = {set={vec3(0,0,4)},c={1,1,0}, w=0.05}
lo('<< forJoint:')
road:setPosition(pos)
-- road:setPosition(vec3(0, 0, 0))
road.canSave = false
@/lua/vehicle/controller/sbrGauges.lua
local consumData = {}
local vecX = vec3(1, 0, 0)
local vecY = vec3(0, -1, 0)
local vecX = vec3(1, 0, 0)
local vecY = vec3(0, -1, 0)
@/lua/ge/extensions/gameplay/rally/transcripts/entry.lua
if not (self.vehicle_data.vehicle_data and self.vehicle_data.vehicle_data.pos) then return nil end
return vec3(self.vehicle_data.vehicle_data.pos)
end
local upVector = vec3(0,0,1) -- 'up' in a Z-up system
local rotatedUpVector = rot * upVector * h -- Rotate and scale the up vector
local forwardVector = vec3(0,1,0)
local rotatedForwardVector = rot * forwardVector * (l/2) -- assume pos is the center of car so divide length by 2
local raise = vec3(0,0,h/2)
frontOfCar = frontOfCar + raise
local wheelPositions = {
{0.5, vec3(-(w/2*0.9), l/2 * 0.6, 0.4)}, -- Front left
{0.5, vec3( (w/2*0.9), l/2 * 0.6, 0.4)}, -- Front right
{0.5, vec3(-(w/2*0.9), l/2 * 0.6, 0.4)}, -- Front left
{0.5, vec3( (w/2*0.9), l/2 * 0.6, 0.4)}, -- Front right
{0.6, vec3(-(w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear left
{0.5, vec3( (w/2*0.9), l/2 * 0.6, 0.4)}, -- Front right
{0.6, vec3(-(w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear left
{0.6, vec3( (w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear right
{0.6, vec3(-(w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear left
{0.6, vec3( (w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear right
}
debugDrawer:drawTextAdvanced(
backOfCar + vec3(0,0,h/2),
String(self:debugDrawText(is_hovered)),
local pos = vec3(cap.pos)
debugDrawer:drawSphere(pos, radius, ColorF(clr[1],clr[2],clr[3],shapeAlpha))
debugDrawer:drawTextAdvanced(
vec3(label_point.pos),
String(calc.cornerCallStr..' '),
-- local pos = vec3(capture.pos)
-- debugDrawer:drawSphere(pos, radius, ColorF(clr[1],clr[2],clr[3],shapeAlpha))
movingStart = true,
pos = cap.pos + vec3(0,0,1),
rot = cap.quat,
local marker = {
pos = vec3(markerData.pos.x, markerData.pos.y, markerData.pos.z),
rot = quat(markerData.rot.x, markerData.rot.y, markerData.rot.z, markerData.rot.w),
@/gameplay/missionTypes/evade/customNodes/getClosestTrafficNode.lua
function C:init()
self.pos = vec3()
end
@/lua/ge/extensions/career/modules/vehiclePerformance.lua
local function switchToLaunchCamera()
local bbHalfAxis0 = vec3(be:getObjectOOBBHalfAxisXYZ(vehId, 0))
local backOffsetDist = bbHalfAxis0:length() * -3.5
local offsetZ = 0.6 -- lower camera height, adjust as needed
setRelativeCamera(vec3(offsetX, offsetY, offsetZ), vec3(15, 180, 10))
core_camera.setFOV(vehId, 80)
local offsetZ = 0.6 -- lower camera height, adjust as needed
setRelativeCamera(vec3(offsetX, offsetY, offsetZ), vec3(15, 180, 10))
core_camera.setFOV(vehId, 80)
local function switchToBrakingCamera()
local bbHalfAxis1 = vec3(be:getObjectOOBBHalfAxisXYZ(vehId, 1))
local offsetDist = bbHalfAxis1:length() * 3
local offsetDist = bbHalfAxis1:length() * 3
setRelativeCamera(vec3(-offsetDist, offsetDist, 1), vec3(135, 180, 0))
targetFOV = 18
local offsetDist = bbHalfAxis1:length() * 3
setRelativeCamera(vec3(-offsetDist, offsetDist, 1), vec3(135, 180, 0))
targetFOV = 18
@/lua/ge/extensions/editor/dynamicDecals/selection.lua
gizmo.rotateFn = function(newGizmoTransform)
local delta = vec3(worldEditorCppApi.getAxisGizmoRotateOffset())
api.rotateLayer(layerData, delta)
if gizmo.getDragCount() > 0 then
local delta = vec3(worldEditorCppApi.getAxisGizmoScaleOffset())
api.scaleLayer(layerData, delta)
@/lua/ge/extensions/core/cameraModes/crash.lua
bestCandidate = bestCandidate or vec3(startPos) + vec3(0,3,3)
bestCandidate = bestCandidate or vec3(startPos) + vec3(0,3,3)
-- Choose a candidate on the ground
local candidate = startPos + vec3(startPos):getRandomPointInCircle(20) + vec3(0,0,1)
local downCastDist = castRayStatic(candidate, vec3(0,0,-1), 50)
-- Choose a candidate on the ground
local candidate = startPos + vec3(startPos):getRandomPointInCircle(20) + vec3(0,0,1)
local downCastDist = castRayStatic(candidate, vec3(0,0,-1), 50)
local candidate = startPos + vec3(startPos):getRandomPointInCircle(20) + vec3(0,0,1)
local downCastDist = castRayStatic(candidate, vec3(0,0,-1), 50)
if downCastDist < 50 then
if downCastDist < 50 then
candidate = candidate + vec3(0,0,-downCastDist + 2)
local candidateDistance = candidate:distance(startPos)
-- stationary camera
data.res.pos = vec3(self.camPos)
data.res.rot = quatFromDir(self.hitPoint - self.camPos)
@/lua/ge/extensions/ui/liveryEditor/layers/cursor.lua
local scaleY = cursorScale.z + (steps_y * MEASUREMENTS.SCALE_STEP_UNIT)
api.setDecalScale(vec3(scaleX, cursorScale.y, scaleY))
notifyListeners()
local cursorScale = api.getDecalScale()
api.setDecalScale(vec3(scaleX, cursorScale.y, scaleY))
notifyListeners()
M.DEFAULT_POSITION = Point2F(0.5, 0.5)
M.DEFAULT_SCALE = vec3(0.5, 1, 0.5)
M.DEFAULT_SKEW = Point2F(0, 0)
@/gameplay/missionTypes/delivery/customNodes/VehicleInTargetAreaNode.lua
local updateData = {
bbCenter = vec3(),
bbHalfAxis0 = vec3(),
bbCenter = vec3(),
bbHalfAxis0 = vec3(),
bbHalfAxis1 = vec3(),
bbHalfAxis0 = vec3(),
bbHalfAxis1 = vec3(),
bbHalfAxis2 = vec3(),
bbHalfAxis1 = vec3(),
bbHalfAxis2 = vec3(),
}
local sqrDist = self.pinIn.targetRad.value * self.pinIn.targetRad.value
local center = vec3(self.pinIn.targetPos.value)
for _, id in ipairs(ids) do
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/flowgraph/nodes/vehicle/vehicleData.lua
local veh, vehicleData
local wCenter, wPos = vec3(), vec3()
local vehQuat = quat()
local veh, vehicleData
local wCenter, wPos = vec3(), vec3()
local vehQuat = quat()
@/lua/ge/extensions/gameplay/crawl/utils.lua
end
debugDrawer:drawSphere(pos.pos+vec3(0,0,0), radius, ColorF(1,1,1,1))
end
if pn.pos then
local dir = vec3(0, 1, 0)
if pn.rotation then
if pn.rotation then
dir = pn.rotation * vec3(0, 1, 0)
end
local currentDist = 0
local dotPos = vec3()
table.insert(dottedPath, {
pos = vec3(dotPos),
distanceFromStart = currentDist
if pathnode.rotation then
local pathnodeForward = pathnode.rotation * vec3(0, 1, 0)
dynamicData = {
vehPos = vec3(),
vehDirectionVector = vec3(),
vehPos = vec3(),
vehDirectionVector = vec3(),
vehDirectionVectorUp = vec3(),
vehDirectionVector = vec3(),
vehDirectionVectorUp = vec3(),
vehRot = quat(),
vehRot = quat(),
vehVelocity = vec3(),
vehObj = veh,
vehObj = veh,
bbCenter = vec3(),
wheelOffsets = {},
local vRot = quatFromDir(veh:getDirectionVector(), veh:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
for i=0, wCount do
local vRot = quatFromDir(veh:getDirectionVector(), veh:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
for i=0, wCount do
local vRot = quatFromDir(veh:getDirectionVector(), veh:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
for i=0, wCount do
local axisNodes = veh:getWheelAxisNodes(i)
local nodePos = vec3(veh:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
local nodePos = vec3(veh:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
table.insert(cD.dynamicData.wheelOffsets, pos)
if not state.crawlerData.dynamicData.prevVehPos then
state.crawlerData.dynamicData.prevVehPos = vec3()
end
if state.pendingTeleportCheck and state.teleportCheckPos then
local currentPos = vec3(veh:getPositionXYZ())
local teleportThreshold = 1.0
local tmp1, tmp2 = vec3(), vec3()
local function checkInfractions(crawlerId, dtSim)
local tmp1, tmp2 = vec3(), vec3()
local function checkInfractions(crawlerId, dtSim)
state.pendingTeleportCheck = true
state.teleportCheckPos = vec3(veh:getPositionXYZ())
end
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/directlyTo.lua
local origin, target = vec3(), vec3()
local origin, target = vec3(), vec3()
--[[ handle first node
local up = vec3(0,0,1) -- hardcode up as up..
local dir = vec3(road:getNodePosition(1)) - vec3(road:getNodePosition(0))
local up = vec3(0,0,1) -- hardcode up as up..
local dir = vec3(road:getNodePosition(1)) - vec3(road:getNodePosition(0))
dir = dir:normalized()
local up = vec3(0,0,1) -- hardcode up as up..
local dir = vec3(road:getNodePosition(1)) - vec3(road:getNodePosition(0))
dir = dir:normalized()
@/lua/ge/extensions/util/trackBuilder/multiTrackMerger.lua
--segment.shape = "square"
nx = point.finalRot:__mul(vec3(1,0,0))
ny = point.finalRot:__mul(vec3(0,1,0))
nx = point.finalRot:__mul(vec3(1,0,0))
ny = point.finalRot:__mul(vec3(0,1,0))
nz = point.finalRot:__mul(vec3(0,0,1))
ny = point.finalRot:__mul(vec3(0,1,0))
nz = point.finalRot:__mul(vec3(0,0,1))
return {
local faces = {}
local p = vec3()
local bezierCount = #edges[1].bezierPoints
local center = vec3()
local normal = vec3()
local center = vec3()
local normal = vec3()
for _,e in ipairs(edges) do center = center+e.bezierPoints[math.ceil(bezierCount/2)].position normal = normal+e.bezierPoints[math.ceil(bezierCount/2)].orientation.nz end
local points = {}
local center = vec3()
for i,s in ipairs(segments) do
orientation = p.orientation,
position = p.position + vec3(0,0,p.zOffset),
rotation = p.rot,
},
position = p.position + vec3(0,0,p.zOffset),
rotation = p.rot,
local splineObject = createObject("ProceduralMesh")
splineObject:setPosition(vec3(0,0,0))
splineObject.canSave = false
@/lua/ge/extensions/core/cameraModes/onboard.lua
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
function C:reset()
self.camRot = vec3()
self.manualzoom:reset()
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
function C:update(data)
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
function C:update(data)
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
function C:update(data)
local nodePos, ref, up, back, left = vec3(), vec3(), vec3(), vec3(), vec3()
local camUp, camLeft, dir, rotatedUp = vec3(), vec3(), vec3(), vec3()
function C:update(data)
@/lua/ge/extensions/editor/toolUtilities/meshAuditionMgr.lua
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local scaleVec = vec3(1, 1, 1)
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local scaleVec = vec3(1, 1, 1)
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local scaleVec = vec3(1, 1, 1)
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local scaleVec = vec3(1, 1, 1)
local greenB = im.ImVec4(0.28627450980392155, 0.7137254901960784, 0.4470588235294118, 1.0)
local timer, time = hptimer(), 0.0
local tmp1 = vec3(0, 0, 0)
@/lua/ge/extensions/gameplay/util/damageAssessment.lua
local offset = vec3(
getCellOffset(x, xAxisLength, xCutDepth), -- offset from center bb
if debug then
local halfCell = vec3(xCellSize, yCellSize, zCellSize) * 0.5
local corners = {
@/lua/ge/extensions/flowgraph/nodes/gameplay/playerMoves.lua
if not self.initialPos then
self.initialPos = vec3(vehData.pos)
self.msgSent = true
@/lua/ge/extensions/editor/decalEditor.lua
local l = vlen(v)
if l > 0 then return vec3(v.x / l, v.y / l, v.z / l) end
return vec3(0,0,1)
if l > 0 then return vec3(v.x / l, v.y / l, v.z / l) end
return vec3(0,0,1)
end
local function rayIntersectsSphere(rayOrigin, rayDir, center, radius)
local oc = vec3(rayOrigin.x - center.x, rayOrigin.y - center.y, rayOrigin.z - center.z)
local b = vdot(oc, rayDir)
local rayOrigin = campos
local rayDir = vnorm(vec3(hit.pos.x - rayOrigin.x, hit.pos.y - rayOrigin.y, hit.pos.z - rayOrigin.z))
local bestT = math.huge
{
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
{
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
{
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
{
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
}
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
}
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
}
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
}
local firstInstance
local averagePos = vec3(0,0,0)
for j = 1, 3 do
local startPt = vec3(cubePoints[i].x, cubePoints[i].y, cubePoints[i].z);
local endPt = vec3(startPt.x, startPt.y, startPt.z);
local startPt = vec3(cubePoints[i].x, cubePoints[i].y, cubePoints[i].z);
local endPt = vec3(startPt.x, startPt.y, startPt.z);
if j == 1 then
if not originalPosition then
originalPosition = vec3(position[0], position[1], position[2])
end
oldPositions[selectedInstance.id] = originalPosition
newPositions[selectedInstance.id] = vec3(position[0], position[1], position[2])
editor.history:commitAction("PositionDecalInstances",
local decalRot = quatFromEuler(degToRad(input4FloatValue[0]), degToRad(input4FloatValue[1]), degToRad(input4FloatValue[2]))
selectedInstance.normal = decalRot:__mul(vec3(0,0,1))
selectedInstance.tangent = decalRot:__mul(vec3(1,0,0))
selectedInstance.normal = decalRot:__mul(vec3(0,0,1))
selectedInstance.tangent = decalRot:__mul(vec3(1,0,0))
editor.notifyDecalModified(selectedInstance)
instance.normal = quat(rotation):__mul(vec3(0,0,1))
instance.tangent = quat(rotation):__mul(vec3(1,0,0))
instance.normal = quat(rotation):__mul(vec3(0,0,1))
instance.tangent = quat(rotation):__mul(vec3(1,0,0))
else
local gizmoRot = rot
instance.normal = gizmoRot:__mul(vec3(originalNormals[instance.id]))
instance.tangent = gizmoRot:__mul(vec3(originalTangents[instance.id]))
instance.normal = gizmoRot:__mul(vec3(originalNormals[instance.id]))
instance.tangent = gizmoRot:__mul(vec3(originalTangents[instance.id]))
end
-- Rotate the positions
local point = vec3(originalPositions[instance.id].x, originalPositions[instance.id].y, originalPositions[instance.id].z)
point = point - rotationPoint
local function scalePoint(point, scale)
return vec3(point.x * scale, point.y * scale, point.z * scale)
end
@/lua/ge/extensions/career/modules/delivery/generator.lua
local tmpVec = vec3()
local function distanceBetween(posA, posB)
@/lua/ge/extensions/gameplay/race/pathnode.lua
self.mode = "manual"
self.pos = vec3()
self.normal = nil
self.sidePadding = vec3(1,3)
self.mode = "manual"
self.pos = vec3(pos)
self.radius = radius
if data.mode == 'navgraph' then
self:setNavgraph(data.navgraphName, {pos = vec3(data.pos), radius = data.radius})
if data.normal then
if data.normal then
self:setNormal(vec3(data.normal))
end
elseif data.mode == 'manual' then
self:setManual(vec3(data.pos),data.radius,vec3(data.normal))
end
elseif data.mode == 'manual' then
self:setManual(vec3(data.pos),data.radius,vec3(data.normal))
end
self.useAsSplit = data.useAsSplit or (data.useAsSplit == nil)
self.sidePadding = data.sidePadding and vec3(data.sidePadding[1], data.sidePadding[2],0) or vec3()
self.useAsSplit = data.useAsSplit or (data.useAsSplit == nil)
self.sidePadding = data.sidePadding and vec3(data.sidePadding[1], data.sidePadding[2],0) or vec3()
local midWidth = self.radius*2 - self.sidePadding.x - self.sidePadding.y
local side = self.normal:cross(vec3(0,0,1)) *(self.radius-self.sidePadding.y - midWidth/2)
return self.pos+side, midWidth
local midWidth = self.radius*2 --- self.sidePadding.x - self.sidePadding.y
local side = self.normal:cross(vec3(0,0,1)) *(self.radius-self.sidePadding.y - midWidth/2)
debugDrawer:drawSquarePrism(
if alignMode == 'terrain' then
rot = qOff * pRot * quatFromDir(vec3(hit.norm), self.normal)
elseif alignMode == 'pathnode' then
elseif alignMode == 'pathnode' then
rot = qOff * pRot * quatFromDir(vec3(0,0,1), self.normal)
elseif alignMode == 'absolute' then
local ret = {
pos = vec3(hit.pt) + zOff * vec3(hit.norm),
scl = vec3(scl),
local ret = {
pos = vec3(hit.pt) + zOff * vec3(hit.norm),
scl = vec3(scl),
pos = vec3(hit.pt) + zOff * vec3(hit.norm),
scl = vec3(scl),
rot = rot,
local rot = quatFromDir(self.normal:z0())
local up = vec3(0,0,1)
-- find positions on side
local pLeft, pRight = self.pos + rot*(vec3(-self.radius,0,0)-posOffset:z0()) + up*rayLength/2,
self.pos + rot*(vec3( self.radius,0,0)+posOffset:z0()) + up*rayLength/2
local pLeft, pRight = self.pos + rot*(vec3(-self.radius,0,0)-posOffset:z0()) + up*rayLength/2,
self.pos + rot*(vec3( self.radius,0,0)+posOffset:z0()) + up*rayLength/2
@/lua/ge/extensions/editor/toolUtilities/skeleton.lua
table.insert(path, vec3(x, y))
visited[i] = true
-- Reverse walk toward control point
local backPath = { vec3(x, y) } -- start at control point
if #forward > 0 then
if not visited[idx] then -- If the current pixel has not been visited, add it to the path and mark it as visited.
path[pathCtr] = vec3(pX, pY) -- Add a deep copy of the current pixel to the path.
pathCtr = pathCtr + 1
local len = sqrt(dx * dx + dy * dy)
t[j] = len > 0 and vec3(dx / len, dy / len) or vec3(0, 0)
end
local len = sqrt(dx * dx + dy * dy)
t[j] = len > 0 and vec3(dx / len, dy / len) or vec3(0, 0)
end
-- [filepath should direct to a .png file of a supported format.]
-- [Returns an array of paths, where each contains a table of 2D points as vec3() and a corresponding widths table.]
local function getPathsFromPng(filepath)
@/lua/console/simpleload.lua
BeamEngine:deleteAllObjects()
BeamEngine:spawnObject(1, "vehicles/pickup", nil, vec3(0, 0, 0))
@/lua/vehicle/controller/tech/roadsSensor.lua
-- The player vehicle state.
local pos, fwd, vel = vec3(0, 0, 0), vec3(0, 0, 0), vec3(0, 0, 0) -- The vehicle's position and forward vector.
local distToCenterline, distToLeft, distToRight = 0.0, 0.0, 0.0 -- The minimum distances between the vehicle's front axle midpoint to each lane.
-- The player vehicle state.
local pos, fwd, vel = vec3(0, 0, 0), vec3(0, 0, 0), vec3(0, 0, 0) -- The vehicle's position and forward vector.
local distToCenterline, distToLeft, distToRight = 0.0, 0.0, 0.0 -- The minimum distances between the vehicle's front axle midpoint to each lane.
-- The player vehicle state.
local pos, fwd, vel = vec3(0, 0, 0), vec3(0, 0, 0), vec3(0, 0, 0) -- The vehicle's position and forward vector.
local distToCenterline, distToLeft, distToRight = 0.0, 0.0, 0.0 -- The minimum distances between the vehicle's front axle midpoint to each lane.
local function closestPointBetween2D(p, a, b)
local u, v = vec3(a.x - p.x, a.y - p.y), vec3(b.x - a.x, b.y - a.y)
local vu, vv = v:dot(u), v:dot(v)
local function closestPointBetween2D(p, a, b)
local u, v = vec3(a.x - p.x, a.y - p.y), vec3(b.x - a.x, b.y - a.y)
local vu, vv = v:dot(u), v:dot(v)
local p1_2d = p1
local pn0_2d, pn1_2d, pn2_2d, pn3_2d = p0 - p1_2d, vec3(0.0, 0.0, 0.0), p2 - p1_2d, p3 - p1_2d
local t1, t2 = computeTangents(pn0_2d, pn1_2d, pn2_2d, pn3_2d)
-- Compute the player vehicle pose data.
pos, fwd, vel = obj:getPosition(), obj:getDirectionVector(), vec3(obj:getSmoothRefVelocityXYZ())
fwd:normalize()
local frontAxleMidpoint, rearAxleMidpoint = pos + (wp[min(ctr, 3)] + wp[min(ctr, 4)]) * 0.5, pos + (wp[min(ctr, 1)] + wp[min(ctr, 2)]) * 0.5
local frontAxleMidpointProjGround = vec3(frontAxleMidpoint.x, frontAxleMidpoint.y, obj:getSurfaceHeightBelow(frontAxleMidpoint))
disc[ctr] = catmullRomCentripetal(p0, p1, p2, p3, q, splineSmoothness)
--obj.debugDrawProxy:drawSphere(0.1, disc[ctr] + vec3(0, 0, 0.25), color(255, 255, 255, 255))
wds[ctr] = catmullRom(w0, w1, w2, w3, q, splineSmoothness)
-- Compute the heading angle when compared the vehicle forward direction.
local fwdproj = vec3(fwd.x, fwd.y, 0); fwdproj:normalize() -- New
local lineSegNormproj = vec3(lineSegNorm.x, lineSegNorm.y, 0); lineSegNormproj:normalize() -- New
local fwdproj = vec3(fwd.x, fwd.y, 0); fwdproj:normalize() -- New
local lineSegNormproj = vec3(lineSegNorm.x, lineSegNorm.y, 0); lineSegNormproj:normalize() -- New
local alfa = 0.5
-- Extrude outwards along the perpendicular vector to get the local left and right road edge point estimates.
local perpVector = vec3(lineSegNorm.y, -lineSegNorm.x, lineSegNorm.z)
--local latVec = halfWidth * lineSegNorm:cross(normals[p2Key])
pLeftRaw.z, pRightRaw.z = p1.z +2, p1.z +2 --9999, 9999
local pLeft = vec3(pLeftRaw.x, pLeftRaw.y, obj:getSurfaceHeightBelow(pLeftRaw))
local pRight = vec3(pRightRaw.x, pRightRaw.y, obj:getSurfaceHeightBelow(pRightRaw))
local pLeft = vec3(pLeftRaw.x, pLeftRaw.y, obj:getSurfaceHeightBelow(pLeftRaw))
local pRight = vec3(pRightRaw.x, pRightRaw.y, obj:getSurfaceHeightBelow(pRightRaw))
--
obj.debugDrawProxy:drawSphere(0.1, pLeft + vec3(0, 0, 0.25), color(255, 0, 0, 255))
obj.debugDrawProxy:drawSphere(0.1, pInt + vec3(0, 0, 0.25), color(0, 255, 0, 255))
obj.debugDrawProxy:drawSphere(0.1, pLeft + vec3(0, 0, 0.25), color(255, 0, 0, 255))
obj.debugDrawProxy:drawSphere(0.1, pInt + vec3(0, 0, 0.25), color(0, 255, 0, 255))
obj.debugDrawProxy:drawSphere(0.1, pRight + vec3(0, 0, 0.25), color(0, 0, 255, 255))
obj.debugDrawProxy:drawSphere(0.1, pInt + vec3(0, 0, 0.25), color(0, 255, 0, 255))
obj.debugDrawProxy:drawSphere(0.1, pRight + vec3(0, 0, 0.25), color(0, 0, 255, 255))
obj.debugDrawProxy:drawSphere(0.2, p0 + vec3(0, 0, 0.25), color(255, 255, 255,255))
obj.debugDrawProxy:drawSphere(0.2, p1 + vec3(0, 0, 0.25), color(255, 155, 155,255))
obj.debugDrawProxy:drawSphere(0.2, p0 + vec3(0, 0, 0.25), color(255, 255, 255,255))
obj.debugDrawProxy:drawSphere(0.2, p1 + vec3(0, 0, 0.25), color(255, 155, 155,255))
obj.debugDrawProxy:drawSphere(0.2, p2 + vec3(0, 0, 0.25), color(155, 155, 255,255))
obj.debugDrawProxy:drawSphere(0.2, p1 + vec3(0, 0, 0.25), color(255, 155, 155,255))
obj.debugDrawProxy:drawSphere(0.2, p2 + vec3(0, 0, 0.25), color(155, 155, 255,255))
obj.debugDrawProxy:drawSphere(0.2, p3 + vec3(0, 0, 0.25), color(255, 255, 255,255))
obj.debugDrawProxy:drawSphere(0.2, p2 + vec3(0, 0, 0.25), color(155, 155, 255,255))
obj.debugDrawProxy:drawSphere(0.2, p3 + vec3(0, 0, 0.25), color(255, 255, 255,255))
--
coeffsR = { uA = 0, uB = 0, uC = 0, uD = 0, vA = 0, vB = 0, vC = 0, vD = 0 }
coordsCL = { a = vec3(0, 0), b = vec3(0, 0), c = vec3(0, 0), d = vec3(0, 0) }
local startCL, startL, startR = vec3(0, 0), vec3(0, 0), vec3(0, 0)
coeffsR = { uA = 0, uB = 0, uC = 0, uD = 0, vA = 0, vB = 0, vC = 0, vD = 0 }
coordsCL = { a = vec3(0, 0), b = vec3(0, 0), c = vec3(0, 0), d = vec3(0, 0) }
local startCL, startL, startR = vec3(0, 0), vec3(0, 0), vec3(0, 0)
coeffsR = { uA = 0, uB = 0, uC = 0, uD = 0, vA = 0, vB = 0, vC = 0, vD = 0 }
coordsCL = { a = vec3(0, 0), b = vec3(0, 0), c = vec3(0, 0), d = vec3(0, 0) }
local startCL, startL, startR = vec3(0, 0), vec3(0, 0), vec3(0, 0)
coeffsR = { uA = 0, uB = 0, uC = 0, uD = 0, vA = 0, vB = 0, vC = 0, vD = 0 }
coordsCL = { a = vec3(0, 0), b = vec3(0, 0), c = vec3(0, 0), d = vec3(0, 0) }
local startCL, startL, startR = vec3(0, 0), vec3(0, 0), vec3(0, 0)
coordsCL = { a = vec3(0, 0), b = vec3(0, 0), c = vec3(0, 0), d = vec3(0, 0) }
local startCL, startL, startR = vec3(0, 0), vec3(0, 0), vec3(0, 0)
--roadRadius = NaN
coordsCL = { a = vec3(0, 0), b = vec3(0, 0), c = vec3(0, 0), d = vec3(0, 0) }
local startCL, startL, startR = vec3(0, 0), vec3(0, 0), vec3(0, 0)
--roadRadius = NaN
coordsCL = { a = vec3(0, 0), b = vec3(0, 0), c = vec3(0, 0), d = vec3(0, 0) }
local startCL, startL, startR = vec3(0, 0), vec3(0, 0), vec3(0, 0)
--roadRadius = NaN
startCL, startL, startR = p1, left1, right1
coordsCL = { a = p1, b = p2, c = p3, d = vec3(NaN, NaN, NaN) }
--roadRadius = 1.0 / inCurvature(p2 - p1, p3 - p2)
startCL, startL, startR = p1, left1, right1
coordsCL = { a = p1, b = p2, c = vec3(NaN, NaN, NaN), d = vec3(NaN, NaN, NaN) }
--roadRadius = NaN
startCL, startL, startR = p1, left1, right1
coordsCL = { a = p1, b = p2, c = vec3(NaN, NaN, NaN), d = vec3(NaN, NaN, NaN) }
--roadRadius = NaN
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veLightsDebug.lua
local zeroVec = vec3(0,0,0)
local arrowHeadVec = vec3(0,0.075,0)
local qDir = quat(worldMat:toQuatF())
local dirVec = qDir * vec3(0, lightRange, 0)
local color = ColorF(1, 0, 0, 0)
local attenuation = vec3(0, 1, 1)
if prop.lightAttenuation then attenuation = vec3(prop.lightAttenuation) end
local attenuation = vec3(0, 1, 1)
if prop.lightAttenuation then attenuation = vec3(prop.lightAttenuation) end
local castShadows = prop.lightCastShadows
@/lua/ge/extensions/util/forestGenerator.lua
local function newMatrix(pos, rotEuler)
pos = pos or vec3()
rotEuler = rotEuler or vec3()
pos = pos or vec3()
rotEuler = rotEuler or vec3()
local mtx = MatrixF(true)
end
return forestData:createNewItem(baseItem:getData(), newMatrix(pos, vec3(0, 0, rotDeg or 0)), scl)
end
itemTypeArray = itemTypeArray or forestItemTypes
pos = pos or vec3(0, 0, 0)
minX = minX or -100
local arraySize = #itemTypeArray
local bluePos = vec3(math.random(), math.random(), 0)
for i = 1, amount do
data.type = itemTypeArray[math.random(arraySize)]
data.pos = vec3(bluePos:getBlueNoise2d())
data.pos.x = lerp(minX, maxX, data.pos.x)
itemTypeArray = itemTypeArray or forestItemTypes
pos = pos or vec3(0, 0, 0)
radius = radius or 50
local arraySize = #itemTypeArray
local bluePos = vec3(pos)
for i = 1, amount do
data.type = itemTypeArray[math.random(arraySize)]
data.pos = vec3(bluePos:getRandomPointInCircle(radius))
data.rotDeg = lerp(0, 360, randomRot / rotSteps)
scl = scl or 1
local mtx = newMatrix(pos, vec3(0, 0, rotDeg or 0))
return forestData:updateItem(item:getKey(), item:getPosition(), item:getData(), mtx, scl, item:getUid())
@/lua/ge/extensions/gameplay/rally/vehicleTracker.lua
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
for i=0, wCount do
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
for i=0, wCount do
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
for i=0, wCount do
local axisNodes = vehicle:getWheelAxisNodes(i)
local nodePos = vec3(vehicle:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
local nodePos = vec3(vehicle:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
table.insert(self.wheelOffsets, pos)
local vehicle = nil
local vehPos = vec3()
function C:pos()
local vehVel = vec3()
-- Draw vehicle position marker
local markerPos = vec3(pos)
markerPos.z = markerPos.z + 2.0
if vel and speed > 0.1 then
local velEnd = vec3(pos) + vel * 2.0 -- Scale for visibility
velEnd.z = velEnd.z + 2.0
-- Draw text info
local textPos = vec3(markerPos)
textPos.z = textPos.z + 1.0
@/lua/ge/extensions/gameplay/crawl/general.lua
local reverseRot180 = quatFromAxisAngle(vec3(0, 1, 0), math.pi)
for _, node in ipairs(M.activeTrail.path.nodes) do
@/lua/ge/extensions/editor/assetBrowser.lua
local camUp = core_camera.getUp()
local camFwd = vec3(camUp.y * camRight.z - camUp.z * camRight.y, camUp.z * camRight.x - camUp.x * camRight.z, camUp.x * camRight.y - camUp.y * camRight.x)
objectPosition = vec3(camPos.x + camFwd.x * 10, camPos.y + camFwd.y * 10, camPos.z + camFwd.z * 10)
local camFwd = vec3(camUp.y * camRight.z - camUp.z * camRight.y, camUp.z * camRight.x - camUp.x * camRight.z, camUp.x * camRight.y - camUp.y * camRight.x)
objectPosition = vec3(camPos.x + camFwd.x * 10, camPos.y + camFwd.y * 10, camPos.z + camFwd.z * 10)
else
else
objectPosition = vec3(0, 0, 0)
end
newObj:setField('shapeName', 0, asset.path)
newObj.scale = vec3(1, 1, 1)
newObj.useInstanceRenderData = true
scenetree.MissionGroup:addObject(var.dragDropMesh.obj)
local camDir = (core_camera.getQuat() * vec3(0,1,0)) * 10
var.dragDropMesh.obj:setPosition(core_camera.getPosition() + camDir)
end
var.dragDropMesh.scale = vec3(1, 1, 1)
var.dragDropMesh:registerObject('')
if editor.getPreference("snapping.terrain.enabled") and editor.getPreference("snapping.terrain.relRotation") then
local rot = vec3(0,0,1):getRotationTo(vec3(hit.normal))
var.dragDropMesh:setPosRot(hit.pos.x, hit.pos.y, hit.pos.z - draggedObjOffset, rot.x, rot.y, rot.z, rot.w)
if editor.getPreference("snapping.terrain.enabled") and editor.getPreference("snapping.terrain.relRotation") then
local rot = vec3(0,0,1):getRotationTo(vec3(hit.normal))
var.dragDropMesh:setPosRot(hit.pos.x, hit.pos.y, hit.pos.z - draggedObjOffset, rot.x, rot.y, rot.z, rot.w)
else
var.dragDropMesh:setPosition(vec3(hit.pos.x, hit.pos.y, hit.pos.z - draggedObjOffset))
end
scenetree.MissionGroup:addObject(prefab.obj)
local camDir = (core_camera.getQuat() * vec3(0,1,0)) * 10
prefab.obj:setPosition(core_camera.getPosition() + camDir)
@/lua/ge/extensions/core/cameraModes/external.lua
-- car state (used for teleporting detection)
self.carPos = vec3()
self.carVel = vec3()
self.carPos = vec3()
self.carVel = vec3()
self.lastCarPos = vec3()
self.carVel = vec3()
self.lastCarPos = vec3()
self.lastCarVel = vec3()
self.lastCarPos = vec3()
self.lastCarVel = vec3()
-- camera panning effect
self.camVel = vec3(0,0,0)
self.lastCamVel = vec3(self.camVel)
self.camVel = vec3(0,0,0)
self.lastCamVel = vec3(self.camVel)
local forwardVector = (futureCarPos - carPos):normalized()
local sideVector = forwardVector:cross(vec3(0,0,1)):normalized()
local upVector = (carPos - futureCarPos):cross(sideVector):normalized()
if self.isFanMode then
self.camVel = vec3(0,0,0)
else
local minUpVel = minUpDist / 8
local panningLocal = vec3(
dzRandom(minSideVel, minSideVel + math.min(2,velLength*chancesMultiplier/20), true), --side
if minHeight then
local up = vec3(0,0,1)
local down = vec3(0,0,-1)
local up = vec3(0,0,1)
local down = vec3(0,0,-1)
local groundDist = castRayStatic(hitPos, down, minHeight, true)
if openxrSessionRunning then return end
offset = vec3(offset:dot(nx), offset:dot(ny), offset:dot(nz)) -- from world axis system to vehicle axis system
self.autopoint.localOffset = offset -- in local vehicle coordinates
if carStopped then
carVel = vec3(dzRandom(0.5, 2, true), dzRandom(0.5 , 2, true), 0) -- random speed
carVel = carVel:toBase(nx, ny, nz) -- speed coords to world coords
local distTravel = carPos:distance(carPosMidway)
local slopeOffset = vec3(0,0,distTravel*0.35)
local newCarPosLast = carPosMidway + slopeOffset
-- yep, it's probably a slope, let's move the vehicle prediction right above the ground
newCarPosLast = carPosMidway + vec3(0,0,distToGround + 0.1)
-- check if the path is clear (to prevent spawning on roofs after an uphill)
-- check if the path is clear (to prevent spawning on roofs after an uphill)
local visible = isVisible(carPos, newCarPosLast + vec3(0, 0, 1)) -- we add a meter in this check because right at the ground we'll probably not see the car immediately, it may take a second to appear if there's a crest
if visible then
local humanCameraHeight = dzRandom(1.3, 2.0)
local distDown = castRayStaticDistance(self.camPos, self.camPos-vec3(0,0,heightTest))
if distDown == 0 or distDown == heightTest then -- we may be underground
if distDown == 0 or distDown == heightTest then -- we may be underground
local distUp = heightTest-castRayStaticDistance(self.camPos+vec3(0,0,heightTest), self.camPos)
if distUp == 0 or distUp == heightTest then -- we are too far over the ground, default to current vehicle height
-- car debug
debugDrawer:drawSphere((carPos+vec3(0,0,2)), 0.5, ColorF(1,0,0,0.5)) -- car position
debugDrawer:drawSphere(carPos, 0.3, ColorF(1,0,0,1.0))
self.handheld.mustReset = true
self.lastCamPos = self.lastCamPos or vec3()
self.camPos = self.camPos or vec3()
self.lastCamPos = self.lastCamPos or vec3()
self.camPos = self.camPos or vec3()
end
@/lua/ge/extensions/editor/decalSpline/populate.lua
local min, max, random = math.min, math.max, math.random
local zeroVec = vec3(0, 0, 0)
local preRotQuats = geom.getPreRotQuats()
local jitterQuat, rot = quat(), quat()
local tmpTan = vec3()
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/veJBeamModifierLeakVis.lua
local tempColVec = vec3(1,1,1)
@/lua/ge/extensions/gameplay/markers/inspectVehicleMarker.lua
local iconRendererObj
local tmpVec = vec3()
local idCounter = 0
local zVector = vec3(0,0,1)
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local zVector = vec3(0,0,1)
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
local zVector = vec3(0,0,1)
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
local zVector = vec3(0,0,1)
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
local zVector = vec3(0,0,1)
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
* (0.5 + 0.5*cruisingFactor), data.dt)
self.iconPos = self.pos + vec3(0,0,iconHeight)
else
self.iconInfo.color = ColorI(255,255,255,0)
self.iconInfo.customSize = vec3(1,1,1)
self.iconInfo.drawIconShadow = false
self.iconOff = vec3(0,0,0)
self.iconPos = vec3(0,0,0)
self.iconOff = vec3(0,0,0)
self.iconPos = vec3(0,0,0)
end
@/lua/common/jbeam/sections/events.lua
-- now clean up the input data
local rotDeg = vec3(ab.rotation)
ab.rotation = vec3(math.rad(rotDeg.x), math.rad(rotDeg.y), math.rad(rotDeg.z))
local rotDeg = vec3(ab.rotation)
ab.rotation = vec3(math.rad(rotDeg.x), math.rad(rotDeg.y), math.rad(rotDeg.z))
ab.translation = vec3(ab.translation)
ab.rotation = vec3(math.rad(rotDeg.x), math.rad(rotDeg.y), math.rad(rotDeg.z))
ab.translation = vec3(ab.translation)
if ab.baseTranslation ~= nil then
ab.baseTranslation = vec3(ab.baseTranslation)
abo.baseTranslation = ab.baseTranslation
if ab.translationOffset ~= nil then
ab.translationOffset = vec3(ab.translationOffset)
abo.translationOffset = ab.translationOffset
if ab.baseRotation ~= nil then
local rot = vec3(ab.baseRotation)
ab.baseRotation = vec3(math.rad(rot.x), math.rad(rot.y), math.rad(rot.z))
local rot = vec3(ab.baseRotation)
ab.baseRotation = vec3(math.rad(rot.x), math.rad(rot.y), math.rad(rot.z))
abo.baseRotation = ab.baseRotation
if typeStr == 'box' and type(ab.size) == 'table' then
ab.size = vec3(ab.size)
abo:setBoxSize(ab.size)
@/gameplay/missionTypes/scatterPickup/customNodes/scatterAnimatorNode.lua
end
scenetree.findObject(e.objectId):setScale(vec3(1,1,1) * sclCurve(e.animationTimer))
scenetree.findObject(e.objectId):setPosition(lerp(e.pos, e.vehicleTarget, posCurve(e.animationTimer)) + vec3(0,0,zAdd(e.animationTimer)*e.zScl))
scenetree.findObject(e.objectId):setScale(vec3(1,1,1) * sclCurve(e.animationTimer))
scenetree.findObject(e.objectId):setPosition(lerp(e.pos, e.vehicleTarget, posCurve(e.animationTimer)) + vec3(0,0,zAdd(e.animationTimer)*e.zScl))
end
end
local tmpVec = vec3()
local camPos = core_camera.getPosition()
@/lua/vehicle/extensions/chassisData.lua
local avgWheelPos = vec3(0, 0, 0)
local wheelCount = 0
for _, wheel in pairs(wheels.wheels) do
local wheelNodePos = vec3(v.data.nodes[wheel.node1].pos) --find the wheel position
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) -- obj:getDirectionVector() --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) -- obj:getDirectionVector() --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) -- obj:getDirectionVector() --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) -- obj:getDirectionVector() --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
for _, wheel in pairs(wheels.wheels) do
local wheelNodePos = vec3(v.data.nodes[wheel.node1].pos) --find the wheel position
local wheelVector = wheelNodePos - avgWheelPos --create a vector from our "center" to the wheel
@/lua/common/utils.lua
-- function testSerialization()
-- d = {a = "foo", b = {c = 123, d = "foo", p = vec3(1,2,3)}}
-- print("original data: " .. tostring(d))
if dir then
local x,y,z = vec3(radius,0,0)*dir,vec3(0,radius,0)*dir,vec3(0,0,radius)*dir
simpleDebugText3d(nil, pos + x, 0.1, ColorF(1,0,0,0.25))
if dir then
local x,y,z = vec3(radius,0,0)*dir,vec3(0,radius,0)*dir,vec3(0,0,radius)*dir
simpleDebugText3d(nil, pos + x, 0.1, ColorF(1,0,0,0.25))
if dir then
local x,y,z = vec3(radius,0,0)*dir,vec3(0,radius,0)*dir,vec3(0,0,radius)*dir
simpleDebugText3d(nil, pos + x, 0.1, ColorF(1,0,0,0.25))
@/lua/ge/extensions/flowgraph/nodes/scene/sevensegmentDisplay.lua
self.tRot = self.rot:toTorqueQuat()
self.scl = vec3(self.data.scaling, self.data.scaling, self.data.scaling)
local pos = self.pinIn.position.value or { 0, 0, 0 }
pos = vec3(pos)
local off = -self.data.spacing * (self.data.count - 1) / 2 + self.data.spacing * (i - 1)
local off = -self.data.spacing * (self.data.count - 1) / 2 + self.data.spacing * (i - 1)
pos = pos + (self.rot:__mul(vec3(-off, 0, 0)))
pos = vec3(pos.x, pos.y, pos.z)
pos = pos + (self.rot:__mul(vec3(-off, 0, 0)))
pos = vec3(pos.x, pos.y, pos.z)
object:setPosition(pos)
if self.data.decimals > 0 and self.data.decimals <= self.data.count then
self:makeDot(vec3(-self.data.spacing * (self.data.count - 1) / 2 + self.data.spacing * (self.data.decimals - 1) - self.data.decimalOffset, 0, 0), 'decimal')
end
if self.data.decimals + 2 < self.data.count then
self:makeDot(vec3(-self.data.spacing * (self.data.count - 1) / 2 + self.data.spacing * (self.data.decimals + 1) - self.data.decimalOffset, 0, 3 * self.scl.z / 100), 'm_1')
self:makeDot(vec3(-self.data.spacing * (self.data.count - 1) / 2 + self.data.spacing * (self.data.decimals + 1) - self.data.decimalOffset, 0, 8 * self.scl.z / 100), 'm_2')
self:makeDot(vec3(-self.data.spacing * (self.data.count - 1) / 2 + self.data.spacing * (self.data.decimals + 1) - self.data.decimalOffset, 0, 3 * self.scl.z / 100), 'm_1')
self:makeDot(vec3(-self.data.spacing * (self.data.count - 1) / 2 + self.data.spacing * (self.data.decimals + 1) - self.data.decimalOffset, 0, 8 * self.scl.z / 100), 'm_2')
end
local pos = self.pinIn.position.value or { 0, 0, 0 }
pos = vec3(pos)
pos = pos + (self.rot:__mul(offset))
pos = pos + (self.rot:__mul(offset))
pos = vec3(pos.x, pos.y, pos.z)
object:setPosition(pos)
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veFlexbodyDebug.lua
local zeroVec = vec3(0,0,0)
local prevMinBounds = vec3(huge,huge,huge)
local prevMaxBounds = vec3(-huge,-huge,-huge)
local prevMinBounds = vec3(huge,huge,huge)
local prevMaxBounds = vec3(-huge,-huge,-huge)
local minBounds = vec3(huge,huge,huge)
local prevMaxBounds = vec3(-huge,-huge,-huge)
local minBounds = vec3(huge,huge,huge)
local maxBounds = vec3(-huge,-huge,-huge)
local minBounds = vec3(huge,huge,huge)
local maxBounds = vec3(-huge,-huge,-huge)
local vehPos = vec3()
local rotInv = quat()
local rotInv = quat()
local localVertPos = vec3()
local vertPosLocal = vec3()
local localVertPos = vec3()
local vertPosLocal = vec3()
local vertPos = vec3()
local vertPosLocal = vec3()
local vertPos = vec3()
local tempVec = vec3()
local vertPos = vec3()
local tempVec = vec3()
local tempVec2 = vec3()
local tempVec = vec3()
local tempVec2 = vec3()
local nodePos = vec3()
local tempVec2 = vec3()
local nodePos = vec3()
local count = 0
local countVec = vec3(0,0,0)
@/lua/ge/extensions/gameplay/drag/saveSystem.lua
local rot = quat(waypoint.transform.rotation.x, waypoint.transform.rotation.y, waypoint.transform.rotation.z, waypoint.transform.rotation.w)
local scl = vec3(waypoint.transform.scale.x, waypoint.transform.scale.y, waypoint.transform.scale.z)
transform = {
position = vec3(waypoint.transform.position.x, waypoint.transform.position.y, waypoint.transform.position.z),
rotation = rot,
-- Legacy compatibility fields
pos = vec3(waypoint.transform.position.x, waypoint.transform.position.y, waypoint.transform.position.z),
rot = rot,
-- Add coordinate system axes for compatibility with areFrontWheelsParallelToLine
x = rot * vec3(scl.x, 0, 0),
y = rot * vec3(0, scl.y, 0),
x = rot * vec3(scl.x, 0, 0),
y = rot * vec3(0, scl.y, 0),
z = rot * vec3(0, 0, scl.z)
y = rot * vec3(0, scl.y, 0),
z = rot * vec3(0, 0, scl.z)
},
-- Fallback: use default forward direction if waypoints are missing
completeLane.stageToEndNormalized = vec3(1, 0, 0)
end
transform = {
position = vec3(lane.boundary.transform.position.x, lane.boundary.transform.position.y, lane.boundary.transform.position.z),
rotation = quat(lane.boundary.transform.rotation.x, lane.boundary.transform.rotation.y, lane.boundary.transform.rotation.z, lane.boundary.transform.rotation.w),
rotation = quat(lane.boundary.transform.rotation.x, lane.boundary.transform.rotation.y, lane.boundary.transform.rotation.z, lane.boundary.transform.rotation.w),
scale = vec3(lane.boundary.transform.scale.x, lane.boundary.transform.scale.y, lane.boundary.transform.scale.z),
}
transform = waypoint.transform or {
pos = vec3(0, 0, 0),
rot = quat(0, 0, 0, 1),
rot = quat(0, 0, 0, 1),
scl = vec3(1, 1, 1)
},
@/lua/ge/extensions/core/cameraModes/topDown.lua
-- get the data
local ref = vec3(data.veh:getNodePosition(self.refNodes.ref))
local back = vec3(data.veh:getNodePosition(self.refNodes.back))
local ref = vec3(data.veh:getNodePosition(self.refNodes.ref))
local back = vec3(data.veh:getNodePosition(self.refNodes.back))
end
self.lastDataPos = vec3(data.pos)
-- and place the camera above it
local camPos = targetPos + vec3(0, 0, (self.vel * 0.9) + 50)
-- set the data, this needs to happen
data.res.pos = camPos -- required, vec3()
data.res.rot = qdir -- required, quat()
@/lua/ge/extensions/gameplay/util/groundContact.lua
-- for GC
local tempVec = vec3()
local vec3TempCenter = vec3()
local tempVec = vec3()
local vec3TempCenter = vec3()
local vecDown = vec3(0,0,-1)
local vec3TempCenter = vec3()
local vecDown = vec3(0,0,-1)
local vec3TempCenter = vec3()
local vecDown = vec3(0,0,-1)
local vec3TempCenter = vec3()
local vec3Offset = vec3(0,0,0.2)
local vec3TempCenter = vec3()
local vec3Offset = vec3(0,0,0.2)
local vehOOBB
local tempVec2 = vec3()
local oobbCenter = vec3()
local tempVec2 = vec3()
local oobbCenter = vec3()
local function isOnWheels(vehId)
@/lua/vehicle/controller/gauges/customModules/navigationData.lua
local vecX = vec3(1, 0, 0)
local vecY = vec3(0, -1, 0)
local vecX = vec3(1, 0, 0)
local vecY = vec3(0, -1, 0)
@/lua/ge/extensions/editor/sidewalkSpline/populate.lua
local abs, atan2, deg = math.abs, math.atan2, math.deg
local defaultScale = vec3(1, 1, 1)
local forwardRot, upRot = quat(), quat()
local tmpPosBack, tmpPosFront = vec3(), vec3()
local tmpForward, tmpUp, tmpRight = vec3(), vec3(), vec3()
local forwardRot, upRot = quat(), quat()
local tmpPosBack, tmpPosFront = vec3(), vec3()
local tmpForward, tmpUp, tmpRight = vec3(), vec3(), vec3()
local tmpPosBack, tmpPosFront = vec3(), vec3()
local tmpForward, tmpUp, tmpRight = vec3(), vec3(), vec3()
local tmpVec1, tmpVec2 = vec3(), vec3()
local tmpPosBack, tmpPosFront = vec3(), vec3()
local tmpForward, tmpUp, tmpRight = vec3(), vec3(), vec3()
local tmpVec1, tmpVec2 = vec3(), vec3()
local tmpPosBack, tmpPosFront = vec3(), vec3()
local tmpForward, tmpUp, tmpRight = vec3(), vec3(), vec3()
local tmpVec1, tmpVec2 = vec3(), vec3()
local tmpForward, tmpUp, tmpRight = vec3(), vec3(), vec3()
local tmpVec1, tmpVec2 = vec3(), vec3()
local cornerPrev, cornerNext, baseVec = vec3(), vec3(), vec3()
local tmpForward, tmpUp, tmpRight = vec3(), vec3(), vec3()
local tmpVec1, tmpVec2 = vec3(), vec3()
local cornerPrev, cornerNext, baseVec = vec3(), vec3(), vec3()
local tmpVec1, tmpVec2 = vec3(), vec3()
local cornerPrev, cornerNext, baseVec = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local tmpVec1, tmpVec2 = vec3(), vec3()
local cornerPrev, cornerNext, baseVec = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local tmpVec1, tmpVec2 = vec3(), vec3()
local cornerPrev, cornerNext, baseVec = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local cornerPrev, cornerNext, baseVec = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local cornerPrev, cornerNext, baseVec = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local cornerPrev, cornerNext, baseVec = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local pizzaScaleVec = vec3(1, 1, 1)
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local pizzaScaleVec = vec3(1, 1, 1)
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local pizzaScaleVec = vec3(1, 1, 1)
local innerPrev, innerNext, interiorDir = vec3(), vec3(), vec3()
local pizzaScaleVec = vec3(1, 1, 1)
maxPlacements = placementIdx
positionArray[placementIdx] = positionArray[placementIdx] or vec3()
rotationArray[placementIdx] = rotationArray[placementIdx] or quat()
forwardRot:setRotationFromTo(vec3(0, 1, 0), tmpForward)
tmpVec1:set(0, 0, 1)
-- Store rect frame for pizza placement pass.
rectForwardArray[placementIdx] = rectForwardArray[placementIdx] or vec3()
rectForwardArray[placementIdx]:set(tmpForward)
rectForwardArray[placementIdx]:set(tmpForward)
rectRightArray[placementIdx] = rectRightArray[placementIdx] or vec3()
rectRightArray[placementIdx]:set(tmpRight)
rectRightArray[placementIdx]:set(tmpRight)
rectUpArray[placementIdx] = rectUpArray[placementIdx] or vec3()
rectUpArray[placementIdx]:set(tmpUp)
rectUpArray[placementIdx]:set(tmpUp)
prevForward = prevForward or vec3()
prevForward:set(tmpForward)
prevForward:set(tmpForward)
prevUp = prevUp or vec3()
prevUp:set(tmpUp)
maxPlacements = placementIdx
positionArray[placementIdx] = positionArray[placementIdx] or vec3()
rotationArray[placementIdx] = rotationArray[placementIdx] or quat()
@/lua/ge/extensions/util/trackBuilder/markers.lua
marker:setField('shapeName', 0, "art/shapes/interface/track_editor_marker.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(0.1, 5, 2.5)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(0.1, 5, 2.5)
marker:setField('rotation', 0, '0 0 1 0')
marker:setField('shapeName', 0, "art/shapes/interface/track_editor_marker.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2, 2, 20)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2, 2, 20)
marker:setField('rotation', 0, '1 0 0 180')
markerRight:setField('shapeName', 0, "art/shapes/interface/checkpoint_marker_sphere.dae")
markerRight:setPosition(vec3(0,0,0))
markerRight.scale = vec3(2,2,2)
markerRight:setPosition(vec3(0,0,0))
markerRight.scale = vec3(2,2,2)
markerRight:setField('rotation', 0, '0 0 1 0')
markerLeft:setField('shapeName', 0, "art/shapes/interface/checkpoint_marker_sphere.dae")
markerLeft:setPosition(vec3(0,0,0))
markerLeft.scale = vec3(2,2,2)
markerLeft:setPosition(vec3(0,0,0))
markerLeft.scale = vec3(2,2,2)
markerLeft:setField('rotation', 0, '0 0 1 0')
marker:setField('shapeName', 0, "art/shapes/interface/track_editor_marker.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(3, 0.1, 3)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(3, 0.1, 3)
marker:setField('rotation', 0, '0 0 1 0')
marker:setField('shapeName', 0, "art/shapes/interface/track_editor_marker.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2.25, 0.1, 2.25)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2.25, 0.1, 2.25)
marker:setField('rotation', 0, '0 0 1 0')
marker:setField('shapeName', 0, "art/shapes/interface/track_editor_marker.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2.25, 0.1, 2.25)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2.25, 0.1, 2.25)
marker:setField('rotation', 0, '0 0 1 0')
marker:setField('shapeName', 0, "art/shapes/interface/checkpoint_marker_sphere.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(3, 0.1, 3)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(3, 0.1, 3)
marker:setField('rotation', 0, '0 0 1 0')
marker:setField('shapeName', 0, "art/shapes/interface/track_editor_marker.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2.25, 0.1, 2.25)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2.25, 0.1, 2.25)
marker:setField('rotation', 0, '0 0 1 0')
marker:setField('shapeName', 0, "art/shapes/interface/track_editor_marker.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2.25, 0.1, 2.25)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(2.25, 0.1, 2.25)
marker:setField('rotation', 0, '0 0 1 0')
marker:setField('shapeName', 0, "art/shapes/interface/track_editor_marker.dae")
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(1.5, 0.1, 5)
marker:setPosition(vec3(0,0,0))
marker.scale = vec3(1.5, 0.1, 5)
marker:setField('rotation', 0, '0 0 1 0')
local m = #list
list[m].scale = vec3(0,0,0)
list[m] = nil
markers['bank'][i].scale = vec3(0.1, 5, 2.5)
markers['bank'][i]:setPosition(node.markerInfo.position)
for i, node in ipairs(nodes) do
markers['height'][i]:setPosition((node.markerInfo.position + vec3(0,0,-1)))
markers['height'][i]:setScale(vec3(1,1, node.markerInfo.position.z -1))
markers['height'][i]:setPosition((node.markerInfo.position + vec3(0,0,-1)))
markers['height'][i]:setScale(vec3(1,1, node.markerInfo.position.z -1))
end
for i, node in ipairs(nodes) do
local right = node.markerInfo.rot:__mul(vec3( node.width.value/2, 0, 0))
local left = node.markerInfo.rot:__mul(vec3(-node.width.value/2, 0, 0))
local right = node.markerInfo.rot:__mul(vec3( node.width.value/2, 0, 0))
local left = node.markerInfo.rot:__mul(vec3(-node.width.value/2, 0, 0))
markers['width'][i*2-1]:setPosition((node.markerInfo.position + right ))
markers['width'][i*2-1].scale = vec3(2,2,2)
markers['width'][i*2]:setPosition((node.markerInfo.position + left))
markers['width'][i*2].scale = vec3(2,2,2)
end
local quat = rot:toTorqueQuat()
local down = node.markerInfo.rot:__mul(vec3( 0, 0, -1))
markers['centerMesh'][i].scale = vec3(2,0.1,2)
local down = node.markerInfo.rot:__mul(vec3( 0, 0, -1))
markers['centerMesh'][i].scale = vec3(2,0.1,2)
markers['centerMesh'][i]:setPosition((node.markerInfo.position + down))
local quat = rot:toTorqueQuat()
local downLeft = node.markerInfo.rot:__mul(vec3( -node.markerInfo.width/2-1, 0, -1))
markers['leftMesh'][i].scale = vec3(2,0.1,2)
local downLeft = node.markerInfo.rot:__mul(vec3( -node.markerInfo.width/2-1, 0, -1))
markers['leftMesh'][i].scale = vec3(2,0.1,2)
markers['leftMesh'][i]:setPosition((node.markerInfo.position + downLeft))
local quat = rot:toTorqueQuat()
local downRight = node.markerInfo.rot:__mul(vec3( node.markerInfo.width/2+1, 0, -1))
markers['rightMesh'][i].scale = vec3(2,0.1,2)
local downRight = node.markerInfo.rot:__mul(vec3( node.markerInfo.width/2+1, 0, -1))
markers['rightMesh'][i].scale = vec3(2,0.1,2)
markers['rightMesh'][i]:setPosition((node.markerInfo.position + downRight))
local quat = rot:toTorqueQuat()
local off = rot:__mul(vec3(node.checkpointPosition.x, node.checkpointPosition.y, node.checkpointPosition.z))
markers['checkpoint'][i].scale = vec3(node.checkpointSize,node.checkpointSize, node.checkpointSize)
local off = rot:__mul(vec3(node.checkpointPosition.x, node.checkpointPosition.y, node.checkpointPosition.z))
markers['checkpoint'][i].scale = vec3(node.checkpointSize,node.checkpointSize, node.checkpointSize)
markers['checkpoint'][i]:setPosition((node.markerInfo.position + off))
local quat = rot:toTorqueQuat()
local downLeft = node.markerInfo.rot:__mul(vec3( -node.markerInfo.width/2-1.5, 0, 0))
markers['leftWall'][i].scale = vec3(1,0.1,3)
local downLeft = node.markerInfo.rot:__mul(vec3( -node.markerInfo.width/2-1.5, 0, 0))
markers['leftWall'][i].scale = vec3(1,0.1,3)
markers['leftWall'][i]:setPosition((node.markerInfo.position + downLeft))
local quat = rot:toTorqueQuat()
local downRight = node.markerInfo.rot:__mul(vec3( node.markerInfo.width/2+1.5, 0, 0))
markers['rightWall'][i].scale = vec3(1,0.1,3)
local downRight = node.markerInfo.rot:__mul(vec3( node.markerInfo.width/2+1.5, 0, 0))
markers['rightWall'][i].scale = vec3(1,0.1,3)
markers['rightWall'][i]:setPosition((node.markerInfo.position + downRight))
local quat = rot:toTorqueQuat()
local upCenter = node.markerInfo.rot:__mul(vec3( 0, 0, node.ceilingMesh.value))
markers['ceilingMesh'][i].scale = vec3(1,0.1,3)
local upCenter = node.markerInfo.rot:__mul(vec3( 0, 0, node.ceilingMesh.value))
markers['ceilingMesh'][i].scale = vec3(1,0.1,3)
markers['ceilingMesh'][i]:setPosition((node.markerInfo.position + upCenter))
if markers[name][i] ~= nil then
markers[name][i].scale = vec3(0,0,0)
end
@/lua/vehicle/extensions/dragAi.lua
local targetPos = vec3(targetPosition)
local myPos = obj:getPosition()
local distanceVector = targetPos - myPos
distanceVector = vec3(distanceVector.x, distanceVector.y, 0)
local directionVector = obj:getDirectionVector()
local directionVector = obj:getDirectionVector()
directionVector = vec3(directionVector.x, directionVector.y, 0)
local angle = (distanceVector:dot(directionVector) / (directionVector:length() * distanceVector:length()))
@/lua/ge/extensions/career/modules/painting.lua
core_camera.setByName(0, "orbit", true)
core_camera.setDefaultRotation(vehId, vec3(145, -15, 0))
core_camera.resetCamera(0)
@/lua/ge/extensions/editor/toolUtilities/render.lua
local numArcSegmentsInv = 1.0 / numArcSegments
local globalUp = vec3(0, 0, 1)
local emptyTable = {}
local finalPoints = {}
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local finalPoints = {}
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local finalPoints = {}
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local finalPoints = {}
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local finalPoints = {}
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local finalPoints = {}
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local finalPoints = {}
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local finalPoints = {}
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local bL, bR, tL, tR, tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpA, tmpB, tmpC, pTemp, tmpTgt, tmpDir = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local tmpTan, tmpBinormal, tmpOff, latVec1, latVec2 = vec3(), vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local offsetP0, offsetP1 = vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local offsetP0, offsetP1 = vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local offsetP0, offsetP1 = vec3(), vec3()
local tmpL1, tmpR1, tmpL2, tmpR2, tmpRef = vec3(), vec3(), vec3(), vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local offsetP0, offsetP1 = vec3(), vec3()
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local offsetP0, offsetP1 = vec3(), vec3()
local tmpPoints = {}
local swCenter1, swEdge1, swEdge2, tmpScale = vec3(), vec3(), vec3(), vec3()
local offsetP0, offsetP1 = vec3(), vec3()
local tmpPoints = {}
for i = 1, numArcSegments + 1 do
tmpPoints[i] = vec3()
end
for j = 1, numDiv do
local p = finalPoints[j] or vec3()
tmpOff:setScaled2(binormals[j], layerPosition * divWidths[j] * 0.5)
for j = 1, numDiv do
local p = finalPoints[j] or vec3()
p:set(divPoints[j]) -- No binormal offset applied
@/lua/ge/extensions/gameplay/speedTraps.lua
local yVec = vec3(0,1,0)
local vehVelocity = vec3()
local triggerDir = vec3()
local vehVelocity = vec3()
local triggerDir = vec3()
local vehPos = vec3()
local triggerDir = vec3()
local vehPos = vec3()
local camPos = vec3()
local vehPos = vec3()
local camPos = vec3()
@/gameplay/missionTypes/scatterPickup/customNodes/scatterResetNode.lua
obj.hidden = false
obj:setScale(vec3(1,1,1))
obj:setPosition(state.pos)
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/scriptAI/pathStored.lua
local dbgPt = vec3()
local lastPt = vec3()
local dbgPt = vec3()
local lastPt = vec3()
local dbgPrimA = Point2F(0.4, 0.7)
function C:drawDebugPath()
local focusPos = vec3(Lua.lastDebugFocusPos)
local camPos = core_camera.getPosition()
@/lua/ge/extensions/scenario/busdriver.lua
m:setField('instanceColor', 0, '1 1 1 0')
m:setPosition(vec3(0, 0, 0))
end
marker:setField('shapeName', 0, "art/shapes/interface/position_marker.dae")
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
end
table.insert(wps, vec3(task[3][1], task[3][2], core_terrain.getTerrainHeight(vec3(task[3]))))
local options = {
end
table.insert(wps, vec3(task[3][1], task[3][2], core_terrain.getTerrainHeight(vec3(task[3]))))
local options = {
local function moveBusMarkers()
local tpos,pos = vec3(nextStop[3]) + vec3(0,0,3), vec3(0,0,0)
local tr = quat(nextStop[4])
local function moveBusMarkers()
local tpos,pos = vec3(nextStop[3]) + vec3(0,0,3), vec3(0,0,0)
local tr = quat(nextStop[4])
local function moveBusMarkers()
local tpos,pos = vec3(nextStop[3]) + vec3(0,0,3), vec3(0,0,0)
local tr = quat(nextStop[4])
local r
local xVec, yVec = tr*vec3(1,0,0), tr*vec3(0,1,0)
local r
local xVec, yVec = tr*vec3(1,0,0), tr*vec3(0,1,0)
end
local heightCorrection = be:castRay( (pos), (pos-vec3(0,0,13)) )
if heightCorrection < 1 then
if heightCorrection < 1 then
local tHeight = be:castRay( (tpos), (tpos-vec3(0,0,13)) )
if tHeight *0.8 > heightCorrection then
pos.z = pos.z-tHeight*0.8
heightCorrection = be:castRay( (pos), (pos-vec3(0,0,13)) )
end
local pos1 = mapData.nodes[second].pos
return (pos1-pos0):normalized():cross(vec3(0, 0, 1)):dot((triggerPos-pos0):normalized()) > 0
end
for i, stop in ipairs(currentLine.tasklist) do
local vec3Destination = vec3(stop[3])
debugDrawer:drawTextAdvanced(vec3Destination, String('['..i..'] '..stop[2] .. ' / ' .. stop[1]), ColorF(0,0,0,1), true, false, ColorI(255, 255, 255, 255))
-- calculate smoothness rating
local fwd = vec3(pv:getDirectionVector()):normalized()
local up = vec3(pv:getDirectionVectorUp()):normalized()
local fwd = vec3(pv:getDirectionVector()):normalized()
local up = vec3(pv:getDirectionVectorUp()):normalized()
local currPos = vec3(pv:getPosition())
local up = vec3(pv:getDirectionVectorUp()):normalized()
local currPos = vec3(pv:getPosition())
local currVel = (prevPos and (currPos - prevPos) or vec3()) / dtSim
local currPos = vec3(pv:getPosition())
local currVel = (prevPos and (currPos - prevPos) or vec3()) / dtSim
local currAcc = (prevVel and (currVel - prevVel) or vec3()) / dtSim
local currVel = (prevPos and (currPos - prevPos) or vec3()) / dtSim
local currAcc = (prevVel and (currVel - prevVel) or vec3()) / dtSim
local currJer = (prevAcc and (currAcc - prevAcc) or vec3()) / dtSim
local currAcc = (prevVel and (currVel - prevVel) or vec3()) / dtSim
local currJer = (prevAcc and (currAcc - prevAcc) or vec3()) / dtSim
local acc = currAcc:rotated(quatFromDir(fwd, up):inversed():normalized())
local busStop = scenetree.findObject(nextStop[1])
local busStopPos = vec3(busStop:getPosition())
currPos = currPos + vec3(pv:getNodePosition(0))
local busStopPos = vec3(busStop:getPosition())
currPos = currPos + vec3(pv:getNodePosition(0))
local diff = (currPos-busStopPos):rotated(quatFromDir(fwd, up):inversed():normalized())
if abs(stopDistance) < 20 then
local fwd = vec3(pv:getDirectionVector()):normalized()
local busStopFwd = vec3(busStop:getTransform():getColumn(1)):normalized()
local fwd = vec3(pv:getDirectionVector()):normalized()
local busStopFwd = vec3(busStop:getTransform():getColumn(1)):normalized()
local busStopUp = vec3(busStop:getTransform():getColumn(2)):normalized()
local busStopFwd = vec3(busStop:getTransform():getColumn(1)):normalized()
local busStopUp = vec3(busStop:getTransform():getColumn(2)):normalized()
local fwdAligned = fwd:projectToOriginPlane(busStopUp):normalized()
--log("E", logTag, "onPreRender nextStop("..dumps(type(nextStop))..")="..dumps(nextStop))
local vec3Destination = vec3(nextStop[3])
local proj = vec3(0,0,5)
local vec3Destination = vec3(nextStop[3])
local proj = vec3(0,0,5)
local heightCorrection = be:castRay( (vec3Destination+proj), (vec3Destination-proj*3) )
debugDrawer:drawSphere(vec3Destination, 1.6, ColorF(1.0,0.0,0.0,1.0))
debugDrawer:drawSphere(vec3(vec3Destination.x,vec3Destination.y,vec3Destination.z-heightCorrection+proj.z ), 0.9, ColorF(0.5,0.0,0.0,1.0))
debugDrawer:drawLine((vec3Destination+proj), (vec3Destination-proj*2), ColorF(0.5,0.0,0.5,1.0))
local mapData = map.getMap()
local vehPos = vec3(playerVehicle:getPosition())
local distanceToWp = function(wp)
local distanceToWp = function(wp)
return (mapData.nodes[wp] and vehPos:distance(vec3(mapData.nodes[wp].pos))) or 0
end
-- 20m is from the center of the trigger, with big trigger can fail after exit 1m from trigger
--if vec3Destination:distance(vec3(pv:getPosition())) > 20 then fail("scenarios.busRoutes.exitTggBeforeTimer") end
end
local ob = pv:getSpawnWorldOOBB()
local vDirVec=vec3(pv:getDirectionVector())
local tr = quat(nextStop[4])
local tr = quat(nextStop[4])
local yVec = tr*vec3(0,1,0)
local trigger = scenetree.findObject(nextStop[1])
trigger = Sim.upcast(trigger)
-- local vUpVec=vec3(pv:getDirectionVectorUp())
-- local vLeftVec=vDirVec:cross(vUpVec)
end
table.insert(wps, vec3(task[3][1], task[3][2], core_terrain.getTerrainHeight(vec3(task[3]))))
local options = {
end
table.insert(wps, vec3(task[3][1], task[3][2], core_terrain.getTerrainHeight(vec3(task[3]))))
local options = {
@/lua/ge/extensions/flowgraph/nodes/scene/storeStatics.lua
local entry = {
pos = vec3(obj:getPosition()):toTable(),
rot = quat(obj:getRotation()):toTable(),
rot = quat(obj:getRotation()):toTable(),
scl = vec3(obj:getScale()):toTable(),
shapeName = obj.shapeName,
-- position
pos = vec3(pos[1],pos[2],pos[3])
object:setPosition(pos)
-- scale
scl = vec3(scl[1],scl[2],scl[3])
object:setScale(scl)
@/lua/ge/extensions/ui/liveryEditor/layerEdit.lua
end
return vec3(scaleX, scaleVec.y, scaleY)
end
M.setScale = function(x, y, lock)
local scale = vec3(x, 1, y)
if useCursorForTransform then
@/lua/ge/extensions/gameplay/rally/recce.lua
local forwardVector = vec3(0,1,0)
local rotatedForwardVector = quat * forwardVector * (l/2) -- assume pos is the center of car so divide length by 2
local raise = vec3(0,0,h/2)
frontOfCar = frontOfCar + raise
local wheelPositions = {
{0.5, vec3(-(w/2*0.9), l/2 * 0.6, 0.4)}, -- Front left
{0.5, vec3( (w/2*0.9), l/2 * 0.6, 0.4)}, -- Front right
{0.5, vec3(-(w/2*0.9), l/2 * 0.6, 0.4)}, -- Front left
{0.5, vec3( (w/2*0.9), l/2 * 0.6, 0.4)}, -- Front right
{0.6, vec3(-(w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear left
{0.5, vec3( (w/2*0.9), l/2 * 0.6, 0.4)}, -- Front right
{0.6, vec3(-(w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear left
{0.6, vec3( (w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear right
{0.6, vec3(-(w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear left
{0.6, vec3( (w/2*1.1), -(l/2 * 0.6), 0.4)}, -- Rear right
}
debugDrawer:drawTextAdvanced(
backOfCar + vec3(0,0,h/2),
String(txt),
@/lua/ge/extensions/editor/drivePathEditor/record.lua
-- Get the current position and velocity of the recording vehicle.
local pos = vec3(recordingVehicle:getPosition())
local vel = max(minVelocity, recordingVehicle:getVelocity():length())
table.clear(recordingVel)
recordingPos[1] = vec3(recordingVehicle:getPosition())
recordingVel[1] = max(minVelocity, recordingVehicle:getVelocity():length())
for i = 1, #recordingPos do
spline.nodes[i] = vec3(recordingPos[i])
spline.vels[i] = recordingVel[i]
for i = 1, pathLength do
spline.widths[i], spline.nmls[i], spline.velLimits[i] = defaultWidth, vec3(0, 0, 1), defaultVelLimit
end
@/lua/ge/extensions/gameplay/missions/missionManager.lua
startingInfo.vehPos = veh:getPosition()
startingInfo.vehRot = quatFromDir(vec3(veh:getDirectionVector()), vec3(veh:getDirectionVectorUp()))
startingInfo.vehId = veh:getID()
startingInfo.vehPos = veh:getPosition()
startingInfo.vehRot = quatFromDir(vec3(veh:getDirectionVector()), vec3(veh:getDirectionVectorUp()))
startingInfo.vehId = veh:getID()
mission._vehicleTransforms[sObj:getId()] = {
pos = vec3(sObj:getPosition()),
rot = quat(sObj:getRotation())
if mission.setupModules.environment.windSpeed > 0 then
mission.setupModules.environment._windVec = vec3(
math.sin(mission.setupModules.environment.windDirAngle) * mission.setupModules.environment.windSpeed,
@/lua/ge/extensions/editor/vehicleEditor/api/nodeTransformer.lua
local lastPickedNodesPos = {}
local deltaPos = vec3(0,0,0)
local axisArrows = {
startPos = vec3()
}
axisArrows.startPos = vec3(editor.getAxisGizmoTransform():inverse():getColumn(3))
end
-- Delta pos in local coordinates
local pos = vec3(editor.getAxisGizmoTransform():inverse():getColumn(3))
deltaPos:set(-(pos - axisArrows.startPos))
local function transformNodes()
local axesArrowPos = vec3(0,0,0)
@/lua/ge/extensions/gameplay/markers/driftLineMarker.lua
local missionColorI = ColorI(255,255,255,255)
local tmpVec = vec3()
function C:update(data)
self.startDir = cluster.startDir
local left = vec3(self.startDir.y, -self.startDir.x, 0)
left:normalize()
@/lua/ge/extensions/ui/liveryEditor/layers/decal.lua
api.setDecalColor(Point4F(1, 1, 1, 1))
api.setDecalScale(vec3(0.5, 1, 0.5))
api.setDecalRotation(0)
@/gameplay/missionTypes/drift/constructor.lua
if not self.cachedWorldPreviewRoute then
local ret = {vec3(self.missionTypeData.startPos), vec3(self.missionTypeData.targetAreaSpherePos)}
if not self.cachedWorldPreviewRoute then
local ret = {vec3(self.missionTypeData.startPos), vec3(self.missionTypeData.targetAreaSpherePos)}
@/lua/ge/extensions/gameplay/missions/missionTypes/editorHelper.lua
elem.drawColor = displayOptions.drawColor or {1,0.25,0,0.5}
elem.defaultPos = valueOptions.defaultPos or vec3()
elem.defaultRot = valueOptions.defaultRot or quat(0,0,0,1)
elem.oneDimScale = valueOptions.oneDimScale or false
elem.defaultScl = valueOptions.defaultScl or (elem.oneDimScale and 1 or vec3(1,1,1))
if valueOptions.hasPos == nil and valueOptions.defaultPos then valueOptions.hasPos = true end
local function boolSetMission(e, mtd) if mtd[e.fieldName] == nil then e.ptr[0] = e.defaultValue else e.ptr[0] = mtd[e.fieldName] end end
local function transformSetMission(e, mtd) e.transform:set(vec3(mtd[e.fieldNamePos] or e.defaultPos), quat(mtd[e.fieldNameRot] or e.defaultRot), e.oneDimScale and (mtd[e.fieldNameScl] or e.defaultScl) or (vec3(mtd[e.fieldNameScl] or e.defaultScl))) end
local function modelConfigSetMission(e, mtd) e.mc.model = mtd[e.fieldNameModel] or e.defaultModel e.mc.config = mtd[e.fieldNameConfig] or e.defaultConfig e.mc.configPath = mtd[e.fieldNameConfigPath] or e.defaultConfigPath ui_flowgraph_editor.vehicleSelectorRefresh(e.mc) end
local function boolSetMission(e, mtd) if mtd[e.fieldName] == nil then e.ptr[0] = e.defaultValue else e.ptr[0] = mtd[e.fieldName] end end
local function transformSetMission(e, mtd) e.transform:set(vec3(mtd[e.fieldNamePos] or e.defaultPos), quat(mtd[e.fieldNameRot] or e.defaultRot), e.oneDimScale and (mtd[e.fieldNameScl] or e.defaultScl) or (vec3(mtd[e.fieldNameScl] or e.defaultScl))) end
local function modelConfigSetMission(e, mtd) e.mc.model = mtd[e.fieldNameModel] or e.defaultModel e.mc.config = mtd[e.fieldNameConfig] or e.defaultConfig e.mc.configPath = mtd[e.fieldNameConfigPath] or e.defaultConfigPath ui_flowgraph_editor.vehicleSelectorRefresh(e.mc) end
--if not e.drawMode == 'hidden' then
debugDrawer:drawTextAdvanced(vec3(e.transform.pos), String(e.label), whiteColorF, true, false, blackColorI)
--end
elseif e.drawMode == 'halfBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)/2
elseif e.drawMode == 'halfBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)/2
elseif e.drawMode == 'halfBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)/2
elseif e.drawMode == 'fullBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)
elseif e.drawMode == 'fullBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)
elseif e.drawMode == 'fullBox' then
local x, y, z = e.transform.rot * vec3(e.transform.scl.x,0,0), e.transform.rot * vec3(0,e.transform.scl.y,0), e.transform.rot * vec3(0,0,e.transform.scl.z)
local scl = (x+y+z)
self.mouseInfo.ray = getCameraMouseRay()
self.mouseInfo.rayDir = vec3(self.mouseInfo.ray.dir)
self.mouseInfo.rayCast = cameraMouseRayCast()
self.mouseInfo.hold = false
self.mouseInfo._downPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._downNormal = vec3(self.mouseInfo.rayCast.normal)
self.mouseInfo._downPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._downNormal = vec3(self.mouseInfo.rayCast.normal)
end
if self.mouseInfo.hold then
self.mouseInfo._holdPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._holdNormal = vec3(self.mouseInfo.rayCast.normal)
self.mouseInfo._holdPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._holdNormal = vec3(self.mouseInfo.rayCast.normal)
end
if self.mouseInfo.up then
self.mouseInfo._upPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._upNormal = vec3(self.mouseInfo.rayCast.normal)
self.mouseInfo._upPos = vec3(self.mouseInfo.rayCast.pos)
self.mouseInfo._upNormal = vec3(self.mouseInfo.rayCast.normal)
end
if self.mouseInfo.closestElementsHovered and self.mouseInfo.valid then
debugDrawer:drawTextAdvanced(vec3(self.mouseInfo.rayCast.pos), String("Click to Edit: " .. self.mouseInfo.closestElementsHovered.label), ColorF(1,1,1,1),true, false, ColorI(0,128,0,255))
if self.mouseInfo.down then
debugDrawer:drawSphere(e.transform.pos, radius, ColorF(e.drawColor[1], e.drawColor[2], e.drawColor[3], e.drawColor[4]))
local normal = e.transform.rot * vec3(0,1,0)
debugDrawer:drawSquarePrism(
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
debugDrawer:drawTriSolid(
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos+yn/2 ),
vec3(pos-xn/2 ),
vec3(pos+yn/2 ),
blackColor)
debugDrawer:drawTriSolid(
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos+yn/2 ),
vec3(pos+xn/2 ),
vec3(pos+yn/2 ),
blackColor)
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
local rot = e.transform.rot
local xn, yn, zn = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
if not e.switchRotation then yn = -yn end
debugDrawer:drawTriSolid(
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos-yn/2 ),
vec3(pos-xn/2 ),
vec3(pos-yn/2 ),
blackColor)
debugDrawer:drawTriSolid(
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos-xn/2 ),
vec3(pos+xn/2 ),
vec3(pos-yn/2 ),
vec3(pos+xn/2 ),
vec3(pos-yn/2 ),
blackColor)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/editor/roadSpline/layerMgr.lua
-- Module state.
local tmp1 = vec3()
tmp1:setScaled2(binormals[i], layerPositionHalfWidth * divWidths[i])
pClipped[ctr] = pClipped[ctr] or vec3()
pClipped[ctr]:setAdd2(divPoints[i], tmp1)
for i = #pClipped, 1, -1 do
pFlip[ctr] = pFlip[ctr] or vec3()
pFlip[ctr]:set(pClipped[i])
@/lua/ge/extensions/flowgraph/nodes/util/roadSegment.lua
local dirVec = vec3()
@/lua/ge/extensions/flowgraph/nodes/scene/getPointOnDecalroad.lua
end
local forward = vec3(self.roadObj:getNodePosition(prevIdx) - self.roadObj:getNodePosition(nextIdx)):normalized()
local q = quatFromDir(forward, vec3(0,0,1))
self.pinOut.rot.value = {q.x,q.y,q.z,q.w}
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/arrive.lua
end
local frontPos = linePointFromXnorm(vec3(veh:getCornerPosition(0)), vec3(veh:getCornerPosition(1)), 0.5)
local dist = (frontPos - node.pos):length()
end
local frontPos = linePointFromXnorm(vec3(veh:getCornerPosition(0)), vec3(veh:getCornerPosition(1)), 0.5)
local dist = (frontPos - node.pos):length()
@/lua/ge/extensions/gameplay/missions/missions.lua
if mission then
return vec3(mission.startTrigger.pos), quat(mission.startTrigger.rot)
end
@/lua/vehicle/extensions/tech/mesh.lua
-- pos, force, vel, mass, partOrigin
nodes[i] = nodes[i] or { vec3(), vec3(), vec3(), 0.0, "no part origin" }
nodes[i][1]:set(obj:getNodePositionRelativeXYZ(i))
-- pos, force, vel, mass, partOrigin
nodes[i] = nodes[i] or { vec3(), vec3(), vec3(), 0.0, "no part origin" }
nodes[i][1]:set(obj:getNodePositionRelativeXYZ(i))
-- pos, force, vel, mass, partOrigin
nodes[i] = nodes[i] or { vec3(), vec3(), vec3(), 0.0, "no part origin" }
nodes[i][1]:set(obj:getNodePositionRelativeXYZ(i))
@/lua/ge/extensions/flowgraph/nodes/scene/pointOnDecalroad.lua
function C:init()
self.point = vec3(0,0,0)
self.pz = 0
@/lua/ge/extensions/flowgraph/nodes/math/quaternion/lookAt.lua
local dirVec, dirVecUp = vec3(), vec3()
local rot = quat()
local dirVec, dirVecUp = vec3(), vec3()
local rot = quat()
@/lua/ge/extensions/flowgraph/nodes/util/distanceRemaining.lua
local lastDistLeft = -1
local prevPos, nextPos, dirVec = vec3(), vec3(), vec3()
local lastDistLeft = -1
local prevPos, nextPos, dirVec = vec3(), vec3(), vec3()
local lastDistLeft = -1
local prevPos, nextPos, dirVec = vec3(), vec3(), vec3()
@/lua/ge/extensions/editor/roadEditor.lua
local u_32_max_int = 4294967295
local xVector = vec3(1,0,0)
local yVector = vec3(0,1,0)
local xVector = vec3(1,0,0)
local yVector = vec3(0,1,0)
local zVector = vec3(0,0,1)
local yVector = vec3(0,1,0)
local zVector = vec3(0,0,1)
-- Params for setting width of node by dragging the mouse after creating it
local dragMouseStartPos = vec3(0,0,0)
local dragNodesStartPositions = {}
-- Params for Rectangle Selection of Nodes on Selected Roads
local rectSelectDragMouseStartPos = vec3(0,0,0)
local rectSelectDragMouseLastPos = vec3(0,0,0)
local rectSelectDragMouseStartPos = vec3(0,0,0)
local rectSelectDragMouseLastPos = vec3(0,0,0)
local isRectSelecting = false
if not editingPos then
local pos = nodePositionsAllSame and nodePosVisible or vec3(0, 0, 0)
nodePosition[0] = pos.x
for _, nodeID in ipairs(nodes) do
newPosTbl[nodeID] = vec3(nodePosition[0], nodePosition[1], nodePosition[2])
end
local function drawFrustumRect(frustum)
local topLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
if not tableIsEmpty(selectedRoadsIds) then
local addNodeRefPoint = vec3(0, 0, 0)
local numNodes = 0
if numNodes > 0 then
addTempNodeStartPos = vec3(addNodeRefPoint.x/numNodes, addNodeRefPoint.y/numNodes, addNodeRefPoint.z/numNodes)
end
local cursorPosImVec = im.GetMousePos()
local cursorPos = vec3(cursorPosImVec.x, cursorPosImVec.y, 0)
local dragLength = (dragStartPosition - cursorPos):length()
local cursorPosImVec = im.GetMousePos()
local cursorPos = vec3(cursorPosImVec.x, cursorPosImVec.y, 0)
-- Set the width of the node by dragging
local selectedRoad = scenetree.findObjectById(roadID)
setNodePosition(selectedRoad, nodeID, nodePosTbl[nodeID] + vec3(diff.x, diff.y, 0))
end
if im.IsMouseClicked(0) and not (im.IsAnyItemHovered() or im.IsWindowHovered(im.HoveredFlags_AnyWindow) or editor_inspector.comboMenuOpen) then
dragMouseStartPos = vec3(im.GetMousePos().x, im.GetMousePos().y, 0)
if not editor.keyModifiers.alt and not isRectSelectKeyCombinationActive then
local topLeft2I = editor.screenToClient(Point2I(rectSelectDragMouseStartPos.x, rectSelectDragMouseStartPos.y))
local topLeft = vec3(topLeft2I.x, topLeft2I.y, 0)
local bottomRight = (topLeft + vec3(delta.x, delta.y, 0))
local topLeft = vec3(topLeft2I.x, topLeft2I.y, 0)
local bottomRight = (topLeft + vec3(delta.x, delta.y, 0))
local rect = {topLeft = topLeft, bottomRight = bottomRight}
local viewportSizeIm = im.GetMainViewport().Size
local viewportSize = vec3(viewportSizeIm.x, viewportSizeIm.y, 0)
local viewFrustum = Engine.sceneGetCameraFrustum()
@/lua/ge/extensions/util/trackBuilder/cameraTransition.lua
local M = {}
local oldPosition = vec3(0,0,0)
local oldQuat = quatFromEuler(0,0,0)
local targetPosition = vec3(0,0,0)
local targetQuat = quatFromEuler(0,0,0)
local currentPosition = vec3(0,0,0)
local currentQuat = vec3(0,0,0)
local currentPosition = vec3(0,0,0)
local currentQuat = vec3(0,0,0)
local perc = 0
@/lua/ge/extensions/editor/gen/test.lua
local direction = vec3(core_camera.getForward())
local startPoint = vec3(core_camera.getPosition())
local direction = vec3(core_camera.getForward())
local startPoint = vec3(core_camera.getPosition())
lo('?? pretest:'..tostring(inworld)..':'..tostring(direction)..':'..tostring(startPoint)) --..':'..tostring(color(0,255,255,255).x))
if inworld then
scenetree.findObject("thePlayer"):setPosition(vec3(x, y, core_terrain.getTerrainHeight(vec3(x,y))))
if true then return end
if inworld then
scenetree.findObject("thePlayer"):setPosition(vec3(x, y, core_terrain.getTerrainHeight(vec3(x,y))))
if true then return end
if true then return end
N.circleSeed(W.ui.node_n, vec3(x, y), W.ui.node_r)
N.pathsUp()
local R = require('/lua/ge/extensions/editor/gen/region')
local p = vec3(-417.601593,64.60771179,73.03094482)
p = vec3(-103,-152,50)
local p = vec3(-417.601593,64.60771179,73.03094482)
p = vec3(-103,-152,50)
R.forRoads(p, D)
local pset = {}
local ref = vec3(0,0,0)
for i,v in pairs(am[1].verts) do
for i,v in pairs(am[1].verts) do
local ang = U.vang(vec3(1,1,0),U.proj2D(v),true)
if ang>0 and math.abs(ang-math.pi)>0.1 then
end
U.out.aset[1] = {set={vec3(0,0,0.1)}}
local id,om = M.meshUp(am, 'tst', scenetree.findObject('edit'))
local id,om = meshUp(am,'tst', groupEdit)
om:setPosition(vec3(0,0,2))
end
local aloop = {obj.aloop[1],obj.aloop[2],obj.aloop[3],obj.aloop[4],obj.aloop[5],obj.aloop[6]}
res = M.framePave(aloop, vec3(0,-1,0), obj.astep)
end
local aloop = obj.aloop -- {obj.aloop[1],obj.aloop[2],obj.aloop[3],obj.aloop[4],obj.aloop[5],obj.aloop[6]}
res = M.framePave(aloop, vec3(0,-1,0), obj.astep)
end
local aloop = obj.aloop -- {obj.aloop[1],obj.aloop[2],obj.aloop[3],obj.aloop[4],obj.aloop[5],obj.aloop[6]}
mbody,pmi,pma,aseq = M.framePave(aloop, vec3(0,-1,0), obj.astep)
end
local w = 10
-- local base = {vec3(0,0), vec3(2, 2), vec3(w, 3)}
--- modules params
local w = 10
-- local base = {vec3(0,0), vec3(2, 2), vec3(w, 3)}
--- modules params
local w = 10
-- local base = {vec3(0,0), vec3(2, 2), vec3(w, 3)}
--- modules params
end
-- base = {vec3(0,0), vec3(3, 2), vec3(7,-1), vec3(w, 3)}
local ref = base[1]
end
-- base = {vec3(0,0), vec3(3, 2), vec3(7,-1), vec3(w, 3)}
local ref = base[1]
end
-- base = {vec3(0,0), vec3(3, 2), vec3(7,-1), vec3(w, 3)}
local ref = base[1]
end
-- base = {vec3(0,0), vec3(3, 2), vec3(7,-1), vec3(w, 3)}
local ref = base[1]
local ref = base[1]
ref = vec3(0.0,0)
for i,b in pairs(base) do
d = d + (doorspace - door.w)/2
ahole[#ahole+1] = {p=vec3(d,0), w=door.w, list={
vec3(0,-0.01),vec3(door.w,-0.01),vec3(door.w,door.h),vec3(0,door.h)
ahole[#ahole+1] = {p=vec3(d,0), w=door.w, list={
vec3(0,-0.01),vec3(door.w,-0.01),vec3(door.w,door.h),vec3(0,door.h)
}}
ahole[#ahole+1] = {p=vec3(d,0), w=door.w, list={
vec3(0,-0.01),vec3(door.w,-0.01),vec3(door.w,door.h),vec3(0,door.h)
}}
ahole[#ahole+1] = {p=vec3(d,0), w=door.w, list={
vec3(0,-0.01),vec3(door.w,-0.01),vec3(door.w,door.h),vec3(0,door.h)
}}
ahole[#ahole+1] = {p=vec3(d,0), w=door.w, list={
vec3(0,-0.01),vec3(door.w,-0.01),vec3(door.w,door.h),vec3(0,door.h)
}}
d = d + (winspace - win.w)/2
ahole[#ahole+1] = {p=vec3(d,winbot), w=win.w, list={
vec3(0,0),vec3(win.w,0),vec3(win.w,win.h),vec3(0,win.h)
ahole[#ahole+1] = {p=vec3(d,winbot), w=win.w, list={
vec3(0,0),vec3(win.w,0),vec3(win.w,win.h),vec3(0,win.h)
}}
ahole[#ahole+1] = {p=vec3(d,winbot), w=win.w, list={
vec3(0,0),vec3(win.w,0),vec3(win.w,win.h),vec3(0,win.h)
}}
ahole[#ahole+1] = {p=vec3(d,winbot), w=win.w, list={
vec3(0,0),vec3(win.w,0),vec3(win.w,win.h),vec3(0,win.h)
}}
ahole[#ahole+1] = {p=vec3(d,winbot), w=win.w, list={
vec3(0,0),vec3(win.w,0),vec3(win.w,win.h),vec3(0,win.h)
}}
local mbody = M.frameSpline({vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},ahole,ap,adist,astep)
if M.valid({mbody}) then
local mbody = M.frameSpline({vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},ahole,ap,adist,astep)
if M.valid({mbody}) then
local mbody = M.frameSpline({vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},ahole,ap,adist,astep)
if M.valid({mbody}) then
local mbody = M.frameSpline({vec3(0,h),vec3(L,h),vec3(L,0),vec3(0,0)},ahole,ap,adist,astep)
if M.valid({mbody}) then
local w = 10
local s2 = 2*vec3(1,0.8)
local mbody = M.framePave({
local mbody = M.framePave({
{vec3(0, 10), vec3(w,10), vec3(w,0), vec3(0,0)},
local mbody = M.framePave({
{vec3(0, 10), vec3(w,10), vec3(w,0), vec3(0,0)},
local mbody = M.framePave({
{vec3(0, 10), vec3(w,10), vec3(w,0), vec3(0,0)},
local mbody = M.framePave({
{vec3(0, 10), vec3(w,10), vec3(w,0), vec3(0,0)},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
{vec3(1,1)-0*vec3(0,2), vec3(4,1)-0*vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1,3)+s2},
--[[
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
--[[
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
--[[
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
--[[
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
--[[
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
--[[
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
{vec3(1,1)-vec3(0,2), vec3(4,1)-vec3(0,2), vec3(4,3), vec3(1, 3)},
{vec3(1+4,1)-vec3(0,2), vec3(4+4,1)-vec3(0,2), vec3(4+4,3), vec3(1+4, 3)},
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1, 3)+s2},
]]
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1, 3)+s2},
]]
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1, 3)+s2},
]]
{vec3(1,1)+s2, vec3(4,1)+s2, vec3(4,3)+s2, vec3(1, 3)+s2},
]]
-- {vec3(6,3), vec3(8.5,3), vec3(8.5,8), vec3(6, 8)},
}, vec3(0,1), 2)
-- {vec3(6,3), vec3(8.5,3), vec3(8.5,8), vec3(6, 8)},
}, vec3(0,1), 2)
-- {vec3(6,3), vec3(8.5,3), vec3(8.5,8), vec3(6, 8)},
}, vec3(0,1), 2)
-- {vec3(6,3), vec3(8.5,3), vec3(8.5,8), vec3(6, 8)},
}, vec3(0,1), 2)
-- {vec3(6,3), vec3(8.5,3), vec3(8.5,8), vec3(6, 8)},
}, vec3(0,1), 2)
if M.valid({mbody}) then
-- lo('?? for_it:'..tostring(f:getPosition()))
f:setPosition(f:getPosition() + vec3(0,0,-1))
editor.updateForestItem(fdata, f:getKey(), f:getPosition(), f:getData(), f:getTransform(), 1, f:getUid())
local m = {
verts = {vec3(2,0,300),vec3(1,1,300),vec3(1,0,301)},
normals = {vec3(1,1,1)},
local m = {
verts = {vec3(2,0,300),vec3(1,1,300),vec3(1,0,301)},
normals = {vec3(1,1,1)},
local m = {
verts = {vec3(2,0,300),vec3(1,1,300),vec3(1,0,301)},
normals = {vec3(1,1,1)},
verts = {vec3(2,0,300),vec3(1,1,300),vec3(1,0,301)},
normals = {vec3(1,1,1)},
uvs = {{u=0, v=0},{u=1, v=0},{u=0, v=2}},
verts = nil,
normals = {vec3(1,0,0)},
uvs = {},
local afloor = deepcopy(desc.afloor)
dlod = houseUp({pos = desc.pos + vec3(0,0,0), afloor = afloor, isbox=true, basement = {yes = false}})
local dirname = editor.getLevelPath()..'bat/'
local afloor = deepcopy(desc.afloor)
dlod = houseUp({pos = desc.pos + vec3(40,0,0), afloor = afloor, isbox=true, basement = {yes = false}})
lo('?? dlod:'..dlod.id)
if false then
-- local j1 = D.junctionUp(vec3(0,-300), 4)
local aang = nil --{1.53198,1.62402,1.66811,1.51353}
local aang = nil --{1.53198,1.62402,1.66811,1.51353}
-- local j2 = D.junctionUp(vec3(-170,-310), 4, true, aang)--, {1.602,1.473,1.573,1.579})
-- local j2 = D.junctionUp(vec3(-250,-170), 3)
-- local j2 = D.junctionUp(vec3(-170,-310), 4, true, aang)--, {1.602,1.473,1.573,1.579})
-- local j2 = D.junctionUp(vec3(-250,-170), 3)
-- local j1 = D.junctionUp(vec3(220,-56), 4, false)
-- local j1 = D.junctionUp(vec3(262,-48), 4)
-- local j1 = D.junctionUp(vec3(220,-56), 4, false)
-- local j1 = D.junctionUp(vec3(262,-48), 4)
-- D.junctionRound()
-- local j2 = D.junctionUp(vec3(96,-293), 3)
aang = nil -- {1.48960,1.51685,1.57692,1.55452}
local j3 = D.junctionUp(vec3(-63,-55), 4, true, aang) --, {1.495,1.490,1.622,1.577})
-- D.junctionRound()
-- D.branchMerge(j1.list[2], j2.list[4])
-- D.setCar(vec3(-4, -186), 0)
-- D.setCar(vec3(-68, -2), 0, 1)
-- U.camSet({-231.66, -21.47, 87.26, -0.0737859, 0.110495, -0.824252, -0.550413})
-- lane left
-- D.setCar(vec3(-67, 6), 0)
-- lane right
-- lane right
-- D.setCar(vec3(-67, -5), 0)
-- D.setCar(vec3(-67, -5), 0)
-- D.setCar(vec3(-67, -5), 0)
-- D.setCar(vec3(-67, -5), 0)
-- D.setCar(vec3(-60, -97), 2)
-- D.setCar(vec3(-67, -5), 0)
-- D.setCar(vec3(-60, -97), 2)
-- D.setCar(vec3(-45, -246),0.3)
-- D.setCar(vec3(-60, -97), 2)
-- D.setCar(vec3(-45, -246),0.3)
--+ D.setCar(vec3(-4, -210), 0)
-- D.setCar(vec3(-45, -246),0.3)
--+ D.setCar(vec3(-4, -210), 0)
-- D.setCar(vec3(-4, -235), 0)
-- D.setCar(vec3(-12.7, -237), 20)
-- D.junctionUp(vec3(0,0), 4)
-- D.junctionUp(vec3(100,100), 4)
-- D.junctionUp(vec3(0,0), 4)
-- D.junctionUp(vec3(100,100), 4)
-- D.junctionUp(vec3(366,211), 4)
-- D.junctionUp(vec3(189,9), 4)
-- D.junctionUp(vec3(366,211), 4)
-- D.junctionUp(vec3(189,9), 4)
-- D.junctionUp(vec3(101,-41), 4)
-- D.junctionUp(vec3(196,110), 4)
-- D.junctionUp(vec3(101,-41), 4)
-- D.junctionUp(vec3(196,110), 4)
return
local base = {}
local pos = vec3(d.coords[1][1],d.coords[1][2],0)
for k=1,#d.coords-1 do
for k=1,#d.coords-1 do
local p = vec3(d.coords[k][1],d.coords[k][2],0) - pos
base[#base+1] = p
base = {
vec3(0,0,0),
vec3(10,0,0),
vec3(0,0,0),
vec3(10,0,0),
vec3(10,6,0),
vec3(10,0,0),
vec3(10,6,0),
vec3(0,6,0),
vec3(10,6,0),
vec3(0,6,0),
}SWWWWWWWWWWWWWWWWS
]]
pos = vec3(0,0,0)
buildingGen(pos, base)
local base = {
vec3(0,0,0),
vec3(10,0,0),
vec3(0,0,0),
vec3(10,0,0),
vec3(10,6,0),
vec3(10,0,0),
vec3(10,6,0),
vec3(0,6,0),
vec3(10,6,0),
vec3(0,6,0),
}
}
buildingGen(vec3(d.pos[1],d.pos[2],d.pos[3]), base)
end
base = {
vec3(0,0,0),
vec3(10,0,0),
vec3(0,0,0),
vec3(10,0,0),
vec3(10,5,0),
vec3(10,0,0),
vec3(10,5,0),
vec3(0,5,0),
vec3(10,5,0),
vec3(0,5,0),
}
{
vec3(3,0,0),
vec3(3,5,0),
vec3(3,0,0),
vec3(3,5,0),
-- vec3(3,0,0),
vec3(3,5,0),
-- vec3(3,0,0),
},
},
{vec3(9,0,0),vec3(9,5,0)},
{
},
{vec3(9,0,0),vec3(9,5,0)},
{
{
vec3(4,1,0),
vec3(6,1,0),
vec3(4,1,0),
vec3(6,1,0),
vec3(6,3,0),
vec3(6,1,0),
vec3(6,3,0),
vec3(4,3,0),
vec3(6,3,0),
vec3(4,3,0),
},
{
vec3(2,2,0),
vec3(3,2,0),
vec3(2,2,0),
vec3(3,2,0),
vec3(3,6,0),
vec3(3,2,0),
vec3(3,6,0),
vec3(2,6,0),
vec3(3,6,0),
vec3(2,6,0),
},
{
vec3(7,2,0),
vec3(8,2,0),
vec3(7,2,0),
vec3(8,2,0),
vec3(8,6,0),
vec3(8,2,0),
vec3(8,6,0),
vec3(7,6,0),
vec3(8,6,0),
vec3(7,6,0),
},
{
vec3(7,2,0),
vec3(8,2,0),
vec3(7,2,0),
vec3(8,2,0),
vec3(8,3,0),
vec3(8,2,0),
vec3(8,3,0),
vec3(7,3,0),
vec3(8,3,0),
vec3(7,3,0),
},
local mbody = M.forBeam({
vec3(0,0,0),
vec3(1,1,0),
vec3(0,0,0),
vec3(1,1,0),
vec3(2,0,0),
vec3(1,1,0),
vec3(2,0,0),
}, 5, true)
local base = {
vec3(0,0,3),
vec3(10,0,3),
vec3(0,0,3),
vec3(10,0,3),
vec3(10,5,3),
vec3(10,0,3),
vec3(10,5,3),
vec3(0,5,3),
vec3(10,5,3),
vec3(0,5,3),
--[[
--[[
vec3(-7.599999905,0,3.200000954),
vec3(-12,0,3.200000954),
vec3(-7.599999905,0,3.200000954),
vec3(-12,0,3.200000954),
vec3(-12,-8,3.200000954),
vec3(-12,0,3.200000954),
vec3(-12,-8,3.200000954),
vec3(-7.599999905,-8,3.200000954),
vec3(-12,-8,3.200000954),
vec3(-7.599999905,-8,3.200000954),
]]
--[[
vec3(0,0,6.4),
vec3(-6.97370631,0,6.4),
vec3(0,0,6.4),
vec3(-6.97370631,0,6.4),
vec3(-12,0,6.4),
vec3(-6.97370631,0,6.4),
vec3(-12,0,6.4),
vec3(-12,-8,6.4),
vec3(-12,0,6.4),
vec3(-12,-8,6.4),
vec3(0,-8,6.4),
vec3(-12,-8,6.4),
vec3(0,-8,6.4),
]]
}
local vhit = vec3(2,2,3)
local inrc = U.inRC(
vhit,
-- vec3(-9.009117526,-6.076205643,3.200000965),
-- vec3(-2.343889972,8.903316751,6.399999692),
-- vec3(-9.009117526,-6.076205643,3.200000965),
-- vec3(-2.343889972,8.903316751,6.399999692),
{base},nil,true)
local base = {
vec3(0,0,0),
vec3(-5.621447284,-5.548863994,0),
vec3(0,0,0),
vec3(-5.621447284,-5.548863994,0),
vec3(-12,0,0),
vec3(-5.621447284,-5.548863994,0),
vec3(-12,0,0),
vec3(-12,-8,0),
vec3(-12,0,0),
vec3(-12,-8,0),
vec3(0,-8,0),
vec3(-12,-8,0),
vec3(0,-8,0),
}
local base = {
vec3(0,0),
vec3(0,4),
vec3(0,0),
vec3(0,4),
vec3(-6,4),
vec3(0,4),
vec3(-6,4),
vec3(-6,0),
vec3(-6,4),
vec3(-6,0),
}
{
vec3(-1,1),
vec3(-1,2),
vec3(-1,1),
vec3(-1,2),
vec3(-2,2),
vec3(-1,2),
vec3(-2,2),
vec3(-2,1),
vec3(-2,2),
vec3(-2,1),
}
base = {
vec3(6,0),
vec3(6,4),
vec3(6,0),
vec3(6,4),
vec3(0,4),
vec3(6,4),
vec3(0,4),
vec3(0,0),
vec3(0,4),
vec3(0,0),
}
1 = {
1 = vec3(2.490093408,2.359999952,0),
2 = vec3(3.109906497,2.359999952,0),
1 = vec3(2.490093408,2.359999952,0),
2 = vec3(3.109906497,2.359999952,0),
3 = vec3(3.109906497,3.608793261,0),
2 = vec3(3.109906497,2.359999952,0),
3 = vec3(3.109906497,3.608793261,0),
4 = vec3(2.490093408,3.608793261,0), },
3 = vec3(3.109906497,3.608793261,0),
4 = vec3(2.490093408,3.608793261,0), },
2 = {
2 = {
1 = vec3(5.690093455,2.359999952,0),
2 = vec3(6.309906545,2.359999952,0),
1 = vec3(5.690093455,2.359999952,0),
2 = vec3(6.309906545,2.359999952,0),
3 = vec3(6.309906545,3.608793261,0),
2 = vec3(6.309906545,2.359999952,0),
3 = vec3(6.309906545,3.608793261,0),
4 = vec3(5.690093455,3.608793261,0), },
3 = vec3(6.309906545,3.608793261,0),
4 = vec3(5.690093455,3.608793261,0), },
3 = {
3 = {
1 = vec3(8.890093503,2.359999952,0),
2 = vec3(9.509906592,2.359999952,0),
1 = vec3(8.890093503,2.359999952,0),
2 = vec3(9.509906592,2.359999952,0),
3 = vec3(9.509906592,3.608793261,0),
2 = vec3(9.509906592,2.359999952,0),
3 = vec3(9.509906592,3.608793261,0),
4 = vec3(8.890093503,3.608793261,0), }, }
3 = vec3(9.509906592,3.608793261,0),
4 = vec3(8.890093503,3.608793261,0), }, }
66820.94122|I|GELua.print| ?? uppder_BASE:
66820.94123|I|GELua.print| {
1 = vec3(0,0,0),
2 = vec3(-7.599999905,0,0),
1 = vec3(0,0,0),
2 = vec3(-7.599999905,0,0),
3 = vec3(-7.599999905,-8,0),
2 = vec3(-7.599999905,0,0),
3 = vec3(-7.599999905,-8,0),
4 = vec3(0,-8,0), }
3 = vec3(-7.599999905,-8,0),
4 = vec3(0,-8,0), }
]]
vec3(0,0,0),
vec3(7.599999905,0,0),
vec3(0,0,0),
vec3(7.599999905,0,0),
vec3(7.599999905,3.2,0),
vec3(7.599999905,0,0),
vec3(7.599999905,3.2,0),
vec3(0,3.2,0),
vec3(7.599999905,3.2,0),
vec3(0,3.2,0),
--[[
vec3(0,0,0),
vec3(12,0,0),
vec3(0,0,0),
vec3(12,0,0),
vec3(12,3.2,0),
vec3(12,0,0),
vec3(12,3.2,0),
vec3(0,3.2,0),
vec3(12,3.2,0),
vec3(0,3.2,0),
vec3(0,0,0),
vec3(10,0,0),
vec3(0,0,0),
vec3(10,0,0),
vec3(10,7,0),
vec3(10,0,0),
vec3(10,7,0),
vec3(6,7,0),
vec3(10,7,0),
vec3(6,7,0),
vec3(6,5,0),
vec3(6,7,0),
vec3(6,5,0),
vec3(0,5,0),
vec3(6,5,0),
vec3(0,5,0),
]]
--vec3(10,3,0),
--vec3(0,3,0),
--vec3(10,3,0),
--vec3(0,3,0),
--[[
vec3(0,0,0),
vec3(2.96,0,0),
vec3(0,0,0),
vec3(2.96,0,0),
vec3(2.96,1.6,0),
vec3(2.96,0,0),
vec3(2.96,1.6,0),
vec3(0,1.6,0),
vec3(2.96,1.6,0),
vec3(0,1.6,0),
]]
]]
--vec3(2.96,1.600000024,0),
--vec3(0,1.600000024,0),
--vec3(2.96,1.600000024,0),
--vec3(0,1.600000024,0),
}
vec3(1.170093455,1.06,0),
vec3(1.789906545+0.1,1.06,0),
vec3(1.170093455,1.06,0),
vec3(1.789906545+0.1,1.06,0),
vec3(1.789906545+0.1,2.308793309,0),
vec3(1.789906545+0.1,1.06,0),
vec3(1.789906545+0.1,2.308793309,0),
vec3(1.170093455,2.308793309,0),
vec3(1.789906545+0.1,2.308793309,0),
vec3(1.170093455,2.308793309,0),
{
vec3(0.9400934078,1.06,0),
vec3(1.559906497,1.06,0),
vec3(0.9400934078,1.06,0),
vec3(1.559906497,1.06,0),
vec3(1.559906497,2.308793309,0),
vec3(1.559906497,1.06,0),
vec3(1.559906497,2.308793309,0),
vec3(0.9400934078,2.308793309,0), },
vec3(1.559906497,2.308793309,0),
vec3(0.9400934078,2.308793309,0), },
{
{
vec3(2.640093408,1.06,0),
vec3(3.259906497,1.06,0),
vec3(2.640093408,1.06,0),
vec3(3.259906497,1.06,0),
vec3(3.259906497,2.308793309,0),
vec3(3.259906497,1.06,0),
vec3(3.259906497,2.308793309,0),
vec3(2.640093408,2.308793309,0), },
vec3(3.259906497,2.308793309,0),
vec3(2.640093408,2.308793309,0), },
3 = {
1 = vec3(4.340093408,1.06,0),
2 = vec3(4.959906497,1.06,0),
1 = vec3(4.340093408,1.06,0),
2 = vec3(4.959906497,1.06,0),
3 = vec3(4.959906497,2.308793309,0),
2 = vec3(4.959906497,1.06,0),
3 = vec3(4.959906497,2.308793309,0),
4 = vec3(4.340093408,2.308793309,0), },
3 = vec3(4.959906497,2.308793309,0),
4 = vec3(4.340093408,2.308793309,0), },
4 = {
4 = {
1 = vec3(6.040093408,1.06,0),
2 = vec3(6.659906497,1.06,0),
1 = vec3(6.040093408,1.06,0),
2 = vec3(6.659906497,1.06,0),
3 = vec3(6.659906497,2.308793309,0),
2 = vec3(6.659906497,1.06,0),
3 = vec3(6.659906497,2.308793309,0),
4 = vec3(6.040093408,2.308793309,0), },
3 = vec3(6.659906497,2.308793309,0),
4 = vec3(6.040093408,2.308793309,0), },
6 = {
1 = vec3(5.340093432,-0.8400000477,0),
2 = vec3(5.959906521,-0.8400000477,0),
1 = vec3(5.340093432,-0.8400000477,0),
2 = vec3(5.959906521,-0.8400000477,0),
3 = vec3(5.959906521,0.4087932611,0),
2 = vec3(5.959906521,-0.8400000477,0),
3 = vec3(5.959906521,0.4087932611,0),
4 = vec3(5.340093432,0.4087932611,0), }
3 = vec3(5.959906521,0.4087932611,0),
4 = vec3(5.340093432,0.4087932611,0), }
]]
{
vec3(2.640093384,-0.8400000477,0),
vec3(3.259906474,-0.8400000477,0),
vec3(2.640093384,-0.8400000477,0),
vec3(3.259906474,-0.8400000477,0),
vec3(3.259906474,0.4087932611,0),
vec3(3.259906474,-0.8400000477,0),
vec3(3.259906474,0.4087932611,0),
vec3(2.640093384,0.4087932611,0), },
vec3(3.259906474,0.4087932611,0),
vec3(2.640093384,0.4087932611,0), },
{
vec3(2.490093408,2.359999952,0),
vec3(3.109906497,2.359999952,0),
vec3(2.490093408,2.359999952,0),
vec3(3.109906497,2.359999952,0),
vec3(3.109906497,3.608793261,0),
vec3(3.109906497,2.359999952,0),
vec3(3.109906497,3.608793261,0),
vec3(2.490093408,3.608793261,0), },
vec3(3.109906497,3.608793261,0),
vec3(2.490093408,3.608793261,0), },
{
{
vec3(5.690093455,2.359999952,0),
vec3(6.309906545,2.359999952,0),
vec3(5.690093455,2.359999952,0),
vec3(6.309906545,2.359999952,0),
vec3(6.309906545,3.608793261,0),
vec3(6.309906545,2.359999952,0),
vec3(6.309906545,3.608793261,0),
vec3(5.690093455,3.608793261,0), },
vec3(6.309906545,3.608793261,0),
vec3(5.690093455,3.608793261,0), },
{
{
vec3(8.890093503,2.359999952,0),
vec3(9.509906592,2.359999952,0),
vec3(8.890093503,2.359999952,0),
vec3(9.509906592,2.359999952,0),
vec3(9.509906592,3.608793261,0),
vec3(9.509906592,2.359999952,0),
vec3(9.509906592,3.608793261,0),
vec3(8.890093503,3.608793261,0), }
vec3(9.509906592,3.608793261,0),
vec3(8.890093503,3.608793261,0), }
{
vec3(0.9400934078,1.06,0),
vec3(1.559906497,1.06,0),
vec3(0.9400934078,1.06,0),
vec3(1.559906497,1.06,0),
vec3(1.559906497,2.308793309,0),
vec3(1.559906497,1.06,0),
vec3(1.559906497,2.308793309,0),
vec3(0.9400934078,2.308793309,0), },
vec3(1.559906497,2.308793309,0),
vec3(0.9400934078,2.308793309,0), },
{
{
vec3(2.640093408,1.06,0),
vec3(3.259906497,1.06,0),
vec3(2.640093408,1.06,0),
vec3(3.259906497,1.06,0),
vec3(3.259906497,2.308793309,0),
vec3(3.259906497,1.06,0),
vec3(3.259906497,2.308793309,0),
vec3(2.640093408,2.308793309,0), },
vec3(3.259906497,2.308793309,0),
vec3(2.640093408,2.308793309,0), },
{
{
vec3(4.340093408,1.06,0),
vec3(4.959906497,1.06,0),
vec3(4.340093408,1.06,0),
vec3(4.959906497,1.06,0),
vec3(4.959906497,2.308793309,0),
vec3(4.959906497,1.06,0),
vec3(4.959906497,2.308793309,0),
vec3(4.340093408,2.308793309,0), },
vec3(4.959906497,2.308793309,0),
vec3(4.340093408,2.308793309,0), },
{
{
vec3(6.040093408,1.06,0),
vec3(6.659906497,1.06,0),
vec3(6.040093408,1.06,0),
vec3(6.659906497,1.06,0),
vec3(6.659906497,2.308793309,0),
vec3(6.659906497,1.06,0),
vec3(6.659906497,2.308793309,0),
vec3(6.040093408,2.308793309,0), },
vec3(6.659906497,2.308793309,0),
vec3(6.040093408,2.308793309,0), },
{
vec3(1.440093455,-0.7399999046,0),
vec3(2.059906545,-0.7399999046,0),
vec3(1.440093455,-0.7399999046,0),
vec3(2.059906545,-0.7399999046,0),
vec3(2.059906545,0.5087934041,0),
vec3(2.059906545,-0.7399999046,0),
vec3(2.059906545,0.5087934041,0),
vec3(1.440093455,0.5087934041,0), },
vec3(2.059906545,0.5087934041,0),
vec3(1.440093455,0.5087934041,0), },
{
{
vec3(4.840093455,-0.7399999046,0),
vec3(5.459906545,-0.7399999046,0),
vec3(4.840093455,-0.7399999046,0),
vec3(5.459906545,-0.7399999046,0),
vec3(5.459906545,0.5087934041,0),
vec3(5.459906545,-0.7399999046,0),
vec3(5.459906545,0.5087934041,0),
vec3(4.840093455,0.5087934041,0), },
vec3(5.459906545,0.5087934041,0),
vec3(4.840093455,0.5087934041,0), },
{
{
vec3(6.540093455,-0.7399999046,0),
vec3(7.159906545,-0.7399999046,0),
vec3(6.540093455,-0.7399999046,0),
vec3(7.159906545,-0.7399999046,0),
vec3(7.159906545,0.5087934041,0),
vec3(7.159906545,-0.7399999046,0),
vec3(7.159906545,0.5087934041,0),
vec3(6.540093455,0.5087934041,0), },
vec3(7.159906545,0.5087934041,0),
vec3(6.540093455,0.5087934041,0), },
]]
{
vec3(1.2700944,0.2,0),
vec3(2,0.2,0),
vec3(1.2700944,0.2,0),
vec3(2,0.2,0),
vec3(2,1.,0),
vec3(2,0.2,0),
vec3(2,1.,0),
vec3(1.2700944,1.,0),
vec3(2,1.,0),
vec3(1.2700944,1.,0),
}
--[[
vec3(1.2700944,1.07,0),
vec3(2,1.07,0),
vec3(1.2700944,1.07,0),
vec3(2,1.07,0),
vec3(2,1.8,0),
vec3(2,1.07,0),
vec3(2,1.8,0),
vec3(1.2700944,1.8,0),
vec3(2,1.8,0),
vec3(1.2700944,1.8,0),
--vec3(2,2.308793309,0),
vec3(1.2700944,1.8,0),
--vec3(2,2.308793309,0),
--vec3(1.1700944,2.308793309,0),
--vec3(2,2.308793309,0),
--vec3(1.1700944,2.308793309,0),
},{
},{
vec3(2.2700944,1.07,0),
vec3(2.6,1.07,0),
vec3(2.2700944,1.07,0),
vec3(2.6,1.07,0),
vec3(2.6,1.8,0),
vec3(2.6,1.07,0),
vec3(2.6,1.8,0),
vec3(2.2700944,1.8,0),
vec3(2.6,1.8,0),
vec3(2.2700944,1.8,0),
]]
local base = {
vec3(0,0,0),
vec3(20,0,0),
vec3(0,0,0),
vec3(20,0,0),
vec3(20,10,0),
vec3(20,0,0),
vec3(20,10,0),
vec3(0,10,0),
vec3(20,10,0),
vec3(0,10,0),
}
{
vec3(12,6),vec3(16,6),vec3(16,12),vec3(12,12)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
{
vec3(12,6),vec3(16,6),vec3(16,12),vec3(12,12)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
{
vec3(12,6),vec3(16,6),vec3(16,12),vec3(12,12)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
{
vec3(12,6),vec3(16,6),vec3(16,12),vec3(12,12)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
vec3(12,6),vec3(16,6),vec3(16,12),vec3(12,12)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
-- vec3(12,1),vec3(16,1),vec3(16,4),vec3(12,4)
vec3(12,6),vec3(16,6),vec3(16,12),vec3(12,12)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
-- vec3(12,1),vec3(16,1),vec3(16,4),vec3(12,4)
vec3(12,6),vec3(16,6),vec3(16,12),vec3(12,12)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
-- vec3(12,1),vec3(16,1),vec3(16,4),vec3(12,4)
vec3(12,6),vec3(16,6),vec3(16,12),vec3(12,12)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
-- vec3(12,1),vec3(16,1),vec3(16,4),vec3(12,4)
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
-- vec3(12,1),vec3(16,1),vec3(16,4),vec3(12,4)
},
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
-- vec3(12,1),vec3(16,1),vec3(16,4),vec3(12,4)
},
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
-- vec3(12,1),vec3(16,1),vec3(16,4),vec3(12,4)
},
-- vec3(12,-1),vec3(16,-1),vec3(16,4),vec3(12,4)
-- vec3(12,1),vec3(16,1),vec3(16,4),vec3(12,4)
},
},
-- {vec3(2,-2),vec3(4,-2),vec3(4,5),vec3(2,5)},
}
},
-- {vec3(2,-2),vec3(4,-2),vec3(4,5),vec3(2,5)},
}
},
-- {vec3(2,-2),vec3(4,-2),vec3(4,5),vec3(2,5)},
}
},
-- {vec3(2,-2),vec3(4,-2),vec3(4,5),vec3(2,5)},
}
local base = {
vec3(-4.050905868,1.554117993,6.4),
vec3(-11.62231497,4.458866583,6.4),
vec3(-4.050905868,1.554117993,6.4),
vec3(-11.62231497,4.458866583,6.4),
vec3(-12,-8,6.4),
vec3(-11.62231497,4.458866583,6.4),
vec3(-12,-8,6.4),
vec3(-7.716314831,-8,6.4),
vec3(-12,-8,6.4),
vec3(-7.716314831,-8,6.4),
}
}
local i = U.inRC(vec3(-7.651718787,0.1104451204,6.400000774), {base})
lo('?? if_inrc:'..tostring(i))
out.apath = {base}
out.avedit = {vec3(-7.651718787,0.1104451204,6.400000774+0.1)}
return
local base = {
vec3(0,0,0),
vec3(-6.783516056,0,0),
vec3(0,0,0),
vec3(-6.783516056,0,0),
vec3(-6.783516056,3.400000095,0),
vec3(-6.783516056,0,0),
vec3(-6.783516056,3.400000095,0),
vec3(-11.6042462,3.400000095,0),
vec3(-6.783516056,3.400000095,0),
vec3(-11.6042462,3.400000095,0),
vec3(-11.6042462,0,0),
vec3(-11.6042462,3.400000095,0),
vec3(-11.6042462,0,0),
vec3(-15,0,0),
vec3(-11.6042462,0,0),
vec3(-15,0,0),
vec3(-15,-10,0),
vec3(-15,0,0),
vec3(-15,-10,0),
vec3(-10,-10,0),
vec3(-15,-10,0),
vec3(-10,-10,0),
vec3(-10,-5,0),
vec3(-10,-10,0),
vec3(-10,-5,0),
vec3(-8.057351058,-5,0),
vec3(-10,-5,0),
vec3(-8.057351058,-5,0),
vec3(-8.057351058,-7.400000036,0),
vec3(-8.057351058,-5,0),
vec3(-8.057351058,-7.400000036,0),
vec3(-5,-7.400000036,0),
vec3(-8.057351058,-7.400000036,0),
vec3(-5,-7.400000036,0),
vec3(-5,-10,0),
vec3(-5,-7.400000036,0),
vec3(-5,-10,0),
vec3(0,-10,0),
vec3(-5,-10,0),
vec3(0,-10,0),
--[[
--[[
vec3(-8.681075329,10.57470741,0),
vec3(-11.99435381,-4.749814454,0),
vec3(-8.681075329,10.57470741,0),
vec3(-11.99435381,-4.749814454,0),
vec3(-16.00175891,-3.883382914,0),
vec3(-11.99435381,-4.749814454,0),
vec3(-16.00175891,-3.883382914,0),
vec3(-17.45997995,-10.62792321,0),
vec3(-16.00175891,-3.883382914,0),
vec3(-17.45997995,-10.62792321,0),
vec3(-13.45257486,-11.49435475,0),
vec3(-17.45997995,-10.62792321,0),
vec3(-13.45257486,-11.49435475,0),
vec3(-15.02081845,-18.74776959,0),
vec3(-13.45257486,-11.49435475,0),
vec3(-15.02081845,-18.74776959,0),
vec3(-5.246659455,-20.8610173,0),
vec3(-15.02081845,-18.74776959,0),
vec3(-5.246659455,-20.8610173,0),
vec3(-3.133411747,-11.0868583,0),
vec3(-5.246659455,-20.8610173,0),
vec3(-3.133411747,-11.0868583,0),
vec3(-8.020491246,-10.03023445,0),
vec3(-3.133411747,-11.0868583,0),
vec3(-8.020491246,-10.03023445,0),
vec3(-7.387644178,-7.103200456,0),
vec3(-8.020491246,-10.03023445,0),
vec3(-7.387644178,-7.103200456,0),
vec3(-3.575722075,-7.927367083,0),
vec3(-7.387644178,-7.103200456,0),
vec3(-3.575722075,-7.927367083,0),
vec3(-2.84092402,-4.528791044,0),
vec3(-3.575722075,-7.927367083,0),
vec3(-2.84092402,-4.528791044,0),
vec3(-6.652846122,-3.704624417,0),
vec3(-2.84092402,-4.528791044,0),
vec3(-6.652846122,-3.704624417,0),
vec3(-5.907243538,-0.2560754472,0),
vec3(-6.652846122,-3.704624417,0),
vec3(-5.907243538,-0.2560754472,0),
vec3(-1.020164039,-1.312699301,0),
vec3(-5.907243538,-0.2560754472,0),
vec3(-1.020164039,-1.312699301,0),
vec3(1.09308367,8.461459697,0),
vec3(-1.020164039,-1.312699301,0),
vec3(1.09308367,8.461459697,0),
]]
--[[
vec3(-0.08119462677,0.1191920268,0),
vec3(-12.07879471,-0.1207919735,0),
vec3(-0.08119462677,0.1191920268,0),
vec3(-12.07879471,-0.1207919735,0),
vec3(-11.91880537,-8.119192027,0),
vec3(-12.07879471,-0.1207919735,0),
vec3(-11.91880537,-8.119192027,0),
vec3(-6.281633979,-8.006433564,0),
vec3(-11.91880537,-8.119192027,0),
vec3(-6.281633979,-8.006433564,0),
vec3(0.07879470677,-7.879208027,0),
vec3(-6.281633979,-8.006433564,0),
vec3(0.07879470677,-7.879208027,0),
]]
vec3(0.2189276122,0.6524122081,0),
vec3(-12.57083375,0.1405487305,0),
vec3(0.2189276122,0.6524122081,0),
vec3(-12.57083375,0.1405487305,0),
vec3(-12.21892761,-8.652412208,0),
vec3(-12.57083375,0.1405487305,0),
vec3(-12.21892761,-8.652412208,0),
vec3(-6.185458591,-8.410944651,0),
vec3(-12.21892761,-8.652412208,0),
vec3(-6.185458591,-8.410944651,0),
vec3(0.5708337531,-8.140548731,0),
vec3(-6.185458591,-8.410944651,0),
vec3(0.5708337531,-8.140548731,0),
}
local base = {
vec3(0,0,0),
vec3(-4.597041148,1.489263353,0),
vec3(0,0,0),
vec3(-4.597041148,1.489263353,0),
vec3(-9.569547253,0,0),
vec3(-4.597041148,1.489263353,0),
vec3(-9.569547253,0,0),
vec3(-15,0,0),
vec3(-9.569547253,0,0),
vec3(-15,0,0),
vec3(-15,-8,0),
vec3(-15,0,0),
vec3(-15,-8,0),
vec3(0,-8,0), }
vec3(-15,-8,0),
vec3(0,-8,0), }
local arc = coverUp(base)
-- generate base with parallels
local cv = vec3(1+math.random(0.5), 1+0.5*math.random())
local pa = {vec3(0,0,0)}
local cv = vec3(1+math.random(0.5), 1+0.5*math.random())
local pa = {vec3(0,0,0)}
local pb = {pa[1]+cv}
local base = {
vec3(0,0,0),
vec3(0,3,0),
vec3(0,0,0),
vec3(0,3,0),
vec3(4,3,0),
vec3(0,3,0),
vec3(4,3,0),
vec3(4,5,0),
vec3(4,3,0),
vec3(4,5,0),
vec3(-3,5,0),
vec3(4,5,0),
vec3(-3,5,0),
vec3(-3,0,0),
vec3(-3,5,0),
vec3(-3,0,0),
--[[
--[[
vec3(0,0,0),
vec3(0,3,0),
vec3(0,0,0),
vec3(0,3,0),
vec3(4,3,0),
vec3(0,3,0),
vec3(4,3,0),
vec3(4,5,0),
vec3(4,3,0),
vec3(4,5,0),
vec3(-3,5,0),
vec3(4,5,0),
vec3(-3,5,0),
vec3(-3,0,0),
vec3(-3,5,0),
vec3(-3,0,0),
vec3(0,0,0),
vec3(0,3,0),
vec3(0,0,0),
vec3(0,3,0),
vec3(4,3,0),
vec3(0,3,0),
vec3(4,3,0),
vec3(4,0,0),
vec3(4,3,0),
vec3(4,0,0),
vec3(0,0,0),
vec3(-12,0,0),
vec3(0,0,0),
vec3(-12,0,0),
vec3(-12,-8,0),
vec3(-12,0,0),
vec3(-12,-8,0),
vec3(0,-8,0),
vec3(-12,-8,0),
vec3(0,-8,0),
]]
}
base = {vec3(0,0,0)}
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
base = {vec3(0,0,0)}
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
base = {vec3(0,0,0)}
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
base[#base+1] = base[#base] + 3*vx
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
local vx,vy = vec3(-5,0,0), vec3(0,-5,0)
base[#base+1] = base[#base] + 3*vx
base = {
vec3(0,0,0),
vec3(-15,0,0),
vec3(0,0,0),
vec3(-15,0,0),
vec3(-15,-10,0),
vec3(-15,0,0),
vec3(-15,-10,0),
vec3(-10,-10,0),
vec3(-15,-10,0),
vec3(-10,-10,0),
vec3(-10,-5,0),
vec3(-10,-10,0),
vec3(-10,-5,0),
vec3(-5,-5,0),
vec3(-10,-5,0),
vec3(-5,-5,0),
vec3(-4,-10,0),
vec3(-5,-5,0),
vec3(-4,-10,0),
vec3(1,-10,0),
vec3(-4,-10,0),
vec3(1,-10,0),
}
base = {vec3(0,0,0)}
for i=0,4 do
for j=1,#d.av do
-- d[1][j] = d[1][j] + vec3(0,0,1)
end
for j=2,#d[1],3 do
-- d[1][j] = d[1][j] + vec3(0,0,1)
end
R.sceneUp(6, nil, groupEdit) --, dmat.wall)
R.move(vec3(0,0.2,3.5))
-- R.voice2job('pick 2 black')
-- R.partPut({{2,1},{3,1}})
-- R.target(vec3(0,2,2))
out.R = R
local base = {
vec3(0,0,0),
vec3(0,0,1.5),
vec3(0,0,0),
vec3(0,0,1.5),
vec3(0,-5,1.5),
vec3(0,0,1.5),
vec3(0,-5,1.5),
vec3(0,-5,0),
vec3(0,-5,1.5),
vec3(0,-5,0),
}
local base = {
vec3(0,0,0),
vec3(0,0,1.5),
vec3(0,0,0),
vec3(0,0,1.5),
vec3(3,0,3),
vec3(0,0,4),
vec3(0,-5,4),
vec3(0,0,4),
vec3(0,-5,4),
vec3(0,-5,3),
vec3(0,-5,1.5),
vec3(0,-5,0),
vec3(0,-5,1.5),
vec3(0,-5,0),
-- vec3(0,-5,0),
vec3(0,-5,0),
-- vec3(0,-5,0),
}
local base = {
vec3(0,0,0),
vec3(1,0,0),
vec3(0,0,0),
vec3(1,0,0),
vec3(1,2,0),
vec3(1,0,0),
vec3(1,2,0),
vec3(3,4,0),
vec3(1,2,0),
vec3(3,4,0),
vec3(5,4,0),
vec3(5,6,0),
vec3(5,4,0),
vec3(5,6,0),
vec3(3,5,0),
vec3(0,3,0),
vec3(3,5,0),
vec3(0,3,0),
}
base = {
vec3(-0.3531624084,3.842578263,0),
vec3(1.427315953,2.237151887,0),
vec3(-0.3531624084,3.842578263,0),
vec3(1.427315953,2.237151887,0),
vec3(3.139744128,3.6,0)
vec3(1.427315953,2.237151887,0),
vec3(3.139744128,3.6,0)
}
base = {
vec3(0,0,0),
vec3(1,0,0),
vec3(0,0,0),
vec3(1,0,0),
-- vec3(1.5,0,0),
vec3(1,0,0),
-- vec3(1.5,0,0),
vec3(1,2,0),
-- vec3(1.5,0,0),
vec3(1,2,0),
vec3(3,4,0),
vec3(1,2,0),
vec3(3,4,0),
vec3(8,4,0),
vec3(8,7,0),
vec3(8,4,0),
vec3(8,7,0),
vec3(3,6,0),
vec3(0,3,0),
vec3(3,6,0),
vec3(0,3,0),
}
base = {
vec3(0, 0, 0),
-- vec3(-5, 0.5, 0),
vec3(0, 0, 0),
-- vec3(-5, 0.5, 0),
vec3(-12, 0, 0),
-- vec3(-5, 0.5, 0),
vec3(-12, 0, 0),
vec3(-12, -8, 0),
vec3(-12, 0, 0),
vec3(-12, -8, 0),
vec3(0, -8, 0),
vec3(-12, -8, 0),
vec3(0, -8, 0),
}
base = {
vec3(0,0,0),
vec3(2,0,0),
vec3(0,0,0),
vec3(2,0,0),
vec3(2,3,0),
vec3(2,0,0),
vec3(2,3,0),
vec3(4,3,0),
vec3(2,3,0),
vec3(4,3,0),
vec3(4,0,0),
vec3(4,3,0),
vec3(4,0,0),
vec3(6,0,0),
vec3(4,0,0),
vec3(6,0,0),
vec3(6,5,0),
vec3(6,0,0),
vec3(6,5,0),
vec3(0,5,0),
vec3(6,5,0),
vec3(0,5,0),
}
-- T.forRidge(nil, base)
-- buildingGen(vec3(-266,1144,0), base, true)
-- if true then return end
base = sbase
-- buildingGen(vec3(-266,1144,0), base, true)
if true then return end
local u = (base[2]-base[1]):normalized()
local v = vec3(-u.y, u.x, 0)
local ref = base[1]
out.m1,out.m2,out.fwhite,out.fyell,out.flbl = M.rcPave({
vec3(0,0,0), vec3(10,0,0), vec3(10,10,0), vec3(0,10,0)
--[[
out.m1,out.m2,out.fwhite,out.fyell,out.flbl = M.rcPave({
vec3(0,0,0), vec3(10,0,0), vec3(10,10,0), vec3(0,10,0)
--[[
out.m1,out.m2,out.fwhite,out.fyell,out.flbl = M.rcPave({
vec3(0,0,0), vec3(10,0,0), vec3(10,10,0), vec3(0,10,0)
--[[
out.m1,out.m2,out.fwhite,out.fyell,out.flbl = M.rcPave({
vec3(0,0,0), vec3(10,0,0), vec3(10,10,0), vec3(0,10,0)
--[[
--[[
vec3(0,0,0),
vec3(12,0,0),
vec3(0,0,0),
vec3(12,0,0),
vec3(12,2.8,0),
vec3(12,0,0),
vec3(12,2.8,0),
vec3(0,2.8,0),
vec3(12,2.8,0),
vec3(0,2.8,0),
]]
--[[
{vec3(1,1,0), vec3(2,1,0), vec3(2,2,0), vec3(1,2,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
--[[
{vec3(1,1,0), vec3(2,1,0), vec3(2,2,0), vec3(1,2,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
--[[
{vec3(1,1,0), vec3(2,1,0), vec3(2,2,0), vec3(1,2,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
--[[
{vec3(1,1,0), vec3(2,1,0), vec3(2,2,0), vec3(1,2,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,1,0), vec3(2,1,0), vec3(2,2,0), vec3(1,2,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
{vec3(1,1,0), vec3(2,1,0), vec3(2,2,0), vec3(1,2,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
{vec3(1,1,0), vec3(2,1,0), vec3(2,2,0), vec3(1,2,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
{vec3(1,1,0), vec3(2,1,0), vec3(2,2,0), vec3(1,2,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
]]
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
]]
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
]]
-- {vec3(2,3,0), vec3(3,3,0), vec3(3,4,0), vec3(2,4,0)},
{vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
]]
]]
-- {vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
]]
-- {vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
]]
-- {vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
]]
-- {vec3(1,3,0), vec3(2,3,0), vec3(2,4,0), vec3(1,4,0)},
--[[
{vec3(1,1,0), vec3(4,1,0), vec3(4,3,0), vec3(1,3,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
--[[
{vec3(1,1,0), vec3(4,1,0), vec3(4,3,0), vec3(1,3,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
--[[
{vec3(1,1,0), vec3(4,1,0), vec3(4,3,0), vec3(1,3,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
--[[
{vec3(1,1,0), vec3(4,1,0), vec3(4,3,0), vec3(1,3,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(1,1,0), vec3(4,1,0), vec3(4,3,0), vec3(1,3,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
{vec3(1,1,0), vec3(4,1,0), vec3(4,3,0), vec3(1,3,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
{vec3(1,1,0), vec3(4,1,0), vec3(4,3,0), vec3(1,3,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
{vec3(1,1,0), vec3(4,1,0), vec3(4,3,0), vec3(1,3,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
--{vec3(2.5,4,0), vec3(3.5,4,0), vec3(3.5,5,0), vec3(2.5,5,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(5,2,0), vec3(9,2,0), vec3(9,6,0), vec3(5,6,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(5,2,0), vec3(9,2,0), vec3(9,6,0), vec3(5,6,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(5,2,0), vec3(9,2,0), vec3(9,6,0), vec3(5,6,0)},
{vec3(3,4,0), vec3(4,4,0), vec3(4,5,0), vec3(3,5,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(5,2,0), vec3(9,2,0), vec3(9,6,0), vec3(5,6,0)},
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(5,2,0), vec3(9,2,0), vec3(9,6,0), vec3(5,6,0)},
]]
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(5,2,0), vec3(9,2,0), vec3(9,6,0), vec3(5,6,0)},
]]
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(5,2,0), vec3(9,2,0), vec3(9,6,0), vec3(5,6,0)},
]]
-- {vec3(3,7,0), vec3(8,7,0), vec3(8,9,0), vec3(3,9,0)},
{vec3(5,2,0), vec3(9,2,0), vec3(9,6,0), vec3(5,6,0)},
]]
{
vec3(1,1,0),
vec3(4,1,0),
vec3(1,1,0),
vec3(4,1,0),
vec3(4,2,0),
vec3(4,1,0),
vec3(4,2,0),
vec3(1,2,0),
vec3(4,2,0),
vec3(1,2,0),
},
{
vec3(3,2,0),
vec3(5,2,0),
vec3(3,2,0),
vec3(5,2,0),
vec3(5,3,0),
vec3(5,2,0),
vec3(5,3,0),
vec3(3,3,0),
vec3(5,3,0),
vec3(3,3,0),
},
{
vec3(2,0,0),
vec3(4,0,0),
vec3(2,0,0),
vec3(4,0,0),
vec3(4,3,0),
vec3(4,0,0),
vec3(4,3,0),
vec3(2,3,0),
vec3(4,3,0),
vec3(2,3,0),
},
{
vec3(2,0,0),
vec3(4,0,0),
vec3(2,0,0),
vec3(4,0,0),
vec3(4,3,0),
vec3(4,0,0),
vec3(4,3,0),
vec3(2,3,0),
vec3(4,3,0),
vec3(2,3,0),
},
{
vec3(1.440093455,1.359999952,0),
vec3(2.059906545,1.359999952,0),
vec3(1.440093455,1.359999952,0),
vec3(2.059906545,1.359999952,0),
vec3(2.059906545,2.608793261,0),
vec3(2.059906545,1.359999952,0),
vec3(2.059906545,2.608793261,0),
vec3(1.440093455,2.608793261,0), },
vec3(2.059906545,2.608793261,0),
vec3(1.440093455,2.608793261,0), },
{
{
vec3(3.140093455,1.359999952,0),
vec3(3.759906545,1.359999952,0),
vec3(3.140093455,1.359999952,0),
vec3(3.759906545,1.359999952,0),
vec3(3.759906545,2.608793261,0),
vec3(3.759906545,1.359999952,0),
vec3(3.759906545,2.608793261,0),
vec3(3.140093455,2.608793261,0), },
vec3(3.759906545,2.608793261,0),
vec3(3.140093455,2.608793261,0), },
{
{
vec3(4.840093455,1.359999952,0),
vec3(5.459906545,1.359999952,0),
vec3(4.840093455,1.359999952,0),
vec3(5.459906545,1.359999952,0),
vec3(5.459906545,2.608793261,0),
vec3(5.459906545,1.359999952,0),
vec3(5.459906545,2.608793261,0),
vec3(4.840093455,2.608793261,0), }
vec3(5.459906545,2.608793261,0),
vec3(4.840093455,2.608793261,0), }
]]
for _,e in pairs(out.fwhite) do
e[1] = e[1] + vec3(-265,1148,1)
e[2] = e[2] + vec3(-265,1148,1)
e[1] = e[1] + vec3(-265,1148,1)
e[2] = e[2] + vec3(-265,1148,1)
end
for i,n in pairs(e) do
e[i] = e[i] + vec3(-265,1148,1)
end
end
-- e[1] = e[1] + vec3(-265,1148,1)
-- e[2] = e[2] + vec3(-265,1148,1)
-- e[1] = e[1] + vec3(-265,1148,1)
-- e[2] = e[2] + vec3(-265,1148,1)
end
for _,e in pairs(out.flbl) do
e[1] = e[1] + vec3(-265,1148,1)
end
-- U.dump(out.fwhite[1], '?? fwhite:'..#out.fwhite)
-- out.avedit = {vec3(-265,1148,1)}
local pth = {
{pos=vec3(0,0,0), width=3},
{pos=vec3(20,20,0), width=3},
{pos=vec3(0,0,0), width=3},
{pos=vec3(20,20,0), width=3},
{pos=vec3(50,60,0), width=4},
{pos=vec3(20,20,0), width=3},
{pos=vec3(50,60,0), width=4},
{pos=vec3(100,100,0), width=3},
{pos=vec3(50,60,0), width=4},
{pos=vec3(100,100,0), width=3},
}
for i=1,#pth do
pth[i].pos = pth[i].pos + vec3(-250,1146,0)
end
for i = 1,#av do
av[i] = av[i] + p + vec3(0,0,5)
end
@/lua/ge/extensions/gameplay/rally/snaproad/geoPacenotes.lua
-- -- Use 2D projections for circle calculation (ignore Z)
-- local p1z = vec3(p1.x, p1.y, 0)
-- local p2z = vec3(p2.x, p2.y, 0)
-- local p1z = vec3(p1.x, p1.y, 0)
-- local p2z = vec3(p2.x, p2.y, 0)
-- local p3z = vec3(p3.x, p3.y, 0)
-- local p2z = vec3(p2.x, p2.y, 0)
-- local p3z = vec3(p3.x, p3.y, 0)
-- local centerZ = (p1.z + p2.z + p3.z) / 3
-- local center = vec3(center2d.x, center2d.y, centerZ)
-- log('D', logTag, 'using halfpoint')
middlePos = vec3(pn.halfpoint.pos)
else
-- Calculate geometric middle point between start and end
middlePos = vec3(
(startPos.x + endPos.x) / 2,
for _, point in ipairs(focusPoints) do
local dist = middlePos:distance(vec3(point.pos))
if dist < closestDist then
if closestPoint then
middlePos = vec3(closestPoint.pos)
end
local midZ = startPos.z + midProgress * (endPos.z - startPos.z)
local midPoint = vec3(
center.x + horizontalRadius * math.cos(midAngle),
-- local pos1 = vec3(
-- center.x + horizontalRadius * math.cos(angle1),
-- )
-- local pos2 = vec3(
-- center.x + horizontalRadius * math.cos(angle2),
local pos1 = vec3(
center.x + horizontalRadius * math.cos(angle1),
)
local pos2 = vec3(
center.x + horizontalRadius * math.cos(angle2),
debugDrawer:drawTextAdvanced(
vec3(midPoint.x, midPoint.y, midPoint.z),
arcLengthText,
-- local radiusText = string.format("Diameter: %.0fm", diameter)
-- local textPos = vec3(center.x, center.y, center.z)
local startPos = vec3(pn:getCornerStartWaypoint().pos)
local endPos = vec3(pn:getCornerEndWaypoint().pos)
local startPos = vec3(pn:getCornerStartWaypoint().pos)
local endPos = vec3(pn:getCornerEndWaypoint().pos)
for i = 1, totalPoints do
local dist = startPos:distance(vec3(focusPoints[i].pos))
if dist < minDistCS then
for i = 1, totalPoints do
local dist = endPos:distance(vec3(focusPoints[i].pos))
if dist < minDistCE then
for i = closestToCS, closestToCE do
local pt = vec3(focusPoints[i].pos)
table.insert(pathPoints, pt)
splitIdx = math.max(2, math.min(#pathPoints - 1, splitIdx))
local splitPoint = vec3(pathPoints[splitIdx])
local segment1MidPathIdx = math.max(2, math.min(splitIdx - 1, math.floor((1 + splitIdx) / 2)))
local segment1Mid = vec3(pathPoints[segment1MidPathIdx])
local segment2MidPathIdx = math.max(splitIdx + 1, math.min(#pathPoints - 1, math.floor((splitIdx + #pathPoints) / 2)))
local segment2Mid = vec3(pathPoints[segment2MidPathIdx])
if pn.halfpoint then
middlePos = vec3(pn.halfpoint.pos)
else
for i = 1, totalPoints do
local dist = startPos:distance(vec3(focusPoints[i].pos))
if dist < minDistCS then
for i = 1, totalPoints do
local dist = endPos:distance(vec3(focusPoints[i].pos))
if dist < minDistCE then
for i = closestToCS, closestToCE do
local pt = vec3(focusPoints[i].pos)
table.insert(pathPoints, pt)
@/lua/ge/extensions/gameplay/rally/notebook/pacenoteGenerator.lua
table.insert(route, {
pos = vec3(pos),
id = i
@/lua/ge/extensions/tech/techCore.lua
pos = vec3(pos)
rot = quat(rot):toTorqueQuat()
proc:setField('rotation', 0, rot.x .. ' ' .. rot.y .. ' ' .. rot.z .. ' ' .. rot.w)
proc.scale = vec3(1, 1, 1)
if annotation ~= nil then
local function tableToVec3(point, cling, offset)
local point = vec3(point[1], point[2], point[3])
if cling then
local z = techUtils.getSurfaceHeight(point)
point = vec3(point.x, point.y, z+offset)
end
else
sobj:setPosition(vec3(request['pos'][1], request['pos'][2], request['pos'][3]))
-- sobj:setPosition(Point3F(request['pos'][1], request['pos'][2], request['pos'][3]))
if not replace then
pos = vec3(pos[1], pos[2], pos[3])
rot = quat(rot)
args.nearFarPlanes = request['nearFarPlanes']
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.colourShmemHandle = request['colourShmemName']
M.handleCameraWorldPointToPixel = function(request)
local point = vec3(request['pointX'], request['pointY'], request['pointZ'])
local pixel = extensions.tech_sensors.convertWorldPointToPixel(sensors[stype.tCamera][request['name']], point)
M.handleSetCameraSensorPosition = function(request)
extensions.tech_sensors.setCameraSensorPosition(sensors[stype.tCamera][request['name']], vec3(request['posX'], request['posY'], request['posZ']))
request:sendACK('CompletedSetCameraSensorPosition')
M.handleSetCameraSensorDirection = function(request)
extensions.tech_sensors.setCameraSensorDirection(sensors[stype.tCamera][request['name']], vec3(request['dirX'], request['dirY'], request['dirZ']))
request:sendACK('CompletedSetCameraSensorDirection')
args.updatePriority = request['priority']
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.verticalResolution = request['vRes']
args.fixedWindowSize = request['fixed_window_size']
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.isVisualised = request['isVisualised']
args.rangeDirectMaxCutoff = request['range_direct_max_cutoff']
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.rangeBins = request['range_bins']
args.physicsUpdateTime = request['physicsUpdateTime']
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.dir = vec3(request['dir'][1], request['dir'][2], request['dir'][3])
args.up = vec3(request['up'][1], request['up'][2], request['up'][3])
args.smootherStrength = request["smootherStrength"]
args.physicsUpdateTime = request['physicsUpdateTime']
args.pos = vec3(request['pos'][1], request['pos'][2], request['pos'][3])
args.refLon = request['refLon']
local direction = request['dir']
local rot = quatFromDir(vec3(direction[1], direction[2], direction[3]))
local name = request['name']
local size = vec3(request['size'])
local material = request['material']
local func = function()
core_camera.setOffset(vid, vec3(pos[1], pos[2], pos[3]))
local up = request['up']
local vDir, vUp = vec3(dir[1], dir[2], dir[3]), vec3(up[1], up[2], -up[3])
local rot = quatFromDir(vDir, vUp):toEulerYXZ() * 57.29578 -- rad to deg.
local up = request['up']
local vDir, vUp = vec3(dir[1], dir[2], dir[3]), vec3(up[1], up[2], -up[3])
local rot = quatFromDir(vDir, vUp):toEulerYXZ() * 57.29578 -- rad to deg.
if k == 'rotation' then
local rotation = vec3(v[1], v[2], v[3])
core_camera.setRotation(id, rotation)
if k == 'offset' then
local offset = vec3(v[1], v[2], v[3])
core_camera.setOffset(id, offset)
local right = fwd:cross(up)
return vec3(fwd:dot(dirLoc), right:dot(dirLoc), up:dot(dirLoc)), vec3(fwd:dot(upLoc), right:dot(upLoc), up:dot(upLoc))
end
local right = fwd:cross(up)
return vec3(fwd:dot(dirLoc), right:dot(dirLoc), up:dot(dirLoc)), vec3(fwd:dot(upLoc), right:dot(upLoc), up:dot(upLoc))
end
@/lua/ge/extensions/flowgraph/nodes/gameplay/decalPath.lua
texture = "art/shapes/arrows/arrow_groundmarkers_1.png",
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
color = ColorF(unpack(self.pinIn.decalColor.value or defaultDecalColor)),
color = ColorF(unpack(self.pinIn.decalColor.value or defaultDecalColor)),
scale = vec3(8, 12, 4),
fadeStart = 400,
local route = require('/lua/ge/extensions/gameplay/route/route')()
local fwd = vec3()
local t, data, a, b
function C:work()
route:setupPathMulti({vec3(self.pinIn.posA.value), vec3(self.pinIn.posB.value)})
local path = route.path
function C:work()
route:setupPathMulti({vec3(self.pinIn.posA.value), vec3(self.pinIn.posB.value)})
local path = route.path
@/lua/vehicle/extensions/scenario/annotate.lua
local function onDebugDraw(focusPos)
local p1 = obj:getPosition() + vec3(0, 0, 2)
obj.debugDrawProxy:drawText(p1, color(0,0,0,255), data.text)
@/lua/ge/extensions/editor/crawlEditor/missionPortTool.lua
for i, vertexPos in ipairs(zone.vertices) do
local pos = vec3(vertexPos[1], vertexPos[2], vertexPos[3])
boundary:addVertex(pos)
active = zone.top.active or false,
pos = vec3(zone.top.pos[1], zone.top.pos[2], zone.top.pos[3]),
normal = vec3(zone.top.normal[1], zone.top.normal[2], zone.top.normal[3])
pos = vec3(zone.top.pos[1], zone.top.pos[2], zone.top.pos[3]),
normal = vec3(zone.top.normal[1], zone.top.normal[2], zone.top.normal[3])
}
active = false,
pos = vec3(0, 0, 10),
normal = vec3(0, 0, 1)
pos = vec3(0, 0, 10),
normal = vec3(0, 0, 1)
}
active = zone.bot.active or false,
pos = vec3(zone.bot.pos[1], zone.bot.pos[2], zone.bot.pos[3]),
normal = vec3(zone.bot.normal[1], zone.bot.normal[2], zone.bot.normal[3])
pos = vec3(zone.bot.pos[1], zone.bot.pos[2], zone.bot.pos[3]),
normal = vec3(zone.bot.normal[1], zone.bot.normal[2], zone.bot.normal[3])
}
active = false,
pos = vec3(0, 0, -10),
normal = vec3(0, 0, -1)
pos = vec3(0, 0, -10),
normal = vec3(0, 0, -1)
}
name = pathnode.name or ("Node " .. i),
pos = vec3(pathnode.pos[1], pathnode.pos[2], pathnode.pos[3]),
radius = pathnode.radius or 6.0,
if startPosData and startPosData.pos then
local startPos = vec3(startPosData.pos[1], startPosData.pos[2], startPosData.pos[3])
if direction:length() > 0.001 then
rotation = quatFromDir(direction, vec3(0, 0, 1))
log('D', logTag, string.format("Calculated start rotation pointing to first checkpoint (distance: %.2f)", direction:length()))
},
iconPosition = vec3(startPosData.pos[1], startPosData.pos[2], startPosData.pos[3] + 2),
metadata = {
@/lua/vehicle/mapmgr.lua
local p1, p2 = vec3(), vec3()
local function surfaceNormalBelow(p, r)
local p1, p2 = vec3(), vec3()
local function surfaceNormalBelow(p, r)
local searchRadius = maxRadius * 5
local tmpVec = vec3()
local edgeVec = vec3()
local tmpVec = vec3()
local edgeVec = vec3()
@/lua/vehicle/extensions/escMeasurement.lua
local actualVelocity = (directionVector:dot(velocity) / (directionVector:length() * directionVector:length()) * directionVector):length()
local velocityVector = vec3(velocity.x, velocity.y, 0)
local dot = velocityVector:dot(directionVector)
@/lua/vehicle/bdebugImpl.lua
local groupIDToEntries, hashToGroupID, jbeamDisplayed, tblPool = {}, {}, {}, {}
local bigOffset = vec3(1e5, 1e5, 1e5)
local tempVec = vec3()
local tempVec2 = vec3()
local tempVec = vec3()
local tempVec2 = vec3()
if not wheelContacts[wheelId] then
wheelContacts[wheelId] = {totalForce = 0, contactPoint = vec3(0, 0, 0)}
end
wheelC.totalForce = wheelC.totalForce + p.normalForce
wheelC.contactPoint = wheelC.contactPoint + vec3(p.pos) * p.normalForce
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 60, 0), color(255, 165, 0, 255), "Mode: " .. modeName)
end
if i ~= TRI_BROKEN then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100 + j * 20, 0), triTypesColors[i], triTypesNames[i])
j = j + 1
for i = 1, #triTypesNames do
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100 + i * 20, 0), triTypesColors[i], triTypesNames[i])
end
if i ~= TRI_BROKEN and i ~= TRI_NONCOLLIDABLE then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100 + j * 20, 0), triTypesColors[i], triTypesNames[i])
j = j + 1
obj.debugDrawProxy:drawSphere(0.1, p, color(255, 0, 0, 255))
obj.debugDrawProxy:drawText(p + vec3(0, 0, 0.3), color(255, 0, 0, 255), string.format("COG (%0.3f, %0.3f, %0.3f)", relCOGPos.x, relCOGPos.y, relCOGPos.z))
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(0, 0, 0, 255), "COG distance above ground: " .. string.format("%0.3f m", obj:getDistanceFromTerrainPoint(p)))
end
local nodeMinDistFromCam = math.huge
local camPos = vec3()
local textNodeForceAvg = 1
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 60, 0), color(0, 0, 0, 255), "Weight: " .. string.format("%.2f kg", totalWeight))
end
end
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 60, 0), color(0, 0, 0, 255), "Average force: " .. string.format("%0.1f N", textNodeForceAvg))
textNodeForceAvg = forcesSum / (currNodesCount + 1e-30)
if not beamPositions[i] then
beamPositions[i] = vec3()
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 60, 0), color(255, 165, 0, 255), "Mode: " .. modeName)
end
for i = 0, #beamTypesNames do
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100 + i * 20, 0), beamTypesColors[i], beamTypesNames[i])
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 0, 0, 255), "Compression")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 0, 0, 255), "Compression")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 0, 0, 255), "Compression")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 0, 0, 255), "Compression")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(255, 255, 255, 255), string.format("Range Max: %.2f", rangeMax))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(255, 255, 255, 255), string.format("Range Max: %.2f", rangeMax))
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 0, 0, 255), "Compression")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 0, 0, 255), "Compression")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(255, 255, 255, 255), string.format("Range Max: %.2f", rangeMax))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(255, 255, 255, 255), string.format("Range Max: %.2f", rangeMax))
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 0, 0, 255), "Compression")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 0, 0, 255), "Compression")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 255, 255), "Extension")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(255, 255, 255, 255), string.format("Range Max: %.2f", rangeMax))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(255, 255, 255, 255), string.format("Range Max: %.2f", rangeMax))
end
if not groupsData[g] then
groupsData[g] = {0, vec3(), getContrastColor(j, 255 * alpha)}
j = j + 1
if not groupsData[g] then
groupsData[g] = {0, vec3(), getContrastColor(j, 255 * alpha)}
j = j + 1
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(0,255,255,255), "Short Bound")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0,128,255,255), "Short Bound Transition")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(0,255,255,255), "Short Bound")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0,128,255,255), "Short Bound Transition")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(0,0,255,255), "Contraction")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0,128,255,255), "Short Bound Transition")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(0,0,255,255), "Contraction")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(0,255,0,255), "Beam")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(0,0,255,255), "Contraction")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(0,255,0,255), "Beam")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 180, 0), color(255,0,0,255), "Expansion")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 160, 0), color(0,255,0,255), "Beam")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 180, 0), color(255,0,0,255), "Expansion")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 200, 0), color(255,128,0,255), "Long Bound Transition")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 180, 0), color(255,0,0,255), "Expansion")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 200, 0), color(255,128,0,255), "Long Bound Transition")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 220, 0), color(255,255,0,255), "Long Bound")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 200, 0), color(255,128,0,255), "Long Bound Transition")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 220, 0), color(255,255,0,255), "Long Bound")
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(0, 0, 255, 255), "Contraction")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(255, 0, 0, 255), "Expansion")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(0, 0, 255, 255), "Contraction")
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(255, 0, 0, 255), "Expansion")
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(0, 0, 0, 255), string.format("%.2f Hz", freq))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 0, 255), string.format("Max Amplitude: %.2f m", ampMax))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(0, 0, 0, 255), string.format("%.2f Hz", freq))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(0, 0, 0, 255), string.format("Max Amplitude: %.2f m", ampMax))
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(255, 0, 0, 255), string.format("Range Max: %.2f", rangeMax))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(255, 0, 0, 255), string.format("Range Max: %.2f", rangeMax))
if mode.showInfinity then
if mode.showInfinity then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 0, 255, 255), "Includes FLT_MAX")
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 60, 0), color(255, 165, 0, 255), "Mode: " .. modeName)
end
if i ~= TORBAR_BROKEN then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100 + j * 20, 0), torbarTypesColors[i][1], torbarTypesNames[i])
j = j + 1
for i = 1, #torbarTypesNames do
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100 + i * 20, 0), torbarTypesColors[i][1], torbarTypesNames[i])
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(255, 0, 0, 255), string.format("Range Max: %.2f", rangeMax))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 100, 0), color(255, 255, 255, 255), string.format("Range Min: %.2f", rangeMin))
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 120, 0), color(255, 0, 0, 255), string.format("Range Max: %.2f", rangeMax))
if mode.showInfinity then
if mode.showInfinity then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 140, 0), color(255, 0, 255, 255), "Includes FLT_MAX")
end
if playerInfo.firstPlayerSeated then
obj.debugDrawProxy:drawText2D(vec3(viewportSizeX - 450 - 40, 60, 0), color(255, 165, 0, 255), "Mode: " .. modeName)
end
@/lua/ge/extensions/editor/missionPlaybook/missionTreeViewer.lua
missionId = m.id,
pos = vec3(m.unlocks.depth*300, id*(nodeSize.y+20),0),
}
@/gameplay/missionTypes/scatterPickup/customNodes/scatterStuffInZonesNode.lua
local icon = {
pos = zone.center + vec3(0,0,1),
visible = false,
local p = vec3(math.random(), math.random(), 0)
for i = 1, (sqArea*sqArea) / density do
local blue = p:getBlueNoise2d():copy() * sqArea
blue = blue + vec3(zone.aabb.xMin, zone.aabb.yMin, 0)
if zone:containsPoint2D(blue) then
local hit = Engine.castRay(blue + vec3(0,0,5), blue + vec3(0,0,-5), true, false)
if hit then
local hit = Engine.castRay(blue + vec3(0,0,5), blue + vec3(0,0,-5), true, false)
if hit then
@/lua/ge/extensions/editor/buildingEditor.lua
if dbg == true then
adbg[#adbg+1] = {p+vec3(0,0,0), ColorF(1,0,1,1), 0.2}
adbg[#adbg+1] = {decal:getMiddleEdgePosition(start)+vec3(0,0,0), ColorF(1,1,0,1), 0.5}
adbg[#adbg+1] = {p+vec3(0,0,0), ColorF(1,0,1,1), 0.2}
adbg[#adbg+1] = {decal:getMiddleEdgePosition(start)+vec3(0,0,0), ColorF(1,1,0,1), 0.5}
end
adbg[#adbg+1] = {
(1 - api/(api + apip))*(decal:getMiddleEdgePosition(i)+vec3(0,0,1))+
api/(api + apip)*(decal:getMiddleEdgePosition(i+1)+vec3(0,0,1)),
(1 - api/(api + apip))*(decal:getMiddleEdgePosition(i)+vec3(0,0,1))+
api/(api + apip)*(decal:getMiddleEdgePosition(i+1)+vec3(0,0,1)),
ColorF(0,1,1,1), 0.2}
U.proj2D = function(v)
return vec3(v.x, v.y, 0) --{ x = v.x, y = v.y, z = 0 }
end
U.vnorm = function(v)
return vec3(-v.y, v.x, 0):normalized()
end
U.vturn = function(v, ang)
return vec3(math.cos(ang)*v.x - math.sin(ang)*v.y, math.sin(ang)*v.x + math.cos(ang)*v.y, v.z)
end
local x, y = U.lineCross(a1, a2, b1, b2)
local p = vec3(x, y, 0)
local eps = 0.01
Render.circle = function(center, r, c)
local v = vec3(center.x+r,center.y,0)
local arg = math.pi/2 + (i - 1 + 1/2)*2*math.pi/circleGrid
local dv = l*vec3(
math.cos(arg),
-- lo('?? rect:'..tostring(u)..':'..tostring(v))
av[#av + 1] = vec3(0, 0, 0)
av[#av + 1] = av[#av] + u
local rdm = createObject("ProceduralMesh")
rdm:setPosition(vec3(0, 0, 0))
rdm.isMesh = true
local massCenter = vec3(0, 0, 0)
local anode, apath, apairskip = {}, {}, {}
local v = anode[path[i]].pos - anode[path[i - 1]].pos
local vn = vec3(-v.y, v.x, 0):normalized()
--?? massCenter role
local nodeInfo = {
pos = pmiddle + vec3(0, 0, h),
width = w, drivability = 1, index = n }
local nodeInfo = {
pos = anode[path[i]].pos + vec3(0, 0, h),
width = w, drivability = 1, index = n }
local pmid = (b - a):normalized()
pmid = (a + b)/2 + s*(b - a):length()*vec3(pmid.y, -pmid.x, 0)
local jo = forOut(roads[brout[1]], ieo, edec) --, nil, true)
adbg[#adbg + 1] = {edec:getLeftEdgePosition(jo)+vec3(0,0,hp), ColorF(0,1,0,1)}
local ji = forIn(roads[brin[1]], iei, edec)
local ji = forIn(roads[brin[1]], iei, edec)
adbg[#adbg + 1] = {edec:getLeftEdgePosition(ji)+vec3(0,0,hp), ColorF(0,1,0,1)}
lo('?? eLoop.BE:'..brout[2]..'>'..jo..':'..brin[2]..':'..ji)
local hp = 0
-- adbg[#adbg + 1] = {pout+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppout+vec3(0,0,hp), ColorF(0,0,1,1)}
-- adbg[#adbg + 1] = {pout+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppout+vec3(0,0,hp), ColorF(0,0,1,1)}
-- adbg[#adbg + 1] = {pin+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppout+vec3(0,0,hp), ColorF(0,0,1,1)}
-- adbg[#adbg + 1] = {pin+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppin+vec3(0,0,hp), ColorF(0,0,1,1)}
-- adbg[#adbg + 1] = {pin+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppin+vec3(0,0,hp), ColorF(0,0,1,1)}
lo('?? ie:'..ieo..'>'..iei..':'..dirout..'>'..dirin..':'..(ppout-pout):length())
local jo = forOut(roads[brout[1]], ieo, edec) --, nil, true)
adbg[#adbg + 1] = {edec:getLeftEdgePosition(jo)+vec3(0,0,hp), ColorF(0,1,0,1)}
local ji = forIn(roads[brin[1]], iei, edec)
lo('?? BE:'..o..':'..brout[2]..'> jo='..jo..':'..brin[2]..'> ji='..ji)
adbg[#adbg + 1] = {edec:getLeftEdgePosition(ji)+vec3(0,0,hp), ColorF(0,1,0,1)}
local ro, ri = roads[brout[1]], roads[brin[1]]
-- local pmid = (pin - pout):normalized()
-- pmid = (pin + pout)/2 + (pin - pout):length()/3*vec3(pmid.y, -pmid.x, 0)
adbg[#adbg + 1] = {pmid, ColorF(1,0,1,1)}
if false then
av[#av + 1] = vec3(2, -5, 1)
av[#av + 1] = vec3(0, -5, 1)
av[#av + 1] = vec3(2, -5, 1)
av[#av + 1] = vec3(0, -5, 1)
av, af = Mesh.strip(2, {vec3(2, -7, 1), vec3(0, -7, 1)}, av, af)
av[#av + 1] = vec3(0, -5, 1)
av, af = Mesh.strip(2, {vec3(2, -7, 1), vec3(0, -7, 1)}, av, af)
av[#av + 1] = vec3(0, -5, 1)
av, af = Mesh.strip(2, {vec3(2, -7, 1), vec3(0, -7, 1)}, av, af)
local rdm = createObject("ProceduralMesh")
-- rdm:setPosition(vec3(0, 0, 0))
rdm:setPosition(vec3(0, 0, 0))
-- rdm:setPosition(vec3(0, 0, 0))
rdm:setPosition(vec3(0, 0, 0))
rdm.isMesh = true
local apos = {
-- rd:getLeftEdgePosition(60 + i) + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + vec3(0, 0, 1),
-- rd:getLeftEdgePosition(60 + i) + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + perp + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + perp + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + 2*perp + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + perp + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + 2*perp + vec3(0, 0, 1),
-- rd:getRightEdgePosition(60 + i) + vec3(0, 0, 1),
rd:getLeftEdgePosition(60 + i) + 2*perp + vec3(0, 0, 1),
-- rd:getRightEdgePosition(60 + i) + vec3(0, 0, 1),
-- rd:getRightEdgePosition(60 + i) + vec3(0, 0, 1),
-- rd:getRightEdgePosition(60 + i) + vec3(0, 0, 1),
-- rd:getRightEdgePosition(60 + i) + vec3(0, 0, 1),
}
local rdm = createObject("ProceduralMesh")
rdm:setPosition(vec3(0, 0, 0))
rdm.isMesh = true
local apos = {
-- rd:getLeftEdgePosition(i) - marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h),
-- rd:getLeftEdgePosition(i) - marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h),
-- rd:getRightEdgePosition(i) + marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h),
-- rd:getRightEdgePosition(i) + marginSide*perp + vec3(0, 0, h + 1),
}
apos = {
-- rd:getLeftEdgePosition(i) - marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h - 0.2),
-- rd:getLeftEdgePosition(i) - marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h - 0.2),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h - 0.2),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h - 0.2),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h - 0.2),
-- rd:getRightEdgePosition(i) + marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h - 0.2),
-- rd:getRightEdgePosition(i) + marginSide*perp + vec3(0, 0, h + 1),
}
local rdm = createObject("ProceduralMesh")
rdm:setPosition(vec3(0, 0, 0))
rdm.isMesh = true
local rdm2 = createObject("ProceduralMesh")
rdm2:setPosition(vec3(0, 0, 0))
rdm2.isMesh = true
n.pos.z = hmap[apin[o][1]] + 0.2
-- editor.setNodePosition(rd, o, n.pos + 1*vec3(0, 0, hmap[r.apin[o]] + 0.2))
end
local v = U.vturn({x=x, y=y}, ang)
v = c1.pos + vn*(c1.r + dmiddle) + vec3(v.x, v.y, 0)
local vflip = U.vturn({x=x, y=-y}, ang)
local vflip = U.vturn({x=x, y=-y}, ang)
vflip = c1.pos + vn*(c1.r + dmiddle) + vec3(vflip.x, vflip.y, 0)
--TODO: massCenter role?
local nd = {
pos = c1.pos + vn*(c1.r + dmiddle) + vec3(v.x, v.y, 0),
r = r,
v = U.vturn({x=-x, y=y}, ang)
nd.pos = c1.pos + vn*(c1.r + dmiddle) + vec3(v.x, v.y, 0)
-- lo('!! sign: x:'..x..' y:'..y..' vn:'..tostring(vn)..' ang:'..ang..':'..tostring(spos)..'>'..tostring(nd.pos)..':'..math.abs((spos - c1.pos):length()/(c1.r + nd.r)))
state[#state+1] = {
pos = vec3(a[1],a[2],a[3]),
r = a[4],
anode = {}
anode[#anode + 1] = { pos = vec3(0, 0, 0), r = ar[1], stamp = '0_0' }
local ang = 2*math.random()*math.pi
end
anode[#anode + 1] = { pos = U.vturn(vec3(ar[1] + ar[2], 0, 0), ang), r = ar[2], ang = ang, stamp = '0_1' }
-- lo('?? FOR_2:'..tostring(ang)..':'..tostring(anode[#anode].pos)..':'..tostring(anode[#anode].ang))
--*********************************************************************
local camInitial = vec3(0, 0, 200)
]]
-- core_camera.setRotation(0, quatFromDir(vec3(0, -1, -1),vec3(0,0,1)))
-- core_camera.setPosition(0, vec3(0, 40, 60))
]]
-- core_camera.setRotation(0, quatFromDir(vec3(0, -1, -1),vec3(0,0,1)))
-- core_camera.setPosition(0, vec3(0, 40, 60))
-- core_camera.setRotation(0, quatFromDir(vec3(0, -1, -1),vec3(0,0,1)))
-- core_camera.setPosition(0, vec3(0, 40, 60))
if U._PRD == 0 and isfirst then
isfirst = false
local pos = vec3(0, 0, 5) - 2*vec3(0, -10, -1)
local q = quatFromDir(vec3(0, -10, -1),vec3(0,0,1))
isfirst = false
local pos = vec3(0, 0, 5) - 2*vec3(0, -10, -1)
local q = quatFromDir(vec3(0, -10, -1),vec3(0,0,1))
local pos = vec3(0, 0, 5) - 2*vec3(0, -10, -1)
local q = quatFromDir(vec3(0, -10, -1),vec3(0,0,1))
local pos = vec3(0, 0, 5) - 2*vec3(0, -10, -1)
local q = quatFromDir(vec3(0, -10, -1),vec3(0,0,1))
-- for base conform, "close to hill"
pos = vec3(15, -72, 10)
local hter = core_terrain.getTerrainHeight(pos)
@/lua/ge/extensions/gameplay/statisticModules/watchRollover.lua
local triggered = false
local vdir = vec3(0,0,0)
local vup = vec3(0,0,0)
local vdir = vec3(0,0,0)
local vup = vec3(0,0,0)
local vright = vec3(0,0,0)
local vup = vec3(0,0,0)
local vright = vec3(0,0,0)
local velocity = vec3(0,0,0)
local vright = vec3(0,0,0)
local velocity = vec3(0,0,0)
-- local vpos = vec3(0,0,0) --debug
local velocity = vec3(0,0,0)
-- local vpos = vec3(0,0,0) --debug
local lastRoof = 0
@/lua/ge/extensions/editor/tech/roadArchitect/junctions.lua
local oneOverRoot2 = 0.7071067811865475
local downRight = vec3(oneOverRoot2, -oneOverRoot2, 0)
local downLeft = vec3(-oneOverRoot2, -oneOverRoot2, 0)
local downRight = vec3(oneOverRoot2, -oneOverRoot2, 0)
local downLeft = vec3(-oneOverRoot2, -oneOverRoot2, 0)
local upRight = vec3(oneOverRoot2, oneOverRoot2, 0)
local downLeft = vec3(-oneOverRoot2, -oneOverRoot2, 0)
local upRight = vec3(oneOverRoot2, oneOverRoot2, 0)
local upLeft = vec3(-oneOverRoot2, oneOverRoot2, 0)
local upRight = vec3(oneOverRoot2, oneOverRoot2, 0)
local upLeft = vec3(-oneOverRoot2, oneOverRoot2, 0)
local xAxis = vec3(1, 0, 0)
local upLeft = vec3(-oneOverRoot2, oneOverRoot2, 0)
local xAxis = vec3(1, 0, 0)
local vertical = vec3(0, 0, 1)
local xAxis = vec3(1, 0, 0)
local vertical = vec3(0, 0, 1)
local halfPi = pi * 0.5
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadX1_I.nodes[1].isLocked = false
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadX2_I.nodes[1].isLocked = false
roadMgr.map[roadCR_X.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadCR_X.nodes[1].isLocked = true
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadX1_I.nodes[1].isLocked = true
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadX2_I.nodes[1].isLocked = true
roadMgr.map[roadY1_I.name] = rIdx
local p1 = vec3(0, -boxYHalf - bevel, 0)
local p2 = vec3(0, -boxYHalf, 0)
local p1 = vec3(0, -boxYHalf - bevel, 0)
local p2 = vec3(0, -boxYHalf, 0)
if isYOneWay then
roadMgr.map[roadY2_I.name] = rIdx
local p1 = vec3(0, boxYHalf + bevel, 0)
local p2 = vec3(0, boxYHalf, 0)
local p1 = vec3(0, boxYHalf + bevel, 0)
local p2 = vec3(0, boxYHalf, 0)
if isYOneWay then
roadMgr.map[roadCR_X.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadCR_X.nodes[1].isLocked = true
roadMgr.map[roadCR_Y.name] = rIdx
local q1 = vec3(0, -boxYHalf, 0)
local q2 = vec3(0, boxYHalf, 0)
local q1 = vec3(0, -boxYHalf, 0)
local q2 = vec3(0, boxYHalf, 0)
if isYOneWay then
roadMgr.map[roadX1_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadX2_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadY1_O.name] = rIdx
local q1 = vec3(0, -boxYHalf - bevel - capLength, 0)
local q2 = vec3(0, -boxYHalf - bevel, 0)
local q1 = vec3(0, -boxYHalf - bevel - capLength, 0)
local q2 = vec3(0, -boxYHalf - bevel, 0)
local q3 = vec3(0, -boxYHalf - bevel - capLength * 2, 0)
local q2 = vec3(0, -boxYHalf - bevel, 0)
local q3 = vec3(0, -boxYHalf - bevel - capLength * 2, 0)
local q4 = vec3(0, -boxYHalf - bevel - capLength * 1.5, 0)
local q3 = vec3(0, -boxYHalf - bevel - capLength * 2, 0)
local q4 = vec3(0, -boxYHalf - bevel - capLength * 1.5, 0)
if isYOneWay then
roadMgr.map[roadY2_O.name] = rIdx
local q1 = vec3(0, boxYHalf + bevel + capLength, 0)
local q2 = vec3(0, boxYHalf + bevel, 0)
local q1 = vec3(0, boxYHalf + bevel + capLength, 0)
local q2 = vec3(0, boxYHalf + bevel, 0)
local q3 = vec3(0, boxYHalf + bevel + capLength * 2, 0)
local q2 = vec3(0, boxYHalf + bevel, 0)
local q3 = vec3(0, boxYHalf + bevel + capLength * 2, 0)
local q4 = vec3(0, boxYHalf + bevel + capLength * 1.5, 0)
local q3 = vec3(0, boxYHalf + bevel + capLength * 2, 0)
local q4 = vec3(0, boxYHalf + bevel + capLength * 1.5, 0)
if isYOneWay then
roadMgr.map[roadTL_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, boxYHalf, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, boxYHalf + bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, boxYHalf, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, boxYHalf + bevel, 0)
local pMid = pCen + downRight * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, boxYHalf + bevel, 0), rot) + cen)
roadTL_S.nodes[1].isLocked = true
roadMgr.map[roadTR_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, boxYHalf + bevel, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, boxYHalf + bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, boxYHalf + bevel, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, boxYHalf + bevel, 0)
local pMid = pCen + downLeft * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, boxYHalf, 0), rot) + cen)
roadTR_S.nodes[1].isLocked = true
roadMgr.map[roadBL_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, -boxYHalf - bevel, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, -boxYHalf - bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, -boxYHalf - bevel, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, -boxYHalf - bevel, 0)
local pMid = pCen + upRight * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, -boxYHalf, 0), rot) + cen)
roadBL_S.nodes[1].isLocked = true
roadMgr.map[roadBR_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, -boxYHalf, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, -boxYHalf - bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, -boxYHalf, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, -boxYHalf - bevel, 0)
local pMid = pCen + upLeft * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, -boxYHalf - bevel, 0), rot) + cen)
roadBR_S.nodes[1].isLocked = true
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadX1_I.nodes[1].isLocked = true
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadX2_I.nodes[1].isLocked = true
roadMgr.map[roadY2_I.name] = rIdx
local p1 = vec3(0, boxYHalf + bevel, 0)
local p2 = vec3(0, boxYHalf, 0)
local p1 = vec3(0, boxYHalf + bevel, 0)
local p2 = vec3(0, boxYHalf, 0)
if isYOneWay then
roadMgr.map[roadCR_X.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadCR_X.nodes[1].isLocked = true
roadMgr.map[roadX1_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadX2_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadY2_O.name] = rIdx
local q1 = vec3(0, boxYHalf + bevel + capLength, 0)
local q2 = vec3(0, boxYHalf + bevel, 0)
local q1 = vec3(0, boxYHalf + bevel + capLength, 0)
local q2 = vec3(0, boxYHalf + bevel, 0)
local q3 = vec3(0, boxYHalf + bevel + capLength * 2, 0)
local q2 = vec3(0, boxYHalf + bevel, 0)
local q3 = vec3(0, boxYHalf + bevel + capLength * 2, 0)
local q4 = vec3(0, boxYHalf + bevel + capLength * 1.5, 0)
local q3 = vec3(0, boxYHalf + bevel + capLength * 2, 0)
local q4 = vec3(0, boxYHalf + bevel + capLength * 1.5, 0)
if isYOneWay then
roadMgr.map[roadT_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf * 0.5, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf * 0.5, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf * 0.5, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf * 0.5, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf * 0.5, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf * 0.5, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, -boxYHalf, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, -boxYHalf, 0), rot) + cen)
roadT_S.nodes[1].isLocked = true
roadMgr.map[roadBL_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, boxYHalf, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, boxYHalf + bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, boxYHalf, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, boxYHalf + bevel, 0)
local pMid = pCen + downRight * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, boxYHalf + bevel, 0), rot) + cen)
roadBL_S.nodes[1].isLocked = true
roadMgr.map[roadBR_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, boxYHalf + bevel, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, boxYHalf + bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, boxYHalf + bevel, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, boxYHalf + bevel, 0)
local pMid = pCen + downLeft * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, boxYHalf, 0), rot) + cen)
roadBR_S.nodes[1].isLocked = true
roadMgr.map[roadCR_X.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen)
roadCR_X.nodes[1].isLocked = true
roadMgr.map[roadX1_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel + innerShift, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel + innerShift, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadX2_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel - innerShift, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel - innerShift, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
local s, c = sin(angRad), cos(angRad)
local p1 = vec3(0, boxYHalf + bevel + capLength - 0.2, 0)
local x, y = p1.x, p1.y
p1:set(x * c - y * s, x * s + y * c, 0.0)
local p2 = vec3(0, boxYHalf + bevel - 0.2 + innerShift, 0)
local x, y = p2.x, p2.y
profileY2_I.conditionEdgesR = im.BoolPtr(true)
ap1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen
local xLat = roadX2_O.renderData[#roadX2_O.renderData][1][6]
local xLat = roadX2_O.renderData[#roadX2_O.renderData][1][6]
ap3 = vec3(np3.x, np3.y, np3.z)
local aCtr = util.intersection2Lines(ap3, ap3 + roadY2_O.renderData[#roadY2_O.renderData][1][6], ap1, ap1 + xLat)
profileY2_I.conditionEdgesR = im.BoolPtr(false)
ap1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen
local xLat = roadX1_O.renderData[#roadX1_O.renderData][1][6]
local xLat = roadX1_O.renderData[#roadX1_O.renderData][1][6]
ap3 = vec3(np3.x, np3.y, np3.z)
local aCtr = util.intersection2Lines(ap3, ap3 + roadY2_O.renderData[#roadY2_O.renderData][1][6], ap1, ap1 + xLat)
profileB_S.isEdgeBlendR = im.BoolPtr(isEdgeBlend)
ap1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen
local xLat = roadX2_O.renderData[#roadX2_O.renderData][1][6]
local xLat = roadX2_O.renderData[#roadX2_O.renderData][1][6]
ap3 = vec3(np3.x, np3.y, np3.z)
local aCtr = util.intersection2Lines(ap3, ap3 + roadY2_O.renderData[#roadY2_O.renderData][1][6], ap1, ap1 + xLat)
profileB_S.isEdgeBlendR = im.BoolPtr(isEdgeBlend)
ap1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen
local xLat = roadX1_O.renderData[#roadX1_O.renderData][1][6]
local xLat = roadX1_O.renderData[#roadX1_O.renderData][1][6]
ap3 = vec3(np3.x, np3.y, np3.z)
local aCtr = util.intersection2Lines(ap3, ap3 + roadY2_O.renderData[#roadY2_O.renderData][1][6], ap1, ap1 + xLat)
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel * 0.5, 0, 0), rot) + cen)
roadX1_I.nodes[1].isLocked = true
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel * 0.5, 0, 0), rot) + cen)
roadX2_I.nodes[1].isLocked = true
roadMgr.map[roadY1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel * 0.5, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel * 0.5, 0), rot) + cen)
roadY1_I.nodes[1].isLocked = true
roadMgr.map[roadY2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel * 0.5, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel * 0.5, 0), rot) + cen)
roadY2_I.nodes[1].isLocked = true
roadMgr.map[roadX1_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel - capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadX2_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(boxXHalf + bevel, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel + capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadY1_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel - capLength, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel - capLength, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel - capLength * 2, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel - capLength * 1.5, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel - capLength * 2, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, -boxYHalf - bevel - capLength * 1.5, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadY2_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel + capLength, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel + capLength, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel + capLength * 2, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel + capLength * 1.5, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel + capLength * 2, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, boxYHalf + bevel + capLength * 1.5, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadRB_1.name] = rIdx
local rp1 = vec3(0, boxYHalf + bevel * 0.65 - numRBLanes * laneWidthRB + jct.extraRadRB[0], 0)
local rp2 = util.rotateVecAroundAxis(rp1, vertical, halfPi)
roadMgr.map[roadRB_2.name] = rIdx
local rp1 = vec3(0, -boxYHalf - bevel * 0.65 + numRBLanes * laneWidthRB - jct.extraRadRB[0], 0)
local rp2 = util.rotateVecAroundAxis(rp1, vertical, halfPi)
roadMgr.map[roadTL_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, boxYHalf, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, boxYHalf + bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, boxYHalf, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, boxYHalf + bevel, 0)
local pMid = pCen + downRight * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, boxYHalf + bevel, 0), rot) + cen)
roadTL_S.nodes[1].isLocked = true
roadMgr.map[roadTR_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, boxYHalf + bevel, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, boxYHalf + bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, boxYHalf + bevel, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, boxYHalf + bevel, 0)
local pMid = pCen + downLeft * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, boxYHalf, 0), rot) + cen)
roadTR_S.nodes[1].isLocked = true
roadMgr.map[roadBL_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, -boxYHalf - bevel, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, -boxYHalf - bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, -boxYHalf - bevel, 0), rot) + cen)
local pCen = vec3(-boxXHalf - bevel, -boxYHalf - bevel, 0)
local pMid = pCen + upRight * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - bevel, -boxYHalf, 0), rot) + cen)
roadBL_S.nodes[1].isLocked = true
roadMgr.map[roadBR_S.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, -boxYHalf, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, -boxYHalf - bevel, 0)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + bevel, -boxYHalf, 0), rot) + cen)
local pCen = vec3(boxXHalf + bevel, -boxYHalf - bevel, 0)
local pMid = pCen + upLeft * bevel
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(pMid, rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, -boxYHalf - bevel, 0), rot) + cen)
roadBR_S.nodes[1].isLocked = true
roadMgr.map[roadX1_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-capLength * 0.5, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(-capLength * 0.5, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 2, 0, 0), rot) + cen)
roadX1_O.nodes[1].isLocked = true
else
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.map[roadX2_O.name] = rIdx
local p1 = util.rotateVecByQuaternion(vec3(capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(capLength * 0.5, 0, 0), rot) + cen
local p1 = util.rotateVecByQuaternion(vec3(capLength, 0, 0), rot) + cen
local p3 = util.rotateVecByQuaternion(vec3(capLength * 0.5, 0, 0), rot) + cen
local p2 = p1 + (p3 - p1) * 0.5
roadMgr.addNodeToRoad(rIdx, p1)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 2, 0, 0), rot) + cen)
roadX2_O.nodes[1].isLocked = true
else
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 2, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 1.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, p1)
if isOneWay and jct.isY1Outwards[0] then
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 0.5, 0, 0), rot) + cen)
roadX3_O.nodes[1].isLocked = true
else
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * 0.5, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * 0.5, 0, 0), rot) + cen)
roadX3_O.nodes[1].isLocked = true
roadMgr.map[roadS1.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadS1.nodes[1].isLocked = false
roadMgr.map[roadS3.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadS3.nodes[1].isLocked = false
roadMgr.map[roadS2.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadS2.nodes[1].isLocked = true
roadMgr.map[roadS1.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadS1.nodes[1].isLocked = false
roadMgr.map[roadS3.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadS3.nodes[1].isLocked = false
roadMgr.map[roadS2.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - boxX / 3, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadS2.nodes[1].isLocked = true
roadMgr.map[roadS1.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadS1.nodes[1].isLocked = false
if isOneWay then
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
else
else
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
end
roadMgr.map[roadS2.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + (boxX / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + (boxX / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - (boxX / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + (boxX / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - (boxX / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - (boxX / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadS2.nodes[1].isLocked = true
roadMgr.map[roadS1.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadS1.nodes[1].isLocked = false
if jct.isY1Outwards[0] then
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadS1.nodes[1].isLocked = false
else
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen)
roadS1.nodes[1].isLocked = true
if jct.isY1Outwards[0] then
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength, 0, 0), rot) + cen)
roadS2.nodes[1].isLocked = true
else
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadS2.nodes[1].isLocked = false
roadMgr.map[roadS1.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(0, 0, 0), rot) + cen)
roadS1.nodes[1].isLocked = false
roadMgr.map[roadS1.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf - capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadS1.nodes[1].isLocked = false
roadMgr.map[roadS4.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength * (2.0 / 3.0), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf + capLength / 3.0, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadS4.nodes[1].isLocked = false
roadMgr.map[roadS2.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + s2Length, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + s2Length, 0, 0), rot) + cen)
roadS2.nodes[1].isLocked = true
roadMgr.map[roadS3.name] = rIdx
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + s2Length, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - (s3Length * 0.5), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(-boxXHalf + s2Length, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - (s3Length * 0.5), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf - (s3Length * 0.5), 0, 0), rot) + cen)
roadMgr.addNodeToRoad(rIdx, util.rotateVecByQuaternion(vec3(boxXHalf, 0, 0), rot) + cen)
roadS3.nodes[1].isLocked = true
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + bevel, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadX3_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-jct.capLength[0] * 0.5, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(jct.capLength[0] * 0.5, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-jct.capLength[0] * 0.5, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(jct.capLength[0] * 0.5, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(0, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(0, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadS2.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf + (boxX / 3.0), 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf + (boxX / 3.0), 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf - (boxX / 3.0), 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf + (boxX / 3.0), 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf - (boxX / 3.0), 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf - (boxX / 3.0), 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(0, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(0, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.map[roadX1_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf - capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(-boxXHalf, 0, 0))
roadMgr.map[roadX2_I.name] = rIdx
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf + capLength, 0, 0))
roadMgr.addNodeToRoad(rIdx, vec3(boxXHalf, 0, 0))
local midX, midY = (xMin + xMax) * 0.5, (yMin + yMax) * 0.5 -- Midpoint of axis-aligned bounding box.
local tmp0 = vec3(midX, midY, 0.0)
local tmp1 = vec3(xMax, yMax, 0.0)
local tmp0 = vec3(midX, midY, 0.0)
local tmp1 = vec3(xMax, yMax, 0.0)
local groundDist = tmp0:distance(tmp1) -- The largest distance from the center of the box to the outside.
local height = groundDist / tan(halfFov) + zMax + 5.0 -- The height that the camera should be to fit all the trajectory in view.
local rot = quatFromDir(vec3(0, 0, -1))
@/lua/ge/extensions/editor/rallyEditor/pacenotes.lua
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
local q = quatFromDir(wp.normal, vec3(0,0,1))
rotation = QuatF(q.x, q.y, q.z, q.w)
if wp.normal then
self.beginDragRotation = deepcopy(quatFromDir(wp.normal, vec3(0,0,1)))
end
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
wp.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Rotate then
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
wp.normal = quat(rotation)*vec3(0,1,0)
else
else
wp.normal = self.beginDragRotation * quat(rotation)*vec3(0,1,0)
end
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
if scl.x ~= 1 then
local rv = rallyUtil.calculateForwardNormal(new_pos, normal_align_pos)
wp_sel.normal = vec3(rv.x, rv.y, rv.z)
end
@/lua/ge/extensions/scenario/quickRace.lua
local rot = quatFromEuler(0,0,math.pi) * sp.rot
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(sp.pos + 1.5*y + 0.33*z)
local rot = quatFromEuler(0,0,math.pi) * sp.rot
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(sp.pos + 1.5*y + 0.33*z)
local rot = quatFromEuler(0,0,math.pi) * sp.rot
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(sp.pos + 1.5*y + 0.33*z)
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local pos = vec3(sp.pos + 1.5*y + 0.33*z)
sc.track.startTransform = {
sc.generatedNodes[nodeName] = {
pos = vec3(node.pos),
radius = node.radius,
radius = node.radius,
rot = node.hasNormal and vec3(node.normal) or nil
}
--jbeam, configString, pos, rot, color, color2, color3, name, cling
local pos = vec3()
local rot = quat()
if spawnObj ~= nil then
pos = vec3(spawnObj:getPosition())
rot = quat(spawnObj:getRotation())
@/lua/ge/extensions/editor/tech/roadArchitect/staticMesh.lua
-- Module constants.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local vertical = vec3(0, 0, 1) -- A vec3 used to represent the global world space 'up' axis.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local vertical = vec3(0, 0, 1) -- A vec3 used to represent the global world space 'up' axis.
local downVec = -vertical
@/lua/ge/extensions/core/cameraModes/autopoint.lua
self.hidden = true
self.localOffset = vec3(0,0,0) -- relative coords where the camera will point at
self:setSpring(5,1)
local nz = nx:cross(ny):normalized()
local offset = vec3(self.localOffset)
offset:set(
@/lua/ge/extensions/c2/panelPlugins/vehicleManager.lua
local pos = veh:getPosition()
local dir = vec3(veh:getDirectionVectorXYZ())
local up = vec3(veh:getDirectionVectorUpXYZ())
local dir = vec3(veh:getDirectionVectorXYZ())
local up = vec3(veh:getDirectionVectorUpXYZ())
local rot = quatFromDir(dir, up)
@/lua/ge/extensions/gameplay/crawl/boundary.lua
objectInfo.animationTimer = 0
obj:setScale(vec3(maxScale, maxScale, maxScale))
obj:setField('instanceColor', 0, '1 1 1 1')
obj:setScale(vec3(currentScale, currentScale, currentScale))
obj:setField('instanceColor', 0, string.format('1 1 1 %.2f', currentAlpha))
elseif objectInfo.animationState == "visible" then
obj:setScale(vec3(maxScale, maxScale, maxScale))
obj:setField('instanceColor', 0, '1 1 1 1')
obj.hidden = true
obj:setScale(vec3(minScale, minScale, minScale))
obj:setField('instanceColor', 0, '1 1 1 0')
else
pos.z = be:getSurfaceHeightBelow(pos + vec3(0, 0, 1)) + 0.1
end
local terrainNormal = vec3(0, 0, 1)
if core_terrain then
if core_terrain then
terrainNormal = core_terrain.getTerrainSmoothNormal(pos) or vec3(0, 0, 1)
else
else
terrainNormal = map.surfaceNormal(pos, 1) or vec3(0, 0, 1)
end
local worldUp = vec3(0, 0, 1)
local terrainUpDot = terrainNormal:dot(worldUp)
marker:setField('shapeName', 0, flagMeshPath)
marker.scale = vec3(1, 1, 1)
marker.useInstanceRenderData = true
boundaryObjects[objectId] = {
finalPosition = vec3(point.pos),
animationState = "hidden",
marker:setPosRot(point.pos.x, point.pos.y, point.pos.z, point.rot.x, point.rot.y, point.rot.z, point.rot.w)
marker:setScale(vec3(minScale, minScale, minScale))
marker:setField('instanceColor', 0, '1 1 1 0')
if not crawlerExitPoints[crawler.id] then
crawlerExitPoints[crawler.id] = vec3(vehPos)
log('D', logTag, string.format('Crawler %s exited boundary at %f, %f, %f', crawler.id, vehPos.x, vehPos.y, vehPos.z))
-- First time outside - save the exit point
crawlerExitPoints[crawler.id] = vec3(corner)
log('D', logTag, string.format('Crawler %s exited boundary at corner %f, %f, %f', crawler.id, corner.x, corner.y, corner.z))
-- Set initial visual state
obj:setScale(vec3(minScale, minScale, minScale))
obj:setField('instanceColor', 0, '1 1 1 0')
@/lua/ge/extensions/gameplay/drift/stuntZones/nearPole.lua
function C:createMarker()
local markerOffset = vec3(0, 0, 2.5)
local veh = scenetree.findObjectById(self.activeData.veh:getId())
@/lua/vehicle/extensions/dynamicVehicleData.lua
local avgWheelPos = vec3(0, 0, 0)
for _, wd in pairs(adjustedWheels) do
if wheelCount <= 4 and wheelCount > 1 then
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
if wheelCount <= 4 and wheelCount > 1 then
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorRight = vectorForward:cross(vectorUp) --vector facing to the right
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorRight = vectorForward:cross(vectorUp) --vector facing to the right
if wd.isPropulsed then
local wheelNodePos = vec3(v.data.nodes[wd.node1].pos) --find the wheel position
local wheelVector = wheelNodePos - avgWheelPos --create a vector from our "center" to the wheel
local function constructAABB()
local min = vec3(math.huge, math.huge, math.huge)
local max = vec3(-math.huge, -math.huge, -math.huge)
local min = vec3(math.huge, math.huge, math.huge)
local max = vec3(-math.huge, -math.huge, -math.huge)
local nodes = v.data.nodes
local refPos = vec3(nodes[v.data.refNodes[0].ref].pos)
min = min - (refPos)
perfectLaunch.onInit()
perfectLaunch.prepare(vec3(20, -10, 0.5))
straightLine.onInit()
straightLine.setTargetDirection(vec3(20, -10, 0.5), "road")
cruiseControl.setSpeed(hundredTenKmh)
straightLine.onInit()
straightLine.setTargetDirection(vec3(0, 600, 0), "offroad")
@/lua/ge/extensions/gameplay/sites/customFields.lua
elseif data.types[name] == 'vec3' then
self:add(name,'vec3',vec3(data.values[name]))
end
@/lua/vehicle/controller/esc.lua
local actualVelocity = (directionVector:dot(velocity) / (directionVector:length() * directionVector:length()) * directionVector):length()
local velocityVector = vec3(velocity.x, velocity.y, 0)
local dot = velocityVector:dot(directionVector)
local tmp = vec3(0, 0, 0)
local totalMass = 0
for _, v in pairs(v.data.nodes) do
tmp = tmp + vec3(v.pos) * v.nodeWeight
totalMass = totalMass + v.nodeWeight
--we need to find the average wheel position (basically the "center" of our vehicle)
local avgWheelPos = vec3(0, 0, 0)
local wheelCount = 0
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) -- obj:getDirectionVector() --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) -- obj:getDirectionVector() --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) -- obj:getDirectionVector() --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) -- obj:getDirectionVector() --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
for _, wheelName in ipairs(escConfigs.actionedWheels) do
local wheelNodePos = vec3(v.data.nodes[wheelCache[wheelNameCache[wheelName]].node1].pos) --find the wheel position
local wheelVector = wheelNodePos - avgWheelPos --create a vector from our "center" to the wheel
@/lua/common/jbeam/sections/meshs.lua
-- Prop translation
p:setTranslation(vec3(prop.translation))
prop.translation = translationWorldToPropAxis(
vec3(prop.translationGlobal),
false,
if prop.baseTranslation then
p:setBaseTranslation(vec3(prop.baseTranslation))
end
local newX, newY, newZ = jbeamUtils.getPosAfterNodeRotateOffsetMove(prop, x, y, z)
local newPos = vec3(newX, newY, newZ)
prop.baseTranslationGlobalWithNodeTransforms = newPos
local newX, newY, newZ = jbeamUtils.getPosAfterNodeRotateOffsetMove(prop, x, y, z)
local newPos = vec3(newX, newY, newZ)
prop.baseTranslationGlobalElasticWithNodeTransforms = newPos
local newX, newY, newZ = jbeamUtils.getPosAfterNodeRotateOffsetMove(prop, x, y, z)
local newPos = vec3(newX, newY, newZ)
prop.baseTranslationGlobalRigidWithNodeTransforms = newPos
if prop.translationOffset then
p:setTranslationOffset(vec3(prop.translationOffset))
end
-- prop rotation euler order is -X -Z -Y intrinsic
local rotDeg = vec3(prop.rotation)
prop.rotation = vec3(math.rad(rotDeg.x), math.rad(rotDeg.y), math.rad(rotDeg.z))
local rotDeg = vec3(prop.rotation)
prop.rotation = vec3(math.rad(rotDeg.x), math.rad(rotDeg.y), math.rad(rotDeg.z))
p:setRotation(prop.rotation)
if prop.rotationGlobal then
rotDeg = vec3(prop.rotationGlobal)
prop.rotationGlobal = vec3(math.rad(rotDeg.x), math.rad(rotDeg.y), math.rad(rotDeg.z))
rotDeg = vec3(prop.rotationGlobal)
prop.rotationGlobal = vec3(math.rad(rotDeg.x), math.rad(rotDeg.y), math.rad(rotDeg.z))
p:setRotationGlobal(prop.rotationGlobal)
if prop.baseRotation then
prop.baseRotation = vec3(math.rad(prop.baseRotation.x), math.rad(prop.baseRotation.y), math.rad(prop.baseRotation.z))
p:setBaseRotation(prop.baseRotation)
if prop.baseRotationGlobal then
prop.baseRotationGlobal = vec3(math.rad(prop.baseRotationGlobal.x), math.rad(prop.baseRotationGlobal.y), math.rad(prop.baseRotationGlobal.z))
p:setBaseRotationGlobal(prop.baseRotationGlobal)
local attenuation = vec3(0, 1, 1)
if prop.lightAttenuation then attenuation = vec3(prop.lightAttenuation) end
local attenuation = vec3(0, 1, 1)
if prop.lightAttenuation then attenuation = vec3(prop.lightAttenuation) end
plight:setLightArgs(innerAngle, outerAngle, brightness, range, color, attenuation, castShadows)
if flexbody.pos then
pos = vec3(tonumber(flexbody.pos.x), tonumber(flexbody.pos.y), tonumber(flexbody.pos.z))
else
else
pos = vec3(0,0,0)
end
if flexbody.rot then
rotDeg = vec3(tonumber(flexbody.rot.x), tonumber(flexbody.rot.y), tonumber(flexbody.rot.z))
else
else
rotDeg = vec3(0,0,0)
end
end
local rotRad = vec3(math.rad(rotDeg.x), math.rad(rotDeg.y), math.rad(rotDeg.z))
if flexbody.scale then
scale = vec3(tonumber(flexbody.scale.x), tonumber(flexbody.scale.y), tonumber(flexbody.scale.z))
else
else
scale = vec3(1,1,1)
end
@/lua/ge/extensions/editor/roadSpline/import.lua
local abs, min, max, sqrt, huge = math.abs, math.min, math.max, math.sqrt, math.huge
local globalUp = vec3(0, 0, 1)
}
local tmp1, pVec, negEdgeTmp, posEdgeTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
}
local tmp1, pVec, negEdgeTmp, posEdgeTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
}
local tmp1, pVec, negEdgeTmp, posEdgeTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
}
local tmp1, pVec, negEdgeTmp, posEdgeTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
local tmp1, pVec, negEdgeTmp, posEdgeTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
local layerTangent, refTangent, binNeg, pTmp = vec3(), vec3(), vec3(), vec3()
local tmp1, pVec, negEdgeTmp, posEdgeTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
local layerTangent, refTangent, binNeg, pTmp = vec3(), vec3(), vec3(), vec3()
local tmp1, pVec, negEdgeTmp, posEdgeTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
local layerTangent, refTangent, binNeg, pTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
local layerTangent, refTangent, binNeg, pTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
local layerTangent, refTangent, binNeg, pTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
local layerTangent, refTangent, binNeg, pTmp = vec3(), vec3(), vec3(), vec3()
local toNode, segmentDir, perpDir = vec3(), vec3(), vec3()
local layerTangent, refTangent, binNeg, pTmp = vec3(), vec3(), vec3(), vec3()
tmp1:setScaled2(tmp1, 0.5)
refNodes[i] = vec3(tmp1) -- Use midpoint of the two edges as the reference node.
refWidths[i] = negEdgeTmp:distance(posEdgeTmp) -- Use the distance between the two edges as the width.
refWidths[i] = negEdgeTmp:distance(posEdgeTmp) -- Use the distance between the two edges as the width.
refNmls[i] = vec3(globalUp) -- Use the global up vector as the normal.
end
@/lua/ge/extensions/util/trackBuilder/borderWallMesh.lua
local pointCount = 0
local tmpVec3 = vec3()
local cappedWidth = 0
-point.orientation.nz +
point.position + vec3(0,0,point.zOffset)
)
-point.orientation.nz +
point.position + vec3(0,0,point.zOffset)
)
point.orientation.nz * (point[sideNameField])+
point.position + vec3(0,0,point.zOffset)
)
point.orientation.nz * (point[sideNameField])+
point.position + vec3(0,0,point.zOffset)
)
@/lua/ge/extensions/editor/dragRaceEditor/facilities.lua
-- Draw facility preview (could show facility boundaries, etc.)
debugDrawer:drawTextAdvanced(vec3(0, 0, 0), String("Facility: " .. facility.name), constants.CONSTANTS.COLORS.WHITE, true, false, constants.CONSTANTS.COLORS.BLACK)
end
@/gameplay/missionTypes/targetjump/customNodes/CalculateZonePointRewardNode.lua
for i = 0, 7 do
table.insert(testPositions, vec3(oobb:getPoint(i)))
end
@/lua/ge/extensions/flowgraph/nodes/math/math.lua
else
self.vecCache[key] = vec3(val)
end
@/lua/ge/extensions/gameplay/drift/freeroam/driftSpots.lua
local plVel = vec3()
local hasAlreadyShownNewRecord = false
local plPos = vec3()
local localPoint = inverseRot * vec3(translatedPoint.x / scl.x, translatedPoint.y / scl.y, translatedPoint.z / scl.z)
return math.abs(localPoint.x) <= 1 and math.abs(localPoint.y) <= 1 and math.abs(localPoint.z) <= 1
id = spotName .. " - " .. lineName,
pos = vec3(lineData.pos),
scl = vec3(lineData.scl),
pos = vec3(lineData.pos),
scl = vec3(lineData.scl),
rot = quat(lineData.rot),
rot = quat(lineData.rot),
startDir = vec3(lineData.startDir),
if spot then
return vec3(spot.spatialInfo.bigMapTp.pos), quat(spot.spatialInfo.bigMapTp.rot)
end
@/lua/ge/extensions/render/renderViews.lua
local defaultRes = vec3(512, 256, 0) -- resolution in pixels
local activateAAAfter
@/lua/ge/extensions/core/hotlapping.lua
if vehId ~= -1 then
cpPos = vec3(be:getObjectOOBBCenterXYZ(vehId))
cpPos.z = be:getSurfaceHeightBelow(cpPos)
local vecUp = vec3(0, 0, 1)
local vecA = vec3()
local vecUp = vec3(0, 0, 1)
local vecA = vec3()
local vecB = vec3()
local vecA = vec3()
local vecB = vec3()
local colorWhite = ColorF(1, 1, 1, 0.2)
local radius = type(info.size) == 'table' and info.size[1] or info.size
M.addCheckPoint(vec3(info.position), vec3(info.direction), radius)
end
local radius = type(info.size) == 'table' and info.size[1] or info.size
M.addCheckPoint(vec3(info.position), vec3(info.direction), radius)
end
@/lua/vehicle/wheels.lua
wheel.inertia = 0
local node1Pos = vec3(v.data.nodes[wheel.node1].pos)
local node2Pos = vec3(v.data.nodes[wheel.node2].pos)
local node1Pos = vec3(v.data.nodes[wheel.node1].pos)
local node2Pos = vec3(v.data.nodes[wheel.node2].pos)
for _, n in pairs(wheel.nodes) do
local wheelNode = v.data.nodes[n]
local distanceToAxis = vec3(wheelNode.pos):distanceToLine(node1Pos, node2Pos)
wheel.inertia = wheel.inertia + wheelNode.nodeWeight * distanceToAxis * distanceToAxis
local avgWheelPos = vec3(0, 0, 0)
for _, rotator in pairs(M.wheelRotators) do
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorRight = vectorForward:cross(vectorUp) --vector facing to the right
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorRight = vectorForward:cross(vectorUp) --vector facing to the right
for _, rotator in pairs(M.wheelRotators) do
local wheelNodePos = vec3(v.data.nodes[rotator.node1].pos) --find the wheel position
local wheelVector = wheelNodePos - avgWheelPos --create a vector from our "center" to the wheel
@/lua/ge/extensions/gameplay/route/raceRoute.lua
-- table.insert(newPoints, {
-- pos = vec3(point.pos),
-- })
table.insert(self.originalFixedPositions, {
pos = vec3(point.pos),
linkCount = point.linkCount,
-- that position is always distance zero to the closest segment, so the route is never shortened.
startPos = vec3(startPos)
local startEndPosTable = {pos = vec3()}
function C:updatePathForPos(pos)
@/gameplay/missionTypes/collection/customNodes/collectionMarkersNode.lua
marker:setPosition(pos)
marker.scale = vec3(1, 1, 1)
marker:registerObject(Sim.getUniqueName("Marker"..tostring(pos)))
if markerObj then
pos = pos + (vec3(0,0,math.sin(os.clockhp()*1.5) * 0.15+1.15))
markerObj:setPosition(pos)
local c = clamp(inverseLerp(1, 100, dist),0,1)
debugDrawer:drawCylinder(pos + vec3(0,0,-100), pos + vec3(0,0,1000), lerp(0.1, 2, r), ColorF(0.5+0.5*clr[1],0.5+0.5*clr[2],0.5+0.5*clr[3],lerp(0.00, 0.3, c)))
end
local c = clamp(inverseLerp(1, 100, dist),0,1)
debugDrawer:drawCylinder(pos + vec3(0,0,-100), pos + vec3(0,0,1000), lerp(0.1, 2, r), ColorF(0.5+0.5*clr[1],0.5+0.5*clr[2],0.5+0.5*clr[3],lerp(0.00, 0.3, c)))
end
@/lua/ge/extensions/gameplay/sites/location.lua
self.name = name or "Location " .. self.id
self.color = vec3(1,1,1)
self.pos = vec3()
self.color = vec3(1,1,1)
self.pos = vec3()
self.radius = 5
self.name = data.name
self.color = vec3(data.color)
self:set(vec3(data.pos),data.radius)
self.color = vec3(data.color)
self:set(vec3(data.pos),data.radius)
self.customFields:onDeserialized(data.customFields)
function C:set(pos, radius)
self.pos = vec3(pos)
self.radius = radius
if not map then return nil end
local name_a,name_b,distance = map.findClosestRoad(vec3(self.pos))
if not name_a or not name_b or not distance then return end
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/scriptAI/playRecording.lua
for _, p in pairs(self.recording.recording.path) do
debugDrawer:drawSphere(vec3(p), 0.1, ColorF(1,0,1,1))
if lastP then
if lastP then
debugDrawer:drawSquarePrism(vec3(lastP), vec3(p), Point2F(0.6, 0.1), Point2F(0.6, 0.1), ColorF(1,0,1,0.1))
end
if lastP then
debugDrawer:drawSquarePrism(vec3(lastP), vec3(p), Point2F(0.6, 0.1), Point2F(0.6, 0.1), ColorF(1,0,1,0.1))
end
@/lua/ge/map.lua
local emptyTable = setmetatable({}, {__newindex = function(t, key, val) log('E', 'map', 'Tried to insert new elements into map.objects') end})
local vecUp = vec3(0,0,1)
local tmpBuf = buffer.new()
return vec3(sumX, sumY, sumZ)
end
local p1 = vec3(p.x, p.y + r, p.z + hr)
local p2 = vec3(p.x + 0.8660254037844386 * r, p.y - 0.5 * r, p1.z) -- sin(60) => 0.8660254037844386, cos(60) => 0.5
local p1 = vec3(p.x, p.y + r, p.z + hr)
local p2 = vec3(p.x + 0.8660254037844386 * r, p.y - 0.5 * r, p1.z) -- sin(60) => 0.8660254037844386, cos(60) => 0.5
local p3 = p2:copy()
mapNodes[nodeName] = {pos = pos, radius = radius, links = {}, manual = 1}
manualWaypoints[nodeName] = {pos = vec3(pos), radius = radius}
end
local searchRadius = maxRadius * 5
local tmpVec = vec3()
local edgeVec = vec3()
local tmpVec = vec3()
local edgeVec = vec3()
local terrain = scenetree.findObject(scenetree.findClassObjects('TerrainBlock')[1])
local terrainPosition = vec3(terrain:getPosition())
trajectory[i] = {
posOrig = vec3(p),
pos = vec3(p),
posOrig = vec3(p),
pos = vec3(p),
normalOrig = vec3(),
pos = vec3(p),
normalOrig = vec3(),
normal = vec3(),
normalOrig = vec3(),
normal = vec3(),
biNormal = surfaceNormal(p, r * 0.5),
biNormal = surfaceNormal(p, r * 0.5),
edgeVec = vec3(),
radius = r,
evolveNormal = ((i == 1 or i == pathCount) and (s.evolveEndNormals and s.evolvePathNormals)) or ((i ~= 1 and i ~= pathCount) and s.evolvePathNormals),
force = vec3(),
length = nil,
posOrig = posOrig,
pos = vec3(posOrig),
normalOrig = vec3(),
pos = vec3(posOrig),
normalOrig = vec3(),
normal = vec3(),
normalOrig = vec3(),
normal = vec3(),
biNormal = surfaceNormal(posOrig, radius * 0.5),
biNormal = surfaceNormal(posOrig, radius * 0.5),
edgeVec = vec3(),
radius = radius,
evolveNormal = s.evolveMidNormals,
force = vec3(),
length = nil,
trajectory[1].normal:set(trajectory[1].normalOrig)
local nVec1, nVec2 = vec3(), vec3()
for i = 2, trajectoryCount-1 do
trajectory[1].normal:set(trajectory[1].normalOrig)
local nVec1, nVec2 = vec3(), vec3()
for i = 2, trajectoryCount-1 do
-- Calculate gradient ("spring") forces
local nforce, v1, v2 = vec3(), vec3(), vec3()
for i = 2, trajectoryCount-1 do
-- Calculate gradient ("spring") forces
local nforce, v1, v2 = vec3(), vec3(), vec3()
for i = 2, trajectoryCount-1 do
-- Calculate gradient ("spring") forces
local nforce, v1, v2 = vec3(), vec3(), vec3()
for i = 2, trajectoryCount-1 do
-- Integrate Forces
local tmpVec = vec3()
local nodeConv = true
if node.junction then
debugDrawer:drawText(map.nodes[node1id].pos + vec3(0, 0, 2), node1id, black)
end
local tailPos = edgeData.inPos + right1 * offset1
local tipPos = vec3()
for j = 1, k do
local tmpPos, edgeDirVec, right1 = vec3(), vec3(), vec3()
for edgeID in edgeKdTree:queryNotNested(quadtree.pointBBox(camPos.x, camPos.y, drawDist)) do
local tmpPos, edgeDirVec, right1 = vec3(), vec3(), vec3()
for edgeID in edgeKdTree:queryNotNested(quadtree.pointBBox(camPos.x, camPos.y, drawDist)) do
local tmpPos, edgeDirVec, right1 = vec3(), vec3(), vec3()
for edgeID in edgeKdTree:queryNotNested(quadtree.pointBBox(camPos.x, camPos.y, drawDist)) do
local tailPos, tipPos = vec3(), vec3()
for i = 1, laneCount do -- draw lanes
local tailPos, tipPos = vec3(), vec3()
for i = 1, laneCount do -- draw lanes
if object and M.objects[objId] == nil then
local obj = objectsCache[objId] or {view = true, pos = vec3(), vel = vec3(), dirVec = vec3(), dirVecUp = vec3()}
if object and M.objects[objId] == nil then
local obj = objectsCache[objId] or {view = true, pos = vec3(), vel = vec3(), dirVec = vec3(), dirVecUp = vec3()}
if object and M.objects[objId] == nil then
local obj = objectsCache[objId] or {view = true, pos = vec3(), vel = vec3(), dirVec = vec3(), dirVecUp = vec3()}
if object and M.objects[objId] == nil then
local obj = objectsCache[objId] or {view = true, pos = vec3(), vel = vec3(), dirVec = vec3(), dirVecUp = vec3()}
local relativePos = pos - vec3(obj:getSpawnWorldOOBB():getCenter())
local relativePosLen = relativePos:length()
local objVel = vec3(obj:getVelocity())
local relativeSpeed = max(objVel:dot(relativePos / (relativePosLen + 1e-30)), 0)
local relativeSpeed = max(objVel:dot(relativePos / (relativePosLen + 1e-30)), 0)
local ff = 0.5 * vecUp:dot(vec3(obj:getDirectionVectorUp())) -- frictionCoeff * Normal Force.
local objDirVec = vec3(obj:getDirectionVector())
local ff = 0.5 * vecUp:dot(vec3(obj:getDirectionVectorUp())) -- frictionCoeff * Normal Force.
local objDirVec = vec3(obj:getDirectionVector())
local fw = vecUp:dot(sign(objVel:dot(objDirVec)) * objDirVec) -- road grade force
--local veh = getObjectByID(id)
local pos = vec3(posX, posY, posZ)
local rot = quat(rotX, rotY, rotZ, rotW)
@/gameplay/missionTypes/longjump/editor.lua
self:addDecoText("Where will the jump off point be? Place it slightly after the ramp.")
self:addTransform("Jump off", "jumpOff", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "halfBox", drawColor = {0,0,1,0.3}})
self:addDecoText("The player will fail the mission if they leave this volume.")
self:addTransform("Mission Bounding Box", "bounds", {hasPos = true, hasRot = true, defaultScl = vec3(200,40,15)},{drawMode = "fullBox", drawColor = {1,0,0,0.1}})
@/lua/ge/extensions/editor/toolUtilities/util.lua
local sqrt, tan, huge = math.sqrt, math.tan, math.huge
local globalDown = vec3(0, 0, -1)
local camLookDownRot = quatFromDir(globalDown)
-- Module state.
local tmp1, tmp2 = vec3(), vec3()
-- Module state.
local tmp1, tmp2 = vec3(), vec3()
@/lua/ge/extensions/editor/api/camera.lua
end
local pos = center + rot * vec3(0, -15, 0)
local rot = quatFromDir(center - pos)
camVars.center = center
camVars.camEndPos = center + rot * vec3(0, -viewRadius, 0)
core_jobsystem.create(cameraSmoothMoveJob, 1, camVars)
cam.angularForce = params.angularForce
cam.angularVelocity = vec3(0,0,0)
else
@/lua/ge/extensions/util/trackBuilder/segmentToProceduralMesh.lua
local splineObject = createObject("ProceduralMesh")
splineObject:setPosition(vec3(0,0,0))
splineObject.canSave = false
if controlPoint.quality[segment.quality] then
nx = M.rotateVectorByQuat(vec3(1,0,0),controlPoint.finalRot)
ny = M.rotateVectorByQuat(vec3(0,1,0),controlPoint.finalRot)
nx = M.rotateVectorByQuat(vec3(1,0,0),controlPoint.finalRot)
ny = M.rotateVectorByQuat(vec3(0,1,0),controlPoint.finalRot)
nz = M.rotateVectorByQuat(vec3(0,0,1),controlPoint.finalRot)
ny = M.rotateVectorByQuat(vec3(0,1,0),controlPoint.finalRot)
nz = M.rotateVectorByQuat(vec3(0,0,1),controlPoint.finalRot)
controlPoint.orientation = {
@/lua/ge/extensions/util/trackBuilder/meshes.lua
for i = 1, steps do
crossPoints[#crossPoints+1] = vec3(math.cos(-(1+0.1*i)*math.pi/2 )*(radius+1),0,radius+math.sin(-(1+0.1*i)*math.pi/2)*(radius+1))
uv[#uv+1] = 0
if wallHeight and wallHeight > 0 and steps == 10 then
crossPoints[#crossPoints+1] = vec3(-(radius+1),0,radius + wallHeight)
crossPoints[#crossPoints+1] = vec3(-(radius) ,0,radius + wallHeight)
crossPoints[#crossPoints+1] = vec3(-(radius+1),0,radius + wallHeight)
crossPoints[#crossPoints+1] = vec3(-(radius) ,0,radius + wallHeight)
uv[#uv+1] = 0
for i = steps, 1,-1 do
crossPoints[#crossPoints+1] = vec3(math.cos(-(1 +0.1*i)*math.pi/2 )*(radius),0,radius+math.sin(-(1 +0.1*i)*math.pi/2)*(radius))
crossPoints[#crossPoints+1] = vec3(math.cos(-(0.95+0.1*i)*math.pi/2 )*(radius),0,radius+math.sin(-(0.95+0.1*i)*math.pi/2)*(radius))
crossPoints[#crossPoints+1] = vec3(math.cos(-(1 +0.1*i)*math.pi/2 )*(radius),0,radius+math.sin(-(1 +0.1*i)*math.pi/2)*(radius))
crossPoints[#crossPoints+1] = vec3(math.cos(-(0.95+0.1*i)*math.pi/2 )*(radius),0,radius+math.sin(-(0.95+0.1*i)*math.pi/2)*(radius))
uv[#uv+1] = 1
crossPoints = {
vec3(-1,0,-1),
vec3(-math.sin(angle)*height,0,math.cos(angle) * height) + vec3(-math.cos(angle),0,-math.sin(angle)),
vec3(-1,0,-1),
vec3(-math.sin(angle)*height,0,math.cos(angle) * height) + vec3(-math.cos(angle),0,-math.sin(angle)),
vec3(-math.sin(angle)*height,0,math.cos(angle) * height)
vec3(-1,0,-1),
vec3(-math.sin(angle)*height,0,math.cos(angle) * height) + vec3(-math.cos(angle),0,-math.sin(angle)),
vec3(-math.sin(angle)*height,0,math.cos(angle) * height)
vec3(-math.sin(angle)*height,0,math.cos(angle) * height) + vec3(-math.cos(angle),0,-math.sin(angle)),
vec3(-math.sin(angle)*height,0,math.cos(angle) * height)
},
@/lua/ge/extensions/util/terrainGenerator.lua
function C:setTerrainOffset(vec) -- sets a new position for the terrain block (vec3(0, 0, 0) is the corner of the terrain block)
if core_terrain.getTerrain() then
local n = core_terrain.getTerrain():getWorldBlockSize() * -0.5
self:setTerrainOffset(vec3(n, n, 0))
end
@/lua/ge/extensions/editor/toolUtilities/gizmo.lua
local beginDragRot = nil
local delta, tmpTan = vec3(), vec3()
local tmpQuatF = QuatF(0, 0, 0, 1)
local beginDragRot = nil
local delta, tmpTan = vec3(), vec3()
local tmpQuatF = QuatF(0, 0, 0, 1)
for i = 1, #spline.nodes do
spline.nmls[i] = vec3(up)
end
else
spline.nmls[nodeIdx] = vec3(up)
end
@/lua/ge/extensions/flowgraph/nodes/vehicle/vehicleOOBB.lua
local center = vec3()
@/lua/ge/extensions/career/modules/loanerVehicles.lua
local vehPos = vec3()
local playerPos = vec3()
local vehPos = vec3()
local playerPos = vec3()
local function onUpdate(dtReal, dtSim, dtRaw)
@/lua/ge/extensions/editor/tech/roadArchitect/utilities.lua
local random = math.random
local xAxis, yAxis = vec3(1, 0, 0), vec3(0, 1, 0)
local downVec = vec3(0, 0, -1)
local random = math.random
local xAxis, yAxis = vec3(1, 0, 0), vec3(0, 1, 0)
local downVec = vec3(0, 0, -1)
local xAxis, yAxis = vec3(1, 0, 0), vec3(0, 1, 0)
local downVec = vec3(0, 0, -1)
local tmp = vec3(0, 0)
local downVec = vec3(0, 0, -1)
local tmp = vec3(0, 0)
local nodeCloseDistSq = nodeCloseDist * nodeCloseDist
local p = road.nodes[nIdx].p
local p_2D = vec3(p.x, p.y, 0)
local rData = road.renderData
local p = pos[l] + rat * (pos[u] - pos[l])
local fN = vec3(0, 0)
fN:setLerp(nml[l], nml[u], rat)
local invDenom = 1.0 / denom
return vec3(
((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) * invDenom,
local invDenom = 1.0 / ((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4))
return vec3((num1 * (x3 - x4) - (x1 - x2) * num2) * invDenom, (num1 * (y3 - y4) - (y1 - y2) * num2) * invDenom )
end
return vec3(projx, projy, p.z)
end
local cy = ((p1x - p2x) * cd - (p2x - p3x) * bc) * detInv
return vec3(cx, cy)
end
-- Computes the (small) angle between two vectors (converted to 2D first).
local function angleBetweenVecs2D(a, b) return angleBetweenVecs(vec3(a.x, a.y, 0.0), vec3(b.x, b.y, 0.0)) end
-- Computes the (small) angle between two vectors (converted to 2D first).
local function angleBetweenVecs2D(a, b) return angleBetweenVecs(vec3(a.x, a.y, 0.0), vec3(b.x, b.y, 0.0)) end
local qOut = (q * quat(v.x, v.y, v.z, 0)) * quat(-q.x, -q.y, -q.z, q.w)
return vec3(qOut.x, qOut.y, qOut.z)
end
@/lua/ge/extensions/tech/pythonExport.lua
local offset = veh:getInitialNodePosition(veh:getRefNodeId())
return vec3(-c.y + offset.x, -c.x + offset.y, c.z + offset.z)
end
local function dir2Python(c, veh)
return vec3(-c.y, -c.x, c.z)
end
{update_priority=0.0},
{pos=vec3(0, 0, 3)},
{dir=vec3(0, -1, 0)},
{pos=vec3(0, 0, 3)},
{dir=vec3(0, -1, 0)},
{up=vec3(0, 0, 1)},
{dir=vec3(0, -1, 0)},
{up=vec3(0, 0, 1)},
{resolution={512, 512}},
{update_priority=0.0},
{pos=vec3(0, 0, 1.7)},
{dir=vec3(0, -1, 0)},
{pos=vec3(0, 0, 1.7)},
{dir=vec3(0, -1, 0)},
{up=vec3(0, 0, 1)},
{dir=vec3(0, -1, 0)},
{up=vec3(0, 0, 1)},
{vertical_resolution=64},
{update_priority=0.0},
{pos=vec3(0, 0, 1.7)},
{dir=vec3(0, -1, 0)},
{pos=vec3(0, 0, 1.7)},
{dir=vec3(0, -1, 0)},
{up=vec3(0, 0, 1)},
{dir=vec3(0, -1, 0)},
{up=vec3(0, 0, 1)},
{size={200, 200}},
{update_priority=0.0},
{pos=vec3(0, 0, 1.7)},
{dir=vec3(0, -1, 0)},
{pos=vec3(0, 0, 1.7)},
{dir=vec3(0, -1, 0)},
{up=vec3(0, 0, 1)},
{dir=vec3(0, -1, 0)},
{up=vec3(0, 0, 1)},
{range_bins=200},
{physics_update_time=0.01},
{pos=vec3(0, 0, 1.7)},
{dir=vec3(0, -1, 0)},
{pos=vec3(0, 0, 1.7)},
{dir=vec3(0, -1, 0)},
{up=vec3(-0, 0, 1)},
{dir=vec3(0, -1, 0)},
{up=vec3(-0, 0, 1)},
{smoother_strength=1.0},
{physics_update_time=0.01},
{pos=vec3(0, 0, 1.7)},
{ref_lon=0.0},
@/lua/ge/extensions/gameplay/missions/proceduralMissionGenerators/busModeMissions.lua
mission.startTrigger.level = string.lower(level.levelName)
mission.startTrigger.pos = vec3(route.spawnLocation.pos.x, route.spawnLocation.pos.y, route.spawnLocation.pos.z)
local rot = route.spawnLocation.rotAngAxisF or route.spawnLocation.rot
if route.missionStartTriggerPos then
mission.startTrigger.pos = vec3(route.missionStartTriggerPos.x, route.missionStartTriggerPos.y, route.missionStartTriggerPos.z)
end
@/lua/ge/extensions/flowgraph/nodes/environment/simplePlanet.lua
local pos = vec3(self.pinIn.position.value)
local radius = self.pinIn.radius.value
@/lua/ge/extensions/gameplay/rally/recce/cutsRecording.lua
jsonlUtils.readJsonlLines(fname, function(obj)
obj.pos = vec3(obj.pos)
obj.quat = quat(obj.quat)
@/lua/vehicle/beamstate.lua
cid = tonumber(cid) - 1
obj:setNodePosition(cid, vec3(node[1]))
if #node > 1 then
@/lua/vehicle/powertrain/combustionEngine.lua
if device.torqueReactionNodes and #device.torqueReactionNodes == 3 and device.torqueReactionNodes[1] >= 0 then
local pos1 = vec3(v.data.nodes[device.torqueReactionNodes[1]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos1 = vec3(v.data.nodes[device.torqueReactionNodes[1]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos3 = vec3(v.data.nodes[device.torqueReactionNodes[3]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos3 = vec3(v.data.nodes[device.torqueReactionNodes[3]].pos)
local avgPos = (((pos1 + pos2) / 2) + pos3) / 2
@/lua/ge/extensions/flowgraph/nodes/gameplay/rally/createRallyGroundMarker.lua
-- Create aligned position on the road
local alignedPos = vec3()
alignedPos:setLerp(nodeA.pos, nodeB.pos, xnorm)
-- for _, pathnode in ipairs(pathnodes) do
-- local wp = vec3(pathnode.pos)
-- local alignedWp = alignToNavgraph(wp)
local startPos = vec3(sp.pos)
-- dont align the final position so its clear where the dest is
@/lua/ge/extensions/core/devices.lua
local M = {}
local beamOrange = vec3(255,102,0)
@/lua/ge/extensions/gameplay/walk.lua
local higherStoppingSpeed = 6.0/3.6
local up = vec3(0,0,1)
local forward = vec3(0,1,0)
local up = vec3(0,0,1)
local forward = vec3(0,1,0)
local placePlayerOffsetFromBody = 0.7
-- TODO if we got rid of the moving threshold, we could get rid of the update function when walking mode is not active
local vehVelocity = vec3()
local function setAtParkingSpeed(veh, dtSim)
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local otherBBCenter, otherBBAxis0, otherBBAxis1, otherBBAxis2 = vec3(), vec3(), vec3(), vec3()
local vehPos = vec3()
local otherBBCenter, otherBBAxis0, otherBBAxis1, otherBBAxis2 = vec3(), vec3(), vec3(), vec3()
local vehPos = vec3()
local otherBBCenter, otherBBAxis0, otherBBAxis1, otherBBAxis2 = vec3(), vec3(), vec3(), vec3()
local vehPos = vec3()
local otherBBCenter, otherBBAxis0, otherBBAxis1, otherBBAxis2 = vec3(), vec3(), vec3(), vec3()
local vehPos = vec3()
local otherBBCenter, otherBBAxis0, otherBBAxis1, otherBBAxis2 = vec3(), vec3(), vec3(), vec3()
local vehPos = vec3()
local function onUpdate(dtReal, dtSim)
@/lua/ge/extensions/core/cameraModes/path.lua
local sqrt = math.sqrt
local origin = vec3(0,0,0)
local veh = data.veh
local forward = vec3(veh:getDirectionVector())
local up = vec3(veh:getDirectionVectorUp())
local forward = vec3(veh:getDirectionVector())
local up = vec3(veh:getDirectionVectorUp())
local right = up:cross(forward):normalized() -- Compute right vector using cross product
end
local targetRotation = quatFromDir(target - pos, vec3(0,0,1))
@/lua/ge/extensions/editor/perfProfiler.lua
for _, s in ipairs(fileData.samples) do
s.pos = vec3(s.pos)
s.rot = quat(s.rot)
@/lua/ge/extensions/scenario/raceMarkers/sideHologramMarker.lua
local zVec = vec3(0,0,1)
local bobFrequency = 0.333
local bobOffset = vec3(0,0,0)
local CONE_HEIGHT = 1
local playerPosition = vec3(0,0,0)
local scale = vec3()
local playerPosition = vec3(0,0,0)
local scale = vec3()
local columnOffset = vec3(0,0,7)
local scale = vec3()
local columnOffset = vec3(0,0,7)
-- todo: replace this by a HSV-lerp if blending with non-gray colors
local lerpedColor = vec3()
local function lerpColor(a,b,t)
leftPillar:setPosition(self.leftPillarPos + bobOffset)
leftPillar:setScale(vec3(scalarThin,scalarThin,1))
leftPillar:updateInstanceRenderData()
rightPillar:setPosition(self.rightPillarPos + bobOffset)
rightPillar:setScale(vec3(scalarThin,scalarThin,1))
rightPillar:updateInstanceRenderData()
local coneScale = 0 + (self.leftPillarOffset+bobOffset.z) / CONE_HEIGHT
leftCone:setScale(vec3(scalarThin, scalarThin, coneScale))
leftCone:updateInstanceRenderData()
local coneScale = 0 + (self.rightPillarOffset+bobOffset.z) / CONE_HEIGHT
rightCone:setScale(vec3(scalarThin, scalarThin, coneScale))
rightCone:updateInstanceRenderData()
--leftCylinder:setPosition(self.leftCylinderPos)
leftCylinder:setScale(vec3(0.1*scalarThin,0.1*scalarThin, self.leftConePos.z-self.leftCylinderPos.z))
leftCylinder:updateInstanceRenderData()
--rightCylinder:setPosition(self.rightCylinderPos)
rightCylinder:setScale(vec3(0.1*scalarThin,0.1*scalarThin, self.rightConePos.z-self.rightCylinderPos.z))
rightCylinder:updateInstanceRenderData()
-- Position arrow 4m above waypoint
local arrowPos = vec3(self.pos.x, self.pos.y, self.pos.z + 4)
arrow:setPosition(arrowPos)
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
self.radius = wp.radius
self.radius = wp.radius
self.normal = wp.normal and vec3(wp.normal) or vec3(1,1,0):normalized()
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.radius = wp.radius
self.normal = wp.normal and vec3(wp.normal) or vec3(1,1,0):normalized()
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.normal = wp.normal and vec3(wp.normal) or vec3(1,1,0):normalized()
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.nextPos = wp.nextPos and vec3(wp.nextPos) or nil
self.normal = wp.normal and vec3(wp.normal) or vec3(1,1,0):normalized()
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.nextPos = wp.nextPos and vec3(wp.nextPos) or nil
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.nextPos = wp.nextPos and vec3(wp.nextPos) or nil
local rot = quatFromDir(self.normal:z0())
local up = vec3(0,0,1)
local rayLengthUp, rayLengthDown = 6, -25
-- Find positions on side
local pLeft = self.pos + rot*(vec3(-self.radius,0,0))
local pRight = self.pos + rot*(vec3(self.radius,0,0))
local pLeft = self.pos + rot*(vec3(-self.radius,0,0))
local pRight = self.pos + rot*(vec3(self.radius,0,0))
-- Get ground positions
self.leftConePos = hitLeft and vec3(hitLeft.pt) or originalLeftPos
self.rightConePos = hitRight and vec3(hitRight.pt) or originalRightPos
self.leftConePos = hitLeft and vec3(hitLeft.pt) or originalLeftPos
self.rightConePos = hitRight and vec3(hitRight.pt) or originalRightPos
if originalLeftPos.z - self.leftConePos.z > 1 then self.leftConePos.z = originalLeftPos.z end
if originalRightPos.z - self.rightConePos.z > 1 then self.rightConePos.z = originalRightPos.z end
self.leftCylinderPos = hitLeft and vec3(hitLeft.pt) or originalLeftPos
self.rightCylinderPos = hitRight and vec3(hitRight.pt) or originalRightPos
self.leftCylinderPos = hitLeft and vec3(hitLeft.pt) or originalLeftPos
self.rightCylinderPos = hitRight and vec3(hitRight.pt) or originalRightPos
self.leftPillarPos = vec3(self.leftConePos)
self.rightPillarPos = vec3(self.rightConePos)
self.leftPillarPos = vec3(self.leftConePos)
self.rightPillarPos = vec3(self.rightConePos)
leftPillar:setField('rotation', 0, rotStr)
leftPillar:setScale(vec3(1,1,1))
end
rightPillar:setField('rotation', 0, rotStr)
rightPillar:setScale(vec3(1,1,1))
end
leftColumn:setField('rotation', 0, rotStr)
leftColumn:setScale(vec3(1,1,1))
end
rightColumn:setField('rotation', 0, rotStr)
rightColumn:setScale(vec3(1,1,1))
end
leftCone:setField('rotation', 0, rotStr)
leftCone:setScale(vec3(1,1,1))
end
rightCone:setField('rotation', 0, rotStr)
rightCone:setScale(vec3(1,1,1))
end
leftCylinder:setField('rotation', 0, rotStr)
leftCylinder:setScale(vec3(0.1,0.1, self.leftConePos.z-self.leftCylinderPos.z))
end
rightCylinder:setField('rotation', 0, rotStr)
rightCylinder:setScale(vec3(0.1,0.1, self.rightConePos.z-self.rightCylinderPos.z))
end
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
@/lua/ge/extensions/core/cameraModes/noise.lua
self.factor = factor or self.factor or 0.2
self.offset = vec3()
self.timeSinceRandom = 100000
if self.timeSinceRandom > 0.1 then
self.offset = vec3((math.random()-0.5) * self.factor, (math.random()-0.5) * self.factor, (math.random()-0.5) * self.factor)
self.timeSinceRandom = 0
@/lua/ge/extensions/gameplay/race/segment.lua
local modes = {'waypoint','navgraphCapsule', 'manualCapsules'}
local missingKeynode = {name = "Missing!", pos = vec3(), radius = 0, mode = "Missing!"}
local node = map.getMap().nodes[path[j]]
table.insert(self.capsulePoints, {pos = vec3(node.pos), radius = node.radius, name = path[j], _generated = true})
end
function C:addCapsule(pos, radius, name, index)
table.insert(self.capsulePoints,index or (#self.capsulePoints+1),{pos = vec3(pos), radius = radius, name = name})
end
local alpha = (drawMode == 'normal') and 0.5 or 1
local textPos = vec3()
if self.mode == 'waypoint' then
local ab = (a.pos-b.pos):normalized()
ab = vec3(ab.y, -ab.x, 0):normalized()
debugDrawer:drawSquarePrism(
debugDrawer:drawSquarePrism(
vec3(a.pos+ab*a.radius),
vec3(b.pos+ab*b.radius),
vec3(a.pos+ab*a.radius),
vec3(b.pos+ab*b.radius),
Point2F(2,0.1),
debugDrawer:drawSquarePrism(
vec3(a.pos-ab*a.radius),
vec3(b.pos-ab*b.radius),
vec3(a.pos-ab*a.radius),
vec3(b.pos-ab*b.radius),
Point2F(2,0.1),
@/lua/vehicle/extensions/vehiclePerformanceData.lua
local avgWheelPos = vec3(0, 0, 0)
for _, wd in pairs(wheels.wheels) do
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorRight = vectorForward:cross(vectorUp) --vector facing to the right
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos) --vector facing forward
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorRight = vectorForward:cross(vectorUp) --vector facing to the right
if wd.isPropulsed then
local wheelNodePos = vec3(v.data.nodes[wd.node1].pos) --find the wheel position
local wheelVector = wheelNodePos - avgWheelPos --create a vector from our "center" to the wheel
@/lua/ge/extensions/editor/raceEditor/pacenotes.lua
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
local q = quatFromDir(note.normal, vec3(0,0,1))
rotation = QuatF(q.x, q.y, q.z, q.w)
if note.normal then
self.beginDragRotation = deepcopy(quatFromDir(note.normal, vec3(0,0,1)))
end
note.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
note.normal = quat(rotation)*vec3(0,1,0)
else
else
note.normal = self.beginDragRotation * quat(rotation)*vec3(0,1,0)
end
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
if scl.x ~= 1 then
local txt = "Add manual Pacenote (Drag for Size)"
debugDrawer:drawTextAdvanced(vec3(self.mouseInfo.rayCast.pos), String(txt), ColorF(1,1,1,1),true, false, ColorI(0,0,0,255))
if self.mouseInfo.hold then
editor.history:commitAction("Change note Position",
{index = self.index, old = note.pos, new = vec3(pacenotePosition[0], pacenotePosition[1], pacenotePosition[2]), field = 'pos', self = self},
setFieldUndo, setFieldRedo)
editor.history:commitAction("Drop Note to Ground",
{index = self.index, old = note.pos,self = self, new = vec3(pacenotePosition[0], pacenotePosition[1], core_terrain.getTerrainHeight(note.pos)), field = 'pos'},
setFieldUndo, setFieldRedo)
editor.history:commitAction("Change Normal",
{index = self.index, old = note.normal, self = self, new = vec3(pacenoteNormal[0], pacenoteNormal[1], pacenoteNormal[2])},
setNormalUndo, setNormalRedo)
local normalTip = note.pos + note.normal*note.radius
normalTip = vec3(normalTip.x, normalTip.y, core_terrain.getTerrainHeight(normalTip))
editor.history:commitAction("Align Normal with Terrain",
@/lua/ge/extensions/core/couplerCameraModifier.lua
local ref = vec3(obj1refNodePos)
local left = vec3(obj1leftNodePos)
local ref = vec3(obj1refNodePos)
local left = vec3(obj1leftNodePos)
local back = vec3(obj1backNodePos)
local left = vec3(obj1leftNodePos)
local back = vec3(obj1backNodePos)
local offset = core_camera.getCameraDataById(objId1).orbit.offset
local camBase = vec3(offset.x / nx:length(), offset.y / ny:length(), offset.z / nz:length())
local camOffset2 = nx * camBase.x + ny * camBase.y + nz * camBase.z
ref = vec3(obj2refNodePos)
left = vec3(obj2leftNodePos)
ref = vec3(obj2refNodePos)
left = vec3(obj2leftNodePos)
back = vec3(obj2backNodePos)
left = vec3(obj2leftNodePos)
back = vec3(obj2backNodePos)
offset = core_camera.getCameraDataById(objId2).orbit.offset
camBase = vec3(offset.x / nx:length(), offset.y / ny:length(), offset.z / nz:length())
camOffset2 = nx * camBase.x + ny * camBase.y + nz * camBase.z
@/lua/ge/extensions/scenario/raceMarkers/sideColumnMarker.lua
local zVec = vec3(0,0,1)
-- todo: replace this by a HSV-lerp if blending with non-gray colors
local lerpedColor = vec3()
local function lerpColor(a,b,t)
-- called every frame to update the visuals.
local playerPosition = vec3(0,0,0)
local scale = vec3()
local playerPosition = vec3(0,0,0)
local scale = vec3()
local markerOffset = vec3(0,0,-10)
local scale = vec3()
local markerOffset = vec3(0,0,-10)
function C:update(dt, dtSim)
end
base:setScale(vec3(self.radius, self.radius, baseHeight))
base:updateInstanceRenderData()
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
self.radius = wp.radius
self.radius = wp.radius
self.normal = wp.normal and vec3(wp.normal) or nil
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.normal = wp.normal and vec3(wp.normal) or nil
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.normal = wp.normal and vec3(wp.normal) or nil
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
if base then
base:setPosition(vec3(self.pos))
base:setScale(vec3(self.radius, self.radius, self.radius))
base:setPosition(vec3(self.pos))
base:setScale(vec3(self.radius, self.radius, self.radius))
end
if left then
left:setPosition(vec3(self.pos - self.side * self.radius))
left:setScale(vec3(1,1,1))
left:setPosition(vec3(self.pos - self.side * self.radius))
left:setScale(vec3(1,1,1))
end
if right then
right:setPosition(vec3(self.pos + self.side * self.radius))
right:setScale(vec3(1,1,1))
right:setPosition(vec3(self.pos + self.side * self.radius))
right:setScale(vec3(1,1,1))
end
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
@/lua/ge/extensions/trackbuilder/trackBuilder.lua
local lastPoint = tb.getSegmentInfo(pieceCount, sub).points[#tb.getSegmentInfo(pieceCount, sub).points]
local inter = lastPoint.position + vec3(0,0,lastPoint.zOffset)
+ lastPoint.orientation.ny*(addSubtrackParams.distance[0] )
+ lastPoint.orientation.ny*(addSubtrackParams.distance[0] )
local center = lastPoint.position + vec3(0,0,lastPoint.zOffset)
+ lastPoint.orientation.ny*(addSubtrackParams.distance[0] + addSubtrackParams.radius[0])
debugDrawer:drawSphere(center, 1, ColorF(1, 0, 0, 1))
debugDrawer:drawLine((lastPoint.position + vec3(0,0,lastPoint.zOffset)), inter,ColorF(1, 1, 0, 1))
debugDrawer:drawLine(center, inter,ColorF(1, 0, 0, 1))
local nx = vec3(lastPoint.orientation.nx.x*math.cos(p)- lastPoint.orientation.nx.y * math.sin(p),
lastPoint.orientation.nx.y*math.cos(p)+ lastPoint.orientation.nx.x * math.sin(p),0)
lastPoint.orientation.nx.y*math.cos(p)+ lastPoint.orientation.nx.x * math.sin(p),0)
local ny = vec3(lastPoint.orientation.ny.x*math.cos(p)- lastPoint.orientation.ny.y * math.sin(p),
lastPoint.orientation.ny.y*math.cos(p)+ lastPoint.orientation.ny.x * math.sin(p),0)
local nx = vec3(lastPoint.orientation.nx.x*math.cos(p)- lastPoint.orientation.nx.y * math.sin(p),
lastPoint.orientation.nx.y*math.cos(p)+ lastPoint.orientation.nx.x * math.sin(p),0)
lastPoint.orientation.nx.y*math.cos(p)+ lastPoint.orientation.nx.x * math.sin(p),0)
local ny = vec3(lastPoint.orientation.ny.x*math.cos(p)- lastPoint.orientation.ny.y * math.sin(p),
lastPoint.orientation.ny.y*math.cos(p)+ lastPoint.orientation.ny.x * math.sin(p),0)
if seg.reverse then
debugDrawer:drawSphere((seg.segment.points[1].position + (vec3(0,0,seg.segment.points[1].zOffset))), 3, ColorF(1, 0, 0, 0.75))
else
else
debugDrawer:drawSphere((seg.segment.points[#seg.segment.points].position + (vec3(0,0,seg.segment.points[#seg.segment.points].zOffset))), 3, ColorF(1, 0, 0, 0.75))
end
if res and res.pos and not im.GetIO().WantCaptureMouse then
res.pos = vec3(res.pos)
--debugDrawer:drawSphere(res.pos, 0.6, ColorF(1,0,0,0.5))
if res and res.pos and not im.GetIO().WantCaptureMouse then
res.pos = vec3(res.pos)
-- debugDrawer:drawSphere(res.pos, 0.3, ColorF(1,0,0,0.5))
variant = obstacleInfo[obstaclesTbl[o.value[0]+1]].variants and o.variant[0] or 1,
position = vec3(o.position[0],o.position[1],o.position[2]),
scale = vec3(o.scale[0],o.scale[1],o.scale[2]),
position = vec3(o.position[0],o.position[1],o.position[2]),
scale = vec3(o.scale[0],o.scale[1],o.scale[2]),
extra = vec3(o.extra[0],o.extra[1],o.extra[2]),
scale = vec3(o.scale[0],o.scale[1],o.scale[2]),
extra = vec3(o.extra[0],o.extra[1],o.extra[2]),
rotation = quatFromEuler(o.rotation[0]/180 * math.pi,o.rotation[1]/180 * math.pi,(o.rotation[2])/180 * math.pi),
rotation = quatFromEuler(o.rotation[0]/180 * math.pi,o.rotation[1]/180 * math.pi,(o.rotation[2])/180 * math.pi),
rotationEuler = vec3(o.rotation[0],o.rotation[1],o.rotation[2]),
offset = o.offset[0],
@/lua/ge/extensions/editor/sceneTree.lua
local bboxCenter = vec3(0, 0, 0)
@/lua/ge/extensions/editor/biomeTool.lua
if not endPoint then
endPoint = startPoint - vec3(0,0,100)
end
end
local res = Engine.castRay((startPoint + vec3(0,0,1)), endPoint, true, false)
if not res then
if not res then
res = Engine.castRay((startPoint + vec3(0,0,100)), (startPoint - vec3(0,0,1000)), true, false)
end
if not res then
res = Engine.castRay((startPoint + vec3(0,0,100)), (startPoint - vec3(0,0,1000)), true, false)
end
local function drawLassoLineSegmented(originNode, targetNode, lassoAreaType, color)
originNode.pos = vec3(originNode.pos.x, originNode.pos.y, originNode.pos.z)
targetNode.pos = vec3(targetNode.pos.x, targetNode.pos.y, targetNode.pos.z)
originNode.pos = vec3(originNode.pos.x, originNode.pos.y, originNode.pos.z)
targetNode.pos = vec3(targetNode.pos.x, targetNode.pos.y, targetNode.pos.z)
local length = (originNode.pos - targetNode.pos):length()
@/lua/ge/extensions/editor/sitesEditor/sortedListDisplay.lua
if editEnded[0] then
self:setField('color', vec3(self.color[0], self.color[1], self.color[2]))
end
local tbl = { self.fields[name][0], self.fields[name][1], self.fields[name][2] }
fields.values[name] = vec3(tbl)
end
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veAeroDebug.lua
-- window
local wind = vec3(0,0,0)
if im.Begin(wndName, windowOpen) then
@/lua/ge/extensions/editor/gen/terrain.lua
if v then
v = vec3(v.x,v.y,v.z)
if not keepz then
local function grid2p(ij)
return vec3(tfr.x + (ij[2]-1)*grid, tfr.y + (ij[1]-1)*grid)
end
for j=ifr,ito do
tb:setMaterialIdxWs(vec3(i,j), 7)
end
end
tb:updateGridMaterials(vec3(ifr,ito,0), vec3(ifr,ito,0))
tb:updateGrid()
end
tb:updateGridMaterials(vec3(ifr,ito,0), vec3(ifr,ito,0))
tb:updateGrid()
]]
lo('<< Ter.clear:'..tostring(tb:getMaterialIdxWs(vec3(1,1))))
end
for i=1,nw do
list[#list+1] = {vec3(
math.random(1,tersize.x),
local function toWorld(j,i)
return vec3(c.x+(j-iR)*grid,c.y+(i-iR)*grid)
end
aregion = {
{p=vec3(-80.86,-1760.73), w=0.968},
{p=vec3(-266.25,-1648.27), w=0.968},
{p=vec3(-80.86,-1760.73), w=0.968},
{p=vec3(-266.25,-1648.27), w=0.968},
{p=vec3(-106.34,-1530.07), w=1.065},
{p=vec3(-266.25,-1648.27), w=0.968},
{p=vec3(-106.34,-1530.07), w=1.065},
}
aregion = {
{p=vec3(-3.17,-1084.04), w=1},
{p=vec3(-75.42,-962.44), w=1},
{p=vec3(-3.17,-1084.04), w=1},
{p=vec3(-75.42,-962.44), w=1},
{p=vec3(182.18,-1095.08), w=1},
{p=vec3(-75.42,-962.44), w=1},
{p=vec3(182.18,-1095.08), w=1},
}
aregion = {
{p=2*vec3(-91,-909),w=1},
{p=2*vec3(-99,-855),w=1},
{p=2*vec3(-91,-909),w=1},
{p=2*vec3(-99,-855),w=1},
{p=2*vec3(-39,-874),w=1},
{p=2*vec3(-99,-855),w=1},
{p=2*vec3(-39,-874),w=1},
{p=2*vec3(-67,-878),w=1},
{p=2*vec3(-39,-874),w=1},
{p=2*vec3(-67,-878),w=1},
}
local afill = {}
c = vec3(0,0,0)
local ap = {}
local p = toWorld(j,i) --c.x+(j-iR)*grid,c.y+(i-iR)*grid
-- ap[#ap+1] = vec3(x,y)
local wma,ima,pma = 0
-- pick strongest
local dist = p:distance(vec3(d.p.x,d.p.y))
local w = d.w/dist
-- ap[#ap+1] = p
-- if pma:distance(vec3(c.x,c.y)) < R then
-- lo('?? to_mm:'..i..':'..j..':'..tostring(ima)..':'..tostring(pma))
for _,p in pairs(list) do
aregion[i].amark[#aregion[i].amark+1] = p+vec3(0,0,forZ(p))
end
-- local p,s =
local p,s = U.lineHit({n.p, n.p+dir}, {vec3(0,0,0), dnorm})
-- local p,s = U.line2seg(n, n+dir, vec3(0,0,0), dnorm)
local p,s = U.lineHit({n.p, n.p+dir}, {vec3(0,0,0), dnorm})
-- local p,s = U.line2seg(n, n+dir, vec3(0,0,0), dnorm)
-- lo('?? regionSlice:'..tostring(s)..':'..tostring(n)..':'..tostring(n+dir)..':'..tostring(dnorm))
if not dnode[stamp] then dnode[stamp] = {{},{}} end
local v = vec3(j,i)
local ord = 1
end
dnode[stamp][ord][#dnode[stamp][ord]+1] = vec3(j,i)
-- U.dump(ari, '?? for_cross:')
if #seg[i] > 0 then
local p = vec3(0,0,0)
for _,e in pairs(seg[i]) do
table.sort(r.star, function(a, b)
return U.vang(anode[a].p-r.p,vec3(1,0), true) > U.vang(anode[b].p-r.p,vec3(1,0), true)
end)
table.sort(r.star, function(a, b)
return U.vang(anode[a].p-r.p,vec3(1,0), true) > U.vang(anode[b].p-r.p,vec3(1,0), true)
end)
for _,k in pairs(r.star) do
lo('?? for_ang:'..k..':'..U.vang(anode[k].p-r.p, vec3(1,0),true))
end
b.list[#b.list-1] - b.list[#b.list]):normalized()
return U.vang(dira,vec3(1,0),true) > U.vang(dirb,vec3(1,0),true)
end)
b.list[#b.list-1] - b.list[#b.list]):normalized()
return U.vang(dira,vec3(1,0),true) > U.vang(dirb,vec3(1,0),true)
end)
for i,d in pairs(aregion) do
d.p = vec3(d.p.x,d.p.y)
d.p.z = forZ(d.p)
for i,d in pairs(aregion) do
d.p = vec3(d.p.x,d.p.y)
aregion[i] = {p=d.p, w=d.w}
@/lua/ge/extensions/editor/drivePathEditor/splineMgr.lua
local abs, min, max = math.abs, math.min, math.max
local globalUp = vec3(0, 0, 1)
local tmpPoint2I = Point2I(0, 0)
local tmp1 = vec3()
local tmpRot = quat()
for i = 1, numNodes do
copyNodes[i] = vec3(splineNodes[i])
end
for i = 1, numNmls do
copyNmls[i] = vec3(splineNmls[i])
end
for i = selectedNodeIdx, numNodes do
nodesNew[ctr] = vec3(splineNodes[i])
widthsNew[ctr] = splineWidths[i]
widthsNew[ctr] = splineWidths[i]
nmlsNew[ctr] = vec3(splineNmls[i])
velsNew[ctr] = splineVels[i]
for i = 1, selectedNodeIdx - 1 do
nodesNew[ctr] = vec3(splineNodes[i])
widthsNew[ctr] = splineWidths[i]
widthsNew[ctr] = splineWidths[i]
nmlsNew[ctr] = vec3(splineNmls[i])
velsNew[ctr] = splineVels[i]
for i = #n2, 1, -1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v2[i], vl2[i], g2[i]
for i = #n2, 1, -1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v2[i], vl2[i], g2[i]
for i = 2, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v1[i], vl1[i], g1[i]
for i = 2, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v1[i], vl1[i], g1[i]
for i = 1, #n2 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v2[i], vl2[i], g2[i]
for i = 1, #n2 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v2[i], vl2[i], g2[i]
for i = 2, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v1[i], vl1[i], g1[i]
for i = 2, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v1[i], vl1[i], g1[i]
for i = 1, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v1[i], vl1[i], g1[i]
for i = 1, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v1[i], vl1[i], g1[i]
for i = 2, #n2 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v2[i], vl2[i], g2[i]
for i = 2, #n2 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v2[i], vl2[i], g2[i]
for i = 1, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v1[i], vl1[i], g1[i]
for i = 1, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v1[i], vl1[i], g1[i]
for i = #n2 - 1, 1, -1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v2[i], vl2[i], g2[i]
for i = #n2 - 1, 1, -1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
velsNew[ctr], velLimitsNew[ctr], graphNodesNew[ctr] = v2[i], vl2[i], g2[i]
if not cachedVehiclePoses[vehicle.vid] then
cachedVehiclePoses[vehicle.vid] = { pos = vec3(veh:getPosition()), rot = quat(veh:getRotation()) }
end
if not cachedVehiclePoses[vehicle.vid] then
cachedVehiclePoses[vehicle.vid] = { pos = vec3(veh:getPosition()), rot = quat(veh:getRotation()) }
end
local n = splineNodes[i]
copyNodes[i] = vec3(n.x, n.y, n.z)
end
local n = nmls[i]
copyNmls[i] = vec3(n.x, n.y, n.z)
end
@/lua/ge/extensions/scenario/raceMarkers/cylinderMarker.lua
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
self.radius = wp.radius
if self.base then
self.base:setPosition(vec3(self.pos))
self.base:setScale(vec3(self.radius*2, self.radius*2, self.radius*2))
self.base:setPosition(vec3(self.pos))
self.base:setScale(vec3(self.radius*2, self.radius*2, self.radius*2))
end
if self.cylinder then
self.cylinder:setPosition(vec3(self.pos))
self.cylinder:setScale(vec3(self.radius, self.radius, 50))
self.cylinder:setPosition(vec3(self.pos))
self.cylinder:setScale(vec3(self.radius, self.radius, 50))
end
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
@/lua/ge/extensions/core/multiseatCamera.lua
local lastLocation = vec3(0, 0, 0);
local i = 0
local meanLocation = vec3(0, 0, 0)
local meanDirection = vec3(0, 0, 0)
local meanLocation = vec3(0, 0, 0)
local meanDirection = vec3(0, 0, 0)
local maxDistance = 0
local maxDistance = 0
local pos = vec3(0, 0, 0)
local plvehicles = tableValuesAsLookupDict(extensions.core_input_bindings.getAssignedPlayers())
local left = vec3(-meanDirection.y, meanDirection.x, targetCenter.z)
local back = vec3(meanDirection.x, -meanDirection.y, targetCenter.z)
local left = vec3(-meanDirection.y, meanDirection.x, targetCenter.z)
local back = vec3(meanDirection.x, -meanDirection.y, targetCenter.z)
local vid = be:getPlayerVehicleID(0)
core_camera.setTargetMode(vid, 'notCenter', vec3(0, 0, 0))
core_camera.setDistance(vid, maxDistance)
@/lua/vehicle/extensions/advancedwheeldebug.lua
--local centerPos = vec3()
local surfaceUp = vec3()
local count = 0
@/lua/ge/extensions/editor/dragRaceEditor/lanes.lua
-- Draw lane preview
debugDrawer:drawTextAdvanced(vec3(0, 0, 0), String("Lane: " .. lane.name), constants.CONSTANTS.COLORS.WHITE, true, false, constants.CONSTANTS.COLORS.BLACK)
end
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/gameplay/traffic/baseRole.lua
if targetVeh then
visible = self.veh:checkRayCast(targetVeh.pos + vec3(0, 0, 1))
end
@/lua/ge/extensions/editor/sitesEditor/locations.lua
function C:beginDrag()
self._beginDragPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
self._beginDragRadius = math.max(0.1, self.current.radius)
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
self.current.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
if scl.x ~= 1 then
function C:endDragging()
local old = {pos = vec3(self._beginDragPos), radius = self._beginDragRadius}
local new = {pos = vec3(self.current.pos), radius = self.current.radius}
local old = {pos = vec3(self._beginDragPos), radius = self._beginDragRadius}
local new = {pos = vec3(self.current.pos), radius = self.current.radius}
editor.history:commitAction("Update Transform of "..self.current.name,
@/lua/ge/extensions/editor/aiTests.lua
if im.Button("Camera##"..marker.objectName) then
marker:set(core_camera.getPosition() - vec3(0, 0, 1))
change = true
local clr = rainbowColor(#route.path, i, 1)
local pos = vec3(point.pos)
debugDrawer:drawSphere(pos, 1, ColorF(clr[1], clr[2], clr[3], 0.6))
if i > 1 then
debugDrawer:drawSquarePrism(pos, vec3(route.path[i-1].pos), Point2F(2, 0.5), Point2F(2, 0.5), ColorF(clr[1], clr[2], clr[3], 0.4))
end
if routeTracking then
route:trackPosition(route.path[1] and route.path[1].pos or vec3())
routeTracking = false
@/lua/ge/extensions/gameplay/drift/stuntZones.lua
texture = defaultDecalPath,
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
color = ColorF(1, 0, 0, 1 ),
color = ColorF(1, 0, 0, 1 ),
scale = vec3(1, 1, 4),
fadeStart = 100,
local result
local pos = vec3()
M.setStuntZones({
{type = "donut", cooldown = 8, pos = pos + vec3(10, 0, 0), scl = 10},
{type = "donut", cooldown = 8, pos = pos + vec3(30, 0, 0), scl = 10},
{type = "donut", cooldown = 8, pos = pos + vec3(10, 0, 0), scl = 10},
{type = "donut", cooldown = 8, pos = pos + vec3(30, 0, 0), scl = 10},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},
{type = "donut", cooldown = 8, pos = pos + vec3(30, 0, 0), scl = 10},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 29, 0), scl = vec3(8, 1, 1)},
{type = "donut", cooldown = 8, pos = pos + vec3(30, 0, 0), scl = 10},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 29, 0), scl = vec3(8, 1, 1)},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 29, 0), scl = vec3(8, 1, 1)},
{type = "hitPole", pos = pos + vec3(-10, 0, 0)},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 29, 0), scl = vec3(8, 1, 1)},
{type = "hitPole", pos = pos + vec3(-10, 0, 0)},
{type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 29, 0), scl = vec3(8, 1, 1)},
{type = "hitPole", pos = pos + vec3(-10, 0, 0)},
{type = "hitPole", pos = pos + vec3(-15, 0, 0)},
{type = "hitPole", pos = pos + vec3(-10, 0, 0)},
{type = "hitPole", pos = pos + vec3(-15, 0, 0)},
{type = "nearPole", pos = pos + vec3(-10, 20, 0)},
{type = "hitPole", pos = pos + vec3(-15, 0, 0)},
{type = "nearPole", pos = pos + vec3(-10, 20, 0)},
{type = "nearPole", pos = pos + vec3(-15, 20, 0)}
{type = "nearPole", pos = pos + vec3(-10, 20, 0)},
{type = "nearPole", pos = pos + vec3(-15, 20, 0)}
})
for i = 1, benchmarkCount[0], 1 do
table.insert(tempStuntZones, {type = "donut", cooldown = 8, pos = pos + vec3(0, i * 20.5, 0), scl = 10})
end
for i = 1, benchmarkCount[0], 1 do
table.insert(tempStuntZones, {type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(0, i * 10, 0), scl = vec3(8, 1, 1)})
end
for i = 1, benchmarkCount[0], 1 do
table.insert(tempStuntZones, {type = "driftThrough", cooldown = 8, rot = quat(0, 0, 0, 1), pos = pos + vec3(0, i * 10, 0), scl = vec3(8, 1, 1)})
end
for i = 1, benchmarkCount[0], 1 do
table.insert(tempStuntZones,{type = "hitPole", pos = pos + vec3(0, i * 10, 0)})
end
for i = 1, benchmarkCount[0], 1 do
table.insert(tempStuntZones, {type = "nearPole", pos = pos + vec3(20, i * 10, 0)})
end
local function onUpdate(dtReal, dtSim, dtRaw)
pos:set(gameplay_drift_drift.getVehPos() or vec3(0,0,0))
elseif stuntZone.type == "driftThrough" then
createdStuntZone.x = stuntZone.rot* vec3(stuntZone.scl.x,0,0)
createdStuntZone.y = stuntZone.rot * vec3(0,stuntZone.scl.y,0)
createdStuntZone.x = stuntZone.rot* vec3(stuntZone.scl.x,0,0)
createdStuntZone.y = stuntZone.rot * vec3(0,stuntZone.scl.y,0)
createdStuntZone.z = stuntZone.rot * vec3(0,0,stuntZone.scl.z)
createdStuntZone.y = stuntZone.rot * vec3(0,stuntZone.scl.y,0)
createdStuntZone.z = stuntZone.rot * vec3(0,0,stuntZone.scl.z)
@/gameplay/missionTypes/targetjump/editor.lua
self:addDecoText("Where will the jump off point be? Place it slightly after the ramp.")
self:addTransform("Jump off", "jumpOff", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "halfBox", drawColor = {0,0,1,0.3}})
self:addDecoText("How should gravity behave ?")
self:addDecoText("The player will fail the mission if they leave this volume.")
self:addTransform("Mission Bounding Box", "bounds", {hasPos = true, hasRot = true, defaultScl = vec3(200,40,15)},{drawMode = "halfBox", drawColor = {1,0,0,0.1}})
@/lua/ge/extensions/editor/sidewalkSpline/kit.lua
local _, pos = obj:getNodeTransform(anchorName)
anchors[anchorId] = vec3(pos)
end
@/lua/ge/extensions/util/procTrack.lua
local pos = M.getPosition(n.points[pIndex].x + (off.x)*3, n.points[pIndex].y +(off.y)*3,0)
scenario.nodes['gym_'..i].pos = vec3(pos.x,pos.y,pos.z)
scenario.nodes['gym_'..i].radius = 7
scenario.nodes['gym_'..i].rot = vec3(nvRot.x,nvRot.y,0)
local checkPoint = createObject('BeamNGWaypoint')
checkPoint:setPosition(vec3(pos.x,pos.y,pos.z))
checkPoint.scale = vec3(scenario.nodes['gym_'..i].radius,scenario.nodes['gym_'..i].radius,scenario.nodes['gym_'..i].radius)
checkPoint:setPosition(vec3(pos.x,pos.y,pos.z))
checkPoint.scale = vec3(scenario.nodes['gym_'..i].radius,scenario.nodes['gym_'..i].radius,scenario.nodes['gym_'..i].radius)
local quat = quatFromEuler(0,0,-math.atan2(nvRot.y, nvRot.x)):toTorqueQuat()
pos = vec3(pos.x,pos.y,pos.z + .5)
--pos = pos
--pos = pos
rot = quatFromDir(vec3(-rot.x,-rot.y))
scenario.startingTransforms['scenario_player0'].pos = pos
@/lua/ge/extensions/gameplay/drift/stuntZones/hitPole.lua
function C:createMarker()
local markerOffset = vec3(0, 0, 2.5)
if self.activeData.veh then
@/lua/ge/extensions/scenario/raceMarkers/sideMarker.lua
local playerPosition = vec3(0,0,0)
-- Should always be facing the camera
local sideSize = lerp(1*self.radius,sideToDistantRatio, smootherstep(distantFade))
self.sides:setScale(vec3(self.radius, self.radius, self.radius))
if distanceFromMarker > self.radius*1.5 then
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
self.radius = wp.radius
self.radius = wp.radius
self.normal = wp.normal and vec3(wp.normal) or nil
if self.base then
self.base:setPosition(vec3(self.pos))
self.base:setScale(vec3(self.radius, self.radius, self.radius))
self.base:setPosition(vec3(self.pos))
self.base:setScale(vec3(self.radius, self.radius, self.radius))
end
if self.sides then
self.sides:setPosition(vec3(self.pos))
self.sides:preApply()
self.sides:postApply()
self.sides:setScale(vec3(self.radius, self.radius, self.radius))
end
if self.distant then
self.distant:setPosition(vec3(self.pos))
self.distant:setScale(vec3(self.radius, self.radius, self.radius))
self.distant:setPosition(vec3(self.pos))
self.distant:setScale(vec3(self.radius, self.radius, self.radius))
end
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
@/lua/vehicle/controller/drivingDynamics/sensors/virtualSensors.lua
-- offset from reference node(where the accelerations are measured) to vehicle center of gravity
local offsetRefNodeFromCoG = vec3(0, 0, 0)
local refNodeCoGTransformationLastOmega = vec3(0, 0, 0)
local refNodeCoGTransformationOmega = vec3(0, 0, 0)
local refNodeCoGTransformationLastOmega = vec3(0, 0, 0)
local refNodeCoGTransformationOmega = vec3(0, 0, 0)
local refNodeCoGTransformationAlpha = vec3(0, 0, 0)
local refNodeCoGTransformationOmega = vec3(0, 0, 0)
local refNodeCoGTransformationAlpha = vec3(0, 0, 0)
local refNodeCoGTransformationAccRefNode = vec3(0, 0, 0)
local refNodeCoGTransformationAlpha = vec3(0, 0, 0)
local refNodeCoGTransformationAccRefNode = vec3(0, 0, 0)
local refNodeCoGTransformationAccCoG = vec3(0, 0, 0)
local refNodeCoGTransformationAccRefNode = vec3(0, 0, 0)
local refNodeCoGTransformationAccCoG = vec3(0, 0, 0)
@/lua/ge/extensions/editor/dynamicDecals/gizmo.lua
local cubePoints = {
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
local cubePoints = {
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
local cubePoints = {
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
local cubePoints = {
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
}
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
}
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
}
vec3(-0.5, -0.5, -0.5), vec3(-0.5, -0.5, 0.5), vec3(-0.5, 0.5, -0.5), vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5), vec3(0.5, -0.5, 0.5), vec3(0.5, 0.5, -0.5), vec3(0.5, 0.5, 0.5)
}
@/lua/ge/extensions/core/vehicle/inplaceEdit.lua
local function text(txt)
debugDrawer:drawTextAdvanced(vec3(0,y,0), txt, consoleTextCol, false, true, consoleTextBgCol)
y = y + 14
@/lua/ge/extensions/gameplay/rally/notebook/pacenoteWaypoint.lua
self.normal = vec3(0,1,0)
self.pos = pos
self.mode = "manual"
self.pos = vec3(pos)
self.radius = radius
if not normal then
self.normal = vec3(0,1,0)
end
self.name = data.name
self:setManual(vec3(data.pos), data.radius, vec3(data.normal))
end
self.name = data.name
self:setManual(vec3(data.pos), data.radius, vec3(data.normal))
end
local midWidth = plane_radius * 2
local side = self.normal:cross(vec3(0,0,1)) * (plane_radius - (midWidth / 2))
local width = self.radius * 2
local side = self.normal:cross(vec3(0,0,1)) * (self.radius - (width / 2))
debugDrawer:drawTextAdvanced(
self.pos + (vec3(0,0,height/2)),
String(noteText),
debugDrawer:drawCylinder(
self.pos + (self.normal:cross(vec3(0,0,1)) * self.radius) + vec3(0,0,-1),
self.pos + (self.normal:cross(vec3(0,0,1)) * self.radius) + (side + vec3(0, 0, (height/2)-radius_cyl)),
debugDrawer:drawCylinder(
self.pos + (self.normal:cross(vec3(0,0,1)) * self.radius) + vec3(0,0,-1),
self.pos + (self.normal:cross(vec3(0,0,1)) * self.radius) + (side + vec3(0, 0, (height/2)-radius_cyl)),
self.pos + (self.normal:cross(vec3(0,0,1)) * self.radius) + vec3(0,0,-1),
self.pos + (self.normal:cross(vec3(0,0,1)) * self.radius) + (side + vec3(0, 0, (height/2)-radius_cyl)),
radius_cyl,
self.pos + (self.normal:cross(vec3(0,0,1)) * self.radius) + vec3(0,0,-1),
self.pos + (self.normal:cross(vec3(0,0,1)) * self.radius) + (side + vec3(0, 0, (height/2)-radius_cyl)),
radius_cyl,
debugDrawer:drawCylinder(
self.pos + (-self.normal:cross(vec3(0,0,1)) * self.radius) + vec3(0,0,-1), -- adjust down through the ground in case the ground is uneven
self.pos + (-self.normal:cross(vec3(0,0,1)) * self.radius) + (side + vec3(0, 0, (height/2)-radius_cyl)),
debugDrawer:drawCylinder(
self.pos + (-self.normal:cross(vec3(0,0,1)) * self.radius) + vec3(0,0,-1), -- adjust down through the ground in case the ground is uneven
self.pos + (-self.normal:cross(vec3(0,0,1)) * self.radius) + (side + vec3(0, 0, (height/2)-radius_cyl)),
self.pos + (-self.normal:cross(vec3(0,0,1)) * self.radius) + vec3(0,0,-1), -- adjust down through the ground in case the ground is uneven
self.pos + (-self.normal:cross(vec3(0,0,1)) * self.radius) + (side + vec3(0, 0, (height/2)-radius_cyl)),
radius_cyl,
self.pos + (-self.normal:cross(vec3(0,0,1)) * self.radius) + vec3(0,0,-1), -- adjust down through the ground in case the ground is uneven
self.pos + (-self.normal:cross(vec3(0,0,1)) * self.radius) + (side + vec3(0, 0, (height/2)-radius_cyl)),
radius_cyl,
debugDrawer:drawCylinder(
self.pos + (self.normal:cross(vec3(0,0,1)) * (self.radius+radius_cyl)) + (side + vec3(0, 0, height/2)),
self.pos + (-self.normal:cross(vec3(0,0,1)) * (self.radius+radius_cyl)) + (side + vec3(0, 0, height/2)),
debugDrawer:drawCylinder(
self.pos + (self.normal:cross(vec3(0,0,1)) * (self.radius+radius_cyl)) + (side + vec3(0, 0, height/2)),
self.pos + (-self.normal:cross(vec3(0,0,1)) * (self.radius+radius_cyl)) + (side + vec3(0, 0, height/2)),
self.pos + (self.normal:cross(vec3(0,0,1)) * (self.radius+radius_cyl)) + (side + vec3(0, 0, height/2)),
self.pos + (-self.normal:cross(vec3(0,0,1)) * (self.radius+radius_cyl)) + (side + vec3(0, 0, height/2)),
radius_cyl,
self.pos + (self.normal:cross(vec3(0,0,1)) * (self.radius+radius_cyl)) + (side + vec3(0, 0, height/2)),
self.pos + (-self.normal:cross(vec3(0,0,1)) * (self.radius+radius_cyl)) + (side + vec3(0, 0, height/2)),
radius_cyl,
@/gameplay/missionTypes/collection/customNodes/collectionNode.lua
self.pinOut.hasRecovery.value = self.currentRecovery ~= nil
self.pinOut.recoveryPos.value = (self.currentRecovery and self.currentRecovery.pos or vec3()):toTable()
self.pinOut.recoveryRot.value = (self.currentRecovery and self.currentRecovery.rot or quat()):toTable()
@/gameplay/missions/automation_test_track/flowgraph/001-Dam/customNodes/getClosestStaticObjectNode.lua
function C:init()
self.pos = vec3()
end
@/lua/ge/extensions/tech/openDriveExporter.lua
for k, p in pairs(coords3d) do
coords2d[k] = vec3(p.x, p.y, 0.0)
end
local function fitCubic(p0, p1, p2, p3, length)
local tangents = computeTangents(p0 - p1, vec3(0.0, 0.0, 0.0), p2 - p1, p3 - p1)
local t1, t2 = tangents['t1'], tangents['t2']
local p1_2d = coords2d[seg1]
local pn0_2d, pn1_2d, pn2_2d, pn3_2d = coords2d[seg0] - p1_2d, vec3(0.0, 0.0, 0.0), coords2d[seg2] - p1_2d, coords2d[seg3] - p1_2d
local geodesicLength2d = pn1_2d:distance(pn2_2d)
local widthCubic = fitCubic(
vec3(coords3d[seg0].x, coords3d[seg0].y, widths[seg0]),
vec3(coords3d[seg1].x, coords3d[seg1].y, widths[seg1]),
vec3(coords3d[seg0].x, coords3d[seg0].y, widths[seg0]),
vec3(coords3d[seg1].x, coords3d[seg1].y, widths[seg1]),
vec3(coords3d[seg2].x, coords3d[seg2].y, widths[seg2]),
vec3(coords3d[seg1].x, coords3d[seg1].y, widths[seg1]),
vec3(coords3d[seg2].x, coords3d[seg2].y, widths[seg2]),
vec3(coords3d[seg3].x, coords3d[seg3].y, widths[seg3]),
vec3(coords3d[seg2].x, coords3d[seg2].y, widths[seg2]),
vec3(coords3d[seg3].x, coords3d[seg3].y, widths[seg3]),
geodesicLength2d)
@/lua/ge/extensions/gameplay/markers/walkingMarker.lua
local markerIndexCorrection = { { 3, 4, 2, 1 }, { 1, 2, 4, 3 } }
local vecZero = vec3(0,0,0)
local vecOne = vec3(1,1,1)
local vecZero = vec3(0,0,0)
local vecOne = vec3(1,1,1)
local quatZero = quat(0,0,0,0)
local quatZero = quat(0,0,0,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local lineColorF = ColorF(1,1,1,1)
local iconWorldSize = 20
local tmpVec = vec3()
local maxVisibleDistance = 15
if screenObjTemp then
Engine.Audio.playOnce('AudioGui','event:>UI>Career>Computer', {position = vec3(self.pos.x, self.pos.y, self.pos.z)})
end
--lineColorF.a = area.iconAlphaSmoother:value()
debugDrawer:drawLine(area.iconPos + vec3(0,0,self.iconOffsetHeight - smootherVal * self.iconOffsetHeight), tmpVec, lineColorF)
end
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/tech/adasUltrasonic.lua
rear = extensions.tech_pythonExport.coeffs2Python(rear, getObjectByID(vid))
local positions = {vec3(front.x + 0.3, front.y - 0.2, front.z - 0.25), vec3(front.x - 0.3, front.y - 0.2, front.z - 0.25), -- fl_near, fr_near
vec3(front.x + 0.8, front.y - 0.1, front.z - 0.25), vec3(front.x - 0.8, front.y - 0.1, front.z - 0.25), -- fl_far, fr_far
rear = extensions.tech_pythonExport.coeffs2Python(rear, getObjectByID(vid))
local positions = {vec3(front.x + 0.3, front.y - 0.2, front.z - 0.25), vec3(front.x - 0.3, front.y - 0.2, front.z - 0.25), -- fl_near, fr_near
vec3(front.x + 0.8, front.y - 0.1, front.z - 0.25), vec3(front.x - 0.8, front.y - 0.1, front.z - 0.25), -- fl_far, fr_far
local positions = {vec3(front.x + 0.3, front.y - 0.2, front.z - 0.25), vec3(front.x - 0.3, front.y - 0.2, front.z - 0.25), -- fl_near, fr_near
vec3(front.x + 0.8, front.y - 0.1, front.z - 0.25), vec3(front.x - 0.8, front.y - 0.1, front.z - 0.25), -- fl_far, fr_far
vec3(rear.x + 0.3, rear.y + 0.2, rear.z - 0.25), vec3(rear.x - 0.3, rear.y + 0.2, rear.z - 0.25), -- rl_near, rr_near
local positions = {vec3(front.x + 0.3, front.y - 0.2, front.z - 0.25), vec3(front.x - 0.3, front.y - 0.2, front.z - 0.25), -- fl_near, fr_near
vec3(front.x + 0.8, front.y - 0.1, front.z - 0.25), vec3(front.x - 0.8, front.y - 0.1, front.z - 0.25), -- fl_far, fr_far
vec3(rear.x + 0.3, rear.y + 0.2, rear.z - 0.25), vec3(rear.x - 0.3, rear.y + 0.2, rear.z - 0.25), -- rl_near, rr_near
vec3(front.x + 0.8, front.y - 0.1, front.z - 0.25), vec3(front.x - 0.8, front.y - 0.1, front.z - 0.25), -- fl_far, fr_far
vec3(rear.x + 0.3, rear.y + 0.2, rear.z - 0.25), vec3(rear.x - 0.3, rear.y + 0.2, rear.z - 0.25), -- rl_near, rr_near
vec3(rear.x + 0.8, rear.y + 0.1, rear.z - 0.25), vec3(rear.x - 0.8, rear.y + 0.1, rear.z - 0.25), -- rl_far, rr_far
vec3(front.x + 0.8, front.y - 0.1, front.z - 0.25), vec3(front.x - 0.8, front.y - 0.1, front.z - 0.25), -- fl_far, fr_far
vec3(rear.x + 0.3, rear.y + 0.2, rear.z - 0.25), vec3(rear.x - 0.3, rear.y + 0.2, rear.z - 0.25), -- rl_near, rr_near
vec3(rear.x + 0.8, rear.y + 0.1, rear.z - 0.25), vec3(rear.x - 0.8, rear.y + 0.1, rear.z - 0.25), -- rl_far, rr_far
vec3(rear.x + 0.3, rear.y + 0.2, rear.z - 0.25), vec3(rear.x - 0.3, rear.y + 0.2, rear.z - 0.25), -- rl_near, rr_near
vec3(rear.x + 0.8, rear.y + 0.1, rear.z - 0.25), vec3(rear.x - 0.8, rear.y + 0.1, rear.z - 0.25), -- rl_far, rr_far
vec3(1.05, -0.4, 0.95), vec3(-1.05, -0.4, 0.95) -- mirror_left, mirror_right
vec3(rear.x + 0.3, rear.y + 0.2, rear.z - 0.25), vec3(rear.x - 0.3, rear.y + 0.2, rear.z - 0.25), -- rl_near, rr_near
vec3(rear.x + 0.8, rear.y + 0.1, rear.z - 0.25), vec3(rear.x - 0.8, rear.y + 0.1, rear.z - 0.25), -- rl_far, rr_far
vec3(1.05, -0.4, 0.95), vec3(-1.05, -0.4, 0.95) -- mirror_left, mirror_right
vec3(rear.x + 0.8, rear.y + 0.1, rear.z - 0.25), vec3(rear.x - 0.8, rear.y + 0.1, rear.z - 0.25), -- rl_far, rr_far
vec3(1.05, -0.4, 0.95), vec3(-1.05, -0.4, 0.95) -- mirror_left, mirror_right
}
vec3(rear.x + 0.8, rear.y + 0.1, rear.z - 0.25), vec3(rear.x - 0.8, rear.y + 0.1, rear.z - 0.25), -- rl_far, rr_far
vec3(1.05, -0.4, 0.95), vec3(-1.05, -0.4, 0.95) -- mirror_left, mirror_right
}
local directions = {vec3(0.15, -0.85, 0), vec3(-0.15, -0.85, 0), -- fl_near, fr_near
vec3(0.5, -0.5, 0), vec3(-0.5, -0.5, 0), -- fl_far, fr_far
local directions = {vec3(0.15, -0.85, 0), vec3(-0.15, -0.85, 0), -- fl_near, fr_near
vec3(0.5, -0.5, 0), vec3(-0.5, -0.5, 0), -- fl_far, fr_far
local directions = {vec3(0.15, -0.85, 0), vec3(-0.15, -0.85, 0), -- fl_near, fr_near
vec3(0.5, -0.5, 0), vec3(-0.5, -0.5, 0), -- fl_far, fr_far
vec3(0.15, 0.85, 0), vec3(-0.15, 0.85, 0), -- rl_near, rr_near
local directions = {vec3(0.15, -0.85, 0), vec3(-0.15, -0.85, 0), -- fl_near, fr_near
vec3(0.5, -0.5, 0), vec3(-0.5, -0.5, 0), -- fl_far, fr_far
vec3(0.15, 0.85, 0), vec3(-0.15, 0.85, 0), -- rl_near, rr_near
vec3(0.5, -0.5, 0), vec3(-0.5, -0.5, 0), -- fl_far, fr_far
vec3(0.15, 0.85, 0), vec3(-0.15, 0.85, 0), -- rl_near, rr_near
vec3(0.5, 0.5, 0), vec3(-0.5, 0.5, 0), -- rl_far, rr_far
vec3(0.5, -0.5, 0), vec3(-0.5, -0.5, 0), -- fl_far, fr_far
vec3(0.15, 0.85, 0), vec3(-0.15, 0.85, 0), -- rl_near, rr_near
vec3(0.5, 0.5, 0), vec3(-0.5, 0.5, 0), -- rl_far, rr_far
vec3(0.15, 0.85, 0), vec3(-0.15, 0.85, 0), -- rl_near, rr_near
vec3(0.5, 0.5, 0), vec3(-0.5, 0.5, 0), -- rl_far, rr_far
vec3(0.6, 0.4, 0), vec3(-0.6, 0.4, 0) -- mirror_left, mirror_right
vec3(0.15, 0.85, 0), vec3(-0.15, 0.85, 0), -- rl_near, rr_near
vec3(0.5, 0.5, 0), vec3(-0.5, 0.5, 0), -- rl_far, rr_far
vec3(0.6, 0.4, 0), vec3(-0.6, 0.4, 0) -- mirror_left, mirror_right
vec3(0.5, 0.5, 0), vec3(-0.5, 0.5, 0), -- rl_far, rr_far
vec3(0.6, 0.4, 0), vec3(-0.6, 0.4, 0) -- mirror_left, mirror_right
}
vec3(0.5, 0.5, 0), vec3(-0.5, 0.5, 0), -- rl_far, rr_far
vec3(0.6, 0.4, 0), vec3(-0.6, 0.4, 0) -- mirror_left, mirror_right
}
@/lua/ge/extensions/editor/gen/lib/ui.lua
if not c then c = colorOn end
if not scale then scale = vec3(1,1) end
if type(kv) ~= 'table' then
end
M.buttonImg('fav_up', 'star', im.ImVec2(lineH,lineH), colorOff, nil, vec3(0.5,0.5))
im.NextColumn()
@/lua/ge/extensions/tech/utils.lua
local args = {}
args.pos = vec3(0, driverNodePos.y, 3.0) -- TODO x=0 is NOT the centerline of the vehicle
M.lidar = tech_sensors.createLidar(vid, args)
M.relativeCamData = {
offset=vec3(-3,-10,10),
rotation=vec3(20, 135, 0),
offset=vec3(-3,-10,10),
rotation=vec3(20, 135, 0),
fov = 80
for _,y in ipairs({-3, 3}) do -- longitudinally
local posRef = vec3(0, sign(y)*(math.abs(y)-1.5), z)
local args = {}
local args = {}
args.pos = vec3(x, y, z)
args.dir = (args.pos - posRef):z0()
name = "Second view",
position = vec3(0, 0, 0),
offsetNode = camNodeID or 0,
@/lua/ge/extensions/editor/trafficDebug.lua
local pos = vec3(be:getObjectPositionXYZ(currId))
local dist = pos:distance(core_camera.getPosition())
local alpha = clamp((dist - 50) / 450, 0.2, 0.8)
debugDrawer:drawSquarePrism(pos, pos + vec3(0, 0, height), Point2F(0, 0), Point2F(height * 0.25, height * 0.25), ColorF(1, 1, 0.25, alpha))
end
@/lua/vehicle/controller/tech/advancedIMU.lua
local sm = {} -- The smoother state.
local edge1, edge2, edge1Norm, edge2Norm = vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local sm = {} -- The smoother state.
local edge1, edge2, edge1Norm, edge2Norm = vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local sm = {} -- The smoother state.
local edge1, edge2, edge1Norm, edge2Norm = vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local sm = {} -- The smoother state.
local edge1, edge2, edge1Norm, edge2Norm = vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local edge1, edge2, edge1Norm, edge2Norm = vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local edge1, edge2, edge1Norm, edge2Norm = vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local edge1, edge2, edge1Norm, edge2Norm = vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local edge1, edge2, edge1Norm, edge2Norm = vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local normal, projPos, currentPos, accel = vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local a1, a2, a3, v1, v2, v3 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local baryCenter, translation, aRot1, aRot2, aRot3 = vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local r1, r2, r3, r, curl = vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local totalAccel, vCenter, angVel, angAccel = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
local forwardTS, upTS, rightTS, forwardWS, upWS, rightWS = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tempVec1, tempVec2, tempVec3, tmpPosWS = vec3(), vec3(), vec3(), vec3()
state.smoothedAccelReading, state.smoothedGyroReading = vec3(), vec3() -- The smoothed acceleration/gyroscopic readings.
state.smootherStrength = math.max(0.0, math.min(5.0, data.smootherStrength)) -- The strength of the smoothing applied to the acceleration/gyroscopic readings.
state.smoothedAccelReading, state.smoothedGyroReading = vec3(), vec3() -- The smoothed acceleration/gyroscopic readings.
state.smootherStrength = math.max(0.0, math.min(5.0, data.smootherStrength)) -- The strength of the smoothing applied to the acceleration/gyroscopic readings.
@/lua/ge/extensions/editor/roadDecorations.lua
local function findOffsetPoint(spline, length, distance, left)
local prevPoint = vec3(spline[1])
local nextPoint = vec3(spline[2])
local prevPoint = vec3(spline[1])
local nextPoint = vec3(spline[2])
local edgeIdx = 0
local offset = vec3(flatDir.y, -flatDir.x, 0)
offset = offset * distance
rotation = rightPoint['rotation']
rotation = rightPoint['rotation'] * quatFromDir(vec3(0, -1, 0))
local height = core_terrain.getTerrainHeight(vec3(pos.x, pos.y, pos.z))
if height then
decoration:registerObject(objName)
decoration.scale = vec3(1, 1, 1)
decoration.canSave = true
for i = 0, segCount - 1 do
local left = vec3(road:getLeftEdgePosition(i))
local right = vec3(road:getRightEdgePosition(i))
local left = vec3(road:getLeftEdgePosition(i))
local right = vec3(road:getRightEdgePosition(i))
table.insert(leftEdge, left)
local zOffset = vec3(0,0,zOff)
@/lua/ge/extensions/gameplay/drift/drift.lua
local frontPoint = {
lastFrameVel = vec3(),
lastFramePos = vec3(),
lastFrameVel = vec3(),
lastFramePos = vec3(),
vel = vec3(),
lastFramePos = vec3(),
vel = vec3(),
pos = vec3(),
vel = vec3(),
pos = vec3(),
} -- arbitrary point placed in front of the car to detect a drift
local rearPoint = {
lastFrameVel = vec3(),
lastFramePos = vec3(),
lastFrameVel = vec3(),
lastFramePos = vec3(),
vel = vec3(),
lastFramePos = vec3(),
vel = vec3(),
pos = vec3(),
vel = vec3(),
pos = vec3(),
} -- arbitrary point placed behind the car to detect a drift
--------- GARBAGE COLLECTION VARIABLES -----------
local vehPos = vec3()
local velDir = vec3(0,0,0)
local vehPos = vec3()
local velDir = vec3(0,0,0)
local veh
local driftAngleDiff
local dirVec = vec3()
local corner_FL = vec3()
local dirVec = vec3()
local corner_FL = vec3()
local corner_FR = vec3()
local corner_FL = vec3()
local corner_FR = vec3()
local corner_BR = vec3()
local corner_FR = vec3()
local corner_BR = vec3()
local corner_BL = vec3()
local corner_BR = vec3()
local corner_BL = vec3()
local center = vec3()
local corner_BL = vec3()
local center = vec3()
local frontCenter = vec3()
local center = vec3()
local frontCenter = vec3()
local rearCenter = vec3()
local frontCenter = vec3()
local rearCenter = vec3()
local up = vec3(0,0,1)
local rearCenter = vec3()
local up = vec3(0,0,1)
local tempVec = vec3(0,0,0)
local up = vec3(0,0,1)
local tempVec = vec3(0,0,0)
local avrgRefPointsKphSpeed -- instead of picking the car speed, we use two off-centered points
direction = nil,
lastFrameVelDir = vec3(velDir),
totalDriftAngle = 0,
totalDonutsInRow = 0,
lastPos = vec3(vehicleData.pos),
avgDriftAngle = 0,
local velocityTip = vec3(0,0,0)
local function calculateDriftAngle(vehData)
local halfAxis0 = vec3()
local halfAxis1 = vec3()
local halfAxis0 = vec3()
local halfAxis1 = vec3()
local halfAxis2 = vec3()
local halfAxis1 = vec3()
local halfAxis2 = vec3()
local oobbCenter = vec3()
local halfAxis2 = vec3()
local oobbCenter = vec3()
local raycastHeightVec = vec3(0,0,driftOptions.raycastHeight)
local oobbCenter = vec3()
local raycastHeightVec = vec3(0,0,driftOptions.raycastHeight)
local function calculateVehCenterAndWheels()
local random = 0.5
local tempVec2 = vec3()
local function calculateDistWall()
-- all for gc
local tempVecCurrVel = vec3()
local tempVecPos = vec3()
local tempVecCurrVel = vec3()
local tempVecPos = vec3()
local tempVecPosUp = vec3()
local tempVecPos = vec3()
local tempVecPosUp = vec3()
local tempVecPosUp2 = vec3()
local tempVecPosUp = vec3()
local tempVecPosUp2 = vec3()
local tempNormalizedVel = vec3()
local tempVecPosUp2 = vec3()
local tempNormalizedVel = vec3()
local tempColor = ColorF(1,0.3,1,0.3)
local frontPointTempVec = vec3()
local rearPointTempVec = vec3()
local frontPointTempVec = vec3()
local rearPointTempVec = vec3()
local crossUpTempVec = vec3()
local rearPointTempVec = vec3()
local crossUpTempVec = vec3()
local function checkOverSteering()
local tempVellDiff = vec3()
local lastFrameVel = vec3()
local tempVellDiff = vec3()
local lastFrameVel = vec3()
local function calculateGForceJerk()
local vec3DistDiff = vec3(0,0,0)
local function detectAndGatherDriftInfo(vehicleData)
-- drift scoring is based on distance, not time
local lastFramePlPos = vec3()
local function calculateDistSinceLastFrame()
@/lua/ge/extensions/core/metrics.lua
if not imguiVisible then
local pos = vec3(0, posY+36, 0)
local fg = ColorF(0.9, 0.9, 0.9, 1)
@/gameplay/missionTypes/knockAway/editor.lua
self:addBool("Has End Zone","hasEndZone",false,nil,{boxText = "If true, challenge ends when player enters this trigger"})
self:addTransform("End Zone", "endZone", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "fullBox", drawColor = {0,0,1,0.3}})
self:addDecoSeparator()
self:addBool("Cinematic Cam","hasEndZoneCamPathTrigger",false,nil, {boxText = "If true, the camera path starts when player enters the 'Cam Start Trigger' and ends when the player enters the 'Cam End Trigger.' Make sure to create both triggers!"})
self:addTransform("Cam Start Trigger", "endZoneCamStarTrigger", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "fullBox", drawColor = {0,0,1,0.3}})
self:addTransform("Cam End Trigger", "endZoneCamEndTrigger", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "fullBox", drawColor = {0,0,1,0.3}})
self:addTransform("Cam Start Trigger", "endZoneCamStarTrigger", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "fullBox", drawColor = {0,0,1,0.3}})
self:addTransform("Cam End Trigger", "endZoneCamEndTrigger", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "fullBox", drawColor = {0,0,1,0.3}})
self:addFixedFile("Cinematic Cam Path", "/cinematic.camPath.json", {optional = true, tooltip="A camera that gets triggered for cinematic effect such as a big jump, crashing through many items at once, or anything else you can think of. Save the file as 'cinematic.camPath.json' and place it in this mission's directory."})
self:addBool("Has Ramp","hasRamp", false,nil,{tooltip="Has a jump/drop point that will remove control from the player when driving through, and end the mission when the vehicle is stopped."})
self:addTransform("Ramp Zone", "rampZone", {hasPos = true, hasRot = true, defaultScl = vec3(1,5,4)}, {drawMode = "fullBox", drawColor = {0,1,1,0.3}})
@/lua/ge/extensions/flowgraph/nodes/scene/camera/procedural/procCamPathPosRot.lua
local from = deepcopy(m)
from.pos = vec3(self.pinIn.pos.value)
from.rot = quat(self.pinIn.rot.value)
@/lua/ge/extensions/gameplay/markers/bigmapMarker.lua
local upVector = vec3(0,0,1)
local camPos2d, markerPos2d = vec3(), vec3()
local tmpVec = vec3()
local camPos2d, markerPos2d = vec3(), vec3()
local tmpVec = vec3()
local camPos2d, markerPos2d = vec3(), vec3()
local tmpVec = vec3()
local vecZero = vec3(0,0,0)
local tmpVec = vec3()
local vecZero = vec3(0,0,0)
local camQuat = quat()
local camQuat = quat()
local camUp = vec3()
local camToCluster = vec3()
local camUp = vec3()
local camToCluster = vec3()
local camToClusterLeft = vec3()
local camToCluster = vec3()
local camToClusterLeft = vec3()
self.bigMapIconId = iconRendererObj:addIcon(cluster.id .. "bigMap", bigMapIconName or "mission_primary_triangle", self.pos + vec3(0,0,columnHeight))
local iconInfo = iconRendererObj:getIconById(self.bigMapIconId)
self.bigMapColumnIconId = iconRendererObj:addIcon(cluster.id .. "bigMapColumn", "marker_column", self.pos + vec3(0,0,columnHeight))
local iconInfo = iconRendererObj:getIconById(self.bigMapColumnIconId)
containedIds = {},
pos = vec3(),
icon = "",
@/lua/ge/extensions/career/modules/testDrive.lua
local vehPos = vehicleData.pos - vec3(0,0,1.8)
local dir = (oobb:getPoint(0) - vehPos)
local finalPos = oobb:getPoint(0) + (dir * 1.3)
gameplay_walk.setWalkingMode(true, finalPos, quatFromDir(-dir, vec3(0,0,1)))
else
@/lua/ge/extensions/core/cameraModes/relative.lua
self.slots[slot] = {
pos = vec3(self.pos),
rot = vec3(self.rot),
pos = vec3(self.pos),
rot = vec3(self.rot),
fov = self.manualzoom.fov
function C:update(data)
local ref = vec3(data.veh:getNodePosition(self.refNodes.ref))
local left = vec3(data.veh:getNodePosition(self.refNodes.left))
local ref = vec3(data.veh:getNodePosition(self.refNodes.ref))
local left = vec3(data.veh:getNodePosition(self.refNodes.left))
local back = vec3(data.veh:getNodePosition(self.refNodes.back))
local left = vec3(data.veh:getNodePosition(self.refNodes.left))
local back = vec3(data.veh:getNodePosition(self.refNodes.back))
local nz = nx:cross(ny):normalized()
local carPos = vec3(data.veh:getSpawnWorldOOBBRearPoint())
local pos = data.pos - carPos
local pos = data.pos - carPos
pos = vec3(pos:dot(nx), pos:dot(ny), pos:dot(nz))
pos.z = ref.z
pos.z = ref.z
local offset = vec3(0,-0.5,0)
self.pos = pos + offset
end
self.rot = self.rot or vec3(0,180,0)
end
if self.resetPos == nil then
self.resetPos = vec3(self.pos) -- copy
self.resetRot = vec3(self.rot) -- copy
self.resetPos = vec3(self.pos) -- copy
self.resetRot = vec3(self.rot) -- copy
end
local dtPosFactor = factorSmoother:getUncapped(adjustedSpeed / 80, data.dt)
local pd = dtPosFactor * data.dt * vec3(dx, dy, dz)
local rdz = MoveManager.rollRelative + 10*data.dt*(MoveManager.rollLeft - MoveManager.rollRight)
self.rot = self.rot + 7*vec3(rdx, rdy, rdz)
data.res.pos = data.pos
data.res.rot = quatFromDir(vec3(0,1,0), vec3(0, 0, 1))
if self.nearClip then data.res.nearClip = self.nearClip end
data.res.pos = data.pos
data.res.rot = quatFromDir(vec3(0,1,0), vec3(0, 0, 1))
if self.nearClip then data.res.nearClip = self.nearClip end
if self.lightBrightness > 0 then
local lightPos = pos -- + qdirLook * vec3(0.01, 0.01, -0.02)
scenetree.relativecameralight:setPosRot(lightPos.x, lightPos.y, lightPos.z, data.res.rot.x, data.res.rot.y, data.res.rot.z, data.res.rot.w)
@/lua/ge/extensions/editor/toolUtilities/splineInput.lua
local min, max, ceil, sqrt = math.min, math.max, math.ceil, math.sqrt
local globalUp = vec3(0, 0, 1)
local joinDistSq = joinDist * joinDist
local allSplines, splineToolNames = {}, {}
local mouseVel2D, mouseLast, binVec = vec3(), vec3(), vec3()
local lastDragMousePos = vec3()
local allSplines, splineToolNames = {}, {}
local mouseVel2D, mouseLast, binVec = vec3(), vec3(), vec3()
local lastDragMousePos = vec3()
local allSplines, splineToolNames = {}, {}
local mouseVel2D, mouseLast, binVec = vec3(), vec3(), vec3()
local lastDragMousePos = vec3()
local mouseVel2D, mouseLast, binVec = vec3(), vec3(), vec3()
local lastDragMousePos = vec3()
local tableIdx = idxLower + 1
table.insert(selSpline.nodes, tableIdx, vec3(pHit))
local widths, nmls = selSpline.widths, selSpline.nmls
if mousePos:squaredDistance(selNodes[1]) < mousePos:squaredDistance(selNodes[#selNodes]) then
table.insert(selNodes, 1, vec3(mousePos))
table.insert(selWidths, 1, selWidths[1])
table.insert(selWidths, 1, selWidths[1])
table.insert(selNmls, 1, vec3(selNmls[1] or globalUp))
if useBars then
else
table.insert(selNodes, vec3(mousePos))
table.insert(selWidths, selWidths[#selWidths])
table.insert(selWidths, selWidths[#selWidths])
table.insert(selNmls, vec3(selNmls[#selNmls]))
if useBars then
else
selNodes[#selNodes + 1] = vec3(mousePos)
table.insert(selWidths, #selWidths > 0 and selWidths[#selWidths] or defaultSplineWidth)
table.insert(selWidths, #selWidths > 0 and selWidths[#selWidths] or defaultSplineWidth)
table.insert(selNmls, vec3(selNmls[#selNmls] or globalUp))
if useBars then
@/lua/ge/extensions/editor/terraform/terraform.lua
local gMin, gMax, tmpPoint2I = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
local tmp1, tmp2 = vec3(), vec3()
local gMin, gMax, tmpPoint2I = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
local tmp1, tmp2 = vec3(), vec3()
-- Each source element is an array containing ordered polyline points with the following structure:
-- { pos = vec3(x, y, z), width = f, binormal = vec3(x, y, z) }.
-- 'DOI' (Domain of Influence) is the max distance at which the terraforming will affect, in meters.
-- Each source element is an array containing ordered polyline points with the following structure:
-- { pos = vec3(x, y, z), width = f, binormal = vec3(x, y, z) }.
-- 'DOI' (Domain of Influence) is the max distance at which the terraforming will affect, in meters.
@/lua/ge/extensions/gameplay/rally/driveline/pointList.lua
return {
pos = vec3(pos),
quat = quat or quat(0, 0, 0, 1),
ts = ts or 0,
normal = vec3(0, 0, 1),
prev = nil,
@/lua/ge/extensions/scenario/raceMarkers/overhead.lua
local playerPosition = vec3(0,0,0)
playerPosition:set(core_camera.getPosition())
local fwd = (playerPosition-self.pos)
--local side = fwd:cross(vec3(0,0,1))
local rot = quatFromDir(fwd:z0()):toTorqueQuat()
self.arrow.instanceColor1 = ColorF(1,1,1,self.currentColor.a):asLinear4F()
self.arrow:setPosition(vec3(0,0,0.4 + math.sin(os.clock()*1.9)*0.4)+self.pos)
-- self.arrow:setField('instanceColor', 1, ""..self.currentColor.r.." "..self.currentColor.g.." "..self.currentColor.b.." "..self.currentColor.a)
self.arrow:updateInstanceRenderData()
self.arrow:setScale(vec3(2,2,2))
end
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
self.radius = wp.radius
if self.arrow then
self.arrow:setPosition(vec3(0,0,1.75)+self.pos)
self.arrow:setScale(vec3(1,1,1))
self.arrow:setPosition(vec3(0,0,1.75)+self.pos)
self.arrow:setScale(vec3(1,1,1))
end
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
@/lua/ge/extensions/editor/terrainEditor.lua
terrainBlock:reorderMaterial(from - 1, to - 1)
terrainBlock:updateGridMaterials(vec3(minFloatValue, minFloatValue, 0), vec3(maxFloatValue, maxFloatValue, 0))
updatePaintMaterialProxies()
terrainBlock:reorderMaterial(from - 1, to - 1)
terrainBlock:updateGridMaterials(vec3(minFloatValue, minFloatValue, 0), vec3(maxFloatValue, maxFloatValue, 0))
updatePaintMaterialProxies()
terrainBlock:removeMaterial(index - 1)
terrainBlock:updateGridMaterials(vec3(minFloatValue, minFloatValue, 0), vec3(maxFloatValue, maxFloatValue, 0))
updatePaintMaterialProxies()
terrainBlock:removeMaterial(index - 1)
terrainBlock:updateGridMaterials(vec3(minFloatValue, minFloatValue, 0), vec3(maxFloatValue, maxFloatValue, 0))
updatePaintMaterialProxies()
if terrainImpExp.applyTransform[0] == true then
terrBlock:setPosition(vec3(terrainImpExp.transformPos.x[0], terrainImpExp.transformPos.y[0], terrainImpExp.transformPos.z[0]))
end
if terrainBlock then
local height = terrainBlock:getHeight(vec3(hit.pos.x,hit.pos.y,0)) - terrainBlock:getPosition().z
editor.setPreference("terrainEditor.general.brushHeight", height)
@/lua/ge/extensions/flowgraph/nodes/ui/onBigmapPoiSelected.lua
self.flags = {}
self.navPos = vec3()
end
end
self.navPos = pos or vec3()
end
@/lua/ge/extensions/core/cameraModes/bigMap.lua
local function getRayCastHit(ray, relativeToCam)
local dist = intersectsRay_Plane(ray.pos, ray.dir, core_terrain.getTerrain() and core_terrain.getTerrain():getWorldBox().minExtents or vec3(0,0,0), vec3(0,0,1))
local hitPoint = ray.pos + ray.dir * dist
local function getRayCastHit(ray, relativeToCam)
local dist = intersectsRay_Plane(ray.pos, ray.dir, core_terrain.getTerrain() and core_terrain.getTerrain():getWorldBox().minExtents or vec3(0,0,0), vec3(0,0,1))
local hitPoint = ray.pos + ray.dir * dist
self.initialCamData = data.initialCamData
local camLookAtPoint = getRayCastHit({pos = self.initialCamData.pos or core_camera.getPosition(), dir = self.initialCamData.rot and self.initialCamData.rot * vec3(0,1,0) or core_camera.getForward()})
camToLookAtPoint = camLookAtPoint - self.initialCamData.pos or core_camera.getPosition()
local camLookAtPoint = getRayCastHit({pos = core_camera.getPosition(), dir = core_camera.getForward()})
local zoomCamStartPos = vec3(self.bigMapCamPosition)
local zoomMouseEndPos = zoomMouseStartPos + (camLookAtPoint - zoomMouseStartPos) * (1-(zoomAfter/zoomBefore))
local forwardDir = quat(self.bigMapCamRotation) * vec3(0,1,0)
forwardDir.z = 0
forwardDir:normalize()
local rightDir = forwardDir:cross(vec3(0,0,1))
self.bigMapCamPosition = self.bigMapCamPosition + (MoveManager.forward * forwardDir + MoveManager.backward * -forwardDir + MoveManager.left * -rightDir + MoveManager.right * rightDir) * self.movementSpeed * data.dtReal * 80 * zoomBasedMovementSpeedFactor
@/lua/ge/extensions/editor/driftDataEditor.lua
for _, elem in ipairs(json.stuntZones or {}) do
if elem.pos and type(elem.pos) == "table" and elem.pos.x and elem.pos.y and elem.pos.z then elem.pos = vec3(elem.pos) end
if elem.rot and type(elem.rot) == "table" and elem.rot.x and elem.rot.y and elem.rot.z and elem.rot.w then elem.rot = quat(elem.rot) end
if elem.rot and type(elem.rot) == "table" and elem.rot.x and elem.rot.y and elem.rot.z and elem.rot.w then elem.rot = quat(elem.rot) end
if elem.scl and type(elem.scl) == "table" and elem.scl.x and elem.scl.y and elem.scl.z then elem.scl = vec3(elem.scl) end
if elem.scl and type(elem.scl) == "number" then end
local newLineData = {
pos = vec3(lineData.pos),
scl = vec3(lineData.scl),
pos = vec3(lineData.pos),
scl = vec3(lineData.scl),
rot = quat(lineData.rot),
rot = quat(lineData.rot),
startDir = vec3(lineData.startDir),
markerObjects = lineData.markerObjects
newDriftSpot.spatialInfo.bigMapTp = {
pos = vec3(spotData.spatialInfo.bigMapTp.pos),
rot = quat(spotData.spatialInfo.bigMapTp.rot),
rot = quat(spotData.spatialInfo.bigMapTp.rot),
scl = vec3(spotData.spatialInfo.bigMapTp.scl)
}
pos = camPos:toTable(),
scl = vec3(1, 1, 1):toTable(),
rot = quat(0, 0, 0, 1):toTable(),
rot = quat(0, 0, 0, 1):toTable(),
startDir = vec3(0,0,0),
markerObjects = {}
rot = quat(0, 0, 0, 1):toTable(),
scl = vec3(1, 1, 1):toTable()
}
local pos = obj:getPosition()
driftData = { stuntZones = {{type = "donut", pos = pos + vec3(10, 0, 0), scl = 10},{type = "driftThrough", rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},{type = "hitPole", pos = pos + vec3(-10, 0, 0)}}}
end
local pos = obj:getPosition()
driftData = { stuntZones = {{type = "donut", pos = pos + vec3(10, 0, 0), scl = 10},{type = "driftThrough", rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},{type = "hitPole", pos = pos + vec3(-10, 0, 0)}}}
end
local pos = obj:getPosition()
driftData = { stuntZones = {{type = "donut", pos = pos + vec3(10, 0, 0), scl = 10},{type = "driftThrough", rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},{type = "hitPole", pos = pos + vec3(-10, 0, 0)}}}
end
local pos = obj:getPosition()
driftData = { stuntZones = {{type = "donut", pos = pos + vec3(10, 0, 0), scl = 10},{type = "driftThrough", rot = quat(0, 0, 0, 1), pos = pos + vec3(10, 20, 0), scl = vec3(8, 1, 1)},{type = "hitPole", pos = pos + vec3(-10, 0, 0)}}}
end
cooldown = 8,
pos = pos + vec3(10, 0, 0),
scl = 10,
rot = quat(0, 0, 0, 1),
pos = pos + vec3(10, 20, 0),
scl = vec3(8, 1, 1),
pos = pos + vec3(10, 20, 0),
scl = vec3(8, 1, 1),
score = shallowcopy(defaultPointsCopy.driftThroughPoints)
type = "hitPole",
pos = pos + vec3(-10, 0, 0),
score = shallowcopy(defaultPointsCopy.hitPolePoints)
debugDrawer:drawTextAdvanced(elem.pos, String(string.format("%d - %s", i, elem.type)), whiteColorF, true, false, blackColorI)
local x, y, z = elem.rot * vec3(elem.scl.x,0,0), elem.rot * vec3(0,elem.scl.y,0), elem.rot * vec3(0,0,elem.scl.z)
local scl = (x+y+z)/2
debugDrawer:drawTextAdvanced(elem.pos, String(string.format("%d - %s", i, elem.type)), whiteColorF, true, false, blackColorI)
local x, y, z = elem.rot * vec3(elem.scl.x,0,0), elem.rot * vec3(0,elem.scl.y,0), elem.rot * vec3(0,0,elem.scl.z)
local scl = (x+y+z)/2
debugDrawer:drawTextAdvanced(elem.pos, String(string.format("%d - %s", i, elem.type)), whiteColorF, true, false, blackColorI)
local x, y, z = elem.rot * vec3(elem.scl.x,0,0), elem.rot * vec3(0,elem.scl.y,0), elem.rot * vec3(0,0,elem.scl.z)
local scl = (x+y+z)/2
debugDrawer:drawTextAdvanced(elem.pos, String(string.format("%d - %s", i, elem.type)), whiteColorF, true, false, blackColorI)
debugDrawer:drawCylinder(elem.pos, elem.pos + vec3(0,0,3), 0.2, ColorF(1,0,0,0.2))
end
if player then
spawn.safeTeleport(player, vec3(currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.pos), quat(currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot), nil, nil, nil, nil, false)
end
-- drift detection box
local x, y, z = lineData.rot * vec3(lineData.scl.x,0,0), lineData.rot * vec3(0,lineData.scl.y,0), lineData.rot * vec3(0,0,lineData.scl.z)
local scl = (x+y+z)/2
-- drift detection box
local x, y, z = lineData.rot * vec3(lineData.scl.x,0,0), lineData.rot * vec3(0,lineData.scl.y,0), lineData.rot * vec3(0,0,lineData.scl.z)
local scl = (x+y+z)/2
-- drift detection box
local x, y, z = lineData.rot * vec3(lineData.scl.x,0,0), lineData.rot * vec3(0,lineData.scl.y,0), lineData.rot * vec3(0,0,lineData.scl.z)
local scl = (x+y+z)/2
im.Text("Drift detection box")
debugDrawer:drawTextAdvanced(vec3(lineData.pos), String(lineName), whiteColorF, true, false, blackColorI)
M.drawAxisBox(((-scl*2)+vec3(lineData.pos)),x*2,y*2,z*2,color(0,0,255,0.2*255))
debugDrawer:drawTextAdvanced(vec3(lineData.pos), String(lineName), whiteColorF, true, false, blackColorI)
M.drawAxisBox(((-scl*2)+vec3(lineData.pos)),x*2,y*2,z*2,color(0,0,255,0.2*255))
local driftBoxTr = transformsUtils[lineName.."driftBox"]
debugDrawer:drawTextAdvanced(lineData.startDir + lineData.pos, "Start dir", whiteColorF, true, false, blackColorI)
debugDrawer:drawCylinder(lineData.startDir + lineData.pos, lineData.startDir + lineData.pos + vec3(0,0,2), 0.2, ColorF(0,0,1,0.2))
local startDirTr = transformsUtils[lineName.."startDir"]
im.Text("Big map TP:")
local x, y, z = currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(1,0,0), currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(0,1,0), currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(0,0,1)
local scl = (x+y+z)/2
im.Text("Big map TP:")
local x, y, z = currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(1,0,0), currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(0,1,0), currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(0,0,1)
local scl = (x+y+z)/2
im.Text("Big map TP:")
local x, y, z = currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(1,0,0), currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(0,1,0), currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.rot * vec3(0,0,1)
local scl = (x+y+z)/2
local scl = (x+y+z)/2
debugDrawer:drawTextAdvanced(vec3(currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.pos), String("Big map TP"), whiteColorF, true, false, blackColorI)
M.drawAxisBox(((-scl*2)+vec3(currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.pos)),x*2,y*2,z*2,color(0,0,255,0.2*255))
debugDrawer:drawTextAdvanced(vec3(currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.pos), String("Big map TP"), whiteColorF, true, false, blackColorI)
M.drawAxisBox(((-scl*2)+vec3(currDriftSpots[selectedDriftSpotId].spatialInfo.bigMapTp.pos)),x*2,y*2,z*2,color(0,0,255,0.2*255))
local bigMapTpTr = transformsUtils["bigMapTp"]
mouseInfo.ray = getCameraMouseRay()
mouseInfo.rayDir = vec3(mouseInfo.ray.dir)
mouseInfo.rayCast = cameraMouseRayCast()
mouseInfo.hold = false
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._downNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._downNormal = vec3(mouseInfo.rayCast.normal)
end
if mouseInfo.hold then
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._holdNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._holdNormal = vec3(mouseInfo.rayCast.normal)
end
if mouseInfo.up then
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._upNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._upNormal = vec3(mouseInfo.rayCast.normal)
end
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/util/booster.lua
if veh then
veh:queueLuaCommand("extensions.core_booster.boost(vec3(0,0,1),0.01)")
end
@/lua/ge/extensions/freeroam/gasStations.lua
local function gasStationCenterRadius(f)
local center, count = vec3(0,0,0), 0
for _, pair in ipairs(f.pumps or {}) do
local pos = veh:getPosition()
Engine.Audio.playOnce('AudioGui',soundByKey[key], {position = vec3(pos.x, pos.y, pos.z)})
else
@/lua/ge/extensions/gameplay/rally/loop/rallyLoopManager.lua
local skipEventPos = vec3()
function C:evaluateSkip()
if data.missionType == 'serviceOut' and data.serviceOutTriggerPos and data.tcLabel then
local pos = vec3(data.serviceOutTriggerPos[1], data.serviceOutTriggerPos[2], data.serviceOutTriggerPos[3])
if shouldDrawShapes then
if data.missionType == 'serviceIn' and data.serviceStallPos then
local pos = vec3(data.serviceStallPos[1], data.serviceStallPos[2], data.serviceStallPos[3])
if shouldDrawShapes then
if data.tcInPos and data.tcInLabel then
local pos = vec3(data.tcInPos.x, data.tcInPos.y, data.tcInPos.z)
if shouldDrawShapes then
if data.tcOutPos and data.tcOutLabel then
local pos = vec3(data.tcOutPos.x, data.tcOutPos.y, data.tcOutPos.z)
if shouldDrawShapes then
if data.ssStartLinePos and data.ssLabel then
local pos = vec3(data.ssStartLinePos.x, data.ssStartLinePos.y, data.ssStartLinePos.z)
if shouldDrawShapes then
if data.ssStopControlPos and data.ssLabel then
local pos = vec3(data.ssStopControlPos.x, data.ssStopControlPos.y, data.ssStopControlPos.z)
if shouldDrawShapes then
-- Convert vec3 direction to quaternion, then to table for array indexing
local rotVec = vec3(rot)
local rotQuat = quatFromDir(rotVec)
@/lua/ge/extensions/editor/toolUtilities/fitPoly.lua
-- Module state.
local toPoint, currentDir = vec3(), vec3()
local dir1, dir2 = vec3(), vec3()
-- Module state.
local toPoint, currentDir = vec3(), vec3()
local dir1, dir2 = vec3(), vec3()
local toPoint, currentDir = vec3(), vec3()
local dir1, dir2 = vec3(), vec3()
local toPoint, currentDir = vec3(), vec3()
local dir1, dir2 = vec3(), vec3()
@/lua/ge/extensions/editor/trafficSignalsEditor.lua
local lastUsed = {signalType = "lightsBasic"}
local oldTransform = {pos = vec3(), rot = quat(), scl = 1}
local options = {smartName = true, smartObjectSelection = true, showClosestRoad = false}
local mousePos, targetPos = vec3(), vec3()
local vecUp = vec3(0, 0, 1)
local mousePos, targetPos = vec3(), vec3()
local vecUp = vec3(0, 0, 1)
local mousePos, targetPos = vec3(), vec3()
local vecUp = vec3(0, 0, 1)
local vecY = vec3(0, 1, 0)
local vecUp = vec3(0, 0, 1)
local vecY = vec3(0, 1, 0)
local cylinderRadius = 0.25
for _, instance in ipairs(data.instances) do
instance.pos = vec3(instance.pos)
instance.dir = vec3(instance.dir)
instance.pos = vec3(instance.pos)
instance.dir = vec3(instance.dir)
local new = trafficSignals.newSignal(instance)
instances[selected.signal].rot = quatFromDir(instances[selected.signal].dir, vecUp)
oldTransform.pos = vec3(instances[selected.signal].pos)
oldTransform.rot = quat(instances[selected.signal].rot)
local newTransform = {
pos = vec3(instances[selected.signal].pos),
rot = quat(instances[selected.signal].rot)
if im.IsMouseClicked(0) then
local act = {pos = vec3(mousePos), controllerId = lastUsed.controllerId, sequenceId = lastUsed.sequenceId}
editor.history:commitAction("Create Signal Instance", act, createInstanceActionUndo, createInstanceActionRedo)
gizmoBeginDrag()
instances[selected.signal].pos = vec3(signalPos[0], signalPos[1], signalPos[2])
gizmoEndDrag()
inputWidth = 100 * im.uiscale[0]
mousePos:set(staticRayCast() or vec3())
@/lua/ge/extensions/editor/meshSpline/populate.lua
local max, random, randomseed = math.max, math.random, math.randomseed
local scaleVec = vec3(1, 1, 1)
local zeroVec, globalUp = vec3(0, 0, 0), vec3(0, 0, 1)
local scaleVec = vec3(1, 1, 1)
local zeroVec, globalUp = vec3(0, 0, 0), vec3(0, 0, 1)
local preRotQuats = geom.getPreRotQuats()
local scaleVec = vec3(1, 1, 1)
local zeroVec, globalUp = vec3(0, 0, 0), vec3(0, 0, 1)
local preRotQuats = geom.getPreRotQuats()
local jitterQuat, rot, tmpRot1 = quat(), quat(), quat()
local tmpPos, tmpTan, tmpBinormal, tmpVec1 = vec3(), vec3(), vec3(), vec3()
local jitterQuat, rot, tmpRot1 = quat(), quat(), quat()
local tmpPos, tmpTan, tmpBinormal, tmpVec1 = vec3(), vec3(), vec3(), vec3()
local jitterQuat, rot, tmpRot1 = quat(), quat(), quat()
local tmpPos, tmpTan, tmpBinormal, tmpVec1 = vec3(), vec3(), vec3(), vec3()
local jitterQuat, rot, tmpRot1 = quat(), quat(), quat()
local tmpPos, tmpTan, tmpBinormal, tmpVec1 = vec3(), vec3(), vec3(), vec3()
@/gameplay/missions/gridmap_v2/collection/002-blenderbowl/script.lua
local ballIds = {}
local ballResetPos = vec3()
local fieldCenterPos = vec3()
local ballResetPos = vec3()
local fieldCenterPos = vec3()
local fieldRadius
@/lua/ge/extensions/flowgraph/nodes/scene/collectionMarker.lua
marker:setField('shapeName', 0, 'art/shapes/collectible/s_collect_BNG.dae')
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(2, 2, 2)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(2, 2, 2)
marker:registerObject(self.id.."marker")
if self.marker then
local pos = vec3(self.pinIn.pos.value)
pos = pos + (vec3(0,0,math.sin(self.mgr.modules.timer.globalTime.real*1.5) * 0.15))
self.marker:setPosition(pos)
@/lua/ge/extensions/gameplay/rally/tools/rallyToolbox.lua
for i, item in ipairs(aiDetailedPath) do
self.racePathAiPath[i] = vec3(item.pos)
end
-- local wpCe = pacenote:getCornerEndWaypoint()
-- table.insert(self.pacenoteWaypoints, vec3(wpCs.pos))
-- table.insert(self.pacenoteWaypoints, vec3(wpCe.pos))
-- table.insert(self.pacenoteWaypoints, vec3(wpCs.pos))
-- table.insert(self.pacenoteWaypoints, vec3(wpCe.pos))
-- end
local midWidth = pn.radius*2
local side = pn.normal:cross(vec3(0,0,1)) *(pn.radius-pn.sidePadding.y - midWidth/2)
-- debugDrawer:drawSquarePrism(
local rot = sp.rot
local normal = rot * vec3(0,-1,0) -- Forward vector from rotation
local midWidth = finish.radius*2 --- self.sidePadding.x - self.sidePadding.y
-- local side = finish.normal:cross(vec3(0,0,1)) *(finish.radius-finish.sidePadding.y - midWidth/2)
-- log('D', logTag, 'finish pos: '..dumps(finish.pos))
local txt = self.selectedPacenote.name .. '['..waypointTypes.shortenWaypointType(self.selectedPacenoteWaypoint.waypointType)..']'
local tagPos = vec3()
tagPos:set(self.selectedPacenoteWaypoint.pos)
tagPos.z = tagPos.z + 4
local bottomPos = vec3(self.selectedPacenoteWaypoint.pos)
bottomPos.z = bottomPos.z - 1
local function drawWp(wp, pacenoteName, pacenoteText, clr)
local txtPos = vec3(wp.pos)
local wpType = waypointTypes.shortenWaypointType(wp.waypointType)
-- for i, point in ipairs(reccePoints) do
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,2), 0.3, ColorF(clr[1],clr[2],clr[3],0.8))
-- debugDrawer:drawTextAdvanced(point.pos + vec3(0,0,2),
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,2), 0.3, ColorF(clr[1],clr[2],clr[3],0.8))
-- debugDrawer:drawTextAdvanced(point.pos + vec3(0,0,2),
-- String(string.format("recce_driveline_point_%d", i)),
-- for i, point in ipairs(finalPreRouteInput) do
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,2), 0.1, ColorF(0.5,0,0.5,0.8))
-- debugDrawer:drawTextAdvanced(point.pos + vec3(0,0,2),
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,2), 0.1, ColorF(0.5,0,0.5,0.8))
-- debugDrawer:drawTextAdvanced(point.pos + vec3(0,0,2),
-- String(string.format("finalPreRouteInput_%d", i)),
-- for i, point in ipairs(debugPreMergePath) do
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,1.5), 0.2, ColorF(1,0.5,0.5,0.8))
-- end
-- for i, point in ipairs(debugPostMergePath) do
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,2), 0.1, ColorF(0,0.5,0.5,0.8))
-- end
-- for i, point in ipairs(debugMergePathSample) do
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,2), 0.1, ColorF(0,1,0.5,0.8))
-- end
-- for i, point in ipairs(debugPostFixStartEnd1) do
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,2.5), 0.05, ColorF(1,1,0.5,0.8))
-- end
-- for i, point in ipairs(debugPostFixStartEnd2) do
-- debugDrawer:drawCylinder(point.pos, point.pos + vec3(0,0,3.0), 0.025, ColorF(0.75,1,0.5,0.8))
-- end
-- if debugFixStartEnd_a and debugFixStartEnd_b and debugFixStartEnd_p then
-- debugDrawer:drawCylinder(debugFixStartEnd_a.pos, debugFixStartEnd_a.pos + vec3(0,0,5.0), 0.01, ColorF(0,1,0,0.8))
-- debugDrawer:drawCylinder(debugFixStartEnd_b.pos, debugFixStartEnd_b.pos + vec3(0,0,5.0), 0.01, ColorF(1,0,0,0.8))
-- debugDrawer:drawCylinder(debugFixStartEnd_a.pos, debugFixStartEnd_a.pos + vec3(0,0,5.0), 0.01, ColorF(0,1,0,0.8))
-- debugDrawer:drawCylinder(debugFixStartEnd_b.pos, debugFixStartEnd_b.pos + vec3(0,0,5.0), 0.01, ColorF(1,0,0,0.8))
-- debugDrawer:drawCylinder(debugFixStartEnd_p.pos, debugFixStartEnd_p.pos + vec3(0,0,5.0), 0.01, ColorF(1,1,0,0.8))
-- debugDrawer:drawCylinder(debugFixStartEnd_b.pos, debugFixStartEnd_b.pos + vec3(0,0,5.0), 0.01, ColorF(1,0,0,0.8))
-- debugDrawer:drawCylinder(debugFixStartEnd_p.pos, debugFixStartEnd_p.pos + vec3(0,0,5.0), 0.01, ColorF(1,1,0,0.8))
-- debugDrawer:drawTextAdvanced(debugFixStartEnd_p.pos,
@/lua/ge/extensions/editor/toolUtilities/riverbed.lua
-- Module state.
local tmp1, tmp2, posWS = vec3(), vec3(), vec3()
local gMin, gMax, tmpPoint2I = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
-- Module state.
local tmp1, tmp2, posWS = vec3(), vec3(), vec3()
local gMin, gMax, tmpPoint2I = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
-- Module state.
local tmp1, tmp2, posWS = vec3(), vec3(), vec3()
local gMin, gMax, tmpPoint2I = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
@/lua/common/jbeam/sections/mirror.lua
local q = quatFromEuler(mrad(v.baseRotationGlobal.x),mrad(v.baseRotationGlobal.y),mrad(v.baseRotationGlobal.z))
mirror.normal = vec3(0,1,0):rotated(q)
-- log("I","proc","Migrated "..dumps(v.mesh) .." baseRotationGlobal="..dumps(mirror.normal) )
elseif v.normal then
local q = vec3(0,1,0):getRotationTo(vec3(v.normal))
local r = q:toEulerYXZ()
elseif v.normal then
local q = vec3(0,1,0):getRotationTo(vec3(v.normal))
local r = q:toEulerYXZ()
local q = quatFromEuler(mrad(v.offsetRotationGlobal.x),mrad(v.offsetRotationGlobal.y),mrad(v.offsetRotationGlobal.z))
mirror.offsetNormal = vec3(0,1,0):rotated(q)
-- log("I","proc","Migrated "..dumps(v.mesh) .." offsetRotationGlobal="..dumps(mirror.offsetNormal) )
log("E","proc","offsetNormal is depracted, fix mesh normals "..dumps(v.mesh))
local q = vec3(0,1,0):getRotationTo(vec3(v.offsetNormal))
local r = q:toEulerYXZ()
log("E","proc","offsetNormal is depracted, fix mesh normals "..dumps(v.mesh))
local q = vec3(0,1,0):getRotationTo(vec3(v.offsetNormal))
local r = q:toEulerYXZ()
@/lua/ge/extensions/util/screenshotCreator.lua
local camOffsetAxisLocal = vec3(-0.75, -0.66, 0.1):normalized()
local camLeftLocal = camOffsetAxisLocal:cross(vec3(0,0,1))
local camOffsetAxisLocal = vec3(-0.75, -0.66, 0.1):normalized()
local camLeftLocal = camOffsetAxisLocal:cross(vec3(0,0,1))
local camUpLocal = camOffsetAxisLocal:cross(vec3(1,0,0))
local camLeftLocal = camOffsetAxisLocal:cross(vec3(0,0,1))
local camUpLocal = camOffsetAxisLocal:cross(vec3(1,0,0))
local zOff = z:dot(vehToCam)
local offset = vec3(xOff, yOff, zOff)
screenshotDelay = 0,
resolution = vec3(currRes[1], currRes[2], 0),
rot = camRot,
rot = camRot,
pos = camPos + vec3(0,0,-0.2),
fov = thumbnailConfig.fov,
@/lua/ge/extensions/flowgraph/nodes/vehicle/applyVelocity.lua
local dirVec = vec3()
@/lua/ge/extensions/editor/gen/exp_meshexplorer.lua
local afav,cpath = {}
local camTarget,meshTarget -- {pos=vec3(), ang=vec3()}
local amodel,cobj,cpreview = {}
local afav,cpath = {}
local camTarget,meshTarget -- {pos=vec3(), ang=vec3()}
local amodel,cobj,cpreview = {}
if om then om:delete() end
local tveh = spawn.spawnVehicle('metal_box', nil, vec3(0,0,0), quat(0,0,1,0))
scenetree.findObjectById(tveh:getId()):delete()
scenetree.findObjectById(tveh:getId()):delete()
cobj = spawn.spawnVehicle(amodel[env.ui['model_up']], nil, vec3(0,0,0), quat(0,0,1,0)):getId()
lo('?? if_COOO:'..tostring(cobj))
local function forBeams(key, ds)
if not ds then ds = vec3(0,0,0) end
-- local pos = amesh[1].body:getPosition()
-- local pos = amesh[1].body:getPosition()
-- local pos = vec3(0.0002040175605,-0.001240882906,0.3043344319)
-- lo('?? forBeams:'..tostring(pos))
local set = {
vec3(0,0,2),
vec3(0,0,3),
vec3(0,0,2),
vec3(0,0,3),
--[[
--[[
vec3(-6.138487654,-0.07713961,4.214617878),
vec3(-6.138487654,-0.07713961,4.156997878),
vec3(-6.138487654,-0.07713961,4.214617878),
vec3(-6.138487654,-0.07713961,4.156997878),
vec3(-6.136799554,-0.07652515,3.246356878),
vec3(-6.138487654,-0.07713961,4.156997878),
vec3(-6.136799554,-0.07652515,3.246356878),
vec3(-6.136799554,-0.07652515,3.188736878)
vec3(-6.136799554,-0.07652515,3.246356878),
vec3(-6.136799554,-0.07652515,3.188736878)
]]
local r,ac,sac = AI.line(set)
U.out.aset[2] = {set = {vec3(sac[1],sac[2],sac[3]),vec3(sac[4],sac[5],sac[6])},
c={0,1,1},w=0.01}
local r,ac,sac = AI.line(set)
U.out.aset[2] = {set = {vec3(sac[1],sac[2],sac[3]),vec3(sac[4],sac[5],sac[6])},
c={0,1,1},w=0.01}
-- dump(ac, '?? if_LINE:'..tostring(r))
U.out.aset[3] = {set = {vec3(ac[1],ac[2],ac[3]),vec3(ac[4],ac[5],ac[6])},w=0.01}
return
-- dump(ac, '?? if_LINE:'..tostring(r))
U.out.aset[3] = {set = {vec3(ac[1],ac[2],ac[3]),vec3(ac[4],ac[5],ac[6])},w=0.01}
return
-- get extents
local mi,ma = vec3(math.huge,math.huge,math.huge),-vec3(math.huge,math.huge,math.huge)
for i,v in pairs(pvd.vdata.nodes) do
-- get extents
local mi,ma = vec3(math.huge,math.huge,math.huge),-vec3(math.huge,math.huge,math.huge)
for i,v in pairs(pvd.vdata.nodes) do
-- beamdata.m = daedata.dgeo[31].m
-- local pos = vec3(0.0002040175605,-0.001240882906,0.3043344319)
local apath = U.map(dbeam['pickup_hood'],function(k,v)
if false then
-- core_camera.setPosition(0,vec3(0,10,2))
-- core_camera.setRotation(0,quatFromDir(vec3(-1.5,-1,0)))
-- core_camera.setPosition(0,vec3(0,10,2))
-- core_camera.setRotation(0,quatFromDir(vec3(-1.5,-1,0)))
camTarget = {dir=vec3(-1.5,-10,0)}
-- core_camera.setRotation(0,quatFromDir(vec3(-1.5,-1,0)))
camTarget = {dir=vec3(-1.5,-10,0)}
-- camTarget = {dir=vec3(-2.46,-10.42,1.27)}
camTarget = {dir=vec3(-1.5,-10,0)}
-- camTarget = {dir=vec3(-2.46,-10.42,1.27)}
local t = i/20*math.pi
local dir = vec3(1,0,0)*t + vec3(1,1,0)
lo('?? for_dir:'..tostring(quatFromDir()))
local t = i/20*math.pi
local dir = vec3(1,0,0)*t + vec3(1,1,0)
lo('?? for_dir:'..tostring(quatFromDir()))
local id,om = M.meshUp(am,'tst', scenetree.findObject('edit'))
om:setPosition(vec3(3,0,5))
end
scenetree.findObjectById(id):delete()
local veh = spawn.spawnVehicle(model, nil, vec3(1,3,4), quat(0,0,1,0))
vid = veh:getId()
local veh = spawn.spawnVehicle(model, nil, vec3(3,3,4), quat(0,0,1,0))
vid = veh:getId()
local id,om = M.meshUp(am,'tst', scenetree.findObject('edit'))
om:setPosition(vec3(3,0,5))
end
local id,om = M.meshUp(am,'tst', scenetree.findObject('edit'))
om:setPosition(vec3(0,0,5))
end
local id,om = M.meshUp(am,'tst', scenetree.findObject('edit'))
om:setPosition(vec3(0,0,2))
end
local w,c,alpha
local cfr,cto = vec3(0,0.9,0.2),vec3(0,0,1)
for i,b in pairs(abeam) do
local w,c,alpha
local cfr,cto = vec3(0,0.9,0.2),vec3(0,0,1)
for i,b in pairs(abeam) do
cpath = nil
camTarget,meshTarget = nil,nil -- {pos=vec3(), ang=vec3()}
--amodel,
cpath = nil
camTarget,meshTarget = nil,nil -- {pos=vec3(), ang=vec3()}
--amodel,
afav,cpath = {},nil
camTarget,meshTarget = nil,nil -- {pos=vec3(), ang=vec3()}
amodel,cobj,cpreview = {},nil,nil
afav,cpath = {},nil
camTarget,meshTarget = nil,nil -- {pos=vec3(), ang=vec3()}
amodel,cobj,cpreview = {},nil,nil
if om then om:delete() end
local tveh = spawn.spawnVehicle('metal_box', nil, vec3(0,0,0), quat(0,0,1,0))
lo('?? mid:'..tostring(tveh))
scenetree.findObjectById(tveh:getId()):delete()
spawn.spawnVehicle(amodel[env.ui['model_up']], nil, vec3(0,0,0), quat(0,0,1,0))
break
if om then om:delete() end
local tveh = spawn.spawnVehicle('metal_box', nil, vec3(0,0,0), quat(0,0,1,0))
scenetree.findObjectById(tveh:getId()):delete()
scenetree.findObjectById(tveh:getId()):delete()
spawn.spawnVehicle(amodel[env.ui['model_up']], nil, vec3(0,0,0), quat(0,0,1,0))
break
-- if om then om:delete() end
-- spawn.spawnVehicle('metal_box', nil, vec3(0,0,0), quat(0,0,1,0))
local djpart = J.part2file()
end
local veh = spawn.spawnVehicle(amodel[env.ui['model_up'] ], nil, vec3(0,0,0), quat(0,0,1,0))
lo('?? for_VEH:'..tostring(veh))
lo('?? reloaded:')
-- spawn.spawnVehicle(amodel[env.ui['model_up'] ], nil, vec3(0,0,0), quat(0,0,1,0))
-- pvd = extensions.core_vehicle_manager.getPlayerVehicleData()
local vy = vx:cross(u:normalized())
local va = U.vturn(vec3(1,0,0),val/180*math.pi)
-- m.verts[ind] = v + vec3(1,0,0)
local va = U.vturn(vec3(1,0,0),val/180*math.pi)
-- m.verts[ind] = v + vec3(1,0,0)
m.verts[ind] = line.ab[1] + (v-line.ab[1]):dot(u)*u + vx*va.x + vy*va.y - pos
lo('?? for_LINE:'..r)
local a,b = vec3(ac[1],ac[2],ac[3]),vec3(ac[4],ac[5],ac[6])
local ang = U.vang(b-a,vec3(0,0,1))
lo('?? for_LINE:'..r)
local a,b = vec3(ac[1],ac[2],ac[3]),vec3(ac[4],ac[5],ac[6])
local ang = U.vang(b-a,vec3(0,0,1))
local a,b = vec3(ac[1],ac[2],ac[3]),vec3(ac[4],ac[5],ac[6])
local ang = U.vang(b-a,vec3(0,0,1))
lo('?? ang:'..ang)
if ang < math.pi/20 then
a = (a+b)/2 - vec3(0,0,1)*(a-b):length()/2
b = (a+b)/2 + vec3(0,0,1)*(a-b):length()/2
a = (a+b)/2 - vec3(0,0,1)*(a-b):length()/2
b = (a+b)/2 + vec3(0,0,1)*(a-b):length()/2
end
lo('?? lod_over:'..daedata.alod[val].zma) --..val..'/'..tostring(env.ui[key])..':'..tostring(pos))
W.out.cmesh = pos + vec3(0,0,daedata.alod[val].zma + 0.25) --+ vec3(0,0,box.maxExtents.z - box.minExtents.z)
break
lo('?? lod_over:'..daedata.alod[val].zma) --..val..'/'..tostring(env.ui[key])..':'..tostring(pos))
W.out.cmesh = pos + vec3(0,0,daedata.alod[val].zma + 0.25) --+ vec3(0,0,box.maxExtents.z - box.minExtents.z)
break
end
local veh = spawn.spawnVehicle(amodel[val], nil, vec3(0,0,0), quat(0,0,1,0))
cobj = veh:getId()
if not env.ui['test'] then
-- camTarget = {dir=vec3(0,0,1)-cpos, pos = cpos}
end
end
local dir = val>0 and core_camera.getForward():cross(vec3(0,0,1)):normalized() or vec3(0,0,1)
M.space(am, cval[key].am, dir, val, 1, daedata)
end
local dir = val>0 and core_camera.getForward():cross(vec3(0,0,1)):normalized() or vec3(0,0,1)
M.space(am, cval[key].am, dir, val, 1, daedata)
for i,p in pairs(cval['DragPos'].m.verts) do
d.pos = vec3(val,0,0)
d.m.verts[i] = p + d.pos
for j=1,#cm.verts do
m.verts[j] = cm.verts[j]+(val>0 and vec3(ds,0,0) or vec3(0,ds,0))
end
for j=1,#cm.verts do
m.verts[j] = cm.verts[j]+(val>0 and vec3(ds,0,0) or vec3(0,ds,0))
end
local w,c,alpha
local cfr,cto = vec3(0,0.5,0.5),vec3(0,0,1)
for i,b in pairs(list) do
local w,c,alpha
local cfr,cto = vec3(0,0.5,0.5),vec3(0,0,1)
for i,b in pairs(list) do
local w,c,alpha
local cfr,cto = vec3(0,0.5,0.5),vec3(0,0,1)
-- dump(beamdata.anode[1], '?? node:')
local w,c,alpha
local cfr,cto = vec3(0,0.5,0.5),vec3(0,0,1)
-- dump(beamdata.anode[1], '?? node:')
U.out.agraph = {}
local cfr,cto = vec3(0,0.5,0.5),vec3(0,0,1)
-- vec3(0,0.4,0.4),vec3(0.4,0,0.4)
U.out.agraph = {}
local cfr,cto = vec3(0,0.5,0.5),vec3(0,0,1)
-- vec3(0,0.4,0.4),vec3(0.4,0,0.4)
local cfr,cto = vec3(0,0.5,0.5),vec3(0,0,1)
-- vec3(0,0.4,0.4),vec3(0.4,0,0.4)
lo('?? if_BEAMS:'..#d.abeam)
local cfr,cto = vec3(0,0.5,0.5),vec3(0,0,1)
-- vec3(0,0.4,0.4),vec3(0.4,0,0.4)
lo('?? if_BEAMS:'..#d.abeam)
-- w = 2 + 6*b.deform
-- c = vec3(0,0.4,0.4)*b.spring + vec3(0.4,0,0.4)*(1-b.spring)
-- alpha = 0.4 + 0.6*b.strength
-- w = 2 + 6*b.deform
-- c = vec3(0,0.4,0.4)*b.spring + vec3(0.4,0,0.4)*(1-b.spring)
-- alpha = 0.4 + 0.6*b.strength
env.ui[key] = val
-- camTarget= {pos=vec3(0, 5, 5), dir=vec3(1,1,-0.5)} -- ang={0,math.pi/4,-math.pi/2}}
-- core_camera.setPosition(0, vec3(0, 5, 5))
env.ui[key] = val
-- camTarget= {pos=vec3(0, 5, 5), dir=vec3(1,1,-0.5)} -- ang={0,math.pi/4,-math.pi/2}}
-- core_camera.setPosition(0, vec3(0, 5, 5))
-- camTarget= {pos=vec3(0, 5, 5), dir=vec3(1,1,-0.5)} -- ang={0,math.pi/4,-math.pi/2}}
-- core_camera.setPosition(0, vec3(0, 5, 5))
-- core_camera.setRotation(0, quatFromEuler(0,0,math.pi/2)) --(0, 0, math.pi/2),)
-- core_camera.setRotation(0, quatFromEuler(math.pi/4,0,0)) --(0, 0, math.pi/2),)
-- core_camera.setRotation(0, quatFromDir(vec3(1,1,0))) --(0, 0, math.pi/2),)
-- local q = quatFromDir(vec3(1,1,0))+quatFromDir(vec3(1,1,0))
-- core_camera.setRotation(0, quatFromDir(vec3(1,1,0))) --(0, 0, math.pi/2),)
-- local q = quatFromDir(vec3(1,1,0))+quatFromDir(vec3(1,1,0))
-- core_camera.setPosRot(0, 0, 5, 3, 0, 0, 0.02, 1)
-- core_camera.setRotation(0, quatFromDir(vec3(1,1,0))) --(0, 0, math.pi/2),)
-- local q = quatFromDir(vec3(1,1,0))+quatFromDir(vec3(1,1,0))
-- core_camera.setPosRot(0, 0, 5, 3, 0, 0, 0.02, 1)
-- part position
local c = vec3(0,0,0)
local mi,ma=vec3(math.huge,math.huge,math.huge),vec3(-math.huge,-math.huge,-math.huge)
local c = vec3(0,0,0)
local mi,ma=vec3(math.huge,math.huge,math.huge),vec3(-math.huge,-math.huge,-math.huge)
for i,v in pairs(daedata.dgeo[val].m.verts) do
local c = vec3(0,0,0)
local mi,ma=vec3(math.huge,math.huge,math.huge),vec3(-math.huge,-math.huge,-math.huge)
for i,v in pairs(daedata.dgeo[val].m.verts) do
-- local dbag = {}
-- local mi,ma = vec3(math.huge,math.huge,math.huge),vec3(-math.huge,-math.huge,-math.huge)
-- if true then
-- local dbag = {}
-- local mi,ma = vec3(math.huge,math.huge,math.huge),vec3(-math.huge,-math.huge,-math.huge)
-- if true then
local pos = amesh[val].body:getPosition()
W.out.cmesh = pos + vec3(0,0,daedata.alod[val].zma + 0.25)
camTarget = {dir=pos + vec3(0,0,daedata.alod[val].zma/2) -core_camera.getPosition()}
W.out.cmesh = pos + vec3(0,0,daedata.alod[val].zma + 0.25)
camTarget = {dir=pos + vec3(0,0,daedata.alod[val].zma/2) -core_camera.getPosition()}
-- W.out.cmesh = pos
local box = om:getWorldBox()
step = 1.5*vec3(box.maxExtents.x-box.minExtents.x,box.maxExtents.y-box.minExtents.y):length()
h = 1.2*(box.maxExtents.z-box.minExtents.z)
local id,om = M.meshUp(am,'tst', scenetree.findObject('edit'))
om:setPosition(vec3(s,0,h))
-- if k==2 then
-- end
-- meshTarget = {pos=vec3(-0,0,1.6*z)}
local box = om:getWorldBox()
local box = om:getWorldBox()
amesh[#amesh+1] = {id=id,name=g.name,body=om,data=am,dim=vec3(box.maxExtents.x-box.minExtents.x,box.maxExtents.y-box.minExtents.y)}
end
local id,om = M.meshUp(am,'tst', scenetree.findObject('edit'))
-- om:setPosition(vec3(-0,0,0.35))
-- om:setPosition(vec3(0,0,0))
-- om:setPosition(vec3(-0,0,0.35))
-- om:setPosition(vec3(0,0,0))
z = 2.2*z
z = 2.2*z
local mt = vec3(0,0,z)
if env.ui['test'] then
local box = om:getWorldBox()
amesh = {{id=id,body=om,data=am,dim=vec3(box.maxExtents.x-box.minExtents.x,box.maxExtents.y-box.minExtents.y)}}
beamdata.ds = beamdata.ds + mt
--[[
local mi,ma = vec3(math.huge,math.huge,math.huge),-vec3(math.huge,math.huge,math.huge)
for i,v in pairs(beamdata.anode) do
--[[
local mi,ma = vec3(math.huge,math.huge,math.huge),-vec3(math.huge,math.huge,math.huge)
for i,v in pairs(beamdata.anode) do
local id,om = M.meshUp(am,'tst', scenetree.findObject('edit'))
om:setPosition(vec3(-0,0,0.5))
meshTarget = {pos=vec3(-0,0,1.6*z)}
om:setPosition(vec3(-0,0,0.5))
meshTarget = {pos=vec3(-0,0,1.6*z)}
local box = om:getWorldBox()
local box = om:getWorldBox()
amesh = {{id=id,body=om,data=am,dim=vec3(box.maxExtents.x-box.minExtents.x,box.maxExtents.y-box.minExtents.y)}}
end
-- local box = om:getWorldBox()
-- amesh = {{id=om:getID(),body=om,data=am,dim=vec3(box.maxExtents.x-box.minExtents.x,box.maxExtents.y-box.minExtents.y)}}
end
if k == 'Mesh_155' then
local pos = vec3(0,0,2) --amesh[1].body:getPosition()
dump(d.m.faces,'??^^^^^^^^^^^^ 155:'..#d.m.verts)
local id,om = M.meshUp(am,'tst', scenetree.findObject('edit'))
om:setPosition(vec3(0,0,5))
local box = om:getWorldBox()
-- amesh[#amesh+1] = {id=id}
amesh = {{id=id,body=om,data=am,dim=vec3(box.maxExtents.x-box.minExtents.x,box.maxExtents.y-box.minExtents.y)}}
else
color = infilter and UI.cbutOn or UI.cbutOff
UI.buttonImg('fav_filter_on', 'star', im.ImVec2(iconsz,iconsz), color, nil, vec3(0.6,0.6))
im.Unindent(-4)
-- im.Indent(-40)
UI.buttonImg('fav_to', 'star', im.ImVec2(iconsz,iconsz), UI.colorOn, nil, vec3(0.6,0.6))
-- im.Unindent(-40)
color = fsnode.adir[i].fav==1 and im.ImVec4(0.7, 0.7, 0.0, 0.7) or UI.cbutOff
UI.buttonImg({'fav_up',i}, 'star', im.ImVec2(iconsz,iconsz), color, nil, vec3(0.6,0.6))
im.Unindent(-4)
UI.buttonImg('model_on', env.ui['model_on'] and 'folder' or 'car', im.ImVec2(36,36),
color, nil, vec3(0.8,0.8))
im.tooltip('To '..(env.ui['model_on'] and 'files' or 'models'))
if om then om:delete() end
local tveh = spawn.spawnVehicle('metal_box', nil, vec3(0,0,0), quat(0,0,1,0))
scenetree.findObjectById(tveh:getId()):delete()
scenetree.findObjectById(tveh:getId()):delete()
spawn.spawnVehicle('pickup', nil, vec3(0,0,0), quat(0,0,1,0))
break
-- if om then om:delete() end
-- spawn.spawnVehicle('metal_box', nil, vec3(0,0,0), quat(0,0,1,0))
local djpart = J.part2file()
local dir = core_camera.getForward():normalized()
local vx = dir:cross(vec3(0,0,1)):normalized()
local vy = vx:cross(dir)
local vy = vx:cross(dir)
local v1 = U.vturn(vec3(1,0,0),math.pi*0)
local v2 = U.vturn(vec3(1,0,0),math.pi*2/3)
local v1 = U.vturn(vec3(1,0,0),math.pi*0)
local v2 = U.vturn(vec3(1,0,0),math.pi*2/3)
local v3 = U.vturn(vec3(1,0,0),math.pi*4/3)
local v2 = U.vturn(vec3(1,0,0),math.pi*2/3)
local v3 = U.vturn(vec3(1,0,0),math.pi*4/3)
local p1,p2,p3 =
local dir = core_camera.getForward():normalized()
local vx = dir:cross(vec3(0,0,1)):normalized()
local vy = vx:cross(dir)
local vy = vx:cross(dir)
local v1 = U.vturn(vec3(1,0,0),math.pi*0)
local v2 = U.vturn(vec3(1,0,0),math.pi*2/3)
local v1 = U.vturn(vec3(1,0,0),math.pi*0)
local v2 = U.vturn(vec3(1,0,0),math.pi*2/3)
local v3 = U.vturn(vec3(1,0,0),math.pi*4/3)
local v2 = U.vturn(vec3(1,0,0),math.pi*2/3)
local v3 = U.vturn(vec3(1,0,0),math.pi*4/3)
debugDrawer:drawTriSolid(
-- get beams displacment
local cm = vec3(0,0,0)
for _,v in pairs(daedata.dgeo[key].m.verts) do
-- dump(d.abeam,'?? for_BM:'..tostring(#d.abeam))
local cb = vec3(0,0,0)
U.map(d.abeam,function(k,v)
cb = cb/#d.abeam/2
local ds = cm-cb+vec3(0.5,2.5,0)
ds = vec3(0.55,0.85,-0.36) --+vec3(0.5,-0.5,0)
local ds = cm-cb+vec3(0.5,2.5,0)
ds = vec3(0.55,0.85,-0.36) --+vec3(0.5,-0.5,0)
ds = vec3(0,0,0)
local ds = cm-cb+vec3(0.5,2.5,0)
ds = vec3(0.55,0.85,-0.36) --+vec3(0.5,-0.5,0)
ds = vec3(0,0,0)
ds = vec3(0.55,0.85,-0.36) --+vec3(0.5,-0.5,0)
ds = vec3(0,0,0)
beamdata.ds = ds
w = 2 + 6*b.deform
c = vec3(0,0.4,0.4)*b.spring + vec3(0.4,0,0.4)*(1-b.spring)
alpha = 0.4 + 0.6*b.strength
w = 2 + 6*b.deform
c = vec3(0,0.4,0.4)*b.spring + vec3(0.4,0,0.4)*(1-b.spring)
alpha = 0.4 + 0.6*b.strength
@/lua/ge/extensions/util/decalRoadsEditor.lua
local n = {
pos = vec3(o:getNodePosition(i)),
radius = o:getNodeWidth(i) * 0.5,
-- draw the segment
local lastPos = vec3()
local dir = (n.pos - lastData.pos)
local s = lrad * 2 * 0.9
data.scale = vec3(s, s, s)
local d = dir * ldir
@/lua/ge/extensions/editor/toolUtilities/terrainPainter.lua
-- Module state.
local tmp1, tmp2, posWS = vec3(), vec3(), vec3()
local gMin, gMax, tmpPoint2I = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
-- Module state.
local tmp1, tmp2, posWS = vec3(), vec3(), vec3()
local gMin, gMax, tmpPoint2I = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
-- Module state.
local tmp1, tmp2, posWS = vec3(), vec3(), vec3()
local gMin, gMax, tmpPoint2I = Point2I(0, 0), Point2I(0, 0), Point2I(0, 0)
local binX, binY, halfWidth = bin.x, bin.y, divWidths[i] * 0.5 + group.paintMargin
leftPts[i] = vec3(p.x - binX * halfWidth, p.y - binY * halfWidth, 0)
rightPts[i] = vec3(p.x + binX * halfWidth, p.y + binY * halfWidth, 0)
leftPts[i] = vec3(p.x - binX * halfWidth, p.y - binY * halfWidth, 0)
rightPts[i] = vec3(p.x + binX * halfWidth, p.y + binY * halfWidth, 0)
end
@/lua/ge/extensions/flowgraph/nodes/vehicle/special/wheelDistance.lua
local target, point, pointToTrigger, vehCenter, dirVec = vec3(), vec3(), vec3(), vec3(), vec3()
local wheelNodePos, wheelNodePosToTrigger = vec3(), vec3()
local target, point, pointToTrigger, vehCenter, dirVec = vec3(), vec3(), vec3(), vec3(), vec3()
local wheelNodePos, wheelNodePosToTrigger = vec3(), vec3()
local target, point, pointToTrigger, vehCenter, dirVec = vec3(), vec3(), vec3(), vec3(), vec3()
local wheelNodePos, wheelNodePosToTrigger = vec3(), vec3()
local target, point, pointToTrigger, vehCenter, dirVec = vec3(), vec3(), vec3(), vec3(), vec3()
local wheelNodePos, wheelNodePosToTrigger = vec3(), vec3()
local target, point, pointToTrigger, vehCenter, dirVec = vec3(), vec3(), vec3(), vec3(), vec3()
local wheelNodePos, wheelNodePosToTrigger = vec3(), vec3()
local target, point, pointToTrigger, vehCenter, dirVec = vec3(), vec3(), vec3(), vec3(), vec3()
local wheelNodePos, wheelNodePosToTrigger = vec3(), vec3()
local wheels = {}
local target, point, pointToTrigger, vehCenter, dirVec = vec3(), vec3(), vec3(), vec3(), vec3()
local wheelNodePos, wheelNodePosToTrigger = vec3(), vec3()
local wheels = {}
@/lua/ge/extensions/editor/assemblySpline/populate.lua
local twoPi = 2.0 * math.pi
local bridgeXAxis, up = vec3(1, 0, 0), vec3(0, 0, 1)
local defaultScale = vec3(1, 1, 1)
local twoPi = 2.0 * math.pi
local bridgeXAxis, up = vec3(1, 0, 0), vec3(0, 0, 1)
local defaultScale = vec3(1, 1, 1)
local bridgeXAxis, up = vec3(1, 0, 0), vec3(0, 0, 1)
local defaultScale = vec3(1, 1, 1)
local preRotQuats = geom.getPreRotQuats()
local freedomJitterQuat, axisJitterQuat = quat(), quat()
local finalPos, tmpScale, bridgeInternalDir = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local freedomJitterQuat, axisJitterQuat = quat(), quat()
local finalPos, tmpScale, bridgeInternalDir = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local freedomJitterQuat, axisJitterQuat = quat(), quat()
local finalPos, tmpScale, bridgeInternalDir = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local finalPos, tmpScale, bridgeInternalDir = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local finalPos, tmpScale, bridgeInternalDir = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local finalPos, tmpScale, bridgeInternalDir = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local sourceForwardVec, sourceUpVec, freedomAxisWorld = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local sourceForwardVec, sourceUpVec, freedomAxisWorld = vec3(), vec3(), vec3()
local posWS, vertOffsetVec, placedPosWS = vec3(), vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local sourceForwardVec, sourceUpVec, freedomAxisWorld = vec3(), vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local sourceForwardVec, sourceUpVec, freedomAxisWorld = vec3(), vec3(), vec3()
local sourceNailAxisWorld, targetNailAxisWorld = vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local sourceForwardVec, sourceUpVec, freedomAxisWorld = vec3(), vec3(), vec3()
local sourceNailAxisWorld, targetNailAxisWorld = vec3(), vec3()
local sourcePosWS, placedForwardVec, placedUpVec = vec3(), vec3(), vec3()
local sourceForwardVec, sourceUpVec, freedomAxisWorld = vec3(), vec3(), vec3()
local sourceNailAxisWorld, targetNailAxisWorld = vec3(), vec3()
local sourceForwardVec, sourceUpVec, freedomAxisWorld = vec3(), vec3(), vec3()
local sourceNailAxisWorld, targetNailAxisWorld = vec3(), vec3()
local bridgeSourceNailAxisWorld, bridgeTargetNailAxisWorld = vec3(), vec3()
local sourceForwardVec, sourceUpVec, freedomAxisWorld = vec3(), vec3(), vec3()
local sourceNailAxisWorld, targetNailAxisWorld = vec3(), vec3()
local bridgeSourceNailAxisWorld, bridgeTargetNailAxisWorld = vec3(), vec3()
local sourceNailAxisWorld, targetNailAxisWorld = vec3(), vec3()
local bridgeSourceNailAxisWorld, bridgeTargetNailAxisWorld = vec3(), vec3()
local bridgeSourcePosWorld, targetAttachPosWS = vec3(), vec3()
local sourceNailAxisWorld, targetNailAxisWorld = vec3(), vec3()
local bridgeSourceNailAxisWorld, bridgeTargetNailAxisWorld = vec3(), vec3()
local bridgeSourcePosWorld, targetAttachPosWS = vec3(), vec3()
local bridgeSourceNailAxisWorld, bridgeTargetNailAxisWorld = vec3(), vec3()
local bridgeSourcePosWorld, targetAttachPosWS = vec3(), vec3()
local sourceNailProj, bridgeSourceNailProj = vec3(), vec3()
local bridgeSourceNailAxisWorld, bridgeTargetNailAxisWorld = vec3(), vec3()
local bridgeSourcePosWorld, targetAttachPosWS = vec3(), vec3()
local sourceNailProj, bridgeSourceNailProj = vec3(), vec3()
local bridgeSourcePosWorld, targetAttachPosWS = vec3(), vec3()
local sourceNailProj, bridgeSourceNailProj = vec3(), vec3()
local targetNailProj, bridgeTargetNailProj = vec3(), vec3()
local bridgeSourcePosWorld, targetAttachPosWS = vec3(), vec3()
local sourceNailProj, bridgeSourceNailProj = vec3(), vec3()
local targetNailProj, bridgeTargetNailProj = vec3(), vec3()
local sourceNailProj, bridgeSourceNailProj = vec3(), vec3()
local targetNailProj, bridgeTargetNailProj = vec3(), vec3()
local tmpVec1, tmpVec2, tmpVec3, tmpVec4 = vec3(), vec3(), vec3(), vec3()
local sourceNailProj, bridgeSourceNailProj = vec3(), vec3()
local targetNailProj, bridgeTargetNailProj = vec3(), vec3()
local tmpVec1, tmpVec2, tmpVec3, tmpVec4 = vec3(), vec3(), vec3(), vec3()
local targetNailProj, bridgeTargetNailProj = vec3(), vec3()
local tmpVec1, tmpVec2, tmpVec3, tmpVec4 = vec3(), vec3(), vec3(), vec3()
local targetNailProj, bridgeTargetNailProj = vec3(), vec3()
local tmpVec1, tmpVec2, tmpVec3, tmpVec4 = vec3(), vec3(), vec3(), vec3()
local targetNailProj, bridgeTargetNailProj = vec3(), vec3()
local tmpVec1, tmpVec2, tmpVec3, tmpVec4 = vec3(), vec3(), vec3(), vec3()
local targetNailProj, bridgeTargetNailProj = vec3(), vec3()
local tmpVec1, tmpVec2, tmpVec3, tmpVec4 = vec3(), vec3(), vec3(), vec3()
for i = 1, maxMolecules * maxRigidMeshes do
translationArray[i] = translationArray[i] or vec3() -- Create reusable vec3 and quat objects, as and when we need them.
rotationArray[i] = rotationArray[i] or quat()
@/lua/vehicle/powertrain/genericTorqueProvider.lua
if device.torqueReactionNodes and #device.torqueReactionNodes == 3 then
local pos1 = vec3(v.data.nodes[device.torqueReactionNodes[1]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos1 = vec3(v.data.nodes[device.torqueReactionNodes[1]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos3 = vec3(v.data.nodes[device.torqueReactionNodes[3]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos3 = vec3(v.data.nodes[device.torqueReactionNodes[3]].pos)
local avgPos = (((pos1 + pos2) / 2) + pos3) / 2
@/lua/ge/extensions/flowgraph/nodes/util/closestPath.lua
function C:_executionStarted()
self.lastTrackedPosValue = vec3()
end
else
route:setupPathMulti({vec3(self.pinIn.posB.value), vec3(self.pinIn.posA.value)})
end
else
route:setupPathMulti({vec3(self.pinIn.posB.value), vec3(self.pinIn.posA.value)})
end
if route ~= nil and self.pinIn.flow.value and self.pinIn.trackedPos.value ~= self.lastTrackedPosValue then
route:trackPosition(vec3(self.pinIn.trackedPos.value))
self.lastTrackedPosValue = self.pinIn.trackedPos.value
@/lua/vehicle/recovery.lua
local useSmartSpawn = true
local upVector = vec3(0,0,1)
local recoverTimer
local objPos = vec3()
if objPosition then
objPosition = vec3(objPosition)
else
else
objPosition = vec3(obj:getPositionXYZ())
end
return {
pos = vec3(a.pos) + (vec3(b.pos) - vec3(a.pos)) * t,
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
return {
pos = vec3(a.pos) + (vec3(b.pos) - vec3(a.pos)) * t,
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
return {
pos = vec3(a.pos) + (vec3(b.pos) - vec3(a.pos)) * t,
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
pos = vec3(a.pos) + (vec3(b.pos) - vec3(a.pos)) * t,
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
dirUp = (vec3(a.dirUp) + (vec3(b.dirUp) - vec3(a.dirUp)) * t):normalized()
pos = vec3(a.pos) + (vec3(b.pos) - vec3(a.pos)) * t,
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
dirUp = (vec3(a.dirUp) + (vec3(b.dirUp) - vec3(a.dirUp)) * t):normalized()
pos = vec3(a.pos) + (vec3(b.pos) - vec3(a.pos)) * t,
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
dirUp = (vec3(a.dirUp) + (vec3(b.dirUp) - vec3(a.dirUp)) * t):normalized()
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
dirUp = (vec3(a.dirUp) + (vec3(b.dirUp) - vec3(a.dirUp)) * t):normalized()
}
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
dirUp = (vec3(a.dirUp) + (vec3(b.dirUp) - vec3(a.dirUp)) * t):normalized()
}
dirFront = (vec3(a.dirFront) + (vec3(b.dirFront) - vec3(a.dirFront)) * t):normalized(),
dirUp = (vec3(a.dirUp) + (vec3(b.dirUp) - vec3(a.dirUp)) * t):normalized()
}
local function constructAABB()
local pmin = vec3(math.huge, math.huge, math.huge)
local pmax = vec3(-math.huge, -math.huge, -math.huge)
local pmin = vec3(math.huge, math.huge, math.huge)
local pmax = vec3(-math.huge, -math.huge, -math.huge)
local nodes = v.data.nodes
local refPos = vec3(nodes[v.data.refNodes[0].ref].pos)
pmin = pmin - (refPos)
return {
vec3(pmin.x, pmin.y, pmin.z),
vec3(pmin.x, pmin.y, pmax.z),
vec3(pmin.x, pmin.y, pmin.z),
vec3(pmin.x, pmin.y, pmax.z),
vec3(pmin.x, pmax.y, pmin.z),
vec3(pmin.x, pmin.y, pmax.z),
vec3(pmin.x, pmax.y, pmin.z),
vec3(pmax.x, pmin.y, pmin.z)
vec3(pmin.x, pmax.y, pmin.z),
vec3(pmax.x, pmin.y, pmin.z)
}
local lastRecoveryPoint
local camPos = vec3()
local camRot = quat()
-- if the angle limits (in degrees) are surpassed, car is reset to upright position, maintaining the recpoint heading
local dirFront = vec3(recPoint.dirFront)
local dirUp = vec3(recPoint.dirUp)
local dirFront = vec3(recPoint.dirFront)
local dirUp = vec3(recPoint.dirUp)
local rot = quatFromDir(dirFront, dirUp)
obj:queueGameEngineLua("spawn.safeTeleport(getObjectByID("..obj:getId().."), vec3("..recPoint.pos.x..","..recPoint.pos.y..","..recPoint.pos.z.."), quat("..rot.x..","..rot.y..","..rot.z..","..rot.w.."), nil, nil, " .. tostring(moveTraffic) .. ")")
else
local rot
local dirFront = vec3(recPoint.dirFront)
local dirUp = vec3(recPoint.dirUp)
local dirFront = vec3(recPoint.dirFront)
local dirUp = vec3(recPoint.dirUp)
local roll, pitch = getRollPitch(dirFront, dirUp)
local aabb
local camOffsetVec = vec3(0,0,0.1)
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local camOffsetVec = vec3(0,0,0.1)
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local camOffsetVec = vec3(0,0,0.1)
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local camOffsetVec = vec3(0,0,0.1)
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local camOffsetVec = vec3(0,0,0.1)
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local camOffsetVec = vec3(0,0,0.1)
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local camOffsetVec = vec3(0,0,0.1)
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local rot = quat()
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local rot = quat()
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local rot = quat()
local p1, p2, t1, t2, backVec, tempVec = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local oobb = {vec3(), vec3(), vec3(), vec3()}
local rot = quat()
relativeNodePositions[i] = nodes[i].pos - nodes[v.data.refNodes[0].ref].pos
nodeRenderPositions[i] = vec3()
end
@/lua/vehicle/extensions/tech/trailSim.lua
--trailerAngle = deg(acos(vehicleDirection:dot(trailerDirection)))
trailerAngle = deg(atan2(vehicleDirection:cross(trailerDirection):dot(vec3(0, 0, 1)), vehicleDirection:dot(trailerDirection)))
end
@/lua/ge/extensions/gameplay/markers/gasStationMarker.lua
local markerIndexCorrection = { { 3, 4, 2, 1 }, { 1, 2, 4, 3 } }
local vecZero = vec3(0,0,0)
local vecOne = vec3(1,1,1)
local vecZero = vec3(0,0,0)
local vecOne = vec3(1,1,1)
local quatZero = quat(0,0,0,0)
local quatZero = quat(0,0,0,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local playModeColorI = ColorI(255,255,255,255)
local iconWorldSize = 20
local tmpVec = vec3()
function C:init()
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/editor/tech/roadArchitect/decals.lua
local abs, min, max, sin, cos, deg2Rad = math.abs, math.min, math.max, math.sin, math.cos, math.rad
local vertical = vec3(0, 0, 1)
local raised = vec3(0, 0, 4.2)
local vertical = vec3(0, 0, 1)
local raised = vec3(0, 0, 4.2)
local numNodes, decalId = #nodes, dRoad:getID()
local last = vec3(0, 0, 1e24)
if sStart > 0 and sEnd > 0 then
local decalId = dRoad:getID()
local last = vec3(0, 0, 1e24)
local ctr = 0
local last = vec3(0, 0, 1e24)
if layer.isReverse[0] then
local last = vec3(0, 0, 1e24)
if layer.isReverse[0] then
@/lua/common/jbeam/sections/vropes.lua
rope.vehiclePropIdB = anchorBProp
--rope.anchorA = vec3(anchorAProp.pos.x, anchorAProp.pos.y, anchorAProp.pos.z)
--rope.anchorB = vec3(anchorBProp.pos.x, anchorBProp.pos.y, anchorBProp.pos.z)
--rope.anchorA = vec3(anchorAProp.pos.x, anchorAProp.pos.y, anchorAProp.pos.z)
--rope.anchorB = vec3(anchorBProp.pos.x, anchorBProp.pos.y, anchorBProp.pos.z)
-- Set rope directions (default to pointing down if not specified)
rope.dirA = ropeConfig.dirA and vec3(ropeConfig.dirA.x, ropeConfig.dirA.y, ropeConfig.dirA.z) or vec3(0, 0, -1)
rope.dirB = ropeConfig.dirB and vec3(ropeConfig.dirB.x, ropeConfig.dirB.y, ropeConfig.dirB.z) or vec3(0, 0, -1)
-- Set rope directions (default to pointing down if not specified)
rope.dirA = ropeConfig.dirA and vec3(ropeConfig.dirA.x, ropeConfig.dirA.y, ropeConfig.dirA.z) or vec3(0, 0, -1)
rope.dirB = ropeConfig.dirB and vec3(ropeConfig.dirB.x, ropeConfig.dirB.y, ropeConfig.dirB.z) or vec3(0, 0, -1)
rope.dirA = ropeConfig.dirA and vec3(ropeConfig.dirA.x, ropeConfig.dirA.y, ropeConfig.dirA.z) or vec3(0, 0, -1)
rope.dirB = ropeConfig.dirB and vec3(ropeConfig.dirB.x, ropeConfig.dirB.y, ropeConfig.dirB.z) or vec3(0, 0, -1)
rope.dirA = ropeConfig.dirA and vec3(ropeConfig.dirA.x, ropeConfig.dirA.y, ropeConfig.dirA.z) or vec3(0, 0, -1)
rope.dirB = ropeConfig.dirB and vec3(ropeConfig.dirB.x, ropeConfig.dirB.y, ropeConfig.dirB.z) or vec3(0, 0, -1)
@/lua/ge/extensions/editor/tech/roadArchitect/clothoid.lua
local C, S = generalizedFresnelCS(dKappa * p * p, kappa * p, theta0)
return vec3(start.x + p * C, start.y + p * S)
end
@/lua/ge/extensions/gameplay/drift/destination.lua
for i = index, #extractedWaypoints - 1 do
remainingDist = remainingDist + vec3(extractedWaypoints[i]):distance(extractedWaypoints[i + 1])
end
local currWrongWayDist = 0
local lastFramePos = vec3()
local function calcWrongWayFail()
currWrongWayDist = 0
lastFramePos = vec3()
end
@/lua/ge/extensions/editor/crawlEditor/paths.lua
self.currentPathnode = nil
self._prevGizmoPos = vec3(0, 0, 0)
self._prevPathnodePos = {}
if posEditEnded[0] then
self.currentPathnode.pos = vec3(pos[0], pos[1], pos[2])
markPathAsDirty(path)
name = "Node " .. tostring(#path.nodes + 1),
pos = vec3(0, 0, 0),
rotation = quat(1, 0, 0, 0),
self._isDragging = true
self._prevGizmoPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
self._prevPathnodePos = deepcopy(self.currentPathnode.pos)
local posOffset = (vec3(editor.getAxisGizmoTransform():getColumn(3)) - self._prevGizmoPos) / 2
self._prevGizmoPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
end
function C:dropToTerrain(pos)
local p = vec3(pos)
if core_terrain then
-- Get forward direction from rotation (Y is forward in BeamNG)
local forwardDir = rotation * vec3(0, 1, 0)
local arrowLength = 3.0 -- Arrow length in meters
@/lua/vehicle/powertrain/electricMotor.lua
if device.torqueReactionNodes and #device.torqueReactionNodes == 3 and device.torqueReactionNodes[1] >= 0 then
local pos1 = vec3(v.data.nodes[device.torqueReactionNodes[1]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos1 = vec3(v.data.nodes[device.torqueReactionNodes[1]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos3 = vec3(v.data.nodes[device.torqueReactionNodes[3]].pos)
local pos2 = vec3(v.data.nodes[device.torqueReactionNodes[2]].pos)
local pos3 = vec3(v.data.nodes[device.torqueReactionNodes[3]].pos)
local avgPos = (((pos1 + pos2) / 2) + pos3) / 2
@/lua/ge/extensions/util/trackBuilder/splineTrack.lua
local heightScale = 1
local vectorScale = vec3(gridScale, gridScale, heightScale)
local pointsMultiplier = 6
local function sortSegmentsForMultiTrack(segments)
local centerP = vec3()
for _,seg in ipairs(segments) do
local rot = p.finalRot or p.rot
local off = M.rotateVectorByQuat(vec3(0, reverse and - 1 or 1, 0), rot)
local up = M.rotateVectorByQuat(vec3(0, 0, 1), rot)
local off = M.rotateVectorByQuat(vec3(0, reverse and - 1 or 1, 0), rot)
local up = M.rotateVectorByQuat(vec3(0, 0, 1), rot)
local num = #scenario.lapConfig
local num = #scenario.lapConfig
local pos = position and rot:__mul(vec3(position.x, position.y, position.z)) or vec3(0, 0, 0)
local num = #scenario.lapConfig
local pos = position and rot:__mul(vec3(position.x, position.y, position.z)) or vec3(0, 0, 0)
local position = (p.basePosition and vec3(p.basePosition) or vec3(p.position)) + vec3(0, 0, p.zOffset) + pos
local scale = (size or p.width) / 2 + 1
local position = (p.basePosition and vec3(p.basePosition) or vec3(p.position)) + vec3(0, 0, p.zOffset) + pos
local scale = (size or p.width) / 2 + 1
local position = (p.basePosition and vec3(p.basePosition) or vec3(p.position)) + vec3(0, 0, p.zOffset) + pos
local scale = (size or p.width) / 2 + 1
checkPoint:setPosition(position)
checkPoint.scale = vec3(scale, scale, scale)
checkPoint:setField('rotation', 0, quat.x .. ' ' ..quat.y..' '..quat.z..' '..quat.w)
local off = M.rotateVectorByQuat(vec3(0, -3, 0), rot)
local pos = vec3(0, 0, 0.25) + point.markerInfo.position + off
local off = M.rotateVectorByQuat(vec3(0, -3, 0), rot)
local pos = vec3(0, 0, 0.25) + point.markerInfo.position + off
local scenario = scenario_scenarios and scenario_scenarios.getScenario()
local cameraPosition = core_camera.getPosition()
local position = M.rotateVectorByQuat(vec3(0, 15, 0), core_camera.getQuat())
position = position + cameraPosition
local trackPosition = subTrackPositions[subTrackIndex]
local cameraLook = M.rotateVectorByQuat(vec3(0, 1, 0), core_camera.getQuat())
local cameraAngle = (-math.atan2(cameraLook.y, -cameraLook.x) + math.pi / 2) * 180 / math.pi
local trackPosition = subTrackPositions[sub]
trackPosition.position = vec3(x, y, z)
if hdg then
-- rotated unit vectors for snapping points to a grid
trackPosition.unitX = quatFromEuler(0, 0, trackPosition.hdg):__mul(vec3(1, 0, 0))
trackPosition.unitY = quatFromEuler(0, 0, trackPosition.hdg):__mul(vec3(0, 1, 0))
trackPosition.unitX = quatFromEuler(0, 0, trackPosition.hdg):__mul(vec3(1, 0, 0))
trackPosition.unitY = quatFromEuler(0, 0, trackPosition.hdg):__mul(vec3(0, 1, 0))
-- place and rotate the origin piece of the track and invalidate whole track
-- place and rotate the origin piece of the track and invalidate whole track
pieces[1].position = vec3(x, y, z)
pieces[1].hdg = trackPosition.hdg
local cameraLook = M.rotateVectorByQuat(vec3(0, 1, 0), core_camera.getQuat())
local cameraAngle = (math.atan2(cameraLook.y, -cameraLook.x) - math.pi / 2)
transition.lerpTo(tip.markerInfo.position + q:__mul(vec3(0, -(distance or M.camDistance), 0)), q, 0.3)
end
trackMarker:setPosition((subTracks[subTrackIndex][index].markerInfo.position))
trackMarker:setScale(vec3(2, 2, 2))
if trackMarker then
trackMarker.scale = vec3(0, 0, 0)
end
trackMarker:setField('shapeName', 0, "art/shapes/interface/checkpoint_marker_sphere.dae")
trackMarker:setPosition(vec3(0, 0, 0))
trackMarker.scale = vec3(1, 1, 1)
trackMarker:setPosition(vec3(0, 0, 0))
trackMarker.scale = vec3(1, 1, 1)
trackMarker:setField('rotation', 0, '0 0 1 0')
else
trackMarker.scale = vec3(1, 1, 1)
end
0):__mul(quatFromEuler(0, math.pi, segment.hdg))
segment.markerInfo.position = segment.markerInfo.basePosition + vec3(0, 0, segment.markerInfo.zOffset)
segment.invalid = false
local pieces = subPieces[subTrackIndex]
local dist = (vec3(track[1].markerInfo.position)
-vec3(track[#track].markerInfo.position)):length()
local dist = (vec3(track[1].markerInfo.position)
-vec3(track[#track].markerInfo.position)):length()
M.addPiece({piece = 'freeBezier', xOff = 0, yOff = 0, dirOff = 0, absolute = true, forwardLen = dist / 16, backwardLen = dist / 16, empty = false})
-- markerInfo position to last point position
segment.markerInfo.basePosition = vec3(segment.points[#segment.points].position)
segment.markerInfo.basePosition = vec3(segment.position):componentMul(vectorScale)
segment.markerInfo.basePosition = vec3(segment.points[#segment.points].position)
segment.markerInfo.basePosition = vec3(segment.position):componentMul(vectorScale)
else
else
segment.markerInfo.basePosition = vec3(segment.position):componentMul(vectorScale)
end
numPoints = numPoints - numPoints % 1
local arcCenter = (segment.position + vec3(-math.sin((segment.hdg - segment.direction * math.pi / 2)), -math.cos((segment.hdg - segment.direction * math.pi / 2)), 0) * math.abs(segment.radius)):componentMul(vectorScale)
for i = 0, numPoints do
points[i + 1] = {
position = arcCenter + vec3(math.cos(angle), math.sin(angle), 0) * segment.radius * gridScale,
rot = quatFromEuler(math.pi, 0, 0):__mul(quatFromEuler(0, 0, -hdg - math.pi / 2)),
local xUnitVector = vec3(math.cos(piece.hdg), -math.sin(piece.hdg), 0)
local yUnitVector = vec3(math.sin(piece.hdg), math.cos(piece.hdg), 0)
local xUnitVector = vec3(math.cos(piece.hdg), -math.sin(piece.hdg), 0)
local yUnitVector = vec3(math.sin(piece.hdg), math.cos(piece.hdg), 0)
local newP = {
position = vec3(
(piece.position.x + p.position.x * xUnitVector.x + p.position.y * yUnitVector.x) * gridScale,
track[i].markerInfo = {
basePosition = vec3(),
position = vec3(),
basePosition = vec3(),
position = vec3(),
zOffset = 0
piece = "init",
position = vec3(0, 0, 0),
bank = {value = 0, interpolation = "smoothSlope"},
subTrackPositions[subTrackIndex] = {
position = vec3(),
hdg = 0
if not o.extra then o.extra = {x=1,y=1,z=1} end
o.position = vec3(o.position.x, o.position.y, o.position.z)
o.scale = vec3(o.scale.x, o.scale.y, o.scale.z)
o.position = vec3(o.position.x, o.position.y, o.position.z)
o.scale = vec3(o.scale.x, o.scale.y, o.scale.z)
o.extra = vec3(o.extra.x, o.extra.y, o.extra.z)
o.scale = vec3(o.scale.x, o.scale.y, o.scale.z)
o.extra = vec3(o.extra.x, o.extra.y, o.extra.z)
o.rotationEuler = vec3(o.rotationEuler.x, o.rotationEuler.y, o.rotationEuler.z)
o.extra = vec3(o.extra.x, o.extra.y, o.extra.z)
o.rotationEuler = vec3(o.rotationEuler.x, o.rotationEuler.y, o.rotationEuler.z)
o.rotation = quatFromEuler(o.rotationEuler.x / 180 * math.pi, o.rotationEuler.y / 180 * math.pi, (o.rotationEuler.z) / 180 * math.pi)
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veJBeamPicker.lua
local tempVec = vec3()
local tempBeamCenterPoses = {}
local tempLinePoint1 = vec3()
local tempLinePoint2 = vec3()
local tempLinePoint1 = vec3()
local tempLinePoint2 = vec3()
local pickedBeamsCIDs = {}
if not tempBeamCenterPoses[beamID] then
tempBeamCenterPoses[beamID] = vec3()
beamCenterPos = tempBeamCenterPoses[beamID]
local tempBeamCenterPos = vec3()
@/lua/ge/extensions/gameplay/rally/notebook/pacenote.lua
local fwd = wp_pos.pos - pos
local up = vec3(0,0,1)
local rot = quatFromDir(fwd, up):normalized()
-- Calculate centroid of triangle formed by halfpoint, CS, and CE
local halfPos = vec3(self.halfpoint.pos)
local csPos = vec3(wp_cs.pos)
local halfPos = vec3(self.halfpoint.pos)
local csPos = vec3(wp_cs.pos)
local cePos = vec3(wp_ce.pos)
local csPos = vec3(wp_cs.pos)
local cePos = vec3(wp_ce.pos)
camPos = vec3(
(halfPos.x + csPos.x + cePos.x) / 3,
-- Fallback to midpoint between CS and CE
local csPos = vec3(wp_cs.pos)
local cePos = vec3(wp_ce.pos)
local csPos = vec3(wp_cs.pos)
local cePos = vec3(wp_ce.pos)
camPos = vec3(
(csPos.x + cePos.x) / 2,
local wp = self:getCornerStartWaypoint()
camPos = wp and vec3(wp.pos) or vec3(0, 0, 0)
end
local wp = self:getCornerStartWaypoint()
camPos = wp and vec3(wp.pos) or vec3(0, 0, 0)
end
@/lua/ge/extensions/career/modules/delivery/vehicleTasks.lua
local valid, res = destinationPs:checkParking(taskData.vehId)
simpleDebugText3d(valid and "Valid" or "Invalid", destinationPs.pos + vec3(0,0,2), 0.25, valid and ColorF(0,1,0,0.25) or ColorF(1,0,0,0.25))
destinationPs:drawDebug()
@/lua/ge/extensions/career/modules/inspectVehicle.lua
local tempVecDir = vec3()
local function checkIfPlayerHasArrivedToVehInspection(playerVehObj, vehObj)
@/lua/ge/extensions/editor/sceneView.lua
local imUtils = require('ui/imguiUtils')
local vecUp = vec3(0, 0, 1)
local renderMain = im.BoolPtr(true)
ortho = im.BoolPtr(data.ortho or false),
dragOffset = data.dragOffset or vec3(0,0,0),
control = ImguiRenderViewControl.getOrCreate(newName),
local function _drawgrid(size, rot, gridOrigin, width)
local p1 = vec3(0,0,-size)
local p2 = vec3(0,0,size)
local p1 = vec3(0,0,-size)
local p2 = vec3(0,0,size)
local col = ColorF(0.3,0.3,0.3,1)
view.mode = 'left'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'right'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'front'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'back'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'top'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
view.mode = 'bottom'
view.dragOffset = vec3(0,0,0)
im.CloseCurrentPopup()
local delta = vec3(0, 0, 0)
local gridSize = 5 -- meters
if view.mode == 'left' then
view.rot = quatFromDir(vec3(-1,0,0), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(0, -delta.x, delta.y)
end
end
view.dragOffset = view.dragOffset + vec3(delta.z, 0, 0)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(10, 0, 0)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'right' then
view.rot = quatFromDir(vec3(1,0,0), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(0, delta.x, delta.y)
end
end
view.dragOffset = view.dragOffset + vec3(delta.z, 0, 0)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(-3, 0, 0)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'front' then
view.rot = quatFromDir(vec3(0,1,0), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(-delta.x, 0, delta.y)
end
end
view.dragOffset = view.dragOffset + vec3(0, delta.z, 0)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(0, -3, 0)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'back' then
view.rot = quatFromDir(vec3(0,-1,0), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(delta.x, 0, delta.y)
end
end
view.dragOffset = view.dragOffset + vec3(0, delta.z, 0)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(0, 6, 0)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'top' then
view.rot = quatFromDir(vec3(0,0,-1), vec3(1,0,0))
if view.mouseDragging0 and view.lastMouseDragPos then
elseif view.mode == 'top' then
view.rot = quatFromDir(vec3(0,0,-1), vec3(1,0,0))
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(delta.x, -delta.y, 0)
end
end
view.dragOffset = view.dragOffset + vec3(0, 0, delta.z)
if focusObj then
local fwd = focusObj:getDirectionVector()
view.pos = focusPos + focusRot * vec3(0, 0, 5)
view.rot = quatFromDir(vec3(0,0,-1), fwd)
view.pos = focusPos + focusRot * vec3(0, 0, 5)
view.rot = quatFromDir(vec3(0,0,-1), fwd)
--view.rot = quatFromDir(focusPos - view.pos, vecUp)
elseif view.mode == 'bottom' then
view.rot = quatFromDir(vec3(0,0,1), vecUp)
if view.mouseDragging0 and view.lastMouseDragPos then
if view.mouseDragging0 and view.lastMouseDragPos then
view.dragOffset = view.dragOffset + vec3(delta.x, delta.y, 0)
end
end
view.dragOffset = view.dragOffset + vec3(0, 0, delta.z)
if focusObj then
if focusObj then
view.pos = focusPos + focusRot * vec3(0.01, 0.01, -5)
view.rot = quatFromDir(focusPos - view.pos, vecUp)
--TODO: this will draw in all render views, use rendermask for each view
debugDrawer:drawTextAdvanced((vec3(0,20,0)), txt, ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:clearTargetRenderViews()
@/lua/ge/main.lua
function replaySpawnVehicle(jbeamFilename, partConfigData)
local veh = spawn.spawnVehicle(jbeamFilename, partConfigData, vec3(), quat(), nil, nil, nil)
if be:getEnterableObjectCount() == 1 then
obj:setField('shapeName', 0, '/art/shapes/collectible/s_collect_BNG.dae')
obj:setPosition(vec3(-2,1,1))
obj.scale = vec3(2, 2, 2)
obj:setPosition(vec3(-2,1,1))
obj.scale = vec3(2, 2, 2)
obj:registerObject("marker_test_v2")
obj:setField('shapeName', 0, '/levels/smallgrid/art/shapes/misc/gm_cube_1m.dae')
obj:setPosition(vec3(2, -2, 0))
obj.scale = vec3(2, 2, 2)
obj:setPosition(vec3(2, -2, 0))
obj.scale = vec3(2, 2, 2)
obj:registerObject("gm_cube_1m_test_v2")
obj:setField('shapeName', 0, '/levels/smallgrid/art/shapes/misc/gm_curb_01.dae')
obj:setPosition(vec3(-2, 2, 0))
obj.scale = vec3(1, 1, 1)
obj:setPosition(vec3(-2, 2, 0))
obj.scale = vec3(1, 1, 1)
obj:registerObject("gm_curb_01_test_v2")
if prefab then
local pos = vec3(6, 3, 2)
local scale = vec3(1.5, 1.5, 1.5)
local pos = vec3(6, 3, 2)
local scale = vec3(1.5, 1.5, 1.5)
local r = quatFromEuler(0, 0, math.rad(45))
for i=1,count do
local pos = vec3(math.random(-600, 600), math.random(-600, 600), math.random(0.5, 12))
local s = math.random(0.5, 3)
local s = math.random(0.5, 3)
local scale = vec3(s, s, s)
local r = quatFromEuler(0, 0, math.rad(math.random(0, 360)))
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/veStaticRenderView.lua
local zeroVec = vec3(0,0,0)
local unitVecs = {vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)}
local zeroVec = vec3(0,0,0)
local unitVecs = {vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)}
local zeroVec = vec3(0,0,0)
local unitVecs = {vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)}
local zeroVec = vec3(0,0,0)
local unitVecs = {vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)}
fov = im.FloatPtr(mainRVData.fov or 70),
pos = mainRVData.pos or vec3(0,0,0),
rot = mainRVData.rot and quat(mainRVData.rot) or quatFromDir(vec3(0,1,0), unitVecs[3]),
pos = mainRVData.pos or vec3(0,0,0),
rot = mainRVData.rot and quat(mainRVData.rot) or quatFromDir(vec3(0,1,0), unitVecs[3]),
gridRot = mainRVData.gridRot and quat(mainRVData.gridRot) or quatFromAxisAngle(vec3(1,0,0), math.rad(90)),
rot = mainRVData.rot and quat(mainRVData.rot) or quatFromDir(vec3(0,1,0), unitVecs[3]),
gridRot = mainRVData.gridRot and quat(mainRVData.gridRot) or quatFromAxisAngle(vec3(1,0,0), math.rad(90)),
ortho = im.BoolPtr(mainRVData.ortho or false),
mainRVData.ortho[0] = false
mainRVData.pos = vec3(0,0,0)
mainRVData.gridRot = quatFromDir(unitVecs[3], unitVecs[2])
if viewMode == VIEW_MODE_LEFT then
qDir = quatFromDir(vec3(1,0,0), unitVecs[3])
elseif viewMode == VIEW_MODE_RIGHT then
elseif viewMode == VIEW_MODE_RIGHT then
qDir = quatFromDir(vec3(-1,0,0), unitVecs[3])
elseif viewMode == VIEW_MODE_BACK then
elseif viewMode == VIEW_MODE_BACK then
qDir = quatFromDir(vec3(0,1,0), unitVecs[3])
elseif viewMode == VIEW_MODE_FRONT then
elseif viewMode == VIEW_MODE_FRONT then
qDir = quatFromDir(vec3(0,-1,0), unitVecs[3])
elseif viewMode == VIEW_MODE_BOTTOM then
elseif viewMode == VIEW_MODE_BOTTOM then
qDir = quatFromDir(vec3(0,0,1), unitVecs[3])
elseif viewMode == VIEW_MODE_TOP then
elseif viewMode == VIEW_MODE_TOP then
qDir = quatFromDir(vec3(0,0,-1), unitVecs[1])
else
mainRVData.pos = qDir * vec3(0,-10,0)
mainRVData.rot = qDir
local halfSize = gridSize / 2
local p1 = vec3(-gridSize,0,0)
local p2 = vec3(gridSize,0,0)
local p1 = vec3(-gridSize,0,0)
local p2 = vec3(gridSize,0,0)
local col = ColorF(0.75,0.75,0.75,1)
local tempLinePoint1, tempLinePoint2 = vec3(), vec3()
local tempLinePoint1, tempLinePoint2 = vec3(), vec3()
-- Don't allow picking arrow if its pretty much inline with vector projected out of user's screen
if arrowVec:dot(vec3(0,-1,0)) < 0.99 then
local xnorm1, xnorm2 = closestLinePoints(rayStartPos, rayEndPos, zeroVec, arrowVec)
-- fade out the arrow to be able to see the other arrows
if math.abs(arrowVec:dot(vec3(0,-1,0))) < 0.99 * vecMult then
--arrowCol.a = (dotProd - 0.75) * 1 / -0.25 + 1
--debugDrawer:drawLine(vec3(0,0,0), vec3(1,0,0), ColorF(1,0,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,1,0), ColorF(0,1,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(1,0,0), ColorF(1,0,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,1,0), ColorF(0,1,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(1,0,0), ColorF(1,0,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,1,0), ColorF(0,1,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,0,1), ColorF(0,0,1,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(1,0,0), ColorF(1,0,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,1,0), ColorF(0,1,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,0,1), ColorF(0,0,1,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,1,0), ColorF(0,1,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,0,1), ColorF(0,0,1,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,1,0), ColorF(0,1,0,1))
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,0,1), ColorF(0,0,1,1))
_drawgrid(gridSize, gridBlockSize, mainRVData.gridRot, vec3(0,0,0), gridLineWidth)
debugDrawer:drawTextAdvanced((vec3(5,15,0)), "Mode: " .. viewModesText[mainRVData.mode], ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--local txt = dumps{'type: ', viewModesText[mainRVData.mode], 'view.pos: ', mainRVData.pos, 'view.rot: ', mainRVData.rot}
--debugDrawer:drawTextAdvanced((vec3(0,15,0)), mainRVData.name, ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,35,0)), "PLEASE DISABLE AMBIENT OCCLUSION", ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,15,0)), mainRVData.name, ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,35,0)), "PLEASE DISABLE AMBIENT OCCLUSION", ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,55,0)), txt, ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,35,0)), "PLEASE DISABLE AMBIENT OCCLUSION", ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,55,0)), txt, ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,75,0)), 'viewport: ' .. mainRVData.renderView.viewPort:__tostring(), ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,55,0)), txt, ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:drawTextAdvanced((vec3(0,75,0)), 'viewport: ' .. mainRVData.renderView.viewPort:__tostring(), ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
local axisGizmoRVMat = QuatF(0,0,0,1):getMatrix()
axisGizmoRVMat:setPosition(vec3(0,-1,0))
if mainRVData.ortho[0] then
mainRVData.pos = mainRVData.pos + mainRVData.rot * vec3(camMove.right - camMove.left, 0, camMove.forward - camMove.backward)
* dt * camOrthoBaseSpeed * camSpeedMult
else
mainRVData.pos = mainRVData.pos + mainRVData.rot * vec3(camMove.right - camMove.left, camMove.forward - camMove.backward, 0)
* dt * camPerspBaseSpeed * camSpeedMult
if focusedWndData.mouseDragging2 and focusedWndData.lastMouseDragPos then
mainRVData.rot = quatFromAxisAngle(vec3(1,0,0), dy) * mainRVData.rot * quatFromAxisAngle(vec3(0,0,1), dx)
end
if focusedWndData.mouseDragging2 and focusedWndData.lastMouseDragPos then
mainRVData.rot = quatFromAxisAngle(vec3(1,0,0), dy) * mainRVData.rot * quatFromAxisAngle(vec3(0,0,1), dx)
end
@/lua/ge/extensions/scenario/raceMarkers/crawlMarker.lua
self.color = nil
self.pathDirection = vec3(0, 1, 0)
local playerPosition = vec3(0,0,0)
playerPosition:set(core_camera.getPosition())
local markerPos2D = vec3(self.pos.x, self.pos.y, 0)
local playerPos2D = vec3(playerPosition.x, playerPosition.y, 0)
local markerPos2D = vec3(self.pos.x, self.pos.y, 0)
local playerPos2D = vec3(playerPosition.x, playerPosition.y, 0)
local distanceFromMarker = markerPos2D:distance(playerPos2D)
local forwardDir = self.pathDirection:normalized()
local rightDir = forwardDir:cross(vec3(0, 0, 1)):normalized()
local leftPos = self.pos + rightDir * flagOffset
local terrainUp = vec3(0, 0, 1)
if core_terrain then
else
local surfaceHeight = be:getSurfaceHeightBelow(leftPos + vec3(0, 0, 1))
if surfaceHeight then
end
self.flagLeft:setPosition(vec3(leftPos))
local flagRot = quatFromDir(rightDir, terrainUp)
local rightPos = self.pos - rightDir * flagOffset
local terrainUp = vec3(0, 0, 1)
if core_terrain then
else
local surfaceHeight = be:getSurfaceHeightBelow(rightPos + vec3(0, 0, 1))
if surfaceHeight then
end
self.flagRight:setPosition(vec3(rightPos))
local flagRot = quatFromDir(-rightDir, terrainUp)
while testHeight <= maxTestHeight do
local arrowPos = vec3(self.pos.x, self.pos.y, self.pos.z + testHeight)
local rayDirection = playerPosition - arrowPos
local currentArrowHeight = self.arrowHeightSmoother:get(targetHeight, dtSim)
self.arrow:setPosition(vec3(0,0,currentArrowHeight)+self.pos)
local currentScale = self.arrowScaleSmoother:get(targetScale, dtSim)
self.arrow:setScale(vec3(currentScale, currentScale, currentScale))
self.arrow:updateInstanceRenderData()
local columnRadius = self.radius or 2.0
centerColumn:setScale(vec3(columnRadius, columnRadius, columnHeight))
centerColumn:updateInstanceRenderData()
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
else
local surfaceHeight = be:getSurfaceHeightBelow(self.pos + vec3(0, 0, 1))
if surfaceHeight then
local forwardDir = vec3(0, 1, 0)
if wp.dir then
if wp.dir then
forwardDir = vec3(wp.dir):normalized()
elseif wp.nextPos then
elseif wp.nextPos then
forwardDir = (vec3(wp.nextPos) - self.pos):normalized()
end
self.arrowHeightSmoother:set(arrowStartHeight)
self.arrow:setPosition(vec3(0,0,arrowStartHeight)+self.pos)
end
if centerColumn then
centerColumn:setPosition(vec3(self.pos))
local columnRadius = self.radius or 2.0
local columnRadius = self.radius or 2.0
centerColumn:setScale(vec3(columnRadius, columnRadius, 200))
end
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
local initialScale = self.baseArrowScale or 2.0
self.arrow:setScale(vec3(initialScale, initialScale, initialScale))
if self.arrowScaleSmoother then
@/lua/ge/extensions/gameplay/race/startPosition.lua
self.pos = vec3()
self.rot = quat()
self.name = data.name
self.pos = vec3(data.pos)
self.rot = quat(data.rot)
function C:set(pos, rot)
self.pos = vec3(pos)
self.rot = quat(rot)
local rot = self.rot
local x,y = rot * vec3(1,0,0), rot * vec3(0,-1,0)
return {
local rot = self.rot
local x,y = rot * vec3(1,0,0), rot * vec3(0,-1,0)
return {
local rot = self.rot
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local col = color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255)
local rot = self.rot
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local col = color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255)
local rot = self.rot
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
local col = color(clr[1]*255,clr[2]*255,clr[3]*255,shapeAlpha*255)
debugDrawer:drawTriSolid(
vec3(self.pos + x + z),
vec3(self.pos + x ),
vec3(self.pos + x + z),
vec3(self.pos + x ),
vec3(self.pos - x ),
vec3(self.pos + x ),
vec3(self.pos - x ),
col)
debugDrawer:drawTriSolid(
vec3(self.pos - x ),
vec3(self.pos - x + z),
vec3(self.pos - x ),
vec3(self.pos - x + z),
vec3(self.pos + x + z),
vec3(self.pos - x + z),
vec3(self.pos + x + z),
col)
debugDrawer:drawTriSolid(
vec3(self.pos - x + z),
vec3(self.pos - x - y*4),
vec3(self.pos - x + z),
vec3(self.pos - x - y*4),
vec3(self.pos - x ),
vec3(self.pos - x - y*4),
vec3(self.pos - x ),
col)
debugDrawer:drawTriSolid(
vec3(self.pos + x + z),
vec3(self.pos + x - y*4),
vec3(self.pos + x + z),
vec3(self.pos + x - y*4),
vec3(self.pos + x ),
vec3(self.pos + x - y*4),
vec3(self.pos + x ),
col)
debugDrawer:drawTriSolid(
vec3(self.pos + x + z),
vec3(self.pos - x ),
vec3(self.pos + x + z),
vec3(self.pos - x ),
vec3(self.pos + x ),
vec3(self.pos - x ),
vec3(self.pos + x ),
col)
debugDrawer:drawTriSolid(
vec3(self.pos - x ),
vec3(self.pos + x + z),
vec3(self.pos - x ),
vec3(self.pos + x + z),
vec3(self.pos - x + z),
vec3(self.pos + x + z),
vec3(self.pos - x + z),
col)
debugDrawer:drawTriSolid(
vec3(self.pos - x + z),
vec3(self.pos - x ),
vec3(self.pos - x + z),
vec3(self.pos - x ),
vec3(self.pos - x - y*4),
vec3(self.pos - x ),
vec3(self.pos - x - y*4),
col)
debugDrawer:drawTriSolid(
vec3(self.pos + x + z),
vec3(self.pos + x ),
vec3(self.pos + x + z),
vec3(self.pos + x ),
vec3(self.pos + x - y*4),
vec3(self.pos + x ),
vec3(self.pos + x - y*4),
col)
debugDrawer:drawSquarePrism(
vec3(self.pos - y * 0.1 + z * 0.9),
vec3(self.pos - y * 4.8 + z * 0.9),
vec3(self.pos - y * 0.1 + z * 0.9),
vec3(self.pos - y * 4.8 + z * 0.9),
Point2F(1.5,1.8),
local fl = vec3(veh:getSpawnWorldOOBB():getPoint(0))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local fl = vec3(veh:getSpawnWorldOOBB():getPoint(0))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local flU = vec3(veh:getSpawnWorldOOBB():getPoint(1))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local flU = vec3(veh:getSpawnWorldOOBB():getPoint(1))
local posOffset = (pos - fl)
local localOffset = vec3(xVeh:dot(posOffset), yVeh:dot(posOffset), zVeh:dot(posOffset))
local xLine, yLine, zLine = self.rot * vec3(1,0,0), self.rot * vec3(0,1,0), self.rot * vec3(0,0,1)
local newFLPos = self.pos - xLine * (fl-fr):length() * 0.5
local xLine, yLine, zLine = self.rot * vec3(1,0,0), self.rot * vec3(0,1,0), self.rot * vec3(0,0,1)
local newFLPos = self.pos - xLine * (fl-fr):length() * 0.5
local xLine, yLine, zLine = self.rot * vec3(1,0,0), self.rot * vec3(0,1,0), self.rot * vec3(0,0,1)
local newFLPos = self.pos - xLine * (fl-fr):length() * 0.5
log('D', logTag, 'safe teleporting vehicle to start position with corrected rotation')
spawn.safeTeleport(veh, vec3(newPos), quat(correctedRot), nil, nil, nil, nil, false)
end
if not veh then return end
local fl = vec3(veh:getSpawnWorldOOBB():getPoint(0))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local fl = vec3(veh:getSpawnWorldOOBB():getPoint(0))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local flU = vec3(veh:getSpawnWorldOOBB():getPoint(1))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local flU = vec3(veh:getSpawnWorldOOBB():getPoint(1))
local normalTip = center + (bl-fl)
normalTip = vec3(normalTip.x, normalTip.y, core_terrain.getTerrainHeight(normalTip))
self.rot = quatFromDir((center - normalTip):normalized(), (flU-bl):normalized())
@/lua/ge/extensions/editor/dragRaceEditor/utils.lua
mouseInfo.ray = getCameraMouseRay()
mouseInfo.rayDir = vec3(mouseInfo.ray.dir)
mouseInfo.rayCast = cameraMouseRayCast()
mouseInfo.hold = false
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._downNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._downNormal = vec3(mouseInfo.rayCast.normal)
end
if mouseInfo.hold then
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._holdNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._holdNormal = vec3(mouseInfo.rayCast.normal)
end
if mouseInfo.up then
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._upNormal = vec3(mouseInfo.rayCast.normal)
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
mouseInfo._upNormal = vec3(mouseInfo.rayCast.normal)
end
-- Convert new format to old format for transformUtil
local pos = vec3(transform.position.x, transform.position.y, transform.position.z)
local rot = quat(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w)
local rot = quat(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w)
local scl = vec3(transform.scale.x, transform.scale.y, transform.scale.z)
@/lua/ge/extensions/editor/tech/roadArchitect/tunnelMesh.lua
{ u = 1.0, v = 1.0 } }
local origin = vec3(0, 0, 0) -- A vec3 used for representing the scene origin.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local origin = vec3(0, 0, 0) -- A vec3 used for representing the scene origin.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local up = vec3(0, 0, 1)
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local up = vec3(0, 0, 1)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local up = vec3(0, 0, 1)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local up = vec3(0, 0, 1)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
if dSq < rAvgSq then
holes[hCtr] = { p = vec3(tmp1.x, tmp1.y, 0), i = tb:getMaterialIdxWs(tmp1) }
hCtr = hCtr + 1
if dSq < rAvgSq then
holes[hCtr] = { p = vec3(tmp1.x, tmp1.y, 0), i = tb:getMaterialIdxWs(tmp1) }
hCtr = hCtr + 1
if dSq < rAvgSq then
holes[hCtr] = { p = vec3(tmp1.x, tmp1.y, 0), i = tb:getMaterialIdxWs(tmp1) }
hCtr = hCtr + 1
if dSq < rAvgSq then
holes[hCtr] = { p = vec3(tmp1.x, tmp1.y, 0), i = tb:getMaterialIdxWs(tmp1) }
hCtr = hCtr + 1
local te = extensions.editor_terrainEditor.getTerrainEditor()
te:worldToGridByPoint2I(vec3(xMinG, yMinG), gMin, tb)
te:worldToGridByPoint2I(vec3(xMaxG, yMaxG), gMax, tb)
te:worldToGridByPoint2I(vec3(xMinG, yMinG), gMin, tb)
te:worldToGridByPoint2I(vec3(xMaxG, yMaxG), gMax, tb)
local w2gMin, w2gMax = vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y)
te:worldToGridByPoint2I(vec3(xMaxG, yMaxG), gMax, tb)
local w2gMin, w2gMax = vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y)
tb:updateGridMaterials(w2gMin, w2gMax)
te:worldToGridByPoint2I(vec3(xMaxG, yMaxG), gMax, tb)
local w2gMin, w2gMax = vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y)
tb:updateGridMaterials(w2gMin, w2gMax)
local te = extensions.editor_terrainEditor.getTerrainEditor()
te:worldToGridByPoint2I(vec3(xMinG, yMinG), gMin, tb)
te:worldToGridByPoint2I(vec3(xMaxG, yMaxG), gMax, tb)
te:worldToGridByPoint2I(vec3(xMinG, yMinG), gMin, tb)
te:worldToGridByPoint2I(vec3(xMaxG, yMaxG), gMax, tb)
local w2gMin, w2gMax = vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y)
te:worldToGridByPoint2I(vec3(xMaxG, yMaxG), gMax, tb)
local w2gMin, w2gMax = vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y)
tb:updateGridMaterials(w2gMin, w2gMax)
te:worldToGridByPoint2I(vec3(xMaxG, yMaxG), gMax, tb)
local w2gMin, w2gMax = vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y)
tb:updateGridMaterials(w2gMin, w2gMax)
@/lua/ge/extensions/editor/tech/roadArchitect/export.lua
local min, max = math.min, math.max
local zeroVec = vec3(0, 0)
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local zeroVec = vec3(0, 0)
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local zeroVec = vec3(0, 0)
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local zeroVec = vec3(0, 0)
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local zeroVec = vec3(0, 0)
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
@/lua/ge/extensions/flowgraph/nodes/types/vec3.lua
local tempQuat = quat()
local vecOut = vec3()
local vecY = vec3(0, 1, 0)
local vecOut = vec3()
local vecY = vec3(0, 1, 0)
function C:work()
builder:Middle()
im.Text(tostring(vec3(self.pinIn.x.value or 0, self.pinIn.y.value or 0, self.pinIn.z.value or 0)))
end
@/lua/ge/extensions/gameplay/markerInteraction.lua
-- detect player velocity
local lastPosition = vec3(0,0,0)
local lastVel
local lastVel
local tmpVec = vec3()
local garageBorderClr = {1,0.5,0.5}
local vel = vec3()
local function getVelocity(dtSim, position)
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local lastCamPos = vec3()
local lastCamVel = vec3()
local lastCamPos = vec3()
local lastCamVel = vec3()
local playerVelLast = vec3()
local lastCamVel = vec3()
local playerVelLast = vec3()
local timeSincePlayerTeleport
updateData.veh = veh
updateData.vehPos = updateData.vehPos or vec3()
updateData.vehPos:set(veh:getPositionXYZ())
updateData.vehPos:set(veh:getPositionXYZ())
updateData.vehPos2d = updateData.vehPos2d or vec3()
updateData.vehPos2d:set(updateData.vehPos)
updateData.vehPos2d.z = 0
updateData.vehVelocity = updateData.vehVelocity or vec3()
updateData.vehVelocity:set(veh:getVelocityXYZ())
local vehId = veh:getID()
updateData.bbCenter = updateData.bbCenter or vec3()
updateData.bbCenter:set(be:getObjectOOBBCenterXYZ(vehId))
updateData.bbCenter:set(be:getObjectOOBBCenterXYZ(vehId))
updateData.bbHalfAxis0 = updateData.bbHalfAxis0 or vec3()
updateData.bbHalfAxis0:set(be:getObjectOOBBHalfAxisXYZ(vehId, 0))
updateData.bbHalfAxis0:set(be:getObjectOOBBHalfAxisXYZ(vehId, 0))
updateData.bbHalfAxis1 = updateData.bbHalfAxis1 or vec3()
updateData.bbHalfAxis1:set(be:getObjectOOBBHalfAxisXYZ(vehId, 1))
updateData.bbHalfAxis1:set(be:getObjectOOBBHalfAxisXYZ(vehId, 1))
updateData.bbHalfAxis2 = updateData.bbHalfAxis2 or vec3()
updateData.bbHalfAxis2:set(be:getObjectOOBBHalfAxisXYZ(vehId, 2))
updateData.playerPosition = veh and updateData.vehPos or updateData.camPos or vec3()
updateData.globalAlpha = globalAlpha
updateData.camPos = updateData.camPos or vec3()
updateData.camPos:set(core_camera.getPositionXYZ())
local pos2Offset = vec3(0, 0, 1000)
local columnColor = ColorF(1,1,1,1)
@/lua/ge/extensions/flowgraph/nodes/vehicle/alignForCoupling.lua
if self.pinIn.relativeRotationQuat.value then
desiredRot = desiredRot * quatFromDir(vec3(v1:getDirectionVector()), vec3(v1:getDirectionVectorUp()))
else
if self.pinIn.relativeRotationQuat.value then
desiredRot = desiredRot * quatFromDir(vec3(v1:getDirectionVector()), vec3(v1:getDirectionVectorUp()))
else
end
rotMatrix:setColumn(0, (desiredRot * vec3(1,0,0)))
rotMatrix:setColumn(1, (desiredRot * vec3(0,1,0)))
rotMatrix:setColumn(0, (desiredRot * vec3(1,0,0)))
rotMatrix:setColumn(1, (desiredRot * vec3(0,1,0)))
rotMatrix:setColumn(2, (desiredRot * vec3(0,0,1)))
rotMatrix:setColumn(1, (desiredRot * vec3(0,1,0)))
rotMatrix:setColumn(2, (desiredRot * vec3(0,0,1)))
end
--debugDrawer:drawSphere(vec3(v1CouplerMatrix:getColumn(3)), 4, ColorF(1,0.0,0.48,0.5))
--debugDrawer:drawSphere(vec3(v2CouplerMatrix:getColumn(3)), 4, ColorF(0,0.05,0.48,0.5))
--debugDrawer:drawSphere(vec3(v1CouplerMatrix:getColumn(3)), 4, ColorF(1,0.0,0.48,0.5))
--debugDrawer:drawSphere(vec3(v2CouplerMatrix:getColumn(3)), 4, ColorF(0,0.05,0.48,0.5))
local res = v1CouplerMatrix * (rotMatrix * v2CouplerMatrix:inverse() * v2:getRefNodeMatrix())
--debugDrawer:drawSphere(vec3(res:getColumn(3)), 1, ColorF(0.91,1,0.48,0.5))
if self.pinIn.ignoreCouple.value then
@/inspector/External/three.js/three.js
var begin_vertex = "\nvec3 transformed = vec3( position );\n";
var beginnormal_vertex = "\nvec3 objectNormal = vec3( normal );\n";
var bsdfs = "float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
var bsdfs = "float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
var bsdfs = "float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n";
var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n";
var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n";
var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n";
var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n";
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
var gradientmap_pars_fragment = "#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n";
var gradientmap_pars_fragment = "#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n";
var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
var lights_pars_begin = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n";
var lights_pars_begin = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n";
var lights_pars_maps = "#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_pars_maps = "#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_pars_maps = "#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_pars_maps = "#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_pars_maps = "#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n";
var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n";
var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n";
var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n";
var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n";
var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n";
var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n";
var map_particle_fragment = "#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n";
var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n";
var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n";
var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n";
var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n";
var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n";
var dithering_pars_fragment = "#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n";
var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
var uv_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
var cube_frag = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n";
var depth_frag = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n";
var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
var points_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
@/lua/ge/extensions/editor/sensorConfigurationEditor.lua
local sensorIcon = im.ImVec2(32, 32) -- Some commonly-used Imgui icon size vectors.
local beginDragRotation = vec3(0, 0)
local p = poiData.cogWithWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithoutWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.frontAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.rearAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehFront
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehRear
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithoutWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.frontAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.rearAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehFront
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehRear
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithoutWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.frontAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.rearAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehFront
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehRear
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithoutWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.frontAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.rearAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehFront
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehRear
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithoutWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.frontAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.rearAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehFront
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehRear
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.cogWithoutWheels
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.frontAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.rearAxleMidpoint
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehFront
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
local p = poiData.vehRear
sensor.pos = util.posVS2Coeffs(vec3(p.x, p.y, p.z), veh)
end
@/lua/ge/extensions/career/modules/insurance/insurance.lua
-- to calculate distance driven
local vec3Zero = vec3(0,0,0)
local lastPos = vec3(0,0,0)
local vec3Zero = vec3(0,0,0)
local lastPos = vec3(0,0,0)
@/lua/ge/extensions/core/cameraModes/chase.lua
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
self.disabledByDefault = true
self.camLastRot = vec3()
self.fwdVeloSmoother = newTemporalSmoothing(100)
self.dirSmoothZ = newTemporalSmoothing(chaseDirSmoothCoef)
self.lastDataPos = vec3()
self.forwardLooking = true
self.forwardLooking = true
self.lastRefPos = vec3()
self.camLastUp = vec3()
self.lastRefPos = vec3()
self.camLastUp = vec3()
self.camResetted = 0
if self.defaultRotation == nil then
self.defaultRotation = vec3(0, -17, 0)
else
else
self.defaultRotation = vec3(self.defaultRotation)
self.defaultRotation.y = -self.defaultRotation.y
end
self.camRot = vec3(self.defaultRotation)
self.camMinDist = self.distanceMin or 3
self.fov = self.fov or 65
self.offset = vec3(self.offset)
self.camBase = vec3()
self.offset = vec3(self.offset)
self.camBase = vec3()
end
function C:reset()
self.camRot = vec3(self.defaultRotation)
self.camRot.x = 0
local rot = vec3()
function C:update(data)
if self.camResetted ~= 0 then
self.lastDataPos = vec3(data.pos)
end
local calculatedCamPos = dist * vec3(
math.sin(rot.x) * math.cos(rot.y)
@/lua/ge/extensions/editor/assemblySpline/molecule.lua
local forwardRot, upRot, aligningRot = quat(), quat(), quat()
local placedPosWS, posWS, attachAnchorPostRotateMS = vec3(), vec3(), vec3()
local placedForwardVec, placedUpVec, rotatedUp = vec3(), vec3(), vec3()
local forwardRot, upRot, aligningRot = quat(), quat(), quat()
local placedPosWS, posWS, attachAnchorPostRotateMS = vec3(), vec3(), vec3()
local placedForwardVec, placedUpVec, rotatedUp = vec3(), vec3(), vec3()
local forwardRot, upRot, aligningRot = quat(), quat(), quat()
local placedPosWS, posWS, attachAnchorPostRotateMS = vec3(), vec3(), vec3()
local placedForwardVec, placedUpVec, rotatedUp = vec3(), vec3(), vec3()
local placedPosWS, posWS, attachAnchorPostRotateMS = vec3(), vec3(), vec3()
local placedForwardVec, placedUpVec, rotatedUp = vec3(), vec3(), vec3()
local placedPosWS, posWS, attachAnchorPostRotateMS = vec3(), vec3(), vec3()
local placedForwardVec, placedUpVec, rotatedUp = vec3(), vec3(), vec3()
local placedPosWS, posWS, attachAnchorPostRotateMS = vec3(), vec3(), vec3()
local placedForwardVec, placedUpVec, rotatedUp = vec3(), vec3(), vec3()
end
joinGroups[joinKey].points[pointType] = vec3(pos.x, pos.y, pos.z) -- Store the point.
else
-- Orthogonalise nail axis to local mesh X-axis (bridge direction).
local localXAxis = vec3(1, 0, 0) -- Local mesh X-axis.
nailVector:normalize()
attachPos = attachPos,
forward = vec3(1, 0, 0), -- Default world forward, since we have no definite forward direction.
up = vec3(0, 0, 1), -- Default world up, since we have no definite up direction.
forward = vec3(1, 0, 0), -- Default world forward, since we have no definite forward direction.
up = vec3(0, 0, 1), -- Default world up, since we have no definite up direction.
freedomAxes = { vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) }, -- Three axes of freedom for this type of join.
up = vec3(0, 0, 1), -- Default world up, since we have no definite up direction.
freedomAxes = { vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) }, -- Three axes of freedom for this type of join.
joinType = ballJoinTypeStr
up = vec3(0, 0, 1), -- Default world up, since we have no definite up direction.
freedomAxes = { vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) }, -- Three axes of freedom for this type of join.
joinType = ballJoinTypeStr
up = vec3(0, 0, 1), -- Default world up, since we have no definite up direction.
freedomAxes = { vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) }, -- Three axes of freedom for this type of join.
joinType = ballJoinTypeStr
@/lua/ge/extensions/ui/liveryEditor/layers/decals.lua
local oldScale = layer.decalScale
layer.decalScale = vec3(oldScale.x + diff, oldScale.y, oldScale.z)
api.setLayer(layer, true)
local oldScale = layer.decalScale
layer.decalScale = vec3(oldScale.x, 1, oldScale.z + diff)
api.setLayer(layer, true)
M.setScale = function(layer, scaleX, scaleY)
layer.decalScale = vec3(scaleX, layer.decalScale.y, scaleY)
api.setLayer(layer, true)
@/lua/ge/extensions/core/vehicle/mirror.lua
local q = quatFromEuler(mrad(x),mrad(0),mrad(z))
mirror.offsetNormal = vec3(0,1,0):rotated(q)
local function _mouseUpdate(save)
local mousePos = vec3(im.GetMousePos().x, im.GetMousePos().y, 1)
local offset = (mouseData.startPos - mousePos) * screenRatio
local mousePos = im.GetMousePos()
mouseData.startPos = vec3(mousePos.x,mousePos.y,1)
mouseData.name = mirror_name
if mdata[mirror_name].angleOffset then
mouseData.originalOffset = vec3(-mdata[mirror_name].angleOffset.z, mdata[mirror_name].angleOffset.x, 0 ) --warn in screen format
else
else
mouseData.originalOffset = vec3(0,0,0)
end
local camPos = veh:getInitialNodePosition(core_camera.getDriverDataById(vid))
local rot = quatFromDir( (camPos-mpos) , vec3(0,0,1) )
local eu = rot:toEulerYXZ()
@/lua/ge/extensions/gameplay/race/race.lua
lastFrameIsOnRoad = nil, -- flag to trigger on/off track calculations
offPos = vec3(), -- remember where we drove off the track
onPos = vec3(), -- remember where we drove back on the track
offPos = vec3(), -- remember where we drove off the track
onPos = vec3(), -- remember where we drove back on the track
debugStuff = {
maxCutDepthPos = vec3(),
maxCutDepth = 0,
if not data.isOnRoad then
table.insert(data.offTrackData.offTrackPath, vec3(data.frontPos.x, data.frontPos.y, data.frontPos.z))
end
-- 2. how deep the player has gone off track
local prevPos = vec3(data.offTrackData.offPos)
for _, pos in ipairs(data.offTrackData.offTrackPath) do
local sorted = {}
local vehVel = vec3()
local vehDir = vec3()
local vehVel = vec3()
local vehDir = vec3()
local vehBBCenter = vec3()
local vehDir = vec3()
local vehBBCenter = vec3()
local vehBBHalfExtents = vec3()
local vehBBCenter = vec3()
local vehBBHalfExtents = vec3()
function C:getTrackedData(dt)
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
for i=0, wCount do
local axisNodes = vehicle:getWheelAxisNodes(i)
local nodePos = vec3(vehicle:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
local nodePos = vec3(vehicle:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
table.insert(self.states[newId].wheelOffsets, pos)
nonBranchingShiftedPathnodes = {}, -- all future pathnodes, if the path is not branching. loops around back to the player
frontPos = vec3(),
aiPathIdx = 1,
local vRot = quatFromDir(veh:getDirectionVector(), veh:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local vRot = quatFromDir(veh:getDirectionVector(), veh:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local vRot = quatFromDir(veh:getDirectionVector(), veh:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
for i=0, wCount do
local axisNodes = veh:getWheelAxisNodes(i)
local nodePos = vec3(veh:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
local nodePos = vec3(veh:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
table.insert(self.states[id].wheelOffsets, pos)
log("E","","No Vehicle position found! " .. id)
return vec3()
end
local vehPos = vec3()
local vehDir = vec3()
local vehPos = vec3()
local vehDir = vec3()
local vehDirUp = vec3()
local vehDir = vec3()
local vehDirUp = vec3()
local vehRot = quat()
state.currentCorners[i]:setAdd(vehPos)
--debugDrawer:drawLine(vec3(state.previousCorners[i]), vec3(state.currentCorners[i]), ColorF(1,0,0,1))
--debugDrawer:drawSphere(vec3(state.currentCorners[i]), 0.025, ColorF(1,0,0,0.25))
state.currentCorners[i]:setAdd(vehPos)
--debugDrawer:drawLine(vec3(state.previousCorners[i]), vec3(state.currentCorners[i]), ColorF(1,0,0,1))
--debugDrawer:drawSphere(vec3(state.currentCorners[i]), 0.025, ColorF(1,0,0,0.25))
--debugDrawer:drawLine(vec3(state.previousCorners[i]), vec3(state.currentCorners[i]), ColorF(1,0,0,1))
--debugDrawer:drawSphere(vec3(state.currentCorners[i]), 0.025, ColorF(1,0,0,0.25))
end
@/lua/ge/extensions/editor/raceEditor/tools.lua
decoration:setPosRot(t.pos.x, t.pos.y, t.pos.z, t.rot.x, t.rot.y, t.rot.z, t.rot.w)
decoration.scale = vec3(t.scl.x, t.scl.y, t.scl.z)
decoration.canSave = true
function C:getSideTransformParameters()
return vec3(posOffset[0],posOffset[1], posOffset[2]),
vec3(rotOffset[0],rotOffset[1], rotOffset[2])*(math.pi/180),
return vec3(posOffset[0],posOffset[1], posOffset[2]),
vec3(rotOffset[0],rotOffset[1], rotOffset[2])*(math.pi/180),
vec3(sclOffset[0],sclOffset[1], sclOffset[2]),
vec3(rotOffset[0],rotOffset[1], rotOffset[2])*(math.pi/180),
vec3(sclOffset[0],sclOffset[1], sclOffset[2]),
alignMode
table.insert(allTransforms, e)
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(e.scl.x,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
table.insert(allTransforms, e)
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(e.scl.x,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
table.insert(allTransforms, e)
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(e.scl.x,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(e.scl.x,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,e.scl.z)), ColorF(0,0,1,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(e.scl.x,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,e.scl.z)), ColorF(0,0,1,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(e.scl.x,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,e.scl.z)), ColorF(0,0,1,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,e.scl.z)), ColorF(0,0,1,1))
end
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,e.scl.z)), ColorF(0,0,1,1))
end
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,e.scl.y,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,e.scl.z)), ColorF(0,0,1,1))
end
local normalTip = node.pos + node.normal*node.radius
normalTip = vec3(normalTip.x, normalTip.y, core_terrain.getTerrainHeight(normalTip))
newDataMap[node.id] = normalTip - node.pos
@/lua/ge/extensions/core/dynamicProps.lua
local up = vec3(0, 0, 1)
local _uid = 0
local plPos
local underTheMap = vec3(0,0,-999)
local dynamicPropsObjs = {}
object.spawnInViewRange = data.spawnInViewRange or 100
object.spawnOffset = data.spawnOffset or vec3(0, 0, 0)
spawnInViewRange = 100,
spawnOffset = vec3(0, 0, -0.22)
})
spawnInViewRange = 150,
spawnOffset = vec3(0, 0, 0)
})
@/lua/common/utils/interactiveShell.lua
do
BeamEngine:spawnObject("vehicles/"..v, nil, vec3(0, 3 * n, 0)) -- this assumes that the object is max. 3 meters high
end
@/lua/ge/extensions/editor/toolUtilities/geom.lua
local splineGranInv = 1.0 / defaultMinNumDivisions
local globalUp = vec3(0, 0, 1)
local preRotQuats = {
local tmpPoint2I = Point2I(0, 0)
local pThis, pLast, mousePos2D, tmpTangent = vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local tmpPoint2I = Point2I(0, 0)
local pThis, pLast, mousePos2D, tmpTangent = vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local tmpPoint2I = Point2I(0, 0)
local pThis, pLast, mousePos2D, tmpTangent = vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local tmpPoint2I = Point2I(0, 0)
local pThis, pLast, mousePos2D, tmpTangent = vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local pThis, pLast, mousePos2D, tmpTangent = vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local pThis, pLast, mousePos2D, tmpTangent = vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local pThis, pLast, mousePos2D, tmpTangent = vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local pThis, pLast, mousePos2D, tmpTangent = vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3 = vec3(), vec3(), vec3(), vec3()
local ab, bc, abNorm, bcNorm, tmpTan, tmpCross = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local pX, pY, latX, latY = p.x, p.y, bin.x * halfWidth, bin.y * halfWidth
leftPts[i], rightPts[i] = vec3(pX - latX, pY - latY, 0), vec3(pX + latX, pY + latY, 0)
end
local pX, pY, latX, latY = p.x, p.y, bin.x * halfWidth, bin.y * halfWidth
leftPts[i], rightPts[i] = vec3(pX - latX, pY - latY, 0), vec3(pX + latX, pY + latY, 0)
end
local dzdy = (tb:getHeightGrid(gx, gy + 1) - tb:getHeightGrid(gx, gy - 1)) * 0.5
local normal = vec3(-dzdx, -dzdy, 1)
normal:normalize()
for i = 1, splitNodeIdx do
nodes1[i], widths1[i], nmls1[i] = vec3(nodes[i]), widths[i], vec3(nmls[i])
end
for i = 1, splitNodeIdx do
nodes1[i], widths1[i], nmls1[i] = vec3(nodes[i]), widths[i], vec3(nmls[i])
end
local j = i - splitNodeIdx + 1
nodes2[j], widths2[j], nmls2[j] = vec3(nodes[i]), widths[i], vec3(nmls[i])
end
local j = i - splitNodeIdx + 1
nodes2[j], widths2[j], nmls2[j] = vec3(nodes[i]), widths[i], vec3(nmls[i])
end
for i = splitNodeIdx, numNodes do -- Copy from split point to end.
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(nodes[i]), widths[i], vec3(nmls[i])
ctr = ctr + 1
for i = splitNodeIdx, numNodes do -- Copy from split point to end.
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(nodes[i]), widths[i], vec3(nmls[i])
ctr = ctr + 1
for i = 1, splitNodeIdx - 1 do -- Copy from start to split point.
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(nodes[i]), widths[i], vec3(nmls[i])
ctr = ctr + 1
for i = 1, splitNodeIdx - 1 do -- Copy from start to split point.
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(nodes[i]), widths[i], vec3(nmls[i])
ctr = ctr + 1
for i = #n2, 1, -1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
ctr = ctr + 1
for i = #n2, 1, -1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
ctr = ctr + 1
for i = 2, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
ctr = ctr + 1
for i = 2, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
ctr = ctr + 1
for i = 1, #n2 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
ctr = ctr + 1
for i = 1, #n2 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
ctr = ctr + 1
for i = 2, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
ctr = ctr + 1
for i = 2, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
ctr = ctr + 1
for i = 1, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
ctr = ctr + 1
for i = 1, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
ctr = ctr + 1
for i = 2, #n2 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
ctr = ctr + 1
for i = 2, #n2 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
ctr = ctr + 1
for i = 1, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
ctr = ctr + 1
for i = 1, #n1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n1[i]), w1[i], vec3(nm1[i])
ctr = ctr + 1
for i = #n2 - 1, 1, -1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
ctr = ctr + 1
for i = #n2 - 1, 1, -1 do
nodesNew[ctr], widthsNew[ctr], nmlsNew[ctr] = vec3(n2[i]), w2[i], vec3(nm2[i])
ctr = ctr + 1
tmp0:setAdd2(p1, tmp0)
outPosns[ctr] = vec3(tmp0)
outTans[ctr] = lerp(tangents[iMinusOne], tangents[i], t)
tmp0:setAdd2(p1, tmp0)
outPosns[ctr] = vec3(tmp0)
outTans[ctr] = lerp(tangents[iMinusOne], tangents[i], t)
local p, bin = pts[i], binormals[i]
out[i] = vec3(p.x + bin.x * t, p.y + bin.y * t, p.z + bin.z * t)
end
local node = nodes[i]
ribPoints[ctr] = ribPoints[ctr] or vec3()
ribPoints[ctr]:setSub2(node, tmp0) -- Left point.
ribPoints[ctr]:setSub2(node, tmp0) -- Left point.
ribPoints[ctr + 1] = ribPoints[ctr + 1] or vec3()
ribPoints[ctr + 1]:setAdd2(node, tmp0) -- Right point.
local node = nodes[i]
ribPoints[ctr] = ribPoints[ctr] or vec3()
ribPoints[ctr]:setSub2(node, tmp0) -- Left point.
ribPoints[ctr]:setSub2(node, tmp0) -- Left point.
ribPoints[ctr + 1] = ribPoints[ctr + 1] or vec3()
ribPoints[ctr + 1]:setAdd2(node, tmp0) -- Right point.
tmp1:set(nodes[i].x, nodes[i].y, nodes[i].z + vals[i] * barScale)
barPoints[i] = barPoints[i] or vec3()
barPoints[i]:set(tmp1)
tmp1:set(node.x, node.y, node.z + vals[i] * barScale)
barPoints[i] = barPoints[i] or vec3()
barPoints[i]:set(tmp1)
local function catmullRomCentripetalFast(p0, p1, p2, p3, t, s, outVec)
outVec = outVec or vec3()
s = s * 2
local t = k * granInv
pts[ctr] = pts[ctr] or vec3()
catmullRomCentripetalFast(p0, p1, p2, p3, t, 0.5, pts[ctr])
local t = k * granInv
pts[ctr] = pts[ctr] or vec3()
catmullRomCentripetalFast(p0, p1, p2, p3, t, 0.5, pts[ctr])
local iPrev, iNext = ((i - twoMinusNumDivPoints) % numDivPoints) + 1, (i % numDivPoints) + 1
tangents[i] = tangents[i] or vec3()
binormals[i] = binormals[i] or vec3()
tangents[i] = tangents[i] or vec3()
binormals[i] = binormals[i] or vec3()
tangents[i]:setSub2(divPoints[iNext], divPoints[iPrev])
local iPrev, iNext = max(1, i - 1), min(numDivPoints, i + 1)
tangents[i] = tangents[i] or vec3()
binormals[i] = binormals[i] or vec3()
tangents[i] = tangents[i] or vec3()
binormals[i] = binormals[i] or vec3()
tangents[i]:setSub2(divPoints[iNext], divPoints[iPrev])
local t = k * step
divPoints[ctr] = divPoints[ctr] or vec3()
normals[ctr] = normals[ctr] or vec3()
divPoints[ctr] = divPoints[ctr] or vec3()
normals[ctr] = normals[ctr] or vec3()
catmullRomCentripetalFast(p0, p1, p2, p3, t, 0.5, divPoints[ctr])
local t = k * step
divPoints[ctr] = divPoints[ctr] or vec3()
normals[ctr] = normals[ctr] or vec3()
divPoints[ctr] = divPoints[ctr] or vec3()
normals[ctr] = normals[ctr] or vec3()
catmullRomCentripetalFast(p0, p1, p2, p3, t, 0.5, divPoints[ctr])
local tPlus1 = t + 1
divPoints[ctr] = divPoints[ctr] or vec3()
normals[ctr] = normals[ctr] or vec3()
divPoints[ctr] = divPoints[ctr] or vec3()
normals[ctr] = normals[ctr] or vec3()
catmullRomCentripetalFast(p0, p1, p2, p3, t, 0.5, divPoints[ctr])
local tPlus1 = t + 1
divPoints[ctr] = divPoints[ctr] or vec3()
normals[ctr] = normals[ctr] or vec3()
divPoints[ctr] = divPoints[ctr] or vec3()
normals[ctr] = normals[ctr] or vec3()
-- Populate the spline's geometry with the navgraph path points
spline.divPoints[ctr] = spline.divPoints[ctr] or vec3()
spline.divPoints[ctr]:set(nodePos)
spline.divWidths[ctr] = 5.0 -- Default width
spline.normals[ctr] = spline.normals[ctr] or vec3(0, 0, 1)
spline.normals[ctr]:set(map.surfaceNormal(nodePos, 1.0))
@/lua/ge/extensions/gameplay/util/crashDetection.lua
local tempVehName = ""
local tempAveragePos = vec3()
local function onImpactEnded(crashData)
newFrameDamage.newDamage = newDamage
newFrameDamage.vehPos = vec3(vehData.pos.x, vehData.pos.y, vehData.pos.z)
newFrameDamage.vehId = vehData.id
local tempVecCurrVel = vec3()
local tempVecCurrAccel = vec3()
local tempVecCurrVel = vec3()
local tempVecCurrAccel = vec3()
local tempVecPos = vec3()
local tempVecCurrAccel = vec3()
local tempVecPos = vec3()
local function updateAccelData(vehData)
tempVecPos:set(vehData.pos + point.offsetFromCenter * vehData.dirVec)
tempVecCurrVel:set((point.lastFramePos and (tempVecPos - point.lastFramePos) or vec3()) / dtSim)
tempVecCurrAccel:set((point.lastFrameVel and (tempVecCurrVel - point.lastFrameVel) or vec3()) / dtSim)
tempVecCurrVel:set((point.lastFramePos and (tempVecPos - point.lastFramePos) or vec3()) / dtSim)
tempVecCurrAccel:set((point.lastFrameVel and (tempVecCurrVel - point.lastFrameVel) or vec3()) / dtSim)
offsetFromCenter = 4, -- arbitrary offset from the center of the vehicle
lastFrameVel = vec3(),
lastFramePos = vec3(),
lastFrameVel = vec3(),
lastFramePos = vec3(),
vel = vec3(),
lastFramePos = vec3(),
vel = vec3(),
},
offsetFromCenter = -4, -- arbitrary offset from the center of the vehicle
lastFrameVel = vec3(),
lastFramePos = vec3(),
lastFrameVel = vec3(),
lastFramePos = vec3(),
vel = vec3(),
lastFramePos = vec3(),
vel = vec3(),
}
@/lua/ge/extensions/flowgraph/nodes/gameplay/rally/rallySuperCountdown.lua
-- Reusable temporary vectors (module-level, shared across instances)
local tmpPlaneNormal = vec3()
local tmpToVehicle = vec3()
local tmpPlaneNormal = vec3()
local tmpToVehicle = vec3()
local tmpClosestPoint = vec3()
local tmpToVehicle = vec3()
local tmpClosestPoint = vec3()
local tmpMidPoint = vec3()
local tmpClosestPoint = vec3()
local tmpMidPoint = vec3()
local veh, vehicleData
local vehPos, vehVel = vec3(), vec3()
local veh, vehicleData
local vehPos, vehVel = vec3(), vec3()
-- Proximity checking state (instance vectors for plane position/rotation)
self.pos = vec3()
self.rot = quat()
-- Recreate plane position/rotation vectors (avoid stale references)
self.pos = vec3()
self.rot = quat()
@/lua/ge/extensions/flowgraph/nodes/gameplay/rally/vehicleStoppedNearPos.lua
local veh, vehicleData
-- local wCenter, wPos = vec3(), vec3()
local vehPos, vehRot, vehVel = vec3(), quat(), vec3()
local veh, vehicleData
-- local wCenter, wPos = vec3(), vec3()
local vehPos, vehRot, vehVel = vec3(), quat(), vec3()
-- local wCenter, wPos = vec3(), vec3()
local vehPos, vehRot, vehVel = vec3(), quat(), vec3()
-- local wCenter, wPos = vec3(), vec3()
local vehPos, vehRot, vehVel = vec3(), quat(), vec3()
if type(self.pinIn.pos.value) == "table" and not self.pinIn.pos.value.x then
self.targetPos = vec3(self.pinIn.pos.value)
elseif self.pinIn.pos.value then
function C:drawDebugVehiclePoint(inside)
-- debugDrawer:drawCylinder(vehPos, vehPos + vec3(0,0,2), 0.1, ColorF(0,1,0,0.5), true, false)
if gameplay_rallyLoop and gameplay_rallyLoop.getDrawFlag('stopZones') then
@/lua/ge/extensions/editor/missionEditor/previewChecker.lua
if alwaysShowScreenshots then
local size = vec3(self.previewImage.size.x, self.previewImage.size.y, 0)
if size.x > im.GetContentRegionAvailWidth() then
im.Image(self.previewImage.texId, im.ImVec2(size.x, size.y), im.ImVec2(0, 0), im.ImVec2(1, 1))
size = vec3(self.thumbImage.size.x, self.thumbImage.size.y, 0)
if size.x > im.GetContentRegionAvailWidth() then
@/lua/ge/extensions/editor/tech/roadArchitect/terraform.lua
-- Update the grid after the changes.
tb:updateGrid(vec3(xMin, yMin), vec3(xMax, yMax))
end
-- Update the grid after the changes.
tb:updateGrid(vec3(xMin, yMin), vec3(xMax, yMax))
end
-- Update the grid after the changes.
tb:updateGrid(vec3(xMin, yMin), vec3(xMax, yMax))
end
-- Update the grid after the changes.
tb:updateGrid(vec3(xMin, yMin), vec3(xMax, yMax))
end
-- Update the terrain block.
tb:updateGrid(vec3(bXMin, bYMin), vec3(bXMax, bYMax))
end
-- Update the terrain block.
tb:updateGrid(vec3(bXMin, bYMin), vec3(bXMax, bYMax))
end
local gMin, gMax = Point2I(0, 0), Point2I(0, 0)
te:worldToGridByPoint2I(vec3(floor(max(tXMin, box.xMin)), floor(max(tYMin, box.yMin))), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(min(tXMax, box.xMax)), ceil(min(tYMax, box.yMax))), gMax, tb)
te:worldToGridByPoint2I(vec3(floor(max(tXMin, box.xMin)), floor(max(tYMin, box.yMin))), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(min(tXMax, box.xMax)), ceil(min(tYMax, box.yMax))), gMax, tb)
local bXMin, bXMax, bYMin, bYMax = gMin.x, gMax.x, gMin.y, gMax.y
local gMin, gMax = Point2I(0, 0), Point2I(0, 0)
te:worldToGridByPoint2I(vec3(floor(max(tXMin, box.xMin)), floor(max(tYMin, box.yMin))), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(min(tXMax, box.xMax)), ceil(min(tYMax, box.yMax))), gMax, tb)
te:worldToGridByPoint2I(vec3(floor(max(tXMin, box.xMin)), floor(max(tYMin, box.yMin))), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(min(tXMax, box.xMax)), ceil(min(tYMax, box.yMax))), gMax, tb)
local bXMin, bXMax, bYMin, bYMax = gMin.x, gMax.x, gMin.y, gMax.y
local gMin, gMax = Point2I(0, 0), Point2I(0, 0)
te:worldToGridByPoint2I(vec3(floor(tXMin), floor(tYMin)), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
te:worldToGridByPoint2I(vec3(floor(tXMin), floor(tYMin)), gMin, tb)
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
tb:updateGrid(vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y))
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
tb:updateGrid(vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y))
end
te:worldToGridByPoint2I(vec3(ceil(tXMax), ceil(tYMax)), gMax, tb)
tb:updateGrid(vec3(gMin.x, gMin.y), vec3(gMax.x, gMax.y))
end
local gMin, gMax = Point2I(0, 0), Point2I(0, 0)
te:worldToGridByPoint2I(vec3(tXMin, tYMin), gMin, tb)
te:worldToGridByPoint2I(vec3(tXMax, tYMax), gMax, tb)
te:worldToGridByPoint2I(vec3(tXMin, tYMin), gMin, tb)
te:worldToGridByPoint2I(vec3(tXMax, tYMax), gMax, tb)
local bXMin, bXMax, bYMin, bYMax = gMin.x, gMax.x, gMin.y, gMax.y
@/lua/ge/extensions/util/trackBuilder/proceduralPrimitives.lua
innerRing[i] = {
v = vec3(math.cos(rad) * thickness,0, math.sin(rad) * thickness),
u = ((i-1) / innerSegments)
local quat = quatFromEuler(-outerRad,0,0)
local outerCenter = vec3(0,math.sin(-outerRad) * radius,math.cos(-outerRad)*radius)
for j,p in ipairs(innerRing) do
local rad = (i-1) * math.pi*2 / segments
local point = vec3(math.cos(rad), math.sin(rad),0)
vertices[#vertices+1] = {x = point.x * radius, y = point.y * radius, z = point.z + height/2}
local rad = (i-1) * math.pi*2 / segments
local point = vec3(math.cos(rad), math.sin(rad),0)
vertices[#vertices+1] = {x = point.x * radius, y = point.y * radius, z = point.z - height/2}
pitch = -(pitch - math.pi)
local topNormal = vec3(-math.cos(pitch), 0, math.sin(pitch))
topNormal:normalize()
topNormal:normalize()
local sideNormal = vec3(0,height+1, (bottomWidth-topWidth)/2)
local sideLen = sideNormal:length()
material = material or 'track_editor_A_border'
local uvReps = vec3(math.ceil(upperWidth/2.5),math.ceil(upperLength/2.5),0)
local lNormal = vec3(0,height,-(upperLength-length)/2)
lNormal:normalize()
lNormal:normalize()
local wNormal = vec3(height,0,-(upperWidth-width)/2)
wNormal:normalize()
local uvReps = math.ceil(height/2.5)
local normalSlope = vec3(height, 0, radius)
normalSlope:normalize()
local rad = (i-1) * math.pi*2 / segments
local point = vec3(math.cos(rad), math.sin(rad),0)
local quat = quatFromEuler(0,0,-rad)
local faces = {}
size = size and vec3(math.abs(size.y), math.abs(size.x), math.abs(size.z)) or vec3(1,1,1)
material = material or 'track_editor_A_border'
local faces = {}
size = size and vec3(math.abs(size.y), math.abs(size.x), math.abs(size.z)) or vec3(1,1,1)
material = material or 'track_editor_A_border'
uvStyle = uvStyle or 1
local uvReps = vec3(math.ceil(size.x/3),math.ceil(size.y/3), math.ceil(size.z/3))
local function createIcosphere(origin, size, subdivisions, planetGravity)
if not origin then origin = vec3(0,0,0) end
if not size then size = 5 end
local vertexList = {
vec3(-X,N,Z), vec3(X,N,Z), vec3(-X,N,-Z), vec3(X,N,-Z),
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
local vertexList = {
vec3(-X,N,Z), vec3(X,N,Z), vec3(-X,N,-Z), vec3(X,N,-Z),
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
local vertexList = {
vec3(-X,N,Z), vec3(X,N,Z), vec3(-X,N,-Z), vec3(X,N,-Z),
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
local vertexList = {
vec3(-X,N,Z), vec3(X,N,Z), vec3(-X,N,-Z), vec3(X,N,-Z),
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(-X,N,Z), vec3(X,N,Z), vec3(-X,N,-Z), vec3(X,N,-Z),
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(Z,X,N), vec3(-Z,X, N), vec3(Z,-X,N), vec3(-Z,-X, N)
vec3(-X,N,Z), vec3(X,N,Z), vec3(-X,N,-Z), vec3(X,N,-Z),
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(Z,X,N), vec3(-Z,X, N), vec3(Z,-X,N), vec3(-Z,-X, N)
vec3(-X,N,Z), vec3(X,N,Z), vec3(-X,N,-Z), vec3(X,N,-Z),
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(Z,X,N), vec3(-Z,X, N), vec3(Z,-X,N), vec3(-Z,-X, N)
vec3(-X,N,Z), vec3(X,N,Z), vec3(-X,N,-Z), vec3(X,N,-Z),
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(Z,X,N), vec3(-Z,X, N), vec3(Z,-X,N), vec3(-Z,-X, N)
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(Z,X,N), vec3(-Z,X, N), vec3(Z,-X,N), vec3(-Z,-X, N)
}
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(Z,X,N), vec3(-Z,X, N), vec3(Z,-X,N), vec3(-Z,-X, N)
}
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(Z,X,N), vec3(-Z,X, N), vec3(Z,-X,N), vec3(-Z,-X, N)
}
vec3(N,Z,X), vec3(N,Z,-X), vec3(N,-Z,X), vec3(N,-Z,-X),
vec3(Z,X,N), vec3(-Z,X, N), vec3(Z,-X,N), vec3(-Z,-X, N)
}
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/vePartTree.lua
if type(node.posX) == 'number' and type(node.posY) == 'number' and type(node.posZ) == 'number' then
node.pos = vec3(node.posX, node.posY, node.posZ)
node.posX = nil
local tempBeamCenterPoses = {}
local tempLinePoint1 = vec3()
local tempLinePoint2 = vec3()
local tempLinePoint1 = vec3()
local tempLinePoint2 = vec3()
if not tempBeamCenterPoses[key] then
tempBeamCenterPoses[key] = vec3()
beamCenterPos = tempBeamCenterPoses[key]
if not tempBeamCenterPoses[key] then
tempBeamCenterPoses[key] = vec3()
beamCenterPos = tempBeamCenterPoses[key]
local rayDir = res and dir or vec3()
local rayStartPos = res and pos or vec3()
local rayDir = res and dir or vec3()
local rayStartPos = res and pos or vec3()
local rayEndPos = rayStartPos + rayDir * 100
@/lua/ge/extensions/editor/gen/utils.lua
local function camSet(acoord)
core_camera.setPosition(0, vec3(acoord[1], acoord[2], acoord[3]))
core_camera.setRotation(0, quat(acoord[4], acoord[5], acoord[6], acoord[7]))
if t.x and t.y then
return vec3(t.x,t.y,t.z)
else
local dir = core_camera.getForward():normalized()
local vx = dir:cross(vec3(0,0,1)):normalized()
local vy = vx:cross(dir)
local vy = vx:cross(dir)
local v1 = U.vturn(vec3(1,0,0),ang + math.pi*0 + math.pi/2)
local v2 = U.vturn(vec3(1,0,0),ang + math.pi*2/3 + math.pi/2)
local v1 = U.vturn(vec3(1,0,0),ang + math.pi*0 + math.pi/2)
local v2 = U.vturn(vec3(1,0,0),ang + math.pi*2/3 + math.pi/2)
local v3 = U.vturn(vec3(1,0,0),ang + math.pi*4/3 + math.pi/2)
local v2 = U.vturn(vec3(1,0,0),ang + math.pi*2/3 + math.pi/2)
local v3 = U.vturn(vec3(1,0,0),ang + math.pi*4/3 + math.pi/2)
local p1,p2,p3 =
out.avedit = {}
local c = vec3(0,0,0)
for _,x in pairs({ob.minExtents.x, ob.maxExtents.x}) do
for _,z in pairs({ob.minExtents.z, ob.maxExtents.z}) do
out.avedit[#out.avedit+1] = vec3(x, y, z)
c = c + vec3(x, y, z)
out.avedit[#out.avedit+1] = vec3(x, y, z)
c = c + vec3(x, y, z)
end
U.curv = function(a,b,c)
-- local a,b,c = vec3(list[i-1].d,list[i-1].h), vec3(list[i].d,list[i].h), vec3(list[i+1].d,list[i+1].h)
return U.vang(c-b, b-a, true)/a:distance(c)
U.curv = function(a,b,c)
-- local a,b,c = vec3(list[i-1].d,list[i-1].h), vec3(list[i].d,list[i].h), vec3(list[i+1].d,list[i+1].h)
return U.vang(c-b, b-a, true)/a:distance(c)
U.curv = function(a,b,c)
-- local a,b,c = vec3(list[i-1].d,list[i-1].h), vec3(list[i].d,list[i].h), vec3(list[i+1].d,list[i+1].h)
return U.vang(c-b, b-a, true)/a:distance(c)
return vec3(x,y)
end
-- lo('?? circ2seg_X:'..x1..':'..x2..':'..c2..':'..c1..':'..c0..':'..math.sqrt(c1*c1-4*c2*c0))
p1,p2 = vec3(x1,-(A*x1+C)/B),vec3(x2,-(A*x2+C)/B)
-- lo('?? p1_2: p1:'..tostring(p1)..' p2:'..tostring(p2)..':'..tostring(a)..':'..tostring(b))
-- lo('?? circ2seg_X:'..x1..':'..x2..':'..c2..':'..c1..':'..c0..':'..math.sqrt(c1*c1-4*c2*c0))
p1,p2 = vec3(x1,-(A*x1+C)/B),vec3(x2,-(A*x2+C)/B)
-- lo('?? p1_2: p1:'..tostring(p1)..' p2:'..tostring(p2)..':'..tostring(a)..':'..tostring(b))
local x,y = lineCross(src[1],src[2],tgt[1],tgt[2])
local p = vec3(x,y)
local s = (p-tgt[1]):length()/(tgt[2]-tgt[1]):length()
-- lo('?? l2s:'..tostring(x)..':'..tostring(y))
local p = vec3(x,y)
if (c-p):dot(d-p) <= sense then
-- lo('?? l2s_has:', true)
-- if (vec3(c[1],c[2],0)-p):dot(vec3(d[1],d[2],0)-p) <= 0 then
local s = (p-c):length()/(d-c):length()
-- lo('?? l2s_has:', true)
-- if (vec3(c[1],c[2],0)-p):dot(vec3(d[1],d[2],0)-p) <= 0 then
local s = (p-c):length()/(d-c):length()
U.bounds = function(set, prop)
local mi,ma = vec3(math.huge,math.huge,math.huge),-vec3(math.huge,math.huge,math.huge)
for i,v in pairs(set) do
U.bounds = function(set, prop)
local mi,ma = vec3(math.huge,math.huge,math.huge),-vec3(math.huge,math.huge,math.huge)
for i,v in pairs(set) do
local x,y = lineCross({x=a[1],y=a[2]}, {x=b[1],y=b[2]}, {x=c[1],y=c[2]}, {x=d[1],y=d[2]})
local p = vec3(x,y,0)
if (vec3(c[1],c[2],0)-p):dot(vec3(d[1],d[2],0)-p) <= 0 then
local p = vec3(x,y,0)
if (vec3(c[1],c[2],0)-p):dot(vec3(d[1],d[2],0)-p) <= 0 then
return p
local p = vec3(x,y,0)
if (vec3(c[1],c[2],0)-p):dot(vec3(d[1],d[2],0)-p) <= 0 then
return p
if c then
local r = c - vec3(p[1],p[2],0)
local d = r:length()
if not base then return end
local c = vec3(0,0,0)
local s = 0
local x,y = lineCross(c1,c1+v1,c2,c2+v2)
local r = base[i]:distance(vec3(x,y))
acirc[#acirc+1] = {c=vec3(x,y),r=r}
local r = base[i]:distance(vec3(x,y))
acirc[#acirc+1] = {c=vec3(x,y),r=r}
end
if b then
av[#av+1] = vec3(adist[i-1] + pproj:distance(a),p.z)
break
local function perp(v)
return vec3(-v.y, v.x)
end
local function vturn(v, ang)
return vec3(math.cos(ang)*v.x - math.sin(ang)*v.y, math.sin(ang)*v.x + math.cos(ang)*v.y, v.z)
end
local function proj2D(v)
return vec3(v.x, v.y, 0)
end
local function onPlane(raypos, p, norm)
norm = norm or vec3(0,0,1)
local campos = core_camera.getPosition()
if v2:length() == 0 then
v2 = -v1:cross(vec3(0, 0, 1))
-- lo('?? NEW_V2:'..tostring(v2))
if v1:length() == 0 then
v1 = -v2:cross(vec3(0, 0, 1))
-- lo('?? NEW_V1:'..tostring(v1))
-- lo('??*********************************** polyMargin:'..i..':'..tostring(v1))
dp = v1:cross(vec3(0,0,1))*margin
else
else
dp = vec3(0, 0, 0)
end
if #mbase > 1 and (mbase[#mbase] - mbase[#mbase - 1]):length() < 0.0001 then
mbase[#mbase - 1] = vec3(mbase[#mbase].x, mbase[#mbase].y, mbase[#mbase].z)
-- lo('??********** polyMargin_close:'..i..':'..(mbase[#mbase] - mbase[#mbase - 1]):length())
@/lua/ge/extensions/editor/raceEditor/segments.lua
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
cap.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
if scl.x ~= 1 then
end
debugDrawer:drawTextAdvanced((vec3(self.mouseInfo.rayCast.pos)), String(txt), ColorF(1,1,1,1),true, false, ColorI(0,0,0,255))
if selected then
local old = segment:onSerialize()
cap.pos = vec3(capsulePosition[0], capsulePosition[1], capsulePosition[2])
self:updateTransform()
@/lua/ge/extensions/scenario/raceMarkers/attention.lua
local plDistToMarkerOffset = 4
local tmpVec = vec3()
local playerPosition = vec3(0,0,0)
playerPosition:set(core_camera.getPosition())
local toMarker2d = (self.pos-playerPosition):z0():normalized()
local toRight = vec3(toMarker2d.y,-toMarker2d.x)
self.left.instanceColor1 = ColorF(0,0,0,self.currentColor.a):asLinear4F()
self.left:setPosition( vec3(0,0,math.sin(os.clock()*3)*(0.2*self.scale.x/1.5))+self.pos+tmpVec)
-- self.left:setField('instanceColor', 1, ""..self.currentColor.r.." "..self.currentColor.g.." "..self.currentColor.b.." "..self.currentColor.a)
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
self.scale = vec3(1,1,1) * (wp.radius or 1.5)
self.pos = vec3(wp.pos)
self.scale = vec3(1,1,1) * (wp.radius or 1.5)
if self.left then
if self.left then
self.left:setPosition(vec3(0,0,1.75)+self.pos)
self.left:setScale(vec3(1,1,1))
self.left:setPosition(vec3(0,0,1.75)+self.pos)
self.left:setScale(vec3(1,1,1))
end
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
@/lua/vehicle/input.lua
local gx_Smoother = newTemporalSmoothing(4) -- it acts like a timer
local velVec = vec3()
local rightVec, frontVec = vec3(), vec3()
local function inputStabilization(st, dt, filter)
local rightVec, frontVec = vec3(), vec3()
local function inputStabilization(st, dt, filter)
@/lua/vehicle/controller/tech/idealRADARSensor.lua
-- Player vehicle state.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0, 0), vec3(0, 0) -- The player vehicle orthogonal frame.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0, 0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local pos = vec3(0, 0) -- The player vehicle position.
local fwd, right = vec3(0, 0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local fwd, right = vec3(0, 0), vec3(0, 0) -- The player vehicle orthogonal frame.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local lastVelPlayer = vec3(0, 0) -- An initial starting value for the player vehicle velocity.
local vehFront = vec3(0, 0) -- The player vehicle front/rear bumper midpoint positions.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local lastVelPlayer = vec3(0, 0) -- An initial starting value for the player vehicle velocity.
local vel, acc = vec3(0, 0), vec3(0, 0) -- The player vehicle velocity and acceleration vectors.
local lastVelPlayer = vec3(0, 0) -- An initial starting value for the player vehicle velocity.
local lastDt = 0.0 -- The previous time step size (used for velocity and acceleration computations).
-- Compute the position, velocity and acceleration of this other vehicle.
local posB, velB, accB = obj:getObjectCenterPosition(k), vec3(0, 0, 0), vec3(0, 0, 0)
if lastPos[k] ~= nil then
-- Compute the position, velocity and acceleration of this other vehicle.
local posB, velB, accB = obj:getObjectCenterPosition(k), vec3(0, 0, 0), vec3(0, 0, 0)
if lastPos[k] ~= nil then
@/lua/ge/extensions/util/trackBuilder/ceilingMesh.lua
{ point = vec3( 0, 0, 1) },
{ point = vec3( 1, 0, 1), sharp = true},
{ point = vec3( 0, 0, 1) },
{ point = vec3( 1, 0, 1), sharp = true},
{ point = vec3( 1, 0, 0), sharp = true},
{ point = vec3( 1, 0, 1), sharp = true},
{ point = vec3( 1, 0, 0), sharp = true},
{ point = vec3( 0, 0, 0) },
{ point = vec3( 1, 0, 0), sharp = true},
{ point = vec3( 0, 0, 0) },
{ point = vec3(-1, 0, 0), sharp = true},
{ point = vec3( 0, 0, 0) },
{ point = vec3(-1, 0, 0), sharp = true},
{ point = vec3(-1, 0, 1), sharp = true},
{ point = vec3(-1, 0, 0), sharp = true},
{ point = vec3(-1, 0, 1), sharp = true},
{ point = vec3( 0, 0, 1) },
{ point = vec3(-1, 0, 1), sharp = true},
{ point = vec3( 0, 0, 1) },
},
vertices[i] = {}
vertices[i].position = vec3(currentP.point.x * scl, currentP.point.y, currentP.point.z)
vertices[i].sharp = shape.crossPoints[i].sharp or false
a:normalize()
normals[#normals+1] = vec3(-a.z,0,a.x)
-- Actual normal.
local n = vec3(
-(a.z) - (b.z),
if len <=0.00001 then
n = vec3(
-(nextP.z - currentP.z),
else
normals[#normals+1] = vec3(-a.z,0,a.x)
normals[#normals+1] = vec3(-b.z,0,b.x)
normals[#normals+1] = vec3(-a.z,0,a.x)
normals[#normals+1] = vec3(-b.z,0,b.x)
end
a:normalize()
normals[#normals+1] = vec3(-a.z,0,a.x)
local pointCount = 0
local tmpVec3 = vec3()
for pIndex = 1, #segment.points do
p.position.z * point.orientation.nz +
point.position + vec3(0,0,point.zOffset)
)
@/lua/ge/extensions/editor/masterSpline/splineMgr.lua
local p = nodes[i]
deserializedNodes[i] = vec3(p.x, p.y, p.z)
end
local n = nmls[i]
deserializedNmls[i] = vec3(n.x, n.y, n.z)
end
@/lua/ge/extensions/core/cameraModes/collision.lua
local smoother
local upVec = vec3(0, 0, 1)
local fwdVec = vec3(0, 1, 0)
local upVec = vec3(0, 0, 1)
local fwdVec = vec3(0, 1, 0)
local lastDistance
local dirTemp = vec3()
local function isObstacleInFrontOfCam(rayDestinations)
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
function C:update(data)
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
function C:update(data)
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
function C:update(data)
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
function C:update(data)
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
function C:update(data)
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
function C:update(data)
local rayDestinations = {vec3(), vec3(), vec3(), vec3()}
local camDir, camRight, camUp, dir, nearClipCenter, rayStart, newCamPos = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
function C:update(data)
lastDistance = smoothedDistance
lastNearClipCenter = lastNearClipCenter or vec3()
lastNearClipCenter:set(nearClipCenter)
@/lua/ge/extensions/editor/dynamicDecals/camera.lua
if im.Button(string.format("%s##%s_%s", name:gsub("^%l", string.upper), "Generate Materials", guiId), im.ImVec2(im.GetContentRegionAvailWidth(), 0)) then
setCamera(vec3(val[1], val[2], val[3]))
end
@/lua/ge/extensions/editor/sitesEditor.lua
mouseInfo.ray = getCameraMouseRay()
mouseInfo.rayDir = vec3(mouseInfo.ray.dir)
mouseInfo.rayCast = cameraMouseRayCast()
mouseInfo.hold = false
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
end
if mouseInfo.hold then
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
end
if mouseInfo.up then
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
end
@/lua/ge/extensions/gameplay/drift/stuntZones/driftThrough.lua
local decalCount
local defaultDecalScale = vec3(0.35,0.35,3)
local t, cosX, sinY, x, y, data, invAmount, filledPerc, cooldownPerc
local a, b
local fwd = vec3()
local lerpVecA = vec3()
local fwd = vec3()
local lerpVecA = vec3()
local lerpVecB = vec3()
local lerpVecA = vec3()
local lerpVecB = vec3()
local lerpVecC = vec3()
local lerpVecB = vec3()
local lerpVecC = vec3()
local lerpVecD = vec3()
local lerpVecC = vec3()
local lerpVecD = vec3()
local color
@/lua/ge/extensions/editor/gen/decal.lua
target = nil,
vel = nil, --vec3(0,0,0),
pos = nil,
for _,n in pairs(nlist) do
anode[#anode+1] = vec3(n.pos.x,n.pos.y)
aw[#aw+1] = n.width
b.list[#b.list-1] - b.list[#b.list]):normalized()
return U.vang(U.proj2D(dira),vec3(1,0),true) > U.vang(U.proj2D(dirb),vec3(1,0),true)
end)
b.list[#b.list-1] - b.list[#b.list]):normalized()
return U.vang(U.proj2D(dira),vec3(1,0),true) > U.vang(U.proj2D(dirb),vec3(1,0),true)
end)
b.list[#b.list-1] - b.list[#b.list]):normalized()
lo('?? for_BB:'..b.ind..':'..tostring(b.list[1])..':'..U.proj2D(b.list[1]):distance(U.proj2D(p))..':'..tostring(dirb)..':'..tostring(p)..':'..U.vang(dirb,vec3(1,0),true))
if t == 1 then
-- D.road2ter(0) --{icheck})
-- D.decalSplit(adec[50], vec3(-139,-427,113.6))
-- adec,aref = decalsLoad('/levels/ce_test/main/MissionGroup/decalroads/AI_decalroads/items.level.json', 4096, 10)
if U._PRD==0 and icheck then
D.decalSplit(adec[icheck], vec3(-139,-427,113.6))
-- adec[icheck].body:setField('hidden',0,'true')
]]
-- D.decalSplit(adec[icheck], vec3(-139,-427,113.6))
--[[
b.list[#b.list-1] - b.list[#b.list]):normalized()
return U.vang(dira,vec3(1,0),true) > U.vang(dirb,vec3(1,0),true)
end)
b.list[#b.list-1] - b.list[#b.list]):normalized()
return U.vang(dira,vec3(1,0),true) > U.vang(dirb,vec3(1,0),true)
end)
if v then
v = vec3(v.x,v.y,v.z)
if not keepz then
grid = tb:getSquareSize()
lo('?? if_TB: size:'..tostring(tersize)..':'..forZ(vec3(-tersize.x/2+25,0.2))..' wb:'..tostring(tb:getWorldBox())..':'..tostring(tfr))
-- U.dump(extents, '?? for_TB:'..tostring(tb)..' sz:'..tostring(tb:getSquareSize()))
local function grid2p(ij)
return vec3(tfr.x + (ij[2]-1)*grid, tfr.y + (ij[1]-1)*grid)
end
forSquare(c, r + m, function(i, j, ic, jc)
local d = vec3(i, j):distance(vec3(ic,jc))*grid
if d <= r+m then
forSquare(c, r + m, function(i, j, ic, jc)
local d = vec3(i, j):distance(vec3(ic,jc))*grid
if d <= r+m then
if false and U._PRD == 0 then
out.acirc[#out.acirc+1] = {p=c+vec3(0,0,0), r=jrad}
out.acirc[#out.acirc+1] = {p=c+vec3(0,0,0), r=jrad+jmargin}
out.acirc[#out.acirc+1] = {p=c+vec3(0,0,0), r=jrad}
out.acirc[#out.acirc+1] = {p=c+vec3(0,0,0), r=jrad+jmargin}
end
]]
-- out.acyan = {c+vec3(0,0,forZ(c))}
rd.apin[#rd.apin+1] = {d = i == 1 and 0 or rd.L, h=hc, fix=true}
if dbg then lo('??++++++++++++ cross_right:'..k..':'..tostring(pc)..':'..d.dir..':'..tostring(aang[k-1].dir)..':'..tostring(aang[k-1].ind)) end
-- out.acyan = {pc+vec3(0,0,forZ(pc))}
-- out.acyan = {D.epos(rd.body, d.dir==-1 and rd.body:getEdgeCount()-1 or 0, d.dir==1 and 'right' or 'left')}
-- lo('?? for_r:'..r)
-- pc = pc + vec3(0,0,core_terrain.getTerrainHeight(pc))
if r > pinext then
r = pc:distance(D.epos(rd.body, d.dir==-1 and rd.body:getEdgeCount()-1 or 0, d.dir==-1 and 'right' or 'left'))
-- pc = pc + vec3(0,0,core_terrain.getTerrainHeight(pc))
-- out.avedit = {c + forZ(c)} -- vec3(0,0,core_terrain.getTerrainHeight(c))}
-- pc = pc + vec3(0,0,core_terrain.getTerrainHeight(pc))
-- out.avedit = {c + forZ(c)} -- vec3(0,0,core_terrain.getTerrainHeight(c))}
if r > pinext then
local function curv(list, i)
local a,b,c = vec3(list[i-1].d,list[i-1].h), vec3(list[i].d,list[i].h), vec3(list[i+1].d,list[i+1].h)
local function curv(list, i)
local a,b,c = vec3(list[i-1].d,list[i-1].h), vec3(list[i].d,list[i].h), vec3(list[i+1].d,list[i+1].h)
local function curv(list, i)
local a,b,c = vec3(list[i-1].d,list[i-1].h), vec3(list[i].d,list[i].h), vec3(list[i+1].d,list[i+1].h)
for i=1,rd.ne do
ae[#ae+1] = D.epos(rd.body, i-1)+vec3(0,0,2)
end
toMark(mark_curv, 'blue', function(d)
return d.p + vec3(0,0,forZ(d.p)+math.abs(d.c)*100)
end, nil, nil, true)
-- lo('?? AM4:'..rd.ind..':'..#am4)
-- out.acyan = {pc+vec3(0,0,forZ(pc))}
local jc,ic = p2grid(pc)
lo('??________________ for_AE:'..#ae)
toMark(ae, 'blue', function(i) return D.epos(rd.body, i)+vec3(0,0,1) end, 0.08, 0.3)
local ppi = D.onSide(rd,'middle',d)
local ppi = D.onSide(rd,'middle',d)
out.acyan = {pc+vec3(0,0,forZ(pc))}
end
out.ared[#out.ared+1] = D.epos(rd.body,ae[i])
out.ared[#out.ared] = out.ared[#out.ared] + vec3(0,0,forZ(out.ared[#out.ared]))
end
if dbg then lo('?? step:'..d/step..':'..d..'/'..rd.L) end
-- local cp = vec3(576.5, 1056.5)
-- local cp = vec3(417, 1092)
-- local cp = vec3(576.5, 1056.5)
-- local cp = vec3(417, 1092)
-- local cp = vec3(82, 692)
-- local cp = vec3(417, 1092)
-- local cp = vec3(82, 692)
-- local cp = vec3(48, 897)
-- local cp = vec3(82, 692)
-- local cp = vec3(48, 897)
local cp = vec3(50,896)
-- local cp = vec3(48, 897)
local cp = vec3(50,896)
amark = {}
local ij = U.stamp({i,j},true)
-- amark[#amark+1] = p + vec3(0,0,forZ(p))
--[[
amark[#amark+1] = p --grid2p({i,j})-- p + vec3(0,0,forZ(p))
end
if d == dbg_step*step then
-- amark[#amark+1] = p + vec3(0,0,forZ(p))
end
fix = nil
-- amark[#amark+1] = p + vec3(0,0,forZ(p)+dh)
--[[
if rdir > 0 then
if p:distance(vec3(398,1083)) < 2 then
lo('?? for_curve:'..tostring(crv))
lo('?? for_curve:'..tostring(crv))
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
end
lo('?? for_curve:'..tostring(crv))
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
end
end
if p:distance(vec3(382,1071)) < 2 then
lo('?? for_curve2:'..tostring(crv))
lo('?? for_curve2:'..tostring(crv))
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
end
lo('?? for_curve2:'..tostring(crv))
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
end
end
amark[#amark+1] = p + vec3(0,0,forZ(p)+dh)
end
if p:distance(cp) < 0.5 then
-- if p:distance(vec3(587, 1066)) < 0.5 then
-- am2[#am2+1] = p
if rdir > 0 and p:distance(cp) < 10 then
-- out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
-- amark[#amark+1] = p + vec3(0,0,forZ(p))
if rdir > 0 and p:distance(cp) < 10 then
-- out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
-- amark[#amark+1] = p + vec3(0,0,forZ(p))
-- out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
-- amark[#amark+1] = p + vec3(0,0,forZ(p))
end
if p:distance(cp) < 1.5 then -- and d/step == 4 then
-- if p:distance(vec3(587, 1066)) < 0.5 then
am2[#am2+1] = p + vec3(0,0,forZ(p)+dp-4)
-- if p:distance(vec3(587, 1066)) < 0.5 then
am2[#am2+1] = p + vec3(0,0,forZ(p)+dp-4)
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
am2[#am2+1] = p + vec3(0,0,forZ(p)+dp-4)
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
lo('?? for_step:'..d/step..':'..i..':'..j)
am2[#am2+1] = p + vec3(0,0,forZ(p)+dp-4)
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
lo('?? for_step:'..d/step..':'..i..':'..j)
if p:distance(cp) < 0.5 then
-- if p:distance(vec3(587, 1066)) < 0.5 then
-- am2[#am2+1] = p
]]
-- amark[#amark+1] = p + vec3(0,0,forZ(p)+dh)
else
-- if
-- amark[#amark+1] = p + vec3(0,0,forZ(p))
end
lo('?? farf:'..crv)
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
am2[#am2+1] = p
lo('?? farf:'..crv)
out.aseg[#out.aseg+1] = {p+vec3(0,0,forZ(p)+1), pp+vec3(0,0,forZ(pp)+1)}
am2[#am2+1] = p
-- am4[#am4+1] = p
-- amark[#amark+1] = p + vec3(0,0,forZ(p))
end
end
-- if p:distance(vec3(587,1066)) < 3 then
-- am2[#am2+1] = p --+ vec3(0,0,forZ(p))
-- if p:distance(vec3(587,1066)) < 3 then
-- am2[#am2+1] = p --+ vec3(0,0,forZ(p))
if i == 3091 and j == 2614 then
-- toMark(am3, 'mag', nil, 0.05, 0.3)
-- out.acyan = {D.epos(rd.body,ae[1])+vec3(0,0,forZ(D.epos(rd.body,ae[1])))}-- {rd.list[1]}
end
end
-- amark[#amark+1] = p + vec3(0,0,forZ(p))
--[[
if i == ic+5 and j == jc+5 and pp then
out.white = {p + vec3(0,0,forZ(p)), pp + vec3(0,0,forZ(pp))}
U.dump(out.ared, '?? pp:'..tostring(p)..':'..tostring(pp))
if i == ic+5 and j == jc+5 and pp then
out.white = {p + vec3(0,0,forZ(p)), pp + vec3(0,0,forZ(pp))}
U.dump(out.ared, '?? pp:'..tostring(p)..':'..tostring(pp))
end
out.acyan[#out.acyan+1] = p + vec3(0,0,forZ(p))
]]
local pos = D.epos(rd.body, i)
out.acyan = {pos + vec3(0,0,forZ(pos))}
local dd = (pos - ppos):length()
if d > dist then
-- out.acyan[#out.acyan+1] = pos + vec3(0,0,forZ(pos))
local c = (d - dist)/dd
-- break
anode[#anode+1] = vec3(ac[1],ac[2])
end
-- out.avedit[#out.avedit+1] = epos(rdb, startb+2, sideb)
-- out.avedit = {vec3(50,0,0)}
-- lo('<< borderCross:')
-- lo('?? line4exit:'..tostring(aline[#aline].list[1])..':'..tostring(toSide(aline[#aline].list[1],b,b.io==1 and 'right' or 'left')..'/'..(b.w/2)))
-- out.acyan = {aline[#aline].list[1]+vec3(0,0,forZ(aline[#aline].list[1]))}
-- lo('?? line1:'..tostring(aline[#aline].list))
local x,y = U.lineCross(list[1],list[2],list[#list],list[#list-1])
local cross = vec3(x,y)
local d,p = U.toLine(cross, {list[2],list[3]})
local x,y = U.lineCross(list[1],list[2],list[#list],list[#list-1])
local cross = vec3(x,y)
local d,p = U.toLine(cross, {list[2],list[3]})
-- out.avedit = {list[1], list[2], list[3], list[4]}
-- out.avedit[#out.avedit+1] = vec3(x,y)
local x,y = U.lineCross(list[1],list[2],list[#list],list[#list-1])
local cross = vec3(x,y)
local d,p = U.toLine(cross, {list[2],list[3]})
-- out.avedit = {list[1], list[2], list[3], list[4]}
-- out.avedit[#out.avedit+1] = vec3(x,y)
for i = 0,nstep+2 do
list[#list+1] = jdesc.p + r*vec3(math.cos(i*2*math.pi/nstep), math.sin(i*2*math.pi/nstep))
end
-- line.list[#line.list] = c -- line.list[#line.list] + vec3(5,5)
-- out.avedit = {line.list[#line.list]}
-- circle
local ang -- = U.vang(vec3(1,0,0), jdesc.list[1].dir, true)
-- lo('?? for_ang0:'..tostring(ang)..':'..tostring(jdesc.list[1].dir))
for i = 0,nstep+2 do
list[#list+1] = jdesc.p + r*vec3(math.cos(i*2*math.pi/nstep), math.sin(i*2*math.pi/nstep))
-- list[#list+1] = jdesc.p + r*vec3(math.cos(i*2*math.pi/nstep+ang-math.pi/2), math.sin(i*2*math.pi/nstep+ang-math.pi/2))
list[#list+1] = jdesc.p + r*vec3(math.cos(i*2*math.pi/nstep), math.sin(i*2*math.pi/nstep))
-- list[#list+1] = jdesc.p + r*vec3(math.cos(i*2*math.pi/nstep+ang-math.pi/2), math.sin(i*2*math.pi/nstep+ang-math.pi/2))
end
-- line.list[#line.list] = c -- line.list[#line.list] + vec3(5,5)
-- out.avedit = {line.list[#line.list]}
local pb,ib = onSide(b, b.io==1 and 'right' or 'left', dw, margin)
-- out.acyan[#out.acyan+1] = pb+vec3(0,0,forZ(pb))
local pe,ie = onSide(b, b.io==1 and 'right' or 'left', b.L - dw, margin)
local pe,ie = onSide(b, b.io==1 and 'right' or 'left', b.L - dw, margin)
-- out.acyan[#out.acyan+1] = pe+vec3(0,0,forZ(pe))
-- lo('?? ps_pe:'..tostring(ps)..':'..tostring(pe)..':'..ib..':'..ie)
for j=1,#line.list do
line.list[j] = line.list[j] + vec3(0,0,forZ(line.list[j]))
end
for k = 1,2 do
list[#list+1] = list[#list] + step*vec3(math.cos(i*ang), math.sin(i*ang))
end
local list = {pos}
list[#list+1] = list[#list] + vec3(step*math.cos(i*2*math.pi/n), step*math.sin(i*2*math.pi/n))
local desc = {list=list, w=laneWidth*default.laneNum*2, mat=default.mat, lane = {default.laneNum,default.laneNum}}
--[[
if (p - vec3(0, 0, 0)):length() < 300 then
lo('?? CC0:'..tostring(p))
for x,h in pairs(row) do
tb:setHeightWs(vec3(x,y), h)
end
for j = y+1,y+20 do
hmapChange(vec3(i,j), 300)
-- tb:setHeightWs(vec3(i,j), 300)
hmapChange(vec3(i,j), 300)
-- tb:setHeightWs(vec3(i,j), 300)
end
cint = 1
local cheight = core_terrain.getTerrainHeight(vec3(anode[1].pos.x,anode[1].pos.y))
-- aepin = {{1, cheight}}
-- aepin = {{1, cheight}}
-- local cheight = core_terrain.getTerrainHeight(vec3(anode[acp[cint]].pos.x,anode[acp[cint]].pos.y))
local inswitch = false
p.z = aepin[#aepin][2]
-- out.apick[#out.apick + 1] = p -- vec3(p.x,p.y,aepin[#aepin][2])
-- lo('?? for_pin1:'..#aepin..':'..tostring(p)..':'..aeinfo[i+1].d)
inswitch = true
cheight = core_terrain.getTerrainHeight(vec3(anode[acp[cint]].pos.x,anode[acp[cint]].pos.y))
cdist = aeinfo[i+1].d
local p = croad:getMiddleEdgePosition(i)
aepin[#aepin+1] = {i+1, core_terrain.getTerrainHeight(vec3(p.x,p.y))}
-- aepin[i+1] = core_terrain.getTerrainHeight(vec3(p.x,p.y))
aepin[#aepin+1] = {i+1, core_terrain.getTerrainHeight(vec3(p.x,p.y))}
-- aepin[i+1] = core_terrain.getTerrainHeight(vec3(p.x,p.y))
cdist = aeinfo[i+1].d
cdist = aeinfo[i+1].d
out.apick[#out.apick + 1] = p -- vec3(p.x,p.y,aepin[#aepin][2])
end
local p = croad:getMiddleEdgePosition(nsec-1)
aepin[#aepin + 1] = {nsec, core_terrain.getTerrainHeight(vec3(p.x,p.y))}
end
local cd = 0
local ex,ey = vec3(1,0,0),vec3(0,1,0)
local nstamp = 0
local cd = 0
local ex,ey = vec3(1,0,0),vec3(0,1,0)
local nstamp = 0
for x = xfr,xto do
local t = vec3(x,y)
t.z = core_terrain.getTerrainHeight(t)
end
-- out.avedit[#out.avedit+1] = vec3(t.x,t.y,h)
elseif dmi < rwidth/2 + mantle then
hmapChange(t, h)
-- out.avedit[#out.avedit+1] = vec3(t.x,t.y,h)
end
if true or dmi < anode[1].width/2 + 1 + 0*mantle then
-- out.avedit[#out.avedit+1] = t + vec3(0,0,1)
end
local inode = aedist[imi][2]
local p1,p2 = vec3(anode[inode].pos.x,anode[inode].pos.y),vec3(anode[inode+1].pos.x,anode[inode+1].pos.y)
local vp = vec3(-(p2-p1).y,(p2-p1).x)
local inode = aedist[imi][2]
local p1,p2 = vec3(anode[inode].pos.x,anode[inode].pos.y),vec3(anode[inode+1].pos.x,anode[inode+1].pos.y)
local vp = vec3(-(p2-p1).y,(p2-p1).x)
local p1,p2 = vec3(anode[inode].pos.x,anode[inode].pos.y),vec3(anode[inode+1].pos.x,anode[inode+1].pos.y)
local vp = vec3(-(p2-p1).y,(p2-p1).x)
local cx,cy = U.lineCross(p1, p2, t, t+vp)
U.proj2D(rd:getMiddleEdgePosition(i)), U.proj2D(rd:getMiddleEdgePosition(i+1)),
t, vec3(t.x, t.y, 1))
if p1 >= 0 and p1 <= 1 then
v = U.proj2D(anode[i+1].pos - anode[i].pos):normalized()
v = vec3(-v.y,v.x)
list[#list+1] = anode[i].pos + v*c*anode[i].width/2
out.avedit = {us1, us2, them1, them2}
out.apick = {vec3(x,y,core_terrain.getTerrainHeight(vec3(x,y)))}
-- lo('?? fr_to:'..ifr..'>'..ito..'/'..nsec..':'..jfr..'>'..jto..'/'..nsecthem)
out.avedit = {us1, us2, them1, them2}
out.apick = {vec3(x,y,core_terrain.getTerrainHeight(vec3(x,y)))}
-- lo('?? fr_to:'..ifr..'>'..ito..'/'..nsec..':'..jfr..'>'..jto..'/'..nsecthem)
local ang = U.vang(u, v)/2
local p = vec3(x,y) + (u + v):normalized()*margin/math.sin(ang)
p.z = core_terrain.getTerrainHeight(p)
v = U.proj2D(anode[nxtnode+1].pos - anode[nxtnode].pos):normalized()
v = vec3(-v.y,v.x)
list[#list+1] = rdobj:getLeftEdgePosition(i) - v*margin
local v = U.proj2D(anode[nxtnode+1].pos - anode[nxtnode].pos):normalized()
v = vec3(-v.y,v.x)
list[#list+1] = croad:getLeftEdgePosition(i) - v*0.3
-- for j,n in pairs(b.list) do
-- editor.setNodePosition(b.body, j-1, n+vec3(0,0,10))
-- end
local r = U.rand(100, 400)
junctionUp(car.pos + r*U.vturn(car.vel:normalized(), U.rand(-math.pi/6, math.pi/6)), math.random(3,5)) --*vec3(math.cos(ang),math.sin(ang)), math.random(3,5))
end
lo('?? to_GEN:'..tostring(car.vel)..':'..r..':'..#amatch)
local jdesc = junctionUp(car.target.p + r*U.vturn(car.vel:normalized(), U.rand(-math.pi/6, math.pi/6)), math.random(3,5)) --*vec3(math.cos(ang),math.sin(ang)), math.random(3,5))
-- lo('?? post_GEN:'..#amatch)
local function curvH(a,b,c)
return U.curv(vec3(0,forZ(a)), vec3(b:distance(a),forZ(b)), vec3(c:distance(b),forZ(c)))
end
local function curvH(a,b,c)
return U.curv(vec3(0,forZ(a)), vec3(b:distance(a),forZ(b)), vec3(c:distance(b),forZ(c)))
end
local function curvH(a,b,c)
return U.curv(vec3(0,forZ(a)), vec3(b:distance(a),forZ(b)), vec3(c:distance(b),forZ(c)))
end
if not pth then pth = {
--vec3(-61.38508606,-169.9675598,0),
--vec3(-9.894002914,-419.5056152,0)
--vec3(-61.38508606,-169.9675598,0),
--vec3(-9.894002914,-419.5056152,0)
vec3(-187.3,-1763.5),
--vec3(-9.894002914,-419.5056152,0)
vec3(-187.3,-1763.5),
vec3(-137,-1692.7),
vec3(-187.3,-1763.5),
vec3(-137,-1692.7),
}
end
-- pth = {vec3(1886.662842,-1487.655273),vec3(1916.427979,-1421.535034)}
-- pth = {vec3(), vec3()}
end
-- pth = {vec3(1886.662842,-1487.655273),vec3(1916.427979,-1421.535034)}
-- pth = {vec3(), vec3()}
-- pth = {vec3(1886.662842,-1487.655273),vec3(1916.427979,-1421.535034)}
-- pth = {vec3(), vec3()}
-- pth = {vec3(1702.53,-1436.44), vec3(1660.6,-1344.61)}
-- pth = {vec3(1886.662842,-1487.655273),vec3(1916.427979,-1421.535034)}
-- pth = {vec3(), vec3()}
-- pth = {vec3(1702.53,-1436.44), vec3(1660.6,-1344.61)}
-- pth = {vec3(), vec3()}
-- pth = {vec3(1702.53,-1436.44), vec3(1660.6,-1344.61)}
-- pth = {vec3(1549.39,-1408.29), vec3(1543.12,-1313.23)}
-- pth = {vec3(), vec3()}
-- pth = {vec3(1702.53,-1436.44), vec3(1660.6,-1344.61)}
-- pth = {vec3(1549.39,-1408.29), vec3(1543.12,-1313.23)}
-- pth = {vec3(1702.53,-1436.44), vec3(1660.6,-1344.61)}
-- pth = {vec3(1549.39,-1408.29), vec3(1543.12,-1313.23)}
-- pth[1] = pth[1] + vec3(0,0,forZ(pth[1]))
-- pth = {vec3(1702.53,-1436.44), vec3(1660.6,-1344.61)}
-- pth = {vec3(1549.39,-1408.29), vec3(1543.12,-1313.23)}
-- pth[1] = pth[1] + vec3(0,0,forZ(pth[1]))
-- pth = {vec3(1549.39,-1408.29), vec3(1543.12,-1313.23)}
-- pth[1] = pth[1] + vec3(0,0,forZ(pth[1]))
-- pth[2] = pth[2] + vec3(0,0,forZ(pth[2]))
-- pth[1] = pth[1] + vec3(0,0,forZ(pth[1]))
-- pth[2] = pth[2] + vec3(0,0,forZ(pth[2]))
-- out.ared = {list[1]}
-- while dc < dcma and n < 10 do
local dcx = math.abs(curvH(a,pmi+vec3(gradstep,0,0),b)) - cmi
local dcy = math.abs(curvH(a,pmi+vec3(0,gradstep,0),b)) - cmi
local dcx = math.abs(curvH(a,pmi+vec3(gradstep,0,0),b)) - cmi
local dcy = math.abs(curvH(a,pmi+vec3(0,gradstep,0),b)) - cmi
local u = vec3(-dcx, -dcy):normalized()
local dcy = math.abs(curvH(a,pmi+vec3(0,gradstep,0),b)) - cmi
local u = vec3(-dcx, -dcy):normalized()
local pt = pmi + u*gradstep
local d = list[i]
ap[#ap+1] = d.e[1] + vec3(0,0,forZ(d.e[1]))
ap2[#ap2+1] = {
ap2[#ap2+1] = {
list[i].e[1]+vec3(0,0,forZ(list[i].e[1])),
U.proj2D(list[i].e[2]) + vec3(0,0,forZ(U.proj2D(list[i].e[2])))}
list[i].e[1]+vec3(0,0,forZ(list[i].e[1])),
U.proj2D(list[i].e[2]) + vec3(0,0,forZ(U.proj2D(list[i].e[2])))}
-- for i,d in pairs(list) do
if i and d.ps then
out.aseg[#out.aseg+1] = {d.ps+vec3(0,0,forZ(d.ps)),d.e[1]+vec3(0,0,forZ(d.e[1]))}
end
if i and d.ps then
out.aseg[#out.aseg+1] = {d.ps+vec3(0,0,forZ(d.ps)),d.e[1]+vec3(0,0,forZ(d.e[1]))}
end
end
-- ap2[#ap2+1] = d.ps+vec3(0,0,forZ(d.ps)+3)
end
-- list[#list+1] = pfr + u*d
-- list[#list] = list[#list] + vec3(0,0,forZ(list[#list]))
end
-- out.avedit = {d.p + b.dir*20}
-- out.atri = {{d.p + b.dir*20, d.p + b.dir*20+vec3(2,0,0), d.p + b.dir*20+vec3(0,2,0)}}
end
-- out.avedit = {d.p + b.dir*20}
-- out.atri = {{d.p + b.dir*20, d.p + b.dir*20+vec3(2,0,0), d.p + b.dir*20+vec3(0,2,0)}}
end
-- out.avedit = {d.p + b.dir*20}
-- out.atri = {{d.p + b.dir*20, d.p + b.dir*20+vec3(2,0,0), d.p + b.dir*20+vec3(0,2,0)}}
end
-- out.avedit = {d.p + b.dir*20}
-- out.atri = {{d.p + b.dir*20, d.p + b.dir*20+vec3(2,0,0), d.p + b.dir*20+vec3(0,2,0)}}
end
out.sidepick = {
p=ps+vec3(0,0,forZ(ps)),
ind=cdescmo,
out.sidepick = {
p=ps+vec3(0,0,forZ(ps)),
ind=cdescmo,
-- if ds < adec[jmi].aw[nmi]/2+2 then
ps = ps + vec3(0,0,forZ(ps))
elseif ds < adec[jmi].aw[nmi]*2/3 then
out.sidepick = {
list = {ps+vec3(0,0,forZ(ps))},
-- p=ps+vec3(0,0,forZ(ps)),
list = {ps+vec3(0,0,forZ(ps))},
-- p=ps+vec3(0,0,forZ(ps)),
ind=cdescmo,
decalSplit(a, out.sidepick.p)
decalSplit(b, ps+vec3(0,0,forZ(ps)))
else
out.sidepick = {p=ps+vec3(0,0,forZ(ps)), src=jmi}
end
out.sidepick = {
p=ps+vec3(0,0,forZ(ps)),
ind=cdescmo,
out.sidepick = {
p=ps+vec3(0,0,forZ(ps)),
ind=cdescmo,
-- veh:setPositionNoPhysicsReset(rayCast.pos)
-- scenetree.findObject("thePlayer"):setPosition(vec3(x, y, core_terrain.getTerrainHeight(vec3(x,y))))
-- elseif editor.keyModifiers.ctrl then -- and out.injunction then --not indrag and U._MODE ~= 'conf' then
-- veh:setPositionNoPhysicsReset(rayCast.pos)
-- scenetree.findObject("thePlayer"):setPosition(vec3(x, y, core_terrain.getTerrainHeight(vec3(x,y))))
-- elseif editor.keyModifiers.ctrl then -- and out.injunction then --not indrag and U._MODE ~= 'conf' then
car.pos = veh:getPosition()
local ang = -U.vang(car.vel or vec3(-1,0,0), car.target.p-car.pos, true)
-- local ang = -U.vang(car.pos, car.target, true)
if cjunc and ajunc[cjunc] and ajunc[cjunc].r then
R.circle(ajunc[cjunc].p+vec3(0,0,1), ajunc[cjunc].r, color(255,255,0,255), 4)
end
-- Render.path(out.pdrag.dir, color(255,255,250,155), 8)
-- debugDrawer:drawLine(vec3(0,0,0), vec3(10,0,0), c, w)
-- line(out.pdrag.dir[1], out.pdrag.dir[2], ColorF(1,0,0,0.4), 14)
-- Render.path(out.pdrag.dir, color(255,255,250,155), 8)
-- debugDrawer:drawLine(vec3(0,0,0), vec3(10,0,0), c, w)
-- line(out.pdrag.dir[1], out.pdrag.dir[2], ColorF(1,0,0,0.4), 14)
@/lua/ge/extensions/gameplay/rally/driveline/drivelineV3.lua
for i, xyz in ipairs(data.points) do
table.insert(positions, vec3(xyz[1], xyz[2], xyz[3]))
end
for i, point in ipairs(points) do
tempNodes[i] = vec3(point.pos)
tempWidths[i] = DrivelineUtil.defaultSplineWidth
tempWidths[i] = DrivelineUtil.defaultSplineWidth
tempNormals[i] = point.normal or vec3(0, 0, 1)
end
for i = 1, #positions do
local pos = vec3(positions[i])
if i < #positions then
dir = (vec3(positions[i + 1]) - pos):normalized()
else
else
dir = (pos - vec3(positions[i - 1])):normalized()
end
-- Create quaternion from forward direction
local up = vec3(0, 0, 1)
local right = dir:cross(up):normalized()
for i = 1, #self.spline.nodes do
copy.nodes[i] = vec3(self.spline.nodes[i])
end
for i = 1, #self.spline.nmls do
copy.nmls[i] = vec3(self.spline.nmls[i])
end
local pos = self.rawDrivelinePoints[i].pos
local pinTop = vec3(pos.x, pos.y, pos.z + pinHeight)
debugDrawer:drawCylinder(pos, pinTop, radius * 0.7, clr)
local pos = self.finalDrivelinePoints[i].pos
local pinTop = vec3(pos.x, pos.y, pos.z + pinHeight)
debugDrawer:drawCylinder(pos, pinTop, radius * 0.7, clr)
@/lua/ge/extensions/flowgraph/nodes/scene/raycast.lua
if not self.pinIn.dir.value then return end
local pos = vec3(self.pinIn.pos.value)
local dir = vec3(self.pinIn.dir.value)
local pos = vec3(self.pinIn.pos.value)
local dir = vec3(self.pinIn.dir.value)
local dist = self.pinIn.dist.value or dir:length()
if self.data.debug then
debugDrawer:drawSphere(vec3(pos), 0.25, ColorF(1,0,0,0.5))
debugDrawer:drawSphere(vec3(hitPos), 0.25, ColorF(0,1,0,0.5))
debugDrawer:drawSphere(vec3(pos), 0.25, ColorF(1,0,0,0.5))
debugDrawer:drawSphere(vec3(hitPos), 0.25, ColorF(0,1,0,0.5))
debugDrawer:drawLine(vec3(pos), vec3(hitPos), ColorF(0,0,1,0.5))
debugDrawer:drawSphere(vec3(hitPos), 0.25, ColorF(0,1,0,0.5))
debugDrawer:drawLine(vec3(pos), vec3(hitPos), ColorF(0,0,1,0.5))
debugDrawer:drawTextAdvanced(hitPos, String(string.format("%0.3f",hitDist)), ColorF(1,1,1,1), true, false, ColorI(0,0,0,192))
debugDrawer:drawSphere(vec3(hitPos), 0.25, ColorF(0,1,0,0.5))
debugDrawer:drawLine(vec3(pos), vec3(hitPos), ColorF(0,0,1,0.5))
debugDrawer:drawTextAdvanced(hitPos, String(string.format("%0.3f",hitDist)), ColorF(1,1,1,1), true, false, ColorI(0,0,0,192))
@/lua/ge/extensions/gameplay/rally/cameraPathPlayer.lua
if i > 1 then
local prev_pos = vec3(points[i-1].pos)
local curr_pos = vec3(cap.pos)
local prev_pos = vec3(points[i-1].pos)
local curr_pos = vec3(cap.pos)
local distance = prev_pos:distance(curr_pos)
movingStart = true,
pos = vec3(cap.pos) + vec3(0,0,height),
rot = cap.quat,
movingStart = true,
pos = vec3(cap.pos) + vec3(0,0,height),
rot = cap.quat,
local marker = {
pos = vec3(markerData.pos.x, markerData.pos.y, markerData.pos.z),
rot = quat(markerData.rot.x, markerData.rot.y, markerData.rot.z, markerData.rot.w),
@/lua/ge/extensions/editor/tech/roadArchitect/roadMesh.lua
{ u = 1.0, v = 1.0 } }
local downVec = vec3(0, 0, -1)
local raised = vec3(0, 0, 4.5)
local downVec = vec3(0, 0, -1)
local raised = vec3(0, 0, 4.5)
local origin = vec3(0, 0, 0) -- A vec3 used for representing the scene origin.
local raised = vec3(0, 0, 4.5)
local origin = vec3(0, 0, 0) -- A vec3 used for representing the scene origin.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local origin = vec3(0, 0, 0) -- A vec3 used for representing the scene origin.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0) -- Some temporary vectors.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0) -- Some temporary vectors.
local materials = { -- The mesh materials, per type.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0) -- Some temporary vectors.
local materials = { -- The mesh materials, per type.
local scaleVec = vec3(1, 1, 1) -- A vec3 used for representing uniform scale.
local tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0) -- Some temporary vectors.
local materials = { -- The mesh materials, per type.
local rD = rData[i][lIdx]
local p1 = vec3(rD[1].x, rD[1].y, rD[1].z) + raised
local p2 = vec3(rD[2].x, rD[2].y, rD[2].z) + raised
local p1 = vec3(rD[1].x, rD[1].y, rD[1].z) + raised
local p2 = vec3(rD[2].x, rD[2].y, rD[2].z) + raised
local p3 = vec3(rD[3].x, rD[3].y, rD[3].z) + raised
local p2 = vec3(rD[2].x, rD[2].y, rD[2].z) + raised
local p3 = vec3(rD[3].x, rD[3].y, rD[3].z) + raised
local p4 = vec3(rD[4].x, rD[4].y, rD[4].z) + raised
local p3 = vec3(rD[3].x, rD[3].y, rD[3].z) + raised
local p4 = vec3(rD[4].x, rD[4].y, rD[4].z) + raised
p1.z = p1.z - castRayStatic(p1, downVec, 1000) + rD[1].z - rD[4].z
local rD = rData[i][lIdx]
local p2 = vec3(rD[1].x, rD[1].y, rD[1].z) + raised
local p1 = vec3(rD[2].x, rD[2].y, rD[2].z) + raised
local p2 = vec3(rD[1].x, rD[1].y, rD[1].z) + raised
local p1 = vec3(rD[2].x, rD[2].y, rD[2].z) + raised
local p4 = vec3(rD[3].x, rD[3].y, rD[3].z) + raised
local p1 = vec3(rD[2].x, rD[2].y, rD[2].z) + raised
local p4 = vec3(rD[3].x, rD[3].y, rD[3].z) + raised
local p3 = vec3(rD[4].x, rD[4].y, rD[4].z) + raised
local p4 = vec3(rD[3].x, rD[3].y, rD[3].z) + raised
local p3 = vec3(rD[4].x, rD[4].y, rD[4].z) + raised
p1.z = p1.z - castRayStatic(p1, downVec, 1000) + rD[2].z - rD[3].z
@/lua/common/utils/pixellib.lua
local s1 = math.floor(size * 0.5)
self:drawFilledCircle(vec3(x, y, 0), s1, color)
end
function LuaPixelBuffer:fill(color)
self:drawFilledRect(vec3(0,0,0), self.width, self.height, color)
end
-- p4 -- p3
local p2 = vec3(p1.x + width, p1.y, 0)
local p3 = vec3(p1.x + width, p1.y + height, 0)
local p2 = vec3(p1.x + width, p1.y, 0)
local p3 = vec3(p1.x + width, p1.y + height, 0)
local p4 = vec3(p1.x, p1.y + height, 0)
local p3 = vec3(p1.x + width, p1.y + height, 0)
local p4 = vec3(p1.x, p1.y + height, 0)
self:drawLine(p1, p2, color, lineWidth)
-- test the drawing
pb:drawIcon(vec3(50, 50, 0), 'x', ColorI(0, 0, 255, 255))
pb:drawIcon(vec3(60, 50, 0), 'o', ColorI(255, 0, 255, 255))
pb:drawIcon(vec3(50, 50, 0), 'x', ColorI(0, 0, 255, 255))
pb:drawIcon(vec3(60, 50, 0), 'o', ColorI(255, 0, 255, 255))
pb:drawLine(vec3(-500,-500,0), vec3(500,500,0), ColorI(100, 100, 100, 100), 20)
pb:drawLine(vec3(-500,-500,0), vec3(500,500,0), ColorI(100, 100, 100, 100), 20)
pb:drawFilledRect(vec3(170,50,0), 50, 100, ColorI(255, 255, 0, 255))
pb:drawRect(vec3(170,50,0), 50, 100, ColorI(150, 150, 0, 255), 5)
pb:drawFilledRect(vec3(170,50,0), 50, 100, ColorI(255, 255, 0, 255))
pb:drawRect(vec3(170,50,0), 50, 100, ColorI(150, 150, 0, 255), 5)
pb:drawLine(vec3(15,15,0), vec3(30,45,0), ColorI(0, 255, 0, 255), 1)
pb:drawLine(vec3(40,55,0), vec3(25,25,0), ColorI(0, 255, 0, 255), 1)
pb:drawLine(vec3(15,15,0), vec3(30,45,0), ColorI(0, 255, 0, 255), 1)
pb:drawLine(vec3(40,55,0), vec3(25,25,0), ColorI(0, 255, 0, 255), 1)
pb:drawLine(vec3(15,15,0), vec3(30,45,0), ColorI(0, 255, 0, 255), 1)
pb:drawLine(vec3(40,55,0), vec3(25,25,0), ColorI(0, 255, 0, 255), 1)
pb:drawLine(vec3(15,15,0), vec3(30,45,0), ColorI(0, 255, 0, 255), 1)
pb:drawLine(vec3(40,55,0), vec3(25,25,0), ColorI(0, 255, 0, 255), 1)
pb:drawLine(vec3(30,45,0), vec3(60,18,0), ColorI(255, 0, 0, 255), 2)
pb:drawLine(vec3(70,28,0), vec3(40,55,0), ColorI(255, 0, 0, 255), 2)
pb:drawLine(vec3(30,45,0), vec3(60,18,0), ColorI(255, 0, 0, 255), 2)
pb:drawLine(vec3(70,28,0), vec3(40,55,0), ColorI(255, 0, 0, 255), 2)
pb:drawLine(vec3(30,45,0), vec3(60,18,0), ColorI(255, 0, 0, 255), 2)
pb:drawLine(vec3(70,28,0), vec3(40,55,0), ColorI(255, 0, 0, 255), 2)
pb:drawLine(vec3(30,45,0), vec3(60,18,0), ColorI(255, 0, 0, 255), 2)
pb:drawLine(vec3(70,28,0), vec3(40,55,0), ColorI(255, 0, 0, 255), 2)
pb:drawLine(vec3(15,15,0), vec3(60,18,0), ColorI(0, 255, 255, 255), 3)
pb:drawLine(vec3(70,28,0), vec3(25,25,0), ColorI(0, 255, 255, 255), 3)
pb:drawLine(vec3(15,15,0), vec3(60,18,0), ColorI(0, 255, 255, 255), 3)
pb:drawLine(vec3(70,28,0), vec3(25,25,0), ColorI(0, 255, 255, 255), 3)
pb:drawLine(vec3(15,15,0), vec3(60,18,0), ColorI(0, 255, 255, 255), 3)
pb:drawLine(vec3(70,28,0), vec3(25,25,0), ColorI(0, 255, 255, 255), 3)
pb:drawLine(vec3(15,15,0), vec3(60,18,0), ColorI(0, 255, 255, 255), 3)
pb:drawLine(vec3(70,28,0), vec3(25,25,0), ColorI(0, 255, 255, 255), 3)
pb:drawFilledCircle(vec3(100,100,0), 50, ColorI(255,0,0,255))
pb:drawCircle(vec3(100,100,0), 50, ColorI(150,0,0,255), 1)
pb:drawFilledCircle(vec3(100,100,0), 50, ColorI(255,0,0,255))
pb:drawCircle(vec3(100,100,0), 50, ColorI(150,0,0,255), 1)
pb:drawFilledCircle(vec3(100,100,0), 30, ColorI(0,255,0,255))
pb:drawCircle(vec3(100,100,0), 30, ColorI(0,150,0,255), 2)
pb:drawFilledCircle(vec3(100,100,0), 30, ColorI(0,255,0,255))
pb:drawCircle(vec3(100,100,0), 30, ColorI(0,150,0,255), 2)
pb:drawFilledCircle(vec3(100,100,0), 10, ColorI(0,0,255,255))
pb:drawCircle(vec3(100,100,0), 10, ColorI(0,0,150,255), 3)
pb:drawFilledCircle(vec3(100,100,0), 10, ColorI(0,0,255,255))
pb:drawCircle(vec3(100,100,0), 10, ColorI(0,0,150,255), 3)
pb:drawText(vec3(0, 200, 0), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', ColorI(0,0,0,255))
pb:drawText(vec3(0, 210, 0), '1234567890!?\'":,.-_', ColorI(0,0,0,255))
pb:drawText(vec3(0, 200, 0), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', ColorI(0,0,0,255))
pb:drawText(vec3(0, 210, 0), '1234567890!?\'":,.-_', ColorI(0,0,0,255))
pb:drawText(vec3(0, 220, 0), "Hello world!", ColorI(0,0,0,255))
pb:drawText(vec3(0, 210, 0), '1234567890!?\'":,.-_', ColorI(0,0,0,255))
pb:drawText(vec3(0, 220, 0), "Hello world!", ColorI(0,0,0,255))
@/lua/ge/extensions/scenario/raceMarkers/singleHologramMarker.lua
local zVec = vec3(0,0,1)
local fadeNear = 50
local bobFrequency = 0.333
local bobOffset = vec3(0,0,0)
local playerPosition = vec3(0,0,0)
local bobOffset = vec3(0,0,0)
local playerPosition = vec3(0,0,0)
local scale = vec3()
local playerPosition = vec3(0,0,0)
local scale = vec3()
local columnOffset = vec3(0,0,7)
local scale = vec3()
local columnOffset = vec3(0,0,7)
local lerpedColor = vec3()
local function lerpColor(a,b,t)
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
self.radius = wp.radius
self.radius = wp.radius
self.normal = wp.normal and vec3(wp.normal) or vec3(1,1,0):normalized()
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.radius = wp.radius
self.normal = wp.normal and vec3(wp.normal) or vec3(1,1,0):normalized()
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.normal = wp.normal and vec3(wp.normal) or vec3(1,1,0):normalized()
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
self.normal = wp.normal and vec3(wp.normal) or vec3(1,1,0):normalized()
self.side = (self.normal or vec3(1,0,0)):cross(vec3(0,0,1))
local rot = quatFromDir(self.normal:z0())
local up = vec3(0,0,1)
local rayLengthUp, rayLengthDown = 6, -25
self.centerPos = hit and vec3(hit.pt) or self.pos
if self.pos.z - self.centerPos.z > 1 then self.centerPos.z = self.pos.z end
centerColumn:setField('rotation', 0, rotStr)
centerColumn:setScale(vec3(1,1,1))
end
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
@/lua/ge/extensions/flowgraph/nodes/util/linePointFromXnorm.lua
local posA = vec3()
local posB = vec3()
local posA = vec3()
local posB = vec3()
function C:work()
@/lua/vehicle/thrusters.lua
local thrusting = false
local zeroVec = vec3(0, 0, 0)
@/lua/ge/extensions/flowgraph/nodes/gameplay/sites/location.lua
self.pinOut.roadSide.value = (closest.pos + (self._location.pos - closest.pos):normalized() * (closest.radius-2)):toTable()
self.pinOut.roadDir.value = quatFromDir(closest.a.pos - closest.b.pos, vec3(0,0,1)):toTable()
else
@/lua/ge/extensions/core/checkpoints.lua
vehicleCheckpoints[vehicleId].checkTimer = 0
vehicleCheckpoints[vehicleId].pos = (cpData and vec3(cpData.desiredPos)) or vehicle:getPosition()
vehicleCheckpoints[vehicleId].dirVec = (cpData and vec3(cpData.desiredDir)) or vehicle:getDirectionVector()
vehicleCheckpoints[vehicleId].pos = (cpData and vec3(cpData.desiredPos)) or vehicle:getPosition()
vehicleCheckpoints[vehicleId].dirVec = (cpData and vec3(cpData.desiredDir)) or vehicle:getDirectionVector()
vehicleCheckpoints[vehicleId].upVec = vehicle:getDirectionVectorUp()
@/lua/ge/extensions/core/groundMarkers.lua
local upVec = vec3(0,0,1)
M.colorSet = 'blue'
texture = 'art/shapes/arrows/arrow_groundmarkers_1.png',
pos = vec3(),
position = vec3(0, 0, 0),
pos = vec3(),
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
position = vec3(0, 0, 0),
forwardVec = vec3(0, 0, 0),
color = ColorF(M.color[1], M.color[2], M.color[3], 0 ),
color = ColorF(M.color[1], M.color[2], M.color[3], 0 ),
scale = vec3(0.5*decalScale, 1*decalScale, 2),
fadeStart = 100,
local lastGenerationPos
local playerVehPos = vec3()
local function onPreRender(dt)
generateRouteDecals(playerVehPos)
lastGenerationPos = lastGenerationPos or vec3()
lastGenerationPos:set(playerVehPos)
for i, wp in ipairs(M.routePathTmp or {}) do
debugDrawer:drawSphere(vec3(wp), 0.25, ColorF(1, 0.4, 1,0.2))
debugDrawer:drawTextAdvanced(wp, String(i), ColorF(1,1,1,1), true, false, ColorI(0,0,0,192))
for i, e in ipairs(M.routePlanner.path) do
debugDrawer:drawSphere(vec3(e.pos), 1, ColorF(0.23, 0.4, 0.1,0.6))
if i > 1 then
debugDrawer:drawSquarePrism(
vec3(e.pos), vec3(M.routePlanner.path[i-1].pos),
Point2F(2,0.5),
debugDrawer:drawSquarePrism(
vec3(e.pos), vec3(M.routePlanner.path[i-1].pos),
Point2F(2,0.5),
local veh = getPlayerVehicle(0)
local vehiclePos = vec3(veh and veh:getPosition() or core_camera.getPosition())
local multiPath = {}
elseif type(w) == 'table' and #w == 3 then
table.insert(multiPath, vec3(w))
else
@/lua/ge/extensions/core/groundMarkerArrows.lua
local arrowSmall, arrowLarge = 3, 4.5
local upVec = vec3(0,0,1)
local arrowHeight = vec3(0,0,3.5)
local upVec = vec3(0,0,1)
local arrowHeight = vec3(0,0,3.5)
local wrongDirectionCounter = -20
arrow:setField('shapeName', 0, "art/shapes/interface/s_mm_arrow_floating.dae")
arrow.scale = vec3(arrowScale, arrowScale, arrowScale)
arrow.useInstanceRenderData = true
arrowProxies[id] = {
pos = vec3(0,0,0),
rot = quat(0,0,0,1),
local yVec = vec3(0,1.5,0)
local actualPos = vec3()
local yVec = vec3(0,1.5,0)
local actualPos = vec3()
local fwd = vec3()
local actualPos = vec3()
local fwd = vec3()
local scale = vec3()
local fwd = vec3()
local scale = vec3()
local function onPreRender(dt)
@/lua/ge/extensions/editor/dynamicDecals/layerTypes/linkedSet.lua
elseif propType == api.types.Point3F then
layer[property.id] = vec3(property.value[1], property.value[2], property.value[3])
elseif propType == api.types.Point4F then
@/gameplay/missionTypes/delivery/constructor.lua
if not self.cachedWorldPreviewRoute then
local ret = {vec3(self.startTrigger.pos), vec3(self.missionTypeData.targetPos)}
-- calculate in-world route
if not self.cachedWorldPreviewRoute then
local ret = {vec3(self.startTrigger.pos), vec3(self.missionTypeData.targetPos)}
-- calculate in-world route
@/lua/ge/extensions/scenario/scenarios.lua
if o:getField('directionalWaypoint',0) == '1' then
rota = quat(o:getRotation())*vec3(1,0,0)
end
scenario.nodes[nodeName] = {
pos = vec3(o:getPosition()),
radius = getSceneWaypointRadius(o),
scenario.nodes[wp].radius = scenario.nodes[wp].radius * aiRadFac
scenario.nodes[wp].pos = vec3(scenario.nodes[wp].pos)
scenario.nodes[wp].rot = vec3(scenario.nodes[wp].rot)
scenario.nodes[wp].pos = vec3(scenario.nodes[wp].pos)
scenario.nodes[wp].rot = vec3(scenario.nodes[wp].rot)
else
vehDisplacementLimit=vehDisplacementLimit, waitTimerLimit=waitTimerLimit, crashedWaitTimer = 0.0,
totalDisplacement = vec3(0, 0, 0), stoppedTimer = -huge}
else
extensions.hook('onVehicleStoppedMoving', vehicleID, false)
data.totalDisplacement = vec3(0, 0, 0)
data.stoppedTimer = -huge
@/lua/ge/extensions/gameplay/rally/util.lua
local normal = vec3(dx / magnitude, dy / magnitude, dz / magnitude)
-- Get front 4 corners of the bounding box
local p0 = vec3(oobb:getPoint(0)) -- front-left
local p1 = vec3(oobb:getPoint(1)) -- front-left-up
local p0 = vec3(oobb:getPoint(0)) -- front-left
local p1 = vec3(oobb:getPoint(1)) -- front-left-up
local p2 = vec3(oobb:getPoint(2)) -- front-right-up
local p1 = vec3(oobb:getPoint(1)) -- front-left-up
local p2 = vec3(oobb:getPoint(2)) -- front-right-up
local p3 = vec3(oobb:getPoint(3)) -- front-right
local p2 = vec3(oobb:getPoint(2)) -- front-right-up
local p3 = vec3(oobb:getPoint(3)) -- front-right
local fl = vec3(oobb:getPoint(0))
local fr = vec3(oobb:getPoint(3))
local fl = vec3(oobb:getPoint(0))
local fr = vec3(oobb:getPoint(3))
-- Bottom 4 corners (indices 0-3)
local p0 = vec3(oobb:getPoint(0)) -- front-left
local p1 = vec3(oobb:getPoint(1)) -- front-left-up
local p0 = vec3(oobb:getPoint(0)) -- front-left
local p1 = vec3(oobb:getPoint(1)) -- front-left-up
local p2 = vec3(oobb:getPoint(2)) -- front-right-up
local p1 = vec3(oobb:getPoint(1)) -- front-left-up
local p2 = vec3(oobb:getPoint(2)) -- front-right-up
local p3 = vec3(oobb:getPoint(3)) -- front-right
local p2 = vec3(oobb:getPoint(2)) -- front-right-up
local p3 = vec3(oobb:getPoint(3)) -- front-right
local p4 = vec3(oobb:getPoint(4)) -- back-left
local p3 = vec3(oobb:getPoint(3)) -- front-right
local p4 = vec3(oobb:getPoint(4)) -- back-left
local p5 = vec3(oobb:getPoint(5)) -- back-left-up
local p4 = vec3(oobb:getPoint(4)) -- back-left
local p5 = vec3(oobb:getPoint(5)) -- back-left-up
local p6 = vec3(oobb:getPoint(6)) -- back-right-up
local p5 = vec3(oobb:getPoint(5)) -- back-left-up
local p6 = vec3(oobb:getPoint(6)) -- back-right-up
local p7 = vec3(oobb:getPoint(7)) -- back-right
local p6 = vec3(oobb:getPoint(6)) -- back-right-up
local p7 = vec3(oobb:getPoint(7)) -- back-right
@/lua/ge/extensions/editor/raceEditor/pathnodes.lua
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
local q = quatFromDir(node.normal, vec3(0,0,1))
rotation = QuatF(q.x, q.y, q.z, q.w)
if node.normal then
self.beginDragRotation = deepcopy(quatFromDir(node.normal, vec3(0,0,1)))
end
if node.mode == 'manual' then
node.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
elseif node.mode == 'navgraph' then
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
node.normal = quat(rotation)*vec3(0,1,0)
else
else
node.normal = self.beginDragRotation * quat(rotation)*vec3(0,1,0)
end
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Scale then
local scl = vec3(worldEditorCppApi.getAxisGizmoScale())
if scl.x ~= 1 then
if hovered.normal then
self.beginDragRotation = deepcopy(quatFromDir(hovered.normal, vec3(0,0,1)))
end
local downVec = vec3(0,0,-1)
local function offsetMousePosWithRaycastZSnap(pos)
local rayDir = downVec
local rayStart = pos + vec3(0,0,offset)
if core_forest.getForestObject() then core_forest.getForestObject():disableCollision() end
local txt = "Add manual Pathnode (Drag for Size)"
debugDrawer:drawTextAdvanced(vec3(self.mouseInfo.rayCast.pos), String(txt), ColorF(1,1,1,1), true, false, ColorI(0,0,0,255))
local txt = "Add Pathnode from Navgraph"
debugDrawer:drawTextAdvanced((vec3(self.mouseInfo.rayCast.pos)), String(txt), ColorF(1,1,1,1),true, false, ColorI(0,0,0,255))
end
debugDrawer:drawTextAdvanced((pos), String(">>>"..name.."<<<"), ColorF(1,1,1,1),true, false, ColorI(0,0,0,255))
debugDrawer:drawCylinder((pos + vec3(0,0,-10000)), (pos + vec3(0,0,10000)), 1, ColorF(1,1,1,0.8))
end
debugDrawer:drawTextAdvanced((pos), String(">>>"..name.."<<<"), ColorF(1,1,1,1),true, false, ColorI(0,0,0,255))
debugDrawer:drawCylinder((pos + vec3(0,0,-10000)), (pos + vec3(0,0,10000)), 1, ColorF(1,1,1,0.8))
end
editor.history:commitAction("Change node Position",
{index = self.index, old = node.pos, new = vec3(pathnodePosition[0], pathnodePosition[1], pathnodePosition[2]), field = 'pos', self = self},
setFieldUndo, setFieldRedo)
editor.history:commitAction("Drop Node to Ground",
{index = self.index, old = node.pos,self = self, new = vec3(pathnodePosition[0], pathnodePosition[1], core_terrain.getTerrainHeight(node.pos)), field = 'pos'},
setFieldUndo, setFieldRedo)
if useNormal[0] then
new = core_camera.getQuat()*vec3(0,1,0)
local tip = node.pos + new*node.radius
local tip = node.pos + new*node.radius
new = vec3(tip.x, tip.y, core_terrain.getTerrainHeight(tip))-node.pos
end
editor.history:commitAction("Change Normal",
{index = self.index, old = node.normal, self = self, new = vec3(pathnodeNormal[0], pathnodeNormal[1], pathnodeNormal[2])},
setNormalUndo, setNormalRedo)
local normalTip = node.pos + node.normal*node.radius
normalTip = vec3(normalTip.x, normalTip.y, core_terrain.getTerrainHeight(normalTip))
editor.history:commitAction("Align Normal with Terrain",
if e then
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(1,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
if e then
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(1,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
if e then
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(1,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(1,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,1)), ColorF(0,0,1,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(1,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,1)), ColorF(0,0,1,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(1,0,0)), ColorF(1,0,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,1)), ColorF(0,0,1,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,1)), ColorF(0,0,1,1))
end
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,1)), ColorF(0,0,1,1))
end
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,1,0)), ColorF(0,1,0,1))
debugDrawer:drawLine(vec3(e.pos), vec3(e.pos + e.rot * vec3(0,0,1)), ColorF(0,0,1,1))
end
local tbl = {self.fields[name][0],self.fields[name][1],self.fields[name][2]}
fields.values[name] = vec3(tbl)
end
editor.history:commitAction("Auto-Create recovery position",
{self = self, index = self.index, pos = vec3(node.pos), normal = vec3(node.normal) * (reverse and -1 or 1), field = reverse and 'reverseRecovery' or 'recovery'},
function(data)
editor.history:commitAction("Auto-Create recovery position",
{self = self, index = self.index, pos = vec3(node.pos), normal = vec3(node.normal) * (reverse and -1 or 1), field = reverse and 'reverseRecovery' or 'recovery'},
function(data)
@/lua/ge/extensions/gameplay/drag/debug.lua
local scl = (x+y+z)/2
editor_dragRaceEditor.drawAxisBox(((-scl*2)+vec3(laneData.transform.position)),x*2,y*2,z*2,color(255,255,255,0.2*255))
local pos = vec3(laneData.transform.position)
editor_dragRaceEditor.drawAxisBox(((-scl*2)+vec3(laneData.transform.position)),x*2,y*2,z*2,color(255,255,255,0.2*255))
local pos = vec3(laneData.transform.position)
debugDrawer:drawLine(pos, pos + x, ColorF(1,0,0,0.8))
@/lua/ge/extensions/core/trafficSignals.lua
local viewDistSq = 90000
local vecUp = vec3(0, 0, 1)
local debugPos, debugTarget, tempVec = vec3(), vec3(), vec3()
local debugPos, debugTarget, tempVec = vec3(), vec3(), vec3()
local debugPos, debugTarget, tempVec = vec3(), vec3(), vec3()
o.name = data.name or 'signal'
o.pos = data.pos or vec3()
o.dir = data.dir or vec3()
o.pos = data.pos or vec3()
o.dir = data.dir or vec3()
o.group = data.group -- optional group (e.g. intersection)
else -- otherwise, match the direction according to the side of the road
dir = dir or vec3(self.dir)
if dir:squaredLength() == 0 then
if dir:squaredLength() == 0 then
dir = vec3(nDir)
dir:setScaled(sign2(pos:xnormOnLine(p1, p1 + nDir:cross(vecUp))))
if count >= 2 then
self.targetPos = vec3()
for _, v in pairs(vectors) do
end
self.pos = vec3(self.pos)
self.dir = vec3(self.dir)
self.pos = vec3(self.pos)
self.dir = vec3(self.dir)
end
@/lua/ge/extensions/editor/levelValidator.lua
table.insert(terrainHeights, core_terrain.getTerrainHeight(bb.maxExtents) or 0)
table.insert(terrainHeights, core_terrain.getTerrainHeight(vec3(bb.minExtents.x, bb.maxExtents.y, 0)) or 0)
table.insert(terrainHeights, core_terrain.getTerrainHeight(vec3(bb.maxExtents.x, bb.minExtents.y, 0)) or 0)
table.insert(terrainHeights, core_terrain.getTerrainHeight(vec3(bb.minExtents.x, bb.maxExtents.y, 0)) or 0)
table.insert(terrainHeights, core_terrain.getTerrainHeight(vec3(bb.maxExtents.x, bb.minExtents.y, 0)) or 0)
local firstSignPositive = (bbMax - terrainHeights[1]) > 0
local center = log.objectPos
local pos = center + rot * vec3(0, -15, 0)
local rot = quatFromDir(center - pos)
@/lua/ge/extensions/editor/missionStartPositionEditor.lua
if not mission or not mission.startTrigger then return nil end
return vec3(mission.startTrigger.pos)
end
local rayCast = cameraMouseRayCast()
local mousePos3D = rayCast and vec3(rayCast.pos) or nil
@/lua/ge/extensions/flowgraph/nodes/gameplay/decalSingle.lua
texture = self.pinIn.decalPath.value,
position = vec3(self.pinIn.pos.value),
forwardVec = quat(self.pinIn.rot.value) * vec3(0, 1, 0),
position = vec3(self.pinIn.pos.value),
forwardVec = quat(self.pinIn.rot.value) * vec3(0, 1, 0),
color = ColorF(unpack(clr)),
color = ColorF(unpack(clr)),
scale = vec3(self.pinIn.scl.value or defaultDecalScale),
fadeStart = 200,
@/lua/ge/extensions/gameplay/rally/tools/devTools.lua
for i, point in ipairs(self.pacenotesTools.elevationProfile) do
local pos = vec3(point.x, point.y, point.z)
local color = normalColor
-- or point.isPacenoteWaypoint then
local textPos = vec3(pos)
textPos.z = textPos.z + 2.0 -- Offset text above the sphere
-- dump(point.pos)
table.insert(self.pacenotesTools.drivelinePoints, vec3(point.pos))
end
for j = 1, #corner.nodes - 1 do
local p1 = vec3(corner.nodes[j].pos)
local p2 = vec3(corner.nodes[j + 1].pos)
local p1 = vec3(corner.nodes[j].pos)
local p2 = vec3(corner.nodes[j + 1].pos)
debugDrawer:drawLineInstance(p1, p2, 10, color)
if corner.nodes and #corner.nodes > 0 and nextCorner.nodes and #nextCorner.nodes > 0 then
local lastPos = vec3(corner.nodes[#corner.nodes].pos)
local nextPos = vec3(nextCorner.nodes[1].pos)
local lastPos = vec3(corner.nodes[#corner.nodes].pos)
local nextPos = vec3(nextCorner.nodes[1].pos)
-- Use color of the current corner for the connecting line
if corner.direction ~= "" then
debugDrawer:drawSphere(vec3(corner.pos), 1.0, color)
end
@/lua/vehicle/scriptai.lua
local prevAccel = 0
local aiPos = vec3(0, 0, 0)
local aiVel = vec3(0, 0, 0)
local aiPos = vec3(0, 0, 0)
local aiVel = vec3(0, 0, 0)
local aiDirVec = vec3(0, 0, 0)
local aiVel = vec3(0, 0, 0)
local aiDirVec = vec3(0, 0, 0)
local aiSpeed = 0
local speedDiffSmoother = newTemporalSmoothingNonLinear(math.huge, 0.3)
local targetPos = vec3(0, 0, 0)
local targetLength = 1
-- Calculate initial average relative (to ref node) wheel node position in the vehicle reference frame [left, back, up]
local avgWheelNodePos, numOfWheels, maxWheelRadius = vec3(), 0, -math.huge
for _, wheel in pairs(wheels.wheels) do
avgWheelNodePos:set(
avgWheelNodePos:dot(vec3(leftVec.x, -dir.x, up.x)),
avgWheelNodePos:dot(vec3(leftVec.y, -dir.y, up.y)),
avgWheelNodePos:dot(vec3(leftVec.x, -dir.x, up.x)),
avgWheelNodePos:dot(vec3(leftVec.y, -dir.y, up.y)),
avgWheelNodePos:dot(vec3(leftVec.z, -dir.z, up.z))
avgWheelNodePos:dot(vec3(leftVec.y, -dir.y, up.y)),
avgWheelNodePos:dot(vec3(leftVec.z, -dir.z, up.z))
)
-- vehicle center position relative to the refNode position in the vehicle reference frame [left, back, up]
local vehCenterPositionRelative = vec3(
vehCenterPosRel:dot(obj:getDirectionVectorUp():cross(obj:getDirectionVector())),
local s1t = script[1].t
local sp = linePointFromXnorm(vec3(script[1]), vec3(script[2]), (timeOffset - s1t) / (script[2].t - s1t))
script[1] = {x = sp.x, y = sp.y, z = sp.z, t = timeOffset}
local s1t = script[1].t
local sp = linePointFromXnorm(vec3(script[1]), vec3(script[2]), (timeOffset - s1t) / (script[2].t - s1t))
script[1] = {x = sp.x, y = sp.y, z = sp.z, t = timeOffset}
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
local vy = dir:cross(up) * -frontPosRelOrig.x
pos = vec3(script[1]) - vx - vz - vy
local dH = wheelToGroundDist(pos, dir, up)
local p1 = vec3(script[1])
local p1z0 = p1:z0()
local p1z0 = p1:z0()
local scriptPosi = vec3()
local k
if k then
local p2 = vec3(script[k])
dir = p2 - p1; dir:normalize()
if scriptLen >= 2 then
local p1, p2 = vec3(script[1]), vec3(script[2])
local prevPos = linePointFromXnorm(p1, p2, clamp(aiPos:xnormOnLine(p1, p2), 0, 1))
if scriptLen >= 2 then
local p1, p2 = vec3(script[1]), vec3(script[2])
local prevPos = linePointFromXnorm(p1, p2, clamp(aiPos:xnormOnLine(p1, p2), 0, 1))
local prevPos = linePointFromXnorm(p1, p2, clamp(aiPos:xnormOnLine(p1, p2), 0, 1))
local curPos = vec3()
targetPos = vec3(script[scriptLen])
end
local scriptLen = #script
if scriptLen == 1 then return vec3(script[1]), vec3(0, 0, 0) end
if scriptLen >= 2 then
local scriptLen = #script
if scriptLen == 1 then return vec3(script[1]), vec3(0, 0, 0) end
if scriptLen >= 2 then
if t < script[1].t then
local p1 = vec3(script[1])
return p1, p1, 0
if t > script[scriptLen].t then
local p1 = vec3(script[scriptLen])
return p1, p1, 1
if t >= s1.t and t <= s2.t then
local p1, p2 = vec3(s1), vec3(s2)
if i + 2 > scriptLen then
if t >= s1.t and t <= s2.t then
local p1, p2 = vec3(s1), vec3(s2)
if i + 2 > scriptLen then
local s3 = script[i+2]
local p3 = vec3(s3)
local l1 = p2:distance(p1)
local s0, s1 = script[scriptLen], script[scriptLen - 1]
local p0, p1 = vec3(s0), vec3(s1)
local s0, s1 = script[scriptLen], script[scriptLen - 1]
local p0, p1 = vec3(s0), vec3(s1)
if recordSpeed then
v = vec3(obj:getSmoothRefVelocityXYZ()):length()
end
local s1, s2 = script[1], script[2] or script[1]
local p1, p2 = vec3(s1), vec3(s2)
local xnorm = aiPos:xnormOnLine(p1, p2)
local s1, s2 = script[1], script[2] or script[1]
local p1, p2 = vec3(s1), vec3(s2)
local xnorm = aiPos:xnormOnLine(p1, p2)
local s1, s2, s3 = script[1], script[2] or script[1], script[3]
local p1, p2 = vec3(s1), vec3(s2)
if s3 == nil and s2 ~= nil then
local s1, s2, s3 = script[1], script[2] or script[1], script[3]
local p1, p2 = vec3(s1), vec3(s2)
if s3 == nil and s2 ~= nil then
local p3 = vec3(s3)
local s1t = script[1].t
local sp = linePointFromXnorm(vec3(script[1]), vec3(script[2]), (timeOffset - s1t) / (script[2].t - s1t))
script[1] = {x = sp.x, y = sp.y, z = sp.z, t = timeOffset}
local s1t = script[1].t
local sp = linePointFromXnorm(vec3(script[1]), vec3(script[2]), (timeOffset - s1t) / (script[2].t - s1t))
script[1] = {x = sp.x, y = sp.y, z = sp.z, t = timeOffset}
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
local vy = dir:cross(up) * -frontPosRelOrig.x
pos = vec3(script[1]) - vx - vz - vy
local dH = wheelToGroundDist(pos, dir, up)
local p1 = vec3(script[1])
local p1z0 = p1:z0()
local p1z0 = p1:z0()
local scriptPosi = vec3()
local k
if k then
local p2 = vec3(script[k])
dir = p2 - p1; dir:normalize()
if M.updateGFX == updateGFXfollow then
debugDrawer:drawSphere(0.2, vec3(targetPos), color(0, 0, 255, 255))
end
for _, s in ipairs(script) do
debugDrawer:drawSphere(0.2, vec3(s), color(255, 0, 0, 255))
end
elseif M.updateGFX == updateGFXfollow then
return {status = "following", scriptTime = scriptTime, time = time, endScriptTime = script[#script].t, posError = posError, targetPos = vec3(targetPos), startDelay = (inScript.startDelay or nil)}
end
@/lua/ge/extensions/gameplay/crawl/saveSystem.lua
name = n.name or ("Node " .. i),
pos = vec3(n.position or {0, 0, 0}),
radius = n.radius or 6.0,
transform = {
position = vec3(data.transform and data.transform.position or {0, 0, 0}),
rotation = quat(data.transform and data.transform.rotation or {0, 0, 0, 1}),
},
iconPosition = vec3(data.iconPosition or {0, 0, 0}),
metadata = data.metadata or {
@/lua/console/simtest.lua
v = newVehicle()
v:spawn("pickup", -1, vec3(0, 0, 0.1))
@/lua/ge/extensions/editor/tech/roadArchitect/link.lua
local vertical = vec3(0, 0, 1)
local jYOuter = roads[roadMap[jct.roads[6]]].nodes[1].p
local test1 = vec3(jYOuter.x, jYOuter.y, jYOuter.z) -- Sample the end Y point in configuration #1.
jctMgr.rotateJunction(jIdx, jCenter, pi)
local jYOuter = roads[roadMap[jct.roads[6]]].nodes[1].p
local test2 = vec3(jYOuter.x, jYOuter.y, jYOuter.z) -- Sample the end Y point in configuration #2 (rotated by pi).
if jLie == 'start' then
jRoad.nodes[1].p = vec3(pp.x, pp.y, pp.z)
jRoad.nodes[2].p = jRoad.nodes[1].p + (pp - pPen):normalized() * 5
else
jRoad.nodes[#jRoad.nodes].p = vec3(pp.x, pp.y, pp.z)
jRoad.nodes[#jRoad.nodes - 1].p = jRoad.nodes[#jRoad.nodes].p + (pp - pPen):normalized() * 5
if orient == 1 then
rNewT1.nodes[#rNewT1.nodes].p = vec3(jX1Outer.x, jX1Outer.y, jX1Outer.z)
rNewT1.nodes[#rNewT1.nodes - 1].p = rNewT1.nodes[#rNewT1.nodes].p + (road4.nodes[1].p - road4.nodes[2].p):normalized() * 5
rNewT1.nodes[#rNewT1.nodes - 1].p = rNewT1.nodes[#rNewT1.nodes].p + (road4.nodes[1].p - road4.nodes[2].p):normalized() * 5
rNewT2.nodes[1].p = vec3(jX2Outer.x, jX2Outer.y, jX2Outer.z)
rNewT2.nodes[2].p = rNewT2.nodes[1].p + (road5.nodes[1].p - road5.nodes[2].p):normalized() * 5
else
rNewT1.nodes[#rNewT1.nodes].p = vec3(jX2Outer.x, jX2Outer.y, jX2Outer.z)
rNewT1.nodes[#rNewT1.nodes - 1].p = rNewT1.nodes[#rNewT1.nodes].p + (road5.nodes[1].p - road5.nodes[2].p):normalized() * 5
rNewT1.nodes[#rNewT1.nodes - 1].p = rNewT1.nodes[#rNewT1.nodes].p + (road5.nodes[1].p - road5.nodes[2].p):normalized() * 5
rNewT2.nodes[1].p = vec3(jX1Outer.x, jX1Outer.y, jX1Outer.z)
rNewT2.nodes[2].p = rNewT2.nodes[1].p + (road4.nodes[1].p - road4.nodes[2].p):normalized() * 5
local jYOuter = roads[roadMap[jct.roads[3]]].nodes[1].p
local test1 = vec3(jYOuter.x, jYOuter.y, jYOuter.z) -- Sample the end Y point in configuration #1.
jctMgr.rotateJunction(jIdx, jCenter, pi)
local jYOuter = roads[roadMap[jct.roads[3]]].nodes[1].p
local test2 = vec3(jYOuter.x, jYOuter.y, jYOuter.z) -- Sample the end Y point in configuration #2 (rotated by pi).
local pp = roadMgr.roads[roadMap[jct.roads[3]]].nodes[1].p
jRoad.nodes[1].p = vec3(pp.x, pp.y, pp.z)
jRoad.nodes[2].p = jRoad.nodes[1].p + (roads[roadMap[jct.roads[3]]].nodes[1].p - roads[roadMap[jct.roads[3]]].nodes[2].p):normalized() * 5
local pp = roads[roadMap[jct.roads[3]]].nodes[1].p
jRoad.nodes[#jRoad.nodes].p = vec3(pp.x, pp.y, pp.z)
jRoad.nodes[#jRoad.nodes - 1].p = jRoad.nodes[#jRoad.nodes].p + (roads[roadMap[jct.roads[3]]].nodes[1].p - roads[roadMap[jct.roads[3]]].nodes[2].p):normalized() * 5
if orient == 1 then
rNewT1.nodes[#rNewT1.nodes].p = vec3(jX1Outer.x, jX1Outer.y, jX1Outer.z)
rNewT1.nodes[#rNewT1.nodes - 1].p = rNewT1.nodes[#rNewT1.nodes].p + (roads[roadMap[jct.roads[1]]].nodes[1].p - roads[roadMap[jct.roads[1]]].nodes[2].p):normalized() * 5
rNewT1.nodes[#rNewT1.nodes - 1].p = rNewT1.nodes[#rNewT1.nodes].p + (roads[roadMap[jct.roads[1]]].nodes[1].p - roads[roadMap[jct.roads[1]]].nodes[2].p):normalized() * 5
rNewT2.nodes[1].p = vec3(jX2Outer.x, jX2Outer.y, jX2Outer.z)
rNewT2.nodes[2].p = rNewT2.nodes[1].p + (roads[roadMap[jct.roads[2]]].nodes[1].p - roads[roadMap[jct.roads[2]]].nodes[2].p):normalized() * 5
else
rNewT1.nodes[#rNewT1.nodes].p = vec3(jX2Outer.x, jX2Outer.y, jX2Outer.z)
rNewT1.nodes[#rNewT1.nodes - 1].p = rNewT1.nodes[#rNewT1.nodes].p + (roads[roadMap[jct.roads[2]]].nodes[1].p - roads[roadMap[jct.roads[2]]].nodes[2].p):normalized() * 5
rNewT1.nodes[#rNewT1.nodes - 1].p = rNewT1.nodes[#rNewT1.nodes].p + (roads[roadMap[jct.roads[2]]].nodes[1].p - roads[roadMap[jct.roads[2]]].nodes[2].p):normalized() * 5
rNewT2.nodes[1].p = vec3(jX1Outer.x, jX1Outer.y, jX1Outer.z)
rNewT2.nodes[2].p = rNewT2.nodes[1].p + (roads[roadMap[jct.roads[1]]].nodes[1].p - roads[roadMap[jct.roads[1]]].nodes[2].p):normalized() * 5
@/lua/ge/extensions/freeroam/bigMapMarkers.lua
local yVector = vec3(0,1,0)
local function pointRayDistance(point, rayPos, rayDir)
@/lua/ge/extensions/editor/audioRibbonEditor.lua
local toolWinName, toolWinSize = 'audioRibbonEditor', im.ImVec2(500, 500) -- The main tool window of the editor. The main UI entry point.
local globalDown = vec3(0, 0, -1)
local cols = style.getImguiCols('crystal')
local nameBinding = im.ArrayChar(128, '')
local tmpPos = vec3()
local out = {
for j = 1, #nodes do
nodesCopy[j] = vec3(nodes[j])
end
local em1, em2, em3, em4, em5 = emitters[1], emitters[2], emitters[3], emitters[4], emitters[5]
emittersCopy[1] = { bestSeg = em1.bestSeg, pos = vec3(em1.pos), bN = em1.bN, eventNameStr = em1.eventNameStr }
emittersCopy[2] = { bestSeg = em2.bestSeg, pos = vec3(em2.pos), bN = em2.bN, eventNameStr = em2.eventNameStr }
emittersCopy[1] = { bestSeg = em1.bestSeg, pos = vec3(em1.pos), bN = em1.bN, eventNameStr = em1.eventNameStr }
emittersCopy[2] = { bestSeg = em2.bestSeg, pos = vec3(em2.pos), bN = em2.bN, eventNameStr = em2.eventNameStr }
emittersCopy[3] = { bestSeg = em3.bestSeg, pos = vec3(em3.pos), bN = em3.bN, eventNameStr = em3.eventNameStr }
emittersCopy[2] = { bestSeg = em2.bestSeg, pos = vec3(em2.pos), bN = em2.bN, eventNameStr = em2.eventNameStr }
emittersCopy[3] = { bestSeg = em3.bestSeg, pos = vec3(em3.pos), bN = em3.bN, eventNameStr = em3.eventNameStr }
emittersCopy[4] = { bestSeg = em4.bestSeg, pos = vec3(em4.pos), bN = em4.bN, eventNameStr = em4.eventNameStr }
emittersCopy[3] = { bestSeg = em3.bestSeg, pos = vec3(em3.pos), bN = em3.bN, eventNameStr = em3.eventNameStr }
emittersCopy[4] = { bestSeg = em4.bestSeg, pos = vec3(em4.pos), bN = em4.bN, eventNameStr = em4.eventNameStr }
emittersCopy[5] = { bestSeg = em5.bestSeg, pos = vec3(em5.pos), bN = em5.bN, eventNameStr = em5.eventNameStr }
emittersCopy[4] = { bestSeg = em4.bestSeg, pos = vec3(em4.pos), bN = em4.bN, eventNameStr = em4.eventNameStr }
emittersCopy[5] = { bestSeg = em5.bestSeg, pos = vec3(em5.pos), bN = em5.bN, eventNameStr = em5.eventNameStr }
end
@/lua/ge/extensions/gameplay/markers/missionMarker.lua
local playModeColorI = ColorI(255,255,255,255)
local tmpVec = vec3()
position = self.pos,
forwardVec = vec3(1, 0, 0),
color = ColorF(1.5,1.5,1.5,0),
color = ColorF(1.5,1.5,1.5,0),
scale = vec3(self.radius*0.7, self.radius*0.7, 1),
fadeStart = 1000,
position = self.pos,
forwardVec = vec3(1, 0, 0),
color = ColorF(1.5,1.5,1.5,0),
color = ColorF(1.5,1.5,1.5,0),
scale = vec3(self.radius*2.7, self.radius*2.7, 1),
fadeStart = 1000,
obj:setField('shapeName', 0, shapeName)
obj:setPosition(vec3(0, 0, 0))
obj.scale = vec3(1, 1, 1)
obj:setPosition(vec3(0, 0, 0))
obj.scale = vec3(1, 1, 1)
obj:setField('rotation', 0, '1 0 0 0')
local offsetForTriangle = {
vec3(math.sin(math.rad(topAngle)), math.cos(math.rad(topAngle))*1.15, 0),
vec3(math.sin(math.rad(topAngle+120)), math.cos(math.rad(topAngle+120)), 0),
vec3(math.sin(math.rad(topAngle)), math.cos(math.rad(topAngle))*1.15, 0),
vec3(math.sin(math.rad(topAngle+120)), math.cos(math.rad(topAngle+120)), 0),
vec3(math.sin(math.rad(topAngle-120)), math.cos(math.rad(topAngle-120)), 0),
vec3(math.sin(math.rad(topAngle+120)), math.cos(math.rad(topAngle+120)), 0),
vec3(math.sin(math.rad(topAngle-120)), math.cos(math.rad(topAngle-120)), 0),
}
}
local a, b, c = vec3(), vec3(), vec3()
local fillColor = color(72,125,249,255)
}
local a, b, c = vec3(), vec3(), vec3()
local fillColor = color(72,125,249,255)
}
local a, b, c = vec3(), vec3(), vec3()
local fillColor = color(72,125,249,255)
containedIds = {},
pos = vec3(),
rot = quat(),
@/lua/ge/extensions/editor/api/object.lua
local selectionCentroidValid = false
local selectionCentroid = vec3(0, 0, 0)
local selectionBoxCentroid = vec3(0, 0, 0)
local selectionCentroid = vec3(0, 0, 0)
local selectionBoxCentroid = vec3(0, 0, 0)
local containsGlobalBounds = false
local bbox = Box3F()
bbox:setExtents(vec3(-1e10 - 1e10, -1e10 - 1e10, -1e10 - 1e10))
bbox:setCenter(vec3(0, 0, 0))
bbox:setExtents(vec3(-1e10 - 1e10, -1e10 - 1e10, -1e10 - 1e10))
bbox:setCenter(vec3(0, 0, 0))
containsGlobalBounds = false
if editor.isObjectSelectionEmpty() then
return vec3(0, 0, 0)
end
local viewportSizeIm = im.GetMainViewport().Size
local viewportSize = vec3(viewportSizeIm.x, viewportSizeIm.y, 0)
currentMax = currentMax / 2
local adjustedDeltaScale = vec3(deltaScale.x / currentMax, deltaScale.y / currentMax, deltaScale.z / currentMax)
local delta = vec3(1,1,1) + adjustedDeltaScale
local adjustedDeltaScale = vec3(deltaScale.x / currentMax, deltaScale.y / currentMax, deltaScale.z / currentMax)
local delta = vec3(1,1,1) + adjustedDeltaScale
-- Get the minimum axis from the axes that are being edited
local adjustedPrevScale = vec3(deltaScale.x == 0 and math.huge or prevScale.x,
deltaScale.y == 0 and math.huge or prevScale.y,
-- Get the maximum axis from the axes that are being edited
local adjustedPrevScale = vec3(deltaScale.x == 0 and -math.huge or prevScale.x,
deltaScale.y == 0 and -math.huge or prevScale.y,
local center = centerPoint or vec3(editor.objectSelectionBBox:getCenter())
for i = 1, tableSize(editor.selection.object) do
local prevScale = object:getScale()
local nextScale = vec3(prevScale.x * delta.x, prevScale.y * delta.y, prevScale.z * delta.z)
-- being reduced to 0 which then cannot be restored by unscaling
local adjustedScale = vec3()
adjustedScale.x = nextScale.x / prevScale.x
local objectsCentroid = vec3(0, 0, 0)
local divisor = 0
end
local scale = vec3(1, 1, 1)
local instance = prefab:spawn(instanceName, position, QuatF(0, 0, 0, 1), scale)
@/lua/ge/extensions/flowgraph/nodes/events/customizedTriggerBox.lua
if self.trigger.type == 'Box' then
--debugDrawer:drawSphere(vec3(cPos), 0.5, ColorF(0.91,0.05,0.48,0.5))
inside = inside or containsOBB_point(self.trigger.pos, self.trigger.x, self.trigger.y, self.trigger.z, pos)
local trigger = {
pos = vec3(self.pinIn.position.value or {0,0,0}),
rot = quat(self.pinIn.rotation.value or {0,0,0,0})
if type(scl) == 'table' then
trigger.scl = vec3(self.pinIn.scale.value)
else
else
trigger.scl = vec3(self.pinIn.scale.value, self.pinIn.scale.value, self.pinIn.scale.value)
end
--if trigger.type == 'Box' then
trigger.x = trigger.rot * vec3(trigger.scl.x,0,0)
trigger.y = trigger.rot * vec3(0,trigger.scl.y,0)
trigger.x = trigger.rot * vec3(trigger.scl.x,0,0)
trigger.y = trigger.rot * vec3(0,trigger.scl.y,0)
trigger.z = trigger.rot * vec3(0,0,trigger.scl.z)
trigger.y = trigger.rot * vec3(0,trigger.scl.y,0)
trigger.z = trigger.rot * vec3(0,0,trigger.scl.z)
--end
if not self.points then
self.points = {vec3(), vec3(), vec3(), vec3()}
self.zOffset = vec3()
if not self.points then
self.points = {vec3(), vec3(), vec3(), vec3()}
self.zOffset = vec3()
if not self.points then
self.points = {vec3(), vec3(), vec3(), vec3()}
self.zOffset = vec3()
if not self.points then
self.points = {vec3(), vec3(), vec3(), vec3()}
self.zOffset = vec3()
self.points = {vec3(), vec3(), vec3(), vec3()}
self.zOffset = vec3()
self.bbPoints = {0, 3, 7, 4}
if not self.points then
self.points = {vec3()}
end
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/career/modules/vehicleShopping.lua
-- TODO this should better take vec3s directly
core_groundMarkers.setPath(vec3(pos.x, pos.y, pos.z))
guihooks.trigger('ChangeState', {state = 'play', params = {}})
for _, vehicleInfo in ipairs(vehiclesInShop) do
vehicleInfo.pos = vec3(vehicleInfo.pos)
end
@/lua/ge/extensions/scenario/raceMarkers/noneMarker.lua
--local color = ColorF(0.91,0.05,0.48,0.5)
--debugDrawer:drawLine(vec3(self.pos + vec3(0,0,3)), vec3(self.pos + vec3(0,0,20)), color)
end
--local color = ColorF(0.91,0.05,0.48,0.5)
--debugDrawer:drawLine(vec3(self.pos + vec3(0,0,3)), vec3(self.pos + vec3(0,0,20)), color)
end
--local color = ColorF(0.91,0.05,0.48,0.5)
--debugDrawer:drawLine(vec3(self.pos + vec3(0,0,3)), vec3(self.pos + vec3(0,0,20)), color)
end
--local color = ColorF(0.91,0.05,0.48,0.5)
--debugDrawer:drawLine(vec3(self.pos + vec3(0,0,3)), vec3(self.pos + vec3(0,0,20)), color)
end
@/lua/ge/extensions/editor/gen/lib/ai.lua
local function loss(av)
local a = vec3(av[1],av[2],av[3])
local b = vec3(av[4],av[5],av[6])
local a = vec3(av[1],av[2],av[3])
local b = vec3(av[4],av[5],av[6])
-- local c = vec3(0,0,0)
-- for i,p in pairs(set) do
-- local u = (ma - mi):normalized()
local u = vec3(U.rand(-1,1), U.rand(-1,1),U.rand(-1,1)):normalized()
local a,b = c - u, c + u
@/lua/common/mathlib.lua
a = vec3(1,2,3)
b = vec3({1,2,3})
a = vec3(1,2,3)
b = vec3({1,2,3})
c = vec3({x = 1, y = 2, z = 3})
b = vec3({1,2,3})
c = vec3({x = 1, y = 2, z = 3})
print(a == b)
print(a == b)
print( (a-b) == vec3(0, 0, 0) )
print( (c*1) )
print( (c*1) )
print( vec3(10,0,0):dot(vec3(10,0,0)) )
]]
print( (c*1) )
print( vec3(10,0,0):dot(vec3(10,0,0)) )
]]
function LuaVec3:__tostring()
return string.format('vec3(%s,%s,%s)', numSer(self.x), numSer(self.y), numSer(self.z))
end
function LuaQuat:toDirUp()
return self * vec3(0,1,0), self * vec3(0,0,1)
end
function LuaQuat:toDirUp()
return self * vec3(0,1,0), self * vec3(0,0,1)
end
tmpv1:setSub2(rpos, c1)
local pM = vec3(tmpv1:dot(x1)*invx1, tmpv1:dot(y1)*invy1, tmpv1:dot(z1)*invz1)
local dirM = vec3(rdir:dot(x1)*invx1, rdir:dot(y1)*invy1, rdir:dot(z1)*invz1)
local pM = vec3(tmpv1:dot(x1)*invx1, tmpv1:dot(y1)*invy1, tmpv1:dot(z1)*invz1)
local dirM = vec3(rdir:dot(x1)*invx1, rdir:dot(y1)*invy1, rdir:dot(z1)*invz1)
@/lua/ge/extensions/gameplay/rally/trafficExclusion.lua
if sp.pos then
table.insert(zones, {pos = vec3(sp.pos), radius = defaultRadius})
end
if pn.pos then
table.insert(zones, {pos = vec3(pn.pos), radius = defaultRadius})
end
if sp.pos then
table.insert(zones, {pos = vec3(sp.pos), radius = defaultRadius})
end
@/lua/ge/extensions/editor/scriptAIManager.lua
if activeVehicleId == vehId then activetxt = '[active] ' end
local p1 = bo:getPosition() + vec3(0, 0, 4)
local dbgTxt = ' ' .. activetxt .. tostring(vehId) .. ' - ' .. tostring(bo:getName()) .. ': ' .. statetxt
local dbgPt = vec3()
local lastPt = vec3()
local dbgPt = vec3()
local lastPt = vec3()
local dbgPrimA = Point2F(0.4, 0.7)
local focusPos = vec3(Lua.lastDebugFocusPos)
local campos = core_camera.getPosition()
@/lua/ge/extensions/editor/crawlEditor/startingPositions.lua
self.currentTransform = nil -- "area" or "icon"
self._prevGizmoPos = vec3(0, 0, 0)
self._prevTransformPos = vec3(0, 0, 0)
self._prevGizmoPos = vec3(0, 0, 0)
self._prevTransformPos = vec3(0, 0, 0)
self.snapToTerrain = true
if posEditEnded[0] then
local newPos = vec3(pos[0], pos[1], pos[2])
editor.history:commitAction("Change Starting Position Area Position",
if iconPosEditEnded[0] then
local newIconPos = vec3(iconPos[0], iconPos[1], iconPos[2])
editor.history:commitAction("Change Starting Position Icon Position",
transform = {
position = vec3(0, 0, 0),
rotation = quat(1, 0, 0, 0),
},
iconPosition = vec3(0, 0, 0),
metadata = {
self._placementTemp = {
oldPosition = vec3(self.startingPosition.transform.position),
oldRotation = quat(self.startingPosition.transform.rotation),
oldRotation = quat(self.startingPosition.transform.rotation),
downPos = vec3(mouseInfo._downPos),
downNormal = mouseInfo._downNormal and vec3(mouseInfo._downNormal) or vec3(0, 0, 1),
downPos = vec3(mouseInfo._downPos),
downNormal = mouseInfo._downNormal and vec3(mouseInfo._downNormal) or vec3(0, 0, 1),
moved = false
downPos = vec3(mouseInfo._downPos),
downNormal = mouseInfo._downNormal and vec3(mouseInfo._downNormal) or vec3(0, 0, 1),
moved = false
self._prevGizmoPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
local posOffset = (vec3(editor.getAxisGizmoTransform():getColumn(3)) - self._prevGizmoPos)
self._prevGizmoPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
end
function C:dropToTerrain(pos)
local p = vec3(pos)
if core_terrain then
if mouseInfo.rayCast then
debugDrawer:drawTextAdvanced(vec3(mouseInfo.rayCast.pos), String(txt), ColorF(1, 1, 1, 1), true, false, ColorI(0, 0, 96, 255))
end
local rot = self.startingPosition.transform.rotation
local forwardDir = rot * vec3(0, 1, 0)
local rightDir = rot * vec3(1, 0, 0)
local forwardDir = rot * vec3(0, 1, 0)
local rightDir = rot * vec3(1, 0, 0)
-- Get forward direction from rotation (Y is forward in BeamNG)
local forwardDir = rotation * vec3(0, 1, 0)
local arrowLength = 3.0 -- Arrow length in meters
@/lua/ge/extensions/gameplay/rally/test/testRouteFix.lua
local path = {
vec3(1499.20874,1593.685303,138.6869507),
vec3(1508.348755,1600.3302,139.9772339),
vec3(1499.20874,1593.685303,138.6869507),
vec3(1508.348755,1600.3302,139.9772339),
vec3(1516.930908,1606.302002,141.7883606)
vec3(1508.348755,1600.3302,139.9772339),
vec3(1516.930908,1606.302002,141.7883606)
}
@/lua/ge/extensions/core/busRouteManager.lua
if trigger.type == "busstop" then
triggerPos[trigger.name] = {trigger.name,trigger.stopName, vec3(trigger:getPosition()):toTable(), quat(trigger:getRotation()):toTable(), vec3(trigger:getScale()):toTable()}
end
if trigger.type == "busstop" then
triggerPos[trigger.name] = {trigger.name,trigger.stopName, vec3(trigger:getPosition()):toTable(), quat(trigger:getRotation()):toTable(), vec3(trigger:getScale()):toTable()}
end
-- data.forwardVec = normal
-- data.scale = vec3(stepDistance, stepDistance, 1.5)
-- Engine.Render.DynamicDecalMgr.addDecal(data)
@/lua/ge/extensions/gameplay/route/route.lua
local startEndPosTable = {pos = vec3()}
function C:updatePathForPos(pos)
@/lua/ge/extensions/editor/cosimulationSignalEditor.lua
local right = fwd:cross(up)
return vec3(fwd:dot(dirLoc), right:dot(dirLoc), up:dot(dirLoc)), vec3(fwd:dot(upLoc), right:dot(upLoc), up:dot(upLoc))
end
local right = fwd:cross(up)
return vec3(fwd:dot(dirLoc), right:dot(dirLoc), up:dot(dirLoc)), vec3(fwd:dot(upLoc), right:dot(upLoc), up:dot(upLoc))
end
isPose = im.BoolPtr(true)
spawn.safeTeleport(vehicle.veh, vec3(posX, posY, posZ), quat(rotX, rotY, rotZ, rotW))
end
if posX then
spawn.safeTeleport(vehicle.veh, vec3(posX, posY, posZ), quat(rotX, rotY, rotZ, rotW))
end
local sensorName = IMUsArray[j]
IMUs[j] = { name = sensorName, pos = vec3(0, 0), dir = vec3(0, 0), up = vec3(0, 0)}
for i = 2, numLines do
local sensorName = IMUsArray[j]
IMUs[j] = { name = sensorName, pos = vec3(0, 0), dir = vec3(0, 0), up = vec3(0, 0)}
for i = 2, numLines do
local sensorName = IMUsArray[j]
IMUs[j] = { name = sensorName, pos = vec3(0, 0), dir = vec3(0, 0), up = vec3(0, 0)}
for i = 2, numLines do
local sensorName = GPSsArray[j]
GPSs[j] = { name = sensorName, pos = vec3(0, 0), dir = vec3(0, 0), up = vec3(0, 0)}
for i = 2, numLines do
local sensorName = GPSsArray[j]
GPSs[j] = { name = sensorName, pos = vec3(0, 0), dir = vec3(0, 0), up = vec3(0, 0)}
for i = 2, numLines do
local sensorName = GPSsArray[j]
GPSs[j] = { name = sensorName, pos = vec3(0, 0), dir = vec3(0, 0), up = vec3(0, 0)}
for i = 2, numLines do
@/lua/ge/extensions/editor/missionEditor/startTrigger.lua
debugDrawer:drawSphere(transformHelper.pos, radius, ColorF(1,0,0,0.5))
local normal = transformHelper.rot * vec3(0,1,0)
debugDrawer:drawSquarePrism(
if self.mission.startTrigger.type == 'coordinates' then
transformHelper:set(vec3(self.mission.startTrigger.pos), quat(self.mission.startTrigger.rot or {0,0,0,1}), self.mission.startTrigger.radius)
end
if stType == 'coordinates' then
transformHelper:set(vec3(self.mission.startTrigger.pos), nil, self.mission.startTrigger.radius)
end
@/lua/ge/extensions/flowgraph/nodes/gameplay/traffic/trafficMoveGroup.lua
local pos = self.pinIn.startPos.value and vec3(self.pinIn.startPos.value)
local rot = self.pinIn.startRot.value and quat(self.pinIn.startRot.value)
@/lua/ge/extensions/flowgraph/nodes/scene/rectMarker.lua
local zerosTable4 = {0,0,0,0}
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local tpos = vec3()
local sc = vec3()
local tpos = vec3()
local sc = vec3()
local tr = quat()
local rot = quat(self.pinIn.rotation.value)
local x, y = rot * vec3(1,0,0), rot * vec3(0,1,0)
local scl = vec3(self.pinIn.scale.value or {1,1,1})
local rot = quat(self.pinIn.rotation.value)
local x, y = rot * vec3(1,0,0), rot * vec3(0,1,0)
local scl = vec3(self.pinIn.scale.value or {1,1,1})
local x, y = rot * vec3(1,0,0), rot * vec3(0,1,0)
local scl = vec3(self.pinIn.scale.value or {1,1,1})
local d = scl.x*0.5-1
local pos = (tpos-x*d-y*w)
local a = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt) + vec3(0,0,0.3)
pos = (tpos+x*d-y*w)
local pos = (tpos-x*d-y*w)
local a = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt) + vec3(0,0,0.3)
pos = (tpos+x*d-y*w)
local pos = (tpos-x*d-y*w)
local a = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt) + vec3(0,0,0.3)
pos = (tpos+x*d-y*w)
local pos = (tpos-x*d-y*w)
local a = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt) + vec3(0,0,0.3)
pos = (tpos+x*d-y*w)
pos = (tpos+x*d-y*w)
local b = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt)+ vec3(0,0,0.3)
pos = (tpos+y*w)
pos = (tpos+x*d-y*w)
local b = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt)+ vec3(0,0,0.3)
pos = (tpos+y*w)
pos = (tpos+x*d-y*w)
local b = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt)+ vec3(0,0,0.3)
pos = (tpos+y*w)
pos = (tpos+x*d-y*w)
local b = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt)+ vec3(0,0,0.3)
pos = (tpos+y*w)
pos = (tpos+y*w)
local c = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt)+ vec3(0,0,0.3)
local clr = clrIn
pos = (tpos+y*w)
local c = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt)+ vec3(0,0,0.3)
local clr = clrIn
pos = (tpos+y*w)
local c = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt)+ vec3(0,0,0.3)
local clr = clrIn
pos = (tpos+y*w)
local c = vec3(castRay(pos+vec3(0,0,2), pos-vec3(0,0,10)).pt)+ vec3(0,0,0.3)
local clr = clrIn
marker:setField('shapeName', 0, "art/shapes/interface/position_marker.dae")
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
if not self._changed then return end
local tpos = vec3(self.pinIn.position.value or zerosTable3)
local pos = vec3(0,0,0)
local tpos = vec3(self.pinIn.position.value or zerosTable3)
local pos = vec3(0,0,0)
local tr = self.pinIn.rotation.value or zerosTable4
tr = quat(tr[1],tr[2],tr[3],tr[4])
local scl = vec3(self.pinIn.scale.value or {1,1,1})
local r
local zVec,yVec,xVec = tr*vec3(0,0,1), tr*vec3(0,1,0), tr*vec3(1,0,0)
local r
local zVec,yVec,xVec = tr*vec3(0,0,1), tr*vec3(0,1,0), tr*vec3(1,0,0)
local r
local zVec,yVec,xVec = tr*vec3(0,0,1), tr*vec3(0,1,0), tr*vec3(1,0,0)
end
pos = vec3(hit.pt) + zVec*0.05
r = r* qOff*quatFromDir(vec3(hit.norm), yVec)
pos = vec3(hit.pt) + zVec*0.05
r = r* qOff*quatFromDir(vec3(hit.norm), yVec)
else
local pos = self.pinIn.position.value or zerosTable3
pos = vec3(pos[1],pos[2],pos[3])
checkPoint:setPosition(pos)
local scl = self.pinIn.scale.value or {1,1,1}
scl = vec3(scl[1],scl[2],scl[3])
local pos = self.pinIn.position.value or zerosTable3
pos = vec3(pos[1],pos[2],pos[3])
checkPoint:setPosition(pos)
local scl = self.pinIn.scale.value or {1,1,1}
scl = vec3(scl[1],scl[2],scl[3])
checkPoint:setScale(scl)
@/lua/ge/extensions/editor/gen/region.lua
-- out.acyan = {}
a = vec3(a.x,a.y)
b = vec3(b.x,b.y)
a = vec3(a.x,a.y)
b = vec3(b.x,b.y)
local fr,to,step = #abase,1,-1
-- out.awhite[#out.awhite+1] = p
local s = closestLinePoints(a, b, p, p + vec3(0,0,1))
-- lo('?? for_s:'..i..':'..j..':'..tostring(s)..'<'..tostring(spre))
if ppre then
local s = closestLinePoints(ppre, p, a, a + vec3(0,0,1))
if 0 <= s and s < 1 then
end
s = closestLinePoints(ppre, p, b, b + vec3(0,0,1))
if 0 <= s and s < 1 then
anode[ni-side.dir], anode[ni],
vec3(x,y), vec3(x,y)+vec3(0,0,1)
)
anode[ni-side.dir], anode[ni],
vec3(x,y), vec3(x,y)+vec3(0,0,1)
)
anode[ni-side.dir], anode[ni],
vec3(x,y), vec3(x,y)+vec3(0,0,1)
)
-- local v = anode[ni+side.dir] - (ni == side.fr and anode[side.fr] or anode[ni-side.dir])
vp = vec3(-v.y,v.x):normalized()
d = U.toLine(U.proj2D(p), {U.proj2D(anode[ni]), U.proj2D(anode[ni] + vp)})
local wd = editor.getNodes(scenetree.findObjectById(adec[side.rd].id))[ni].width
return p + vec3(-vt.y,vt.x)*(mrg + wd/2)
end
return anode[side.to] + vec3(-vt.y,vt.x)*(mrg + wd/2)
end
local v = anode[sto.fr+sto.dir] - anode[sto.fr]
local w = vec3(-v.y,v.x):normalized() * (wd + margin + mm_depth[1])
local pc,ang = line2side({anode[sto.fr]+w,anode[sto.fr+sto.dir]+w}, sfr)
anode[ni-side.dir], anode[ni],
p, p+vec3(0,0,1)
)
local vt = (anode[ni] - anode[ni-side.dir])
bnxt = pto + vec3(-vt.y, vt.x):normalized() * (p - pfr):length()
base[#base + 1] = bnxt
local v = base[#base] - base[#base - 1]
local w = vec3(-v.y, v.x):normalized()*depth
abound[#abase+1] = {v,w}
return
-- return prd + U.proj2D(p - prd):normalized()*sideWidth(side, ni), vec3()
end
-- local v = anode[nj] - anode[nj-sadj.dir]
local vt = vec3(-v.y,v.x):normalized()
local p = anode[nj] + parity*vt*dfr
for i = #basepre/2,#basepre/2+1 do
local s = closestLinePoints(basepre[i], basepre[i+1], p, p + vec3(0,0,1))
if 0 <= s and s < 1 then
local v = anode[nj] - anode[nj-sadj.dir]
local vt = vec3(-v.y,v.x):normalized()
local p = anode[nj] + vt*(1 + margin + anobjthem[nj].width/2 + mm_depth[2])
out.avedit = {
U.proj2D(adec[rmi].list[nmi])+vec3(0,0,core_terrain.getTerrainHeight(U.proj2D(adec[rmi].list[nmi]))),
U.proj2D(adec[rmi].list[nmi+1])+vec3(0,0,core_terrain.getTerrainHeight(U.proj2D(adec[rmi].list[nmi+1]))),
U.proj2D(adec[rmi].list[nmi])+vec3(0,0,core_terrain.getTerrainHeight(U.proj2D(adec[rmi].list[nmi]))),
U.proj2D(adec[rmi].list[nmi+1])+vec3(0,0,core_terrain.getTerrainHeight(U.proj2D(adec[rmi].list[nmi+1]))),
}
tb:setHeightWs(vec3(x,y), 0)
lo('?? 0_0 : h='..core_terrain.getTerrainHeight(vec3(x,y)))
tb:setHeightWs(vec3(x,y), 0)
lo('?? 0_0 : h='..core_terrain.getTerrainHeight(vec3(x,y)))
lo('?? -1_0 : '..core_terrain.getTerrainHeight(vec3(x-1,y)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? -1_0 : '..core_terrain.getTerrainHeight(vec3(x-1,y)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? 0_+1 : '..core_terrain.getTerrainHeight(vec3(x,y+1)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? 0_+1 : '..core_terrain.getTerrainHeight(vec3(x,y+1)))
tb:setHeightWs(vec3(x,y), 1)
lo('?? 0_0 : h='..core_terrain.getTerrainHeight(vec3(x,y)))
tb:setHeightWs(vec3(x,y), 1)
lo('?? 0_0 : h='..core_terrain.getTerrainHeight(vec3(x,y)))
lo('?? -1_0 : '..core_terrain.getTerrainHeight(vec3(x-1,y)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? -1_0 : '..core_terrain.getTerrainHeight(vec3(x-1,y)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? 0_+1 : '..core_terrain.getTerrainHeight(vec3(x,y+1)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? 0_+1 : '..core_terrain.getTerrainHeight(vec3(x,y+1)))
tb:setHeightWs(vec3(x,y), 0)
lo('?? 0_0 : h='..core_terrain.getTerrainHeight(vec3(x,y)))
tb:setHeightWs(vec3(x,y), 0)
lo('?? 0_0 : h='..core_terrain.getTerrainHeight(vec3(x,y)))
lo('?? -1_0 : '..core_terrain.getTerrainHeight(vec3(x-1,y)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? -1_0 : '..core_terrain.getTerrainHeight(vec3(x-1,y)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? +1_0 : '..core_terrain.getTerrainHeight(vec3(x+1,y)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? 0_+1 : '..core_terrain.getTerrainHeight(vec3(x,y+1)))
lo('?? 0_-1 : '..core_terrain.getTerrainHeight(vec3(x,y-1)))
lo('?? 0_+1 : '..core_terrain.getTerrainHeight(vec3(x,y+1)))
return
-- tb:setHeightWs(vec3(x,y), 5)
end
-- local ndecal = editor.getDecalTemplates():size()
-- lo('?? ndec:'..tostring(out.inconform)) --tostring(Engine.Render.DecalMgr.getSet())) --..tostring(Engine.Render.DecalMgr.getClosestDecal(vec3(0,0,0)))) --..tostring(editor.getDecalInstance(1)))
-- get limiting circle (with margin)
local pos = vec3(desc.pos.x, desc.pos.y)
local base = desc.afloor[1].base
-- building center
local c = vec3(0,0,0)
for _,p in pairs(base) do
U.dump(desc.afloor[1].base, '>> conform: pos = '..tostring(desc.pos)..' c:'..tostring(c)..' hbase:'..hbase..':'..tostring(indrag)) --..':'..desc.id)
out.apoint = {c + vec3(0, 0, hbase + W.forHeight(desc.afloor) + 0.0)}
out.apick = {}
for y = math.floor(c.y - r), math.ceil(c.y + r) do
-- lo('?? for_H:'..x..':'..y..':'..core_terrain.getTerrainHeight(vec3(x,y)), true)
-- out.avedit[#out.avedit + 1] = vec3(x, y, desc.pos.z + 5)
-- lo('?? for_H:'..x..':'..y..':'..core_terrain.getTerrainHeight(vec3(x,y)), true)
-- out.avedit[#out.avedit + 1] = vec3(x, y, desc.pos.z + 5)
local p = vec3(x, y)
-- out.avedit[#out.avedit + 1] = vec3(x, y, desc.pos.z + 5)
local p = vec3(x, y)
-- lo('?? XY:'..x..':'..y)
local dh = 0.5
-- out.avedit[#out.avedit + 1] = vec3(x, y, hbase) -- desc.pos.z + 5)
if dir <= 0 and dirpre <= 0 then
if dir <= 0 and dirpre <= 0 then
-- out.avedit[#out.avedit + 1] = vec3(x, y, hbase) -- desc.pos.z + 5)
-- lo('?? step:'..dmi) -- ..tostring(M.step(base, dmi)))
hmapChange(p, hbase)
-- out.apick[#out.apick + 1] = vec3(x, y, hbase + dh)
-- tb:setHeightWs(p, hbase)
-- lo('?? out:'..imi..':'..dmi..':'..(p-pos):distanceToLineSegment(base[imi], base[imi+1]))
-- out.avedit[#out.avedit + 1] = vec3(x, y, hbase)
if dmi < margin then
if dmi < margin then
-- out.avedit[#out.avedit + 1] = vec3(x, y, hbase + dh) -- desc.pos.z + 5)
hmapChange(p, hbase)
-- if y == 231 and x <= -512 then
out.apick[#out.apick + 1] = vec3(x, y, hbase + dh) -- desc.pos.z + 5)
-- check decals
-- skip changes
-- out.avedit[#out.avedit+1] = vec3(x, y, hbase + dh)
else
-- b = drmi - 0.1
out.avedit[#out.avedit+1] = vec3(x, y, hbase + dh)
end
end
-- out.avedit[#out.avedit + 1] = vec3(x, y, hbase) -- desc.pos.z + 5)
end
@/lua/vehicle/tech/techVehicleUtils.lua
local totalMass = 0
local cogWeighted = vec3(0, 0, 0)
local inertiaX = 0
@/lua/ge/extensions/editor/tech/roadArchitect/import.lua
local targetLonResInv, targetArcResInv = 1.0 / targetLonRes, 1.0 / targetArcRes
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local targetLonResInv, targetArcResInv = 1.0 / targetLonRes, 1.0 / targetArcRes
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local pX, pY = r * sin(q), kSROpp * cos(q) + kSignR
poly[i + 1] = vec3(hCos * pX - hSin * pY + xStart, hSin * pX + hCos * pY + yStart)
end
local eP = elevs[eIdx]
poly3D[i] = vec3(p2D.x, p2D.y, evalExpCubic(eP.a, eP.b, eP.c, eP.d, sLocal) + verticalNodeOffset)
end
local p2D = poly2D[i]
poly3D[i] = vec3(p2D.x, p2D.y, 0.0)
end
if splitIndices[i] then
build[bCtr] = vec3(p.x, p.y)
bLS[bCtr] = arcLengths[i]
sCtr = sCtr + 1
build, bCtr = { vec3(p.x, p.y) }, 2
bLS = { arcLengths[i] }
else
build[bCtr] = vec3(p.x, p.y)
bLS[bCtr] = arcLengths[i]
local dG = v3.xarg
geom[#geom + 1] = { s = tonumber(dG.s), start = vec3(tonumber(dG.x), tonumber(dG.y)), hdg = tonumber(dG.hdg), length = tonumber(dG.length), geom = gInner }
end
@/lua/ge/extensions/gameplay/rally/transcripts/path.lua
-- testP = pos
-- testP = testP + vec3(0,0,20)
-- testQ = rot
--
-- local upVector = vec3(0, 0, 1) -- 'up' in a Z-up system
-- local rotatedUpVector = testQ * upVector * h -- Rotate and scale the up vector
--
-- local forwardVector = vec3(0, 1, 0)
-- local rotatedForwardVector = testQ * forwardVector * l
@/lua/vehicle/extensions/tech/techCore.lua
for idx, n in ipairs(nodes) do
local pos = vec3(n['pos'][1], n['pos'][2], 10000)
if cling then
local pos = request['pos']
pos = vec3(pos[1], pos[2], pos[3])
local debug = request['debug']
@/lua/ge/extensions/flowgraph/nodes/gameplay/race/pathDefaultStartTransform.lua
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
self.pinOut.pos.value = vec3(sp.pos - (self.data.startBoxLength / 2) * y + (self.data.startBoxHeight / 2) * z):toTable()
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
self.pinOut.pos.value = vec3(sp.pos - (self.data.startBoxLength / 2) * y + (self.data.startBoxHeight / 2) * z):toTable()
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
self.pinOut.pos.value = vec3(sp.pos - (self.data.startBoxLength / 2) * y + (self.data.startBoxHeight / 2) * z):toTable()
local x, y, z = rot * vec3(1,0,0), rot * vec3(0,1,0), rot * vec3(0,0,1)
self.pinOut.pos.value = vec3(sp.pos - (self.data.startBoxLength / 2) * y + (self.data.startBoxHeight / 2) * z):toTable()
self.pinOut.origPos.value = sp.pos:toTable()
@/lua/ge/extensions/editor/vehicleDetailViewer.lua
camUp = ax[3],
camUpAxis = vec3(0,0,1),
},
camUp = ax[3],
camUpAxis = vec3(0,0,1),
},
camUp = -ax[1],
camUpAxis = vec3(-1,0,0),
},
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,0,10), colRed)
--debugDrawer:drawLine(vec3(0,0,0), vec3(0,0,10), colRed)
@/lua/ge/extensions/render/viewDemo.lua
local mat = QuatF(0, 0, 0, 1):getMatrix()
mat:setPosition(vec3(0, 0, 0))
local mat = QuatF(0, 0, 0, 1):getMatrix()
mat:setPosition(vec3(math.sin(timer), 0, math.cos(timer) + 1.5))
renderView.cameraMatrix = mat
--debugDrawer:setTargetRenderViews(targetRenderView)
debugDrawer:drawTextAdvanced((vec3(20,20,0)), 'Hello world view :)', ColorF(0,0,0,1), false, true, ColorI(0, 0, 0, 255))
--debugDrawer:clearTargetRenderViews()
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/simpleFollowDecalroad.lua
for i = 0, segCount-1 do
local vec = vec3(road:getNodePosition(i))
table.insert(path,{x = vec.x, y = vec.y, z = vec.z, t = self.distance / self.data.speed})
table.insert(path,{x = vec.x, y = vec.y, z = vec.z, t = self.distance / self.data.speed})
self.distance = self.distance + (vec3(road:getNodePosition(i+1)) - vec3(road:getNodePosition(i))):length()
end
table.insert(path,{x = vec.x, y = vec.y, z = vec.z, t = self.distance / self.data.speed})
self.distance = self.distance + (vec3(road:getNodePosition(i+1)) - vec3(road:getNodePosition(i))):length()
end
-- handle first node
local up = vec3(0,0,1) -- hardcode up as up..
local dir = vec3(road:getNodePosition(1)) - vec3(road:getNodePosition(0))
local up = vec3(0,0,1) -- hardcode up as up..
local dir = vec3(road:getNodePosition(1)) - vec3(road:getNodePosition(0))
dir = dir:normalized()
local up = vec3(0,0,1) -- hardcode up as up..
local dir = vec3(road:getNodePosition(1)) - vec3(road:getNodePosition(0))
dir = dir:normalized()
for _, p in pairs(self.path.path) do
debugDrawer:drawSphere(vec3(p), 0.1, ColorF(1,0,1,1))
if lastP then
if lastP then
debugDrawer:drawSquarePrism(vec3(lastP), vec3(p), Point2F(0.6, 0.1), Point2F(0.6, 0.1), ColorF(1,0,1,0.1))
end
if lastP then
debugDrawer:drawSquarePrism(vec3(lastP), vec3(p), Point2F(0.6, 0.1), Point2F(0.6, 0.1), ColorF(1,0,1,0.1))
end
@/gameplay/missionTypes/arrive/constructor.lua
if not self.cachedWorldPreviewRoute then
local ret = {vec3(self.missionTypeData.startLocatorPos), vec3(self.missionTypeData.targetPos)}
if not self.cachedWorldPreviewRoute then
local ret = {vec3(self.missionTypeData.startLocatorPos), vec3(self.missionTypeData.targetPos)}
@/lua/ge/extensions/editor/raceEditor.lua
mouseInfo.ray = getCameraMouseRay()
mouseInfo.rayDir = vec3(mouseInfo.ray.dir)
mouseInfo.rayCast = cameraMouseRayCast()
mouseInfo.hold = false
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
end
if mouseInfo.hold then
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
end
if mouseInfo.up then
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
end
@/lua/ge/extensions/flowgraph/modules/prefabModule.lua
function C:spawnPrefab(fileName)
local pos = vec3(0,0,0)
@/lua/ge/extensions/gameplay/rally/loop/stagedCountdownUtils.lua
local scale = 10
local x, y, z = rot * vec3(scale/2,0,0), rot * vec3(0,scale/2,0), rot * vec3(0,0,scale/2)
local col = color(128, 0, 255, 128) -- purple
local scale = 10
local x, y, z = rot * vec3(scale/2,0,0), rot * vec3(0,scale/2,0), rot * vec3(0,0,scale/2)
local col = color(128, 0, 255, 128) -- purple
local scale = 10
local x, y, z = rot * vec3(scale/2,0,0), rot * vec3(0,scale/2,0), rot * vec3(0,0,scale/2)
local col = color(128, 0, 255, 128) -- purple
-- Y axis (back - plane normal) - Green
local yEnd = pos + rot * vec3(0, axisLength, 0)
debugDrawer:drawLineInstance(pos, yEnd, 4, ColorF(0, 1, 0, 1), false)
-- -Y axis (front) - Red
local yBackEnd = pos + rot * vec3(0, -axisLength, 0)
debugDrawer:drawLineInstance(pos, yBackEnd, 4, ColorF(1, 0, 0, 1), false)
debugDrawer:drawTriSolid(
vec3(pos + x + z),
vec3(pos + x ),
vec3(pos + x + z),
vec3(pos + x ),
vec3(pos - x ),
vec3(pos + x ),
vec3(pos - x ),
col)
debugDrawer:drawTriSolid(
vec3(pos - x ),
vec3(pos - x + z),
vec3(pos - x ),
vec3(pos - x + z),
vec3(pos + x + z),
vec3(pos - x + z),
vec3(pos + x + z),
col)
@/lua/console/bananabench-async.lua
for i=currentObjects + 1, n do
BeamEngine:spawnObject(i, testVehicle, '', vec3(300 * i, 300 * i, 300 * i)) -- this assumes that the object is max. 300 meters high
currentObjects = currentObjects + 1
BeamEngine:deleteAllObjects()
BeamEngine:spawnObject(k, testVehicle, '', vec3(300 * k, 300 * k, 300 * k))
local obj = BeamEngine:getSlot(0)
@/lua/ge/extensions/editor/tech/roadArchitect/groups.lua
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local twoPi = math.pi * 2.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local camRotAngle = 0.0
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local camRotAngle = 0.0
local midX, midY = (xMin + xMax) * 0.5, (yMin + yMax) * 0.5 -- Midpoint of axis-aligned bounding box.
local tmp0 = vec3(midX, midY, 0.0)
local tmp1 = vec3(xMax, yMax, 0.0)
local tmp0 = vec3(midX, midY, 0.0)
local tmp1 = vec3(xMax, yMax, 0.0)
local groundDist = tmp0:distance(tmp1) -- The largest distance from the center of the box to the outside.
local height = groundDist / tan(halfFov) + zMax + 5.0 -- The height that the camera should be to fit all the trajectory in view.
local rot = quatFromDir(vec3(0, 0, -1))
@/lua/ge/extensions/core/weather.lua
-- log('I', logTag, "weather.lua:setVec3()")
return vec3(
former[1] + diff[1] * timer / switchWeatherTimer,
elseif (fields[attrName].type == 'Point3F' or fields[attrName].type == 'vec3') and type(attrValue) == 'table' and #attrValue == 3 then
val = vec3(attrValue[1], attrValue[2], attrValue[3])
end
@/lua/ge/extensions/flowgraph/nodes/scene/particleEmitter.lua
local object = createObject('ParticleEmitterNode')
object:setPosition(vec3(0, 0, 0))
object.scale = vec3(1, 1, 1)
object:setPosition(vec3(0, 0, 0))
object.scale = vec3(1, 1, 1)
object:setField('rotation', 0, '1 0 0 0')
hidden = false,
position = vec3(0,0,0),
alphaMult = 1
self:fillFields()
self.object.position = vec3(self.position)
self.object.obj:setPosition(vec3(self.position))
self.object.position = vec3(self.position)
self.object.obj:setPosition(vec3(self.position))
self.object.obj:setScale(vec3(self.radius, self.radius, 50))
self.object.obj:setPosition(vec3(self.position))
self.object.obj:setScale(vec3(self.radius, self.radius, 50))
end
@/lua/ge/extensions/gameplay/garageMode.lua
local camPresets = {
default = vec3(145, -5, 0),
front = vec3(180, 0, 0),
default = vec3(145, -5, 0),
front = vec3(180, 0, 0),
back = vec3(0, 0, 0),
front = vec3(180, 0, 0),
back = vec3(0, 0, 0),
side = vec3(90, 0, 0),
back = vec3(0, 0, 0),
side = vec3(90, 0, 0),
left = vec3(-90, 0, 0),
side = vec3(90, 0, 0),
left = vec3(-90, 0, 0),
right = vec3(90, 0, 0),
left = vec3(-90, 0, 0),
right = vec3(90, 0, 0),
top = vec3(90, -90, 0), -- may produce an unwanted rotation for a few degrees depending on a starting vector
right = vec3(90, 0, 0),
top = vec3(90, -90, 0), -- may produce an unwanted rotation for a few degrees depending on a starting vector
}
@/lua/common/extensions/ui/imguiUtils.lua
local function pointToLine(nodePos,startPos,endPos)
local v = vec3(endPos - startPos)
local w = vec3(nodePos - startPos)
local v = vec3(endPos - startPos)
local w = vec3(nodePos - startPos)
local c1 = w:dot(v)
@/lua/ge/extensions/flowgraph/nodes/debug/debugLine.lua
end
debugDrawer:drawLine(vec3(self.pinIn.posA.value), vec3(self.pinIn.posB.value), color)
end
end
debugDrawer:drawLine(vec3(self.pinIn.posA.value), vec3(self.pinIn.posB.value), color)
end
@/lua/ge/extensions/editor/dynamicDecals/brushes.lua
if value then
return vec3(value[1], value[2], value[3])
else
else
return vec3(prop.default[1], prop.default[2], prop.default[3])
end
-- api.setDecalTexturePath("roughness", getValueOrDefault("decalRoughnessTexturePath", brush.decalRoughnessTexturePath))
-- api.setDecalScale(vec3(brush.decalScale[1], brush.decalScale[2], brush.decalScale[3]))
-- api.setDecalSkew(Point2F.fromTable(getValueOrDefault("decalSkew", brush.decalSkew)))
@/lua/ge/extensions/tech/impactgen/crashOutput.lua
local camera = nil
local cameraArgs = {pos = vec3(0, 0, 0), size = ({100, 100}), isSnappingDesired = false,
nearFarPlanes = {0.1, 1000}, isStatic = true, requestedUpdateTime = -1.0,
cameraRequestWaitFrames = 0
local camPos = vec3(camRadius * math.cos(angle), camRadius * math.sin(angle), camHeight)
local camDir = vec3(-camPos.x, -camPos.y, -camPos.z)
local camPos = vec3(camRadius * math.cos(angle), camRadius * math.sin(angle), camHeight)
local camDir = vec3(-camPos.x, -camPos.y, -camPos.z)
local camRot = quatFromDir(camDir, vec3(0, 0, 1))
local camDir = vec3(-camPos.x, -camPos.y, -camPos.z)
local camRot = quatFromDir(camDir, vec3(0, 0, 1))
camPos = camPos + origin
camPos = camPos + origin
camPos = vec3(camPos.x, camPos.y, camPos.z)
camRot = QuatF(camRot.x, camRot.y, camRot.z, camRot.w)
obj.shapeName = 'levels/west_coast_usa/art/shapes/objects/lamp1.dae'
local pos = vec3(polePos[1], polePos[2], polePos[3])
obj:setPosition(pos)
obj:setPosition(pos)
local scl = vec3(1, 1, 1)
obj:setScale(scl)
@/lua/ge/extensions/flowgraph/nodes/scene/camera/cameraAutoRotate.lua
local vecUp = vec3(0, 0, 1)
function C:work()
local camPos = core_camera.getPosition()
local camRot = quatFromDir(vec3(self.pinIn.position.value) - camPos, vecUp)
core_camera.setPosRot(0, camPos.x, camPos.y, camPos.z, camRot.x, camRot.y, camRot.z, camRot.w)
@/lua/ge/extensions/editor/rallyEditor.lua
mouseInfo.ray = getCameraMouseRay()
mouseInfo.rayDir = vec3(mouseInfo.ray.dir)
mouseInfo.rayCast = cameraMouseRayCast()
mouseInfo.hold = false
mouseInfo._downPos = vec3(mouseInfo.rayCast.pos)
end
if mouseInfo.hold then
mouseInfo._holdPos = vec3(mouseInfo.rayCast.pos)
end
if mouseInfo.up then
mouseInfo._upPos = vec3(mouseInfo.rayCast.pos)
end
@/lua/ge/extensions/editor/renderTest.lua
local vecUp = vec3(0, 0, 1)
local ortho = im.BoolPtr(true)
--rot = quatFromDir(vec3(0,0,-1), vecUp)
if focusPos then
@/lua/ge/extensions/flowgraph/nodes/scene/spawnLight.lua
local pos = self.pinIn.position.value or {0,0,0}
pos = vec3(pos[1],pos[2],pos[3])
object:setPosition(pos)
local pos = self.pinIn.position.value or {0,0,0}
pos = vec3(pos[1],pos[2],pos[3])
object:setPosition(pos)
@/lua/console/test_dyncol.lua
v = newVehicle()
v:spawn("pickup", -1, vec3(0, 0, 0.1))
--v = newVehicle()
--v = newVehicle()
--v:spawn("hatch", -1, vec3(0, 0, 10.1))
--v = newVehicle()
--v = newVehicle()
--v:spawn("pickup", -1, vec3(0, 0, 20.1))
@/lua/ge/extensions/editor/rallyEditor/drivelineTab.lua
for i, pathPoint in ipairs(pointsToUse) do
table.insert(self.drivelineV3.spline.nodes, vec3(pathPoint.pos))
table.insert(self.drivelineV3.spline.widths, drivelineUtil.defaultSplineWidth)
table.insert(self.drivelineV3.spline.widths, drivelineUtil.defaultSplineWidth)
table.insert(self.drivelineV3.spline.nmls, vec3(0, 0, 1))
end
for i = 1, #old.nodes do
self.drivelineV3.spline.nodes[i] = vec3(old.nodes[i])
end
for i = 1, #old.nmls do
self.drivelineV3.spline.nmls[i] = vec3(old.nmls[i])
end
for i = 1, #new.nodes do
self.drivelineV3.spline.nodes[i] = vec3(new.nodes[i])
end
for i = 1, #new.nmls do
self.drivelineV3.spline.nmls[i] = vec3(new.nmls[i])
end
for _, point in ipairs(self.drivelineV3.finalDrivelinePoints) do
table.insert(self.bufferPoints, vec3(point.pos))
end
self.bufferBounds = {
min = vec3(minX - margin, minY - margin, minZ - margin),
max = vec3(maxX + margin, maxY + margin, maxZ + margin)
min = vec3(minX - margin, minY - margin, minZ - margin),
max = vec3(maxX + margin, maxY + margin, maxZ + margin)
}
local clr_bbox = ColorF(1, 1, 0, 1) -- Yellow
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(max.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, max.y, min.z), clr_bbox)
local clr_bbox = ColorF(1, 1, 0, 1) -- Yellow
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(max.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(max.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(min.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(max.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(min.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(min.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(min.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(min.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, max.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(min.x, max.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, max.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, max.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, max.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, min.y, min.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, max.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, max.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, max.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, max.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, max.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, max.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, max.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, max.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, max.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, max.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, max.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, max.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, max.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, max.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, max.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, max.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, max.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, max.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, max.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, max.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, min.y, min.z), vec3(min.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, min.y, min.z), vec3(max.x, min.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(max.x, max.y, min.z), vec3(max.x, max.y, max.z), clr_bbox)
debugDrawer:drawLine(vec3(min.x, max.y, min.z), vec3(min.x, max.y, max.z), clr_bbox)
-- Compute tangent (direction along driveline)
local tangent = vec3(1, 0, 0) -- Default
if i > 1 and i < #self.bufferPoints then
-- Compute binormal (perpendicular to tangent, horizontal)
local up = vec3(0, 0, 1)
local binormal = tangent:cross(up):normalized()
-- If tangent is vertical, use different reference
binormal = vec3(1, 0, 0)
end
preDrag = self.drivelineV3:deepCopySpline(),
lastMousePos = vec3(mousePos) -- Store initial mouse position
}
local nodeIdx = self.dragState.nodeIdx
local deltaXY = vec3(mousePos.x - self.dragState.lastMousePos.x,
mousePos.y - self.dragState.lastMousePos.y,
self.dragState.lastMousePos = vec3(mousePos)
self.drivelineV3.spline.isDirty = true
local insertIdx = idxLower + 1
table.insert(self.drivelineV3.spline.nodes, insertIdx, vec3(pHit))
table.insert(self.drivelineV3.spline.widths, insertIdx, drivelineUtil.defaultSplineWidth)
-- Interpolate normal
local prevNml = self.drivelineV3.spline.nmls[idxLower] or vec3(0, 0, 1)
local nextNml = self.drivelineV3.spline.nmls[insertIdx] or vec3(0, 0, 1)
local prevNml = self.drivelineV3.spline.nmls[idxLower] or vec3(0, 0, 1)
local nextNml = self.drivelineV3.spline.nmls[insertIdx] or vec3(0, 0, 1)
table.insert(self.drivelineV3.spline.nmls, insertIdx, lerp(prevNml, nextNml, 0.5))
-- First node - just add it
table.insert(nodes, vec3(mousePos))
table.insert(widths, drivelineUtil.defaultSplineWidth)
table.insert(widths, drivelineUtil.defaultSplineWidth)
table.insert(nmls, vec3(0, 0, 1))
self.selectedNodeIdx = 1
-- Second node - add to end
table.insert(nodes, vec3(mousePos))
table.insert(widths, widths[1])
table.insert(widths, widths[1])
table.insert(nmls, vec3(nmls[1] or vec3(0, 0, 1)))
self.selectedNodeIdx = 2
table.insert(widths, widths[1])
table.insert(nmls, vec3(nmls[1] or vec3(0, 0, 1)))
self.selectedNodeIdx = 2
-- Add to start
table.insert(nodes, 1, vec3(mousePos))
table.insert(widths, 1, widths[1])
table.insert(widths, 1, widths[1])
table.insert(nmls, 1, vec3(nmls[1] or vec3(0, 0, 1)))
self.selectedNodeIdx = 1
table.insert(widths, 1, widths[1])
table.insert(nmls, 1, vec3(nmls[1] or vec3(0, 0, 1)))
self.selectedNodeIdx = 1
-- Add to end
table.insert(nodes, vec3(mousePos))
table.insert(widths, widths[#widths])
table.insert(widths, widths[#widths])
table.insert(nmls, vec3(nmls[#nmls] or vec3(0, 0, 1)))
self.selectedNodeIdx = #nodes
table.insert(widths, widths[#widths])
table.insert(nmls, vec3(nmls[#nmls] or vec3(0, 0, 1)))
self.selectedNodeIdx = #nodes
@/lua/vehicle/controller/tech/tyreBarrier.lua
local initalVelOffset = 0.5 -- An offset added on to boost the hitting of the intial velocity target.
local targetStartPos = vec3(100, 0) -- The target test start position.
local distToStartTolSq = 1.0 -- A tolerance (m^2) used when testing how close the vehicle is to the start position.
if data.posX ~= nil then -- Set the target start position, if it has been provided by the user.
targetStartPos = vec3(data.posX, data.posY, data.posZ)
end
@/lua/ge/extensions/editor/meshEditor.lua
local u_32_max_int = 4294967295
local upVector = vec3(0,0,1)
local whiteF = ColorF(1.0,1.0,1.0,1.0)
-- Multiple selected nodes
local averagePos = vec3(0,0,0)
for index,_ in pairs(selectedNodes) do
if positionSliderEditEnded[0] then
editor.history:commitAction("PositionMeshNode", {meshID = selectedMeshId, nodeIDs = {selectedNode}, oldPositions = {[selectedNode] = selectedMesh:getNodePosition(selectedNode)}, newPositions = {[selectedNode] = vec3(nodePosition[0], nodePosition[1], nodePosition[2])}}, positionNodeActionUndo, positionNodeActionRedo)
editingPos = false
if heightSliderEditEnded[0] then
editor.history:commitAction("PositionMeshNode", {meshID = selectedMeshId, nodeIDs = {selectedNode}, oldPositions = {[selectedNode] = selectedNodePos}, newPositions = {[selectedNode] = vec3(selectedNodePos.x, selectedNodePos.y, prevNodeHeight + nodeHeightRelative[0])}}, positionNodeActionUndo, positionNodeActionRedo)
end
local origin = vec3(0,0,0)
local function gizmoDragging()
local function onEditorPreferenceValueChanged(path, value)
if path == M.preferencesName .. ".general.defaultHeight" then heightOffset = vec3(0, 0, value) end
end
@/lua/vehicle/extensions/core/booster.lua
local function boost(force, dt)
table.insert(boosts, {vec3(force), dt})
end
@/lua/vehicle/controller/playerController.lua
local ballGroundContactNodesPast = {}
local ballCenterVelocity = vec3(0, 0, 0)
local ballBasedPlayerVelocity = vec3(0, 0, 0)
local ballCenterVelocity = vec3(0, 0, 0)
local ballBasedPlayerVelocity = vec3(0, 0, 0)
local ballTorqueSmoother = newTemporalSmoothing(10, 1)
local cameraRotation = quat(0, 0, 0, 0)
local cameraRotationStandardVector = vec3(0, 1, 0)
local walkVector = vec3(0, 0, 0)
local cameraRotationStandardVector = vec3(0, 1, 0)
local walkVector = vec3(0, 0, 0)
local movementSpeedCoef = 0
local ballTorqueNodes = {}
local ballTorqueAxis = vec3(0, 0, 0)
local ballDesiredTorque = 0
--stabilization
local forceVectorFront = vec3()
local forceVectorLeft = vec3()
local forceVectorFront = vec3()
local forceVectorLeft = vec3()
--yaw
--take a look at physics particles and use the node and slip velocities to estimate a ball center velocity that is local to the unicycle
local slipVelocity = vec3(p.slipVec)
local nodeVelocity = vec3(p.nodeVel)
local slipVelocity = vec3(p.slipVec)
local nodeVelocity = vec3(p.nodeVel)
ballBasedPlayerVelocity = ballCenterVelocity - nodeVelocity + (slipVelocity * slipUsageCoef)
local normalRight = normalLeft:cross(vectorUp):normalized()
local targetVector = vec3(0, 0, 1)
if not isTouchingGround or particleRate < 100 then
ballBasedPlayerVelocity = vec3(0, 0, 0) --ball based AV doesn't work in water, make sure to reset the measured value to 0
end
forceVectorFront = vec3()
forceVectorLeft = vec3()
forceVectorFront = vec3()
forceVectorLeft = vec3()
walkVector = vec3(0, 0, 0)
ballTorqueAxis = vec3(0, 0, 0)
walkVector = vec3(0, 0, 0)
ballTorqueAxis = vec3(0, 0, 0)
stabilizationPIDs.frontRear:reset()
@/lua/ge/extensions/core/vehicles.lua
local trailerOffset = MatrixF(true)
local rotOffsetVec = vec3(math.rad(rotOffset.rx or 0), math.rad(rotOffset.ry or 0), math.rad(rotOffset.rz or 0))
trailerOffset:setFromEuler(rotOffsetVec)
local pos = vdata.nodes[cid].pos
couplerOffset[cid] = vec3(pos.x - refPos.x, pos.y - refPos.y, pos.z - refPos.z)
end
local offsetMat = MatrixF(true)
offsetMat:setFromEuler(vec3(math.rad(offset.rx or 0), math.rad(offset.ry or 0), math.rad(offset.rz or 0)))
offsetMat:setPosition(vec3(offset.x or 0, offset.y or 0, offset.z or 0))
offsetMat:setFromEuler(vec3(math.rad(offset.rx or 0), math.rad(offset.ry or 0), math.rad(offset.rz or 0)))
offsetMat:setPosition(vec3(offset.x or 0, offset.y or 0, offset.z or 0))
vehsPreventCollectionResetFlag[childVehId] = true
@/lua/ge/extensions/flowgraph/nodes/vehicle/ai/goToEndLine.lua
end
local frontPos = linePointFromXnorm(vec3(veh:getCornerPosition(0)), vec3(veh:getCornerPosition(1)), 0.5)
local endLinePosition = self.pinIn.endLinePosition.value
end
local frontPos = linePointFromXnorm(vec3(veh:getCornerPosition(0)), vec3(veh:getCornerPosition(1)), 0.5)
local endLinePosition = self.pinIn.endLinePosition.value
if type(endLinePosition) == "table" then
endLinePosition = vec3(endLinePosition)
end
@/lua/ge/extensions/gameplay/taxi.lua
local direction = (path[i+1].pos - marker.pos):normalized()
skipRotation = quatFromDir(direction, vec3(0, 0, 1))
end
@/lua/ge/extensions/editor/dragRaceEditor/waypoints.lua
-- Draw waypoint preview
local pos = vec3(waypoint.transform.position.x, waypoint.transform.position.y, waypoint.transform.position.z)
local scale = waypoint.transform.scale.x
@/lua/ge/extensions/editor/sitesEditor/parkingSpots.lua
local psVehScales = {
Car = vec3(2.5, 6, 3),
LargeCar = vec3(3.25, 8, 4),
Car = vec3(2.5, 6, 3),
LargeCar = vec3(3.25, 8, 4),
Bus = vec3(4, 14, 8)
LargeCar = vec3(3.25, 8, 4),
Bus = vec3(4, 14, 8)
}
if node.multiSpotData.spotDirection == "Left" then
dirVec = rot * vec3(-i * (node.scl.x + node.multiSpotData.spotOffset), 0, 0)
elseif node.multiSpotData.spotDirection == "Right" then
elseif node.multiSpotData.spotDirection == "Right" then
dirVec = rot * vec3(i * (node.scl.x + node.multiSpotData.spotOffset), 0, 0)
elseif node.multiSpotData.spotDirection == "Front" then
elseif node.multiSpotData.spotDirection == "Front" then
dirVec = rot * vec3(0, i * (node.scl.y + node.multiSpotData.spotOffset), 0)
elseif node.multiSpotData.spotDirection == "Back" then
elseif node.multiSpotData.spotDirection == "Back" then
dirVec = rot * vec3(0, -i * (node.scl.y + node.multiSpotData.spotOffset), 0)
end
local rotated = (node.scl * 0.5):rotated(rot)
local minDist, maxDist = intersectsRay_OBB(mouseInfo.camPos, mouseInfo.rayDir:normalized(), pos, vec3(rotated.x, 0, 0), vec3(0, rotated.y, 0), vec3(0, 0, rotated.z))
if minDist > 0 and maxDist > 0 and minDist < maxDist and minDist < minNodeDist then -- camera needs to be outside of bounding box to select object
local rotated = (node.scl * 0.5):rotated(rot)
local minDist, maxDist = intersectsRay_OBB(mouseInfo.camPos, mouseInfo.rayDir:normalized(), pos, vec3(rotated.x, 0, 0), vec3(0, rotated.y, 0), vec3(0, 0, rotated.z))
if minDist > 0 and maxDist > 0 and minDist < maxDist and minDist < minNodeDist then -- camera needs to be outside of bounding box to select object
local rotated = (node.scl * 0.5):rotated(rot)
local minDist, maxDist = intersectsRay_OBB(mouseInfo.camPos, mouseInfo.rayDir:normalized(), pos, vec3(rotated.x, 0, 0), vec3(0, rotated.y, 0), vec3(0, 0, rotated.z))
if minDist > 0 and maxDist > 0 and minDist < maxDist and minDist < minNodeDist then -- camera needs to be outside of bounding box to select object
local old = {pos = transformUtil.beginDragPos or self.current.pos, rot = transformUtil.beginDragRot or self.current.rot, scl = transformUtil.beginDragScl or self.current.scl}
local new = {pos = vec3(transformUtil.pos), rot = quat(transformUtil.rot), scl = vec3(transformUtil.scl)}
editor.history:commitAction("Update Transform of "..self.current.name,
local old = {pos = transformUtil.beginDragPos or self.current.pos, rot = transformUtil.beginDragRot or self.current.rot, scl = transformUtil.beginDragScl or self.current.scl}
local new = {pos = vec3(transformUtil.pos), rot = quat(transformUtil.rot), scl = vec3(transformUtil.scl)}
editor.history:commitAction("Update Transform of "..self.current.name,
@/lua/ge/extensions/editor/masterSpline/layerMgr.lua
-- Module state.
local tmp1 = vec3()
tmp1:setScaled2(binormal, layerPositionHalfWidth * divWidths[i]) -- Apply the lateral offset to every discretiaed point in this layer.
layerBufP[ctr] = layerBufP[ctr] or vec3()
layerBufP[ctr]:setAdd2(divPoints[i], tmp1) -- Store the transformed data using get-or-create pattern.
layerBufW[ctr] = divWidths[i] -- Store the discretized width.
layerBufN[ctr] = layerBufN[ctr] or vec3()
layerBufN[ctr]:set(masterSpline.normals[i]) -- Store the discretized normal using get-or-create pattern.
for i = 1, ctr - 1 do
tempPoints[i] = vec3(layerBufP[i])
tempWidths[i] = layerBufW[i]
tempWidths[i] = layerBufW[i]
tempNormals[i] = vec3(layerBufN[i])
end
local srcIdx = count - i + 1
pFlip[i] = pFlip[i] or vec3()
pFlip[i]:set(tempPoints[srcIdx])
wFlip[i] = tempWidths[srcIdx]
nFlip[i] = nFlip[i] or vec3()
nFlip[i]:set(tempNormals[srcIdx])
@/gameplay/missionTypes/chase/customNodes/suspectDistanceNode.lua
local pos1, pos2 = vec3(), vec3()
local pos1, pos2 = vec3(), vec3()
@/lua/ge/extensions/util/maptiles.lua
local function gameCoordsToExportCoords(p)
p = vec3(-p.y - minX, p.x - minY)
local f = basePixelSize / (baseTileSize*2)
local t = (a.pos - b.pos):normalized()
t = vec3(t.y, -t.x, 0)
local h, i, j, k = a.pos + t*a.radius, b.pos + t*b.radius, b.pos - t*b.radius, a.pos - t*a.radius
pixelSize = pixelSize,
topLeft = vec3(x, y+tileSize),
})
-- Use the same camera orientation as before
local q = quatFromDir(vec3(0, 0, -1), vec3(0, 1, 0))
q = QuatF(q.x, q.y, q.z, q.w)
-- Use the same camera orientation as before
local q = quatFromDir(vec3(0, 0, -1), vec3(0, 1, 0))
q = QuatF(q.x, q.y, q.z, q.w)
if not tile.decalPosition then
local rayStart = vec3(tile.x, tile.y, 1000)
local rayEnd = vec3(tile.x, tile.y, -1000)
local rayStart = vec3(tile.x, tile.y, 1000)
local rayEnd = vec3(tile.x, tile.y, -1000)
local hit = Engine.castRay(rayStart, rayEnd, true, true)
if hit then
tile.tileCenterPos = vec3(tile.x, tile.y, hit.pt.z)
end
end
mat:setPosition(vec3(tile.x, tile.y, tile.tileCenterPos.z + 250))
data.color = ColorF(1, 0, 0, 0.75)
data.forwardVec = vec3(0, 1, 0)
data.scale = vec3(10, 10, 1)
data.forwardVec = vec3(0, 1, 0)
data.scale = vec3(10, 10, 1)
Engine.Render.DynamicDecalMgr.addDecal(data)
local halfTileSize = tile.tileSize / 2
local minPoint = vec3(tile.x - halfTileSize, tile.y - halfTileSize, tile.tileCenterPos.z + 100)
local maxPoint = vec3(tile.x + halfTileSize, tile.y + halfTileSize, tile.tileCenterPos.z - 100)
local minPoint = vec3(tile.x - halfTileSize, tile.y - halfTileSize, tile.tileCenterPos.z + 100)
local maxPoint = vec3(tile.x + halfTileSize, tile.y + halfTileSize, tile.tileCenterPos.z - 100)
local color = ColorF(1, 0, 0, 0.2) -- Red color
@/lua/ge/extensions/editor/api/gui.lua
local function drawBrushSolidEdgeEllipse(pos, fromPoint, toPoint, color)
local fromOffsetted = fromPoint + vec3(vec3(pos.x, pos.y, fromPoint.z) - fromPoint):normalized() * editor.getPreference("gizmos.brush.marginSize")
local toOffsetted = toPoint + vec3(vec3(pos.x, pos.y, toPoint.z) - toPoint):normalized() * editor.getPreference("gizmos.brush.marginSize")
local function drawBrushSolidEdgeEllipse(pos, fromPoint, toPoint, color)
local fromOffsetted = fromPoint + vec3(vec3(pos.x, pos.y, fromPoint.z) - fromPoint):normalized() * editor.getPreference("gizmos.brush.marginSize")
local toOffsetted = toPoint + vec3(vec3(pos.x, pos.y, toPoint.z) - toPoint):normalized() * editor.getPreference("gizmos.brush.marginSize")
local fromOffsetted = fromPoint + vec3(vec3(pos.x, pos.y, fromPoint.z) - fromPoint):normalized() * editor.getPreference("gizmos.brush.marginSize")
local toOffsetted = toPoint + vec3(vec3(pos.x, pos.y, toPoint.z) - toPoint):normalized() * editor.getPreference("gizmos.brush.marginSize")
debugDrawer:drawQuadSolid(fromPoint, fromOffsetted, toOffsetted, toPoint, color)
local fromOffsetted = fromPoint + vec3(vec3(pos.x, pos.y, fromPoint.z) - fromPoint):normalized() * editor.getPreference("gizmos.brush.marginSize")
local toOffsetted = toPoint + vec3(vec3(pos.x, pos.y, toPoint.z) - toPoint):normalized() * editor.getPreference("gizmos.brush.marginSize")
debugDrawer:drawQuadSolid(fromPoint, fromOffsetted, toOffsetted, toPoint, color)
-- TODO: move this to gizmo.lua
local xVec = vec3(1, 0, 0)
local yVec = vec3(0, 1, 0)
local xVec = vec3(1, 0, 0)
local yVec = vec3(0, 1, 0)
local negXVec = -xVec
for i=0, numberOfSegments-1, 1 do
local fromPoint = vec3(
pos.x + radius * ((brushRatio > 1) and (2-brushRatio) or 1) * math.cos(i/numberOfSegments * 2 * math.pi + brushRotation/180*math.pi),
)
local toPoint = vec3(
pos.x + radius * ((brushRatio > 1) and (2-brushRatio) or 1) * math.cos((i+1)/numberOfSegments* 2 * math.pi + brushRotation/180*math.pi),
if terrainBlock then
fromPoint.z = terrainBlock:getHeight(vec3(fromPoint.x,fromPoint.y,0)) + 0.1
toPoint.z = terrainBlock:getHeight(vec3(toPoint.x,toPoint.y,0)) + 0.1
fromPoint.z = terrainBlock:getHeight(vec3(fromPoint.x,fromPoint.y,0)) + 0.1
toPoint.z = terrainBlock:getHeight(vec3(toPoint.x,toPoint.y,0)) + 0.1
end
rayStart.z = rayStart.z + radius
local rayDir = vec3(0,0,-1)
local rayDist = castRayStatic(rayStart, rayDir, radius*2)
for i = 0, numberOfSegments, 1 do
table.insert(line1, vec3(
pos.x - radius,
for i = 0, numberOfSegments, 1 do
table.insert(line2, vec3(
pos.x - radius + (i*2*radius/numberOfSegments),
for i = 0, numberOfSegments, 1 do
table.insert(line3, vec3(
pos.x + radius,
for i = 0, numberOfSegments, 1 do
table.insert(line4, vec3(
pos.x + radius - (i*2*radius/numberOfSegments),
for k,v in ipairs(line1) do
v.z = terrainBlock:getHeight(vec3(v.x,v.y,0)) + 0.1
end
for k,v in ipairs(line2) do
v.z = terrainBlock:getHeight(vec3(v.x,v.y,0)) + 0.1
end
for k,v in ipairs(line3) do
v.z = terrainBlock:getHeight(vec3(v.x,v.y,0)) + 0.1
end
for k,v in ipairs(line4) do
v.z = terrainBlock:getHeight(vec3(v.x,v.y,0)) + 0.1
end
local tempTextureObj = nil
local tempVec3 = vec3(0,0,0)
local tempImVec4 = imgui.ImVec4(0,0,0,0)
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veCrashTester.lua
local startYaw = 90 -- degrees
local startDir = quatFromAxisAngle(vec3(0,0,1), math.rad(startYaw))
local tempStartYaw = startYaw
local tempStartYaw = startYaw
local tempStartDir = quatFromAxisAngle(vec3(0,0,1), math.rad(startYaw))
local spawnPos = startPos + startDir * vec3(10 * (i - 1), 0, 0)
local startVelocity = startDir * vec3(0,1,0) * targetSpeedPtr[0] / 3.6
local spawnPos = startPos + startDir * vec3(10 * (i - 1), 0, 0)
local startVelocity = startDir * vec3(0,1,0) * targetSpeedPtr[0] / 3.6
table.insert(vehsData, {veh = veh, initPos = vec3(spawnPos), done = false})
end
tempStartYaw = tempStartYaw + io.MouseWheel * 5
tempStartDir = quatFromAxisAngle(vec3(0,0,1), math.rad(tempStartYaw))
end
for i = 1, numVehsPtr[0] do
local pos = hit.pos + tempStartDir * vec3(10 * (i - 1), 0, 0)
debugDrawer:drawTriSolid(
pos + tempStartDir * vec3(1,0,0),
pos + tempStartDir * vec3(-1,0,0),
pos + tempStartDir * vec3(1,0,0),
pos + tempStartDir * vec3(-1,0,0),
pos + tempStartDir * vec3(0,3,0),
pos + tempStartDir * vec3(-1,0,0),
pos + tempStartDir * vec3(0,3,0),
color(255,0,0,128)
for i = 1, numVehsPtr[0] do
local pos = startPos + startDir * vec3(10 * (i - 1), 0, 0)
debugDrawer:drawTriSolid(
pos + startDir * vec3(1,0,0),
pos + startDir * vec3(-1,0,0),
pos + startDir * vec3(1,0,0),
pos + startDir * vec3(-1,0,0),
pos + startDir * vec3(0,3,0),
pos + startDir * vec3(-1,0,0),
pos + startDir * vec3(0,3,0),
color(255,0,0,255)
@/lua/ge/extensions/core/cameraModes/observer.lua
local camPos = vec3(cam:getPosition())
if cam.PositionMove then
local targetPos = vec3():fromString(cam.PositionMove)
camPos = camPos + (targetPos - camPos) * self.camT
--log('A','observer','self.targetOverride: ' ..dumps(self.targetOverride))
data.pos = vec3(targetObject:getPosition())
end
@/lua/ge/extensions/flowgraph/nodes/gameplay/traffic/pursuitRoadblock.lua
local params = {angle = self.pinIn.angle.value, centerAngle = self.pinIn.centerAngle.value, width = self.pinIn.width.value}
gameplay_police.placeRoadblock(vehIds, vec3(self.pinIn.pos.value), quat(self.pinIn.rot.value), params)
end
@/lua/ge/extensions/gameplay/race/pacenote.lua
self.name = name or "Pacenote " .. self.id
self.pos = vec3()
self.normal = vec3(0,1,0)
self.pos = vec3()
self.normal = vec3(0,1,0)
self.radius = 0
if not normal then
self.normal = vec3(0,1,0)
end
self.mode = "manual"
self.pos = vec3(pos)
self.radius = radius
self.name = data.name
self:setManual(vec3(data.pos),data.radius,vec3(data.normal))
self.note = data.note
self.name = data.name
self:setManual(vec3(data.pos),data.radius,vec3(data.normal))
self.note = data.note
local midWidth = self.radius*2
local side = self.normal:cross(vec3(0,0,1)) *(self.radius - midWidth/2)
debugDrawer:drawSquarePrism(
@/lua/vehicle/extensions/aeroDebug.lua
--obj.debugDrawProxy:drawSphere(0.05, cog, color(255,0,255,255))
aeroData.totalAeroForceVehicle = vec3(aeroData.totalAeroForce:dot(M.directionVectorLeft), aeroData.totalAeroForce:dot(M.directionVector), aeroData.totalAeroForce:dot(M.directionVectorUp))
aeroData.afX = aeroData.totalAeroForce:dot(M.directionVectorLeft)
aeroData.totalAeroTorqueVehicle = vec3(aeroData.totalAeroTorque:dot(M.directionVectorLeft), aeroData.totalAeroTorque:dot(M.directionVector), aeroData.totalAeroTorque:dot(M.directionVectorUp))
aeroData.aTX = aeroData.totalAeroTorque:dot(M.directionVectorLeft)
@/lua/ge/extensions/gameplay/parking.lua
local sites, vehPool, vars
local aheadPos, lastPos, debugPos, tempVec = vec3(), vec3(), vec3(), vec3()
local focus
local sites, vehPool, vars
local aheadPos, lastPos, debugPos, tempVec = vec3(), vec3(), vec3(), vec3()
local focus
local sites, vehPool, vars
local aheadPos, lastPos, debugPos, tempVec = vec3(), vec3(), vec3(), vec3()
local focus
local sites, vehPool, vars
local aheadPos, lastPos, debugPos, tempVec = vec3(), vec3(), vec3(), vec3()
local focus
local xRandom, yRandom = randomGauss3() / 3 - 0.5, clamp(randomGauss3() / 3 - (backwards and 0.75 or 0.25), -0.5, 0.5)
offsetPos = vec3(xRandom * offsetVal * xGap, yRandom * offsetVal * yGap, 0)
offsetRot = quatFromEuler(0, 0, (randomGauss3() / 3 - 0.5) * offsetVal * 0.25)
local defaultParkingSpotSize = vec3(2.5, 6, 3)
local function checkDimensions(vehId) -- checks if the vehicle would fit in a standard sized parking spot
event = "none",
aheadPos = vec3(),
focusPos = vec3(),
aheadPos = vec3(),
focusPos = vec3(),
maxDist = 80,
local bbCenter, vehDirection, bbHalfExtents = vec3(), vec3(), vec3()
local result = {}
local bbCenter, vehDirection, bbHalfExtents = vec3(), vec3(), vec3()
local result = {}
local bbCenter, vehDirection, bbHalfExtents = vec3(), vec3(), vec3()
local result = {}
local ps = v.ps
local psDirVec = vec3(0, 1, 0):rotated(ps.rot)
local dColor = ps.vehicle and ColorF(1, 0.5, 0.5, 0.2) or ColorF(1, 1, 1, 0.2)
local dColor = v and ColorF(0.3, 1, 0.3, 0.5) or ColorF(1, 0.3, 0.3, 0.5)
debugDrawer:drawCylinder(bestPs.vertices[i], bestPs.vertices[i] + vec3(0, 0, 10), 0.05, dColor)
end
local vehPos = vec3()
local function onUpdate(dt, dtSim)
if M.debugLevel >= 3 then
local vecUpHigh = vec3(0, 0, 1000)
debugDrawer:drawCylinder(aheadPos, aheadPos + vecUpHigh, 0.25, ColorF(1, 1, 0, 0.5))
lastPos.z = core_terrain.getTerrainHeight(lastPos)
debugDrawer:drawCylinder(lastPos, lastPos + vec3(0, 0, 1), checkRadius, ColorF(0, 1, 0, 0.1))
lastPos.z = 0
debugPos.z = core_terrain.getTerrainHeight(debugPos)
debugDrawer:drawCylinder(debugPos, debugPos + vec3(0, 0, 1), areaRadius, ColorF(0, 1, 1, 0.1))
debugPos.z = 0
@/lua/ge/extensions/core/cameraModes/handheld.lua
self.rotk = rotspring or self.rotk or 3
self.vel = vec3()
self.mustReset = true
local up = (-self.rotk * data.dt * force:projectToOriginPlane(self.dir) + vec3(0,0,1)):normalized()
if data.openxrSessionRunning then
if data.openxrSessionRunning then
up = vec3(0,0,1)
end
@/lua/ge/extensions/editor/gen/render.lua
if not w then w = 1 end
local v = center + vec3(r,0,0)
-- local v = vec3(center.x+r,center.y,0)
local v = center + vec3(r,0,0)
-- local v = vec3(center.x+r,center.y,0)
local arg = math.pi/2 + (i - 1 + 1/2)*2*math.pi/circleGrid
local dv = l*vec3(
math.cos(arg),
@/lua/ge/extensions/editor/raceEditor/startPositions.lua
if editor.getAxisGizmoMode() == editor.AxisGizmoMode_Translate then
sp.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
elseif editor.getAxisGizmoMode() == editor.AxisGizmoMode_Rotate then
local txt = "Add Start Position (Drag for Rotation)"
debugDrawer:drawTextAdvanced(vec3(self.mouseInfo.rayCast.pos), String(txt), ColorF(1,1,1,1),true, false, ColorI(0,0,0,255))
if self.mouseInfo.hold then
local q = quatFromDir(normal, vec3(0,0,1))
local x, y, z = q * vec3(1,0,0), q * vec3(0,3,0), q * vec3(0,0,1)
local q = quatFromDir(normal, vec3(0,0,1))
local x, y, z = q * vec3(1,0,0), q * vec3(0,3,0), q * vec3(0,0,1)
debugDrawer:drawSquarePrism(
local q = quatFromDir(normal, vec3(0,0,1))
local x, y, z = q * vec3(1,0,0), q * vec3(0,3,0), q * vec3(0,0,1)
debugDrawer:drawSquarePrism(
local q = quatFromDir(normal, vec3(0,0,1))
local x, y, z = q * vec3(1,0,0), q * vec3(0,3,0), q * vec3(0,0,1)
debugDrawer:drawSquarePrism(
debugDrawer:drawSquarePrism(
vec3(self.mouseInfo._downPos + x),
vec3(self.mouseInfo._downPos - x),
vec3(self.mouseInfo._downPos + x),
vec3(self.mouseInfo._downPos - x),
Point2F(2,0),
debugDrawer:drawSquarePrism(
vec3(self.mouseInfo._downPos + x),
vec3(self.mouseInfo._downPos + x - y),
vec3(self.mouseInfo._downPos + x),
vec3(self.mouseInfo._downPos + x - y),
Point2F(2,0),
debugDrawer:drawSquarePrism(
vec3(self.mouseInfo._downPos - x),
vec3(self.mouseInfo._downPos - x - y),
vec3(self.mouseInfo._downPos - x),
vec3(self.mouseInfo._downPos - x - y),
Point2F(2,0),
sp:set(data.mouseInfo._downPos,
quatFromDir(data.mouseInfo._upPos - data.mouseInfo._downPos):normalized(), vec3(0,0,1))
data.spid = sp.id
local old = sp:onSerialize()
sp.pos = vec3(spPosition[0], spPosition[1], spPosition[2])
self:updateTransform(self.index)
local old = sp:onSerialize()
sp.pos = vec3(spPosition[0], spPosition[1], core_terrain.getTerrainHeight(sp.pos))
self:updateTransform(self.index)
local old = sp:onSerialize()
local normalTip = sp.pos + sp.rot*vec3(0,-4.5, 0)
normalTip = vec3(normalTip.x, normalTip.y, core_terrain.getTerrainHeight(normalTip))
local normalTip = sp.pos + sp.rot*vec3(0,-4.5, 0)
normalTip = vec3(normalTip.x, normalTip.y, core_terrain.getTerrainHeight(normalTip))
sp.rot = quatFromDir((sp.pos - normalTip):normalized(), vec3(0,0,1))
normalTip = vec3(normalTip.x, normalTip.y, core_terrain.getTerrainHeight(normalTip))
sp.rot = quatFromDir((sp.pos - normalTip):normalized(), vec3(0,0,1))
self:updateTransform(self.index)
@/lua/ge/extensions/gameplay/rally/snaproad.lua
-- local newZ = core_terrain.getTerrainHeight(pos)
-- return vec3(pos.x, pos.y, newZ-(r*0.25))
return pos
pos,
pos + vec3(0,0,h),
radius,
clr = cap.calc.angle_data.color
local pos = vec3(cap.pos)
debugDrawer:drawSphere(pos, radius, ColorF(clr[1],clr[2],clr[3],shapeAlpha))
debugDrawer:drawTextAdvanced(
vec3(label_point.pos),
String(calc.cornerCallStr..' '),
for _,point in ipairs(points) do
local pos = vec3(point.pos)
local distSq = (pos - source_pos):squaredLength()
-- else
-- toPoint = point + vec3(1,0,0)
-- end
-- local normVec = rallyUtil.calculateForwardNormal(fromPoint.pos, toPoint.pos)
-- return vec3(normVec.x, normVec.y, normVec.z)
-- end
if prevPoint then
dist = dist + vec3(toPoint.pos):distance(vec3(prevPoint.pos))
if prevPoint then
dist = dist + vec3(toPoint.pos):distance(vec3(prevPoint.pos))
if nextPoint then
dist = dist + vec3(toPoint.pos):distance(vec3(nextPoint.pos))
if nextPoint then
dist = dist + vec3(toPoint.pos):distance(vec3(nextPoint.pos))
@/lua/ge/extensions/flowgraph/nodes/util/routePointToPoint.lua
local pos = vec3()
@/lua/ge/extensions/core/cameraModes/driver.lua
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local min, max, abs = math.min, math.max, math.abs
self.saveTimeout = nil
self.camLastRot = vec3()
self.rockPos = vec3()
self.camLastRot = vec3()
self.rockPos = vec3()
self.cameraResetted = 3
self.cameraResetted = 3
self.camRot = vec3(0, 0, 0)
self.relativeYaw = 0
function C:resetSeat()
self.rockPos = vec3()
self.seatPosition = vec3()
self.rockPos = vec3()
self.seatPosition = vec3()
self.seatRotation = 0
function C:resetSeatAll()
self.rockPos = vec3()
self.seatPosition = vec3()
self.rockPos = vec3()
self.seatPosition = vec3()
self.seatRotation = 0
self.relativePitch = 0
self.rockPos = vec3()
end
local currentCarPos, prevCarPos = vec3(), vec3()
local rot = vec3()
local currentCarPos, prevCarPos = vec3(), vec3()
local rot = vec3()
local currentCarPos, prevCarPos = vec3(), vec3()
local rot = vec3()
local left, ref, back = vec3(), vec3(), vec3()
local rot = vec3()
local left, ref, back = vec3(), vec3(), vec3()
local carLeft, carFwd, carUp, carRot, carRotInverse = vec3(), vec3(), vec3(), quat(), quat()
local rot = vec3()
local left, ref, back = vec3(), vec3(), vec3()
local carLeft, carFwd, carUp, carRot, carRotInverse = vec3(), vec3(), vec3(), quat(), quat()
local rot = vec3()
local left, ref, back = vec3(), vec3(), vec3()
local carLeft, carFwd, carUp, carRot, carRotInverse = vec3(), vec3(), vec3(), quat(), quat()
local left, ref, back = vec3(), vec3(), vec3()
local carLeft, carFwd, carUp, carRot, carRotInverse = vec3(), vec3(), vec3(), quat(), quat()
local nodePos = vec3()
local left, ref, back = vec3(), vec3(), vec3()
local carLeft, carFwd, carUp, carRot, carRotInverse = vec3(), vec3(), vec3(), quat(), quat()
local nodePos = vec3()
local left, ref, back = vec3(), vec3(), vec3()
local carLeft, carFwd, carUp, carRot, carRotInverse = vec3(), vec3(), vec3(), quat(), quat()
local nodePos = vec3()
local carLeft, carFwd, carUp, carRot, carRotInverse = vec3(), vec3(), vec3(), quat(), quat()
local nodePos = vec3()
local camUp, camRot = vec3(), quat()
local nodePos = vec3()
local camUp, camRot = vec3(), quat()
local camPosLocal, combinedPos, rotationOffset = vec3(), vec3(), vec3()
local camUp, camRot = vec3(), quat()
local camPosLocal, combinedPos, rotationOffset = vec3(), vec3(), vec3()
local intermediateCamPos = vec3()
local camUp, camRot = vec3(), quat()
local camPosLocal, combinedPos, rotationOffset = vec3(), vec3(), vec3()
local intermediateCamPos = vec3()
local camUp, camRot = vec3(), quat()
local camPosLocal, combinedPos, rotationOffset = vec3(), vec3(), vec3()
local intermediateCamPos = vec3()
local camPosLocal, combinedPos, rotationOffset = vec3(), vec3(), vec3()
local intermediateCamPos = vec3()
local nRockPos, projectedRockPos = vec3(), vec3()
local intermediateCamPos = vec3()
local nRockPos, projectedRockPos = vec3(), vec3()
local intermediateCamPos = vec3()
local nRockPos, projectedRockPos = vec3(), vec3()
local vehConfig = vehConfigs[vehicleName] or {0,0,0}
self.seatPosition = vec3(0, vehConfig[2], vehConfig[3])
self.seatRotation = vehConfig[1]
if self.camPosInitialLocal == nil then ---- FIXME this can happen at any point, e.g. when vehicle is damaged
self.camPosInitialLocal = vec3(camPosLocal)
local origSpawnAABB = data.veh:getSpawnLocalAABB()
@/lua/ge/extensions/core/paths.lua
local marker = {
pos = vec3(markerData.pos.x, markerData.pos.y, markerData.pos.z),
rot = quat(markerData.rot.x, markerData.rot.y, markerData.rot.z, markerData.rot.w),
local d = {
pos = vec3(marker:getPosition()),
rot = quat(marker:getRotation()),
@/lua/ge/extensions/tech/sensors.lua
local args = {}
args.pos = vec3(initData.posX, initData.posY, initData.posZ)
args.up = vec3(initData.upX, initData.upY, initData.upZ)
args.pos = vec3(initData.posX, initData.posY, initData.posZ)
args.up = vec3(initData.upX, initData.upY, initData.upZ)
args.size = { initData.resX, initData.resY }
local aperture = math.pi * 0.5 + initData.overlap
local dir = vec3(initData.dirX, initData.dirY, initData.dirZ)
args.dir = rotateVecAroundAxis(dir, args.up, -math.pi * 0.25) -- The first quadrant sensor is centered at -45 degrees.
local z = unpack_float(pts:byte(i + 8), pts:byte(i + 9), pts:byte(i + 10), pts:byte(i + 11))
table.insert(pointsData, vec3(x, y, z))
end
-- Set optional parameters to defaults if they are not provided by the user.
if args.pos == nil then args.pos = vec3(0, 0, 3) end
if args.dir == nil then args.dir = vec3(0, -1, 0) end
if args.pos == nil then args.pos = vec3(0, 0, 3) end
if args.dir == nil then args.dir = vec3(0, -1, 0) end
if args.up == nil then args.up = vec3(0, 0, 1) end
if args.dir == nil then args.dir = vec3(0, -1, 0) end
if args.up == nil then args.up = vec3(0, 0, 1) end
args.up = -args.up -- // we need to flip the up direction vector to get the orientation correct when attaching the sensor.
-- Set optional parameters to defaults if they are not provided by the user.
if args.pos == nil then args.pos = vec3(0, 0, 3) end
if args.dir == nil then args.dir = vec3(0, -1, 0) end
if args.pos == nil then args.pos = vec3(0, 0, 3) end
if args.dir == nil then args.dir = vec3(0, -1, 0) end
if args.up == nil then args.up = vec3(0, 0, 1) end
if args.dir == nil then args.dir = vec3(0, -1, 0) end
if args.up == nil then args.up = vec3(0, 0, 1) end
args.up = -args.up -- // we need to flip the up direction vector to get the orientation correct when attaching the sensor.
local args = {}
args.pos = vec3(0.0, 0.2575, 0.504)
args.dir = vec3(0.0086, -0.9847, -0.1739)
args.pos = vec3(0.0, 0.2575, 0.504)
args.dir = vec3(0.0086, -0.9847, -0.1739)
args.up = vec3(-0.0017, -0.1739, 0.9848)
args.dir = vec3(0.0086, -0.9847, -0.1739)
args.up = vec3(-0.0017, -0.1739, 0.9848)
args.GFXUpdateTime = 0.00001
local args = {}
args.pos = IMUPos or vec3(0, 0, 0)
args.dir = IMUDir or vec3(0, -1, 0)
args.pos = IMUPos or vec3(0, 0, 0)
args.dir = IMUDir or vec3(0, -1, 0)
args.up = IMUUp or vec3(0, 0, 1)
args.dir = IMUDir or vec3(0, -1, 0)
args.up = IMUUp or vec3(0, 0, 1)
args.GFXUpdateTime = 0.00001
args.initialVel = initialVel
args.startPos = startPos or vec3(0, 0, 0)
@/lua/ge/extensions/editor/tech/sensorConfiguration/utilities.lua
local right = fwd:cross(up)
return vec3(posVS:dot(fwd), posVS:dot(right), posVS:dot(up))
end
local right = fwd:cross(up)
return vec3(fwd:dot(dirLoc), right:dot(dirLoc), up:dot(dirLoc)), vec3(fwd:dot(upLoc), right:dot(upLoc), up:dot(upLoc))
end
local right = fwd:cross(up)
return vec3(fwd:dot(dirLoc), right:dot(dirLoc), up:dot(dirLoc)), vec3(fwd:dot(upLoc), right:dot(upLoc), up:dot(upLoc))
end
local right = fwd:cross(up)
return vec3(fwd:dot(dirVS), right:dot(dirVS), up:dot(dirVS)), vec3(fwd:dot(upVS), right:dot(upVS), up:dot(upVS))
end
local right = fwd:cross(up)
return vec3(fwd:dot(dirVS), right:dot(dirVS), up:dot(dirVS)), vec3(fwd:dot(upVS), right:dot(upVS), up:dot(upVS))
end
local offset = veh:getInitialNodePosition(veh:getRefNodeId())
return vec3(-c.y + offset.y, -c.x + offset.x, c.z - offset.z)
end
local function dirToDirWorldSpace(c)
return vec3(-c.y, -c.x, c.z)
end
@/lua/ge/extensions/core/cameraModes/orbit.lua
C.__index = C
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local lookBackVec = vec3(0,-0.3,0)
local vecZ = vec3(0,0,1)
local lookBackVec = vec3(0,-0.3,0)
self.target = false
self.camLastTargetPos = vec3()
self.camLastTargetPos2 = vec3()
self.camLastTargetPos = vec3()
self.camLastTargetPos2 = vec3()
self.camLastPos = vec3()
self.camLastTargetPos2 = vec3()
self.camLastPos = vec3()
self.camLastPos2 = vec3()
self.camLastPos = vec3()
self.camLastPos2 = vec3()
self.camLastPosPerp = vec3()
self.camLastPos2 = vec3()
self.camLastPosPerp = vec3()
self.camVel = vec3()
self.camLastPosPerp = vec3()
self.camVel = vec3()
self.cameraResetted = 3
self.lockCamera = false
self.orbitOffset = vec3()
self.preResetPos = vec3(1e+300, 0, 0)
self.orbitOffset = vec3()
self.preResetPos = vec3(1e+300, 0, 0)
self.smoothedPitchOffset = newTemporalSigmoidSmoothing(2, 2, 2, 2)
self.dynamicPitchQuat = quat()
self.targetCenter = vec3(0, 0, 0)
self.targetLeft = vec3(0, 0, 0)
self.targetCenter = vec3(0, 0, 0)
self.targetLeft = vec3(0, 0, 0)
self.targetBack = vec3(0, 0, 0)
self.targetLeft = vec3(0, 0, 0)
self.targetBack = vec3(0, 0, 0)
self.configChanged = false
local veh = getObjectByID(vehId)
local bottomRear = vec3()
local bbHalfExtents = vec3()
local bottomRear = vec3()
local bbHalfExtents = vec3()
local bbCenter = vec3()
local bbHalfExtents = vec3()
local bbCenter = vec3()
bbHalfExtents:set(be:getObjectOOBBHalfExtentsXYZ(vehId))
bottomRear:setAdd(vec3(0,-bbHalfExtents.y,0))
bottomRear:setAdd(vec3(0,0,-bbHalfExtents.z))
bottomRear:setAdd(vec3(0,-bbHalfExtents.y,0))
bottomRear:setAdd(vec3(0,0,-bbHalfExtents.z))
bbCenter:set(be:getObjectOOBBCenterXYZ(vehId))
-- defaultCamPos is relative to targetPos
local defaultCamPos = vec3()
if self.defaultRotation == nil then
self.defaultRotation = vec3(0, -17, 0)
end
end
self.defaultRotation = vec3(self.defaultRotation)
self.offset = vec3(self.offset)
self.defaultRotation = vec3(self.defaultRotation)
self.offset = vec3(self.offset)
if not self.camRot then self.camRot = vec3(self.defaultRotation) end
self.offset = vec3(self.offset)
if not self.camRot then self.camRot = vec3(self.defaultRotation) end
self.camLastRot = vec3(math.rad(self.camRot.x), math.rad(self.camRot.y), 0)
if not self.camRot then self.camRot = vec3(self.defaultRotation) end
self.camLastRot = vec3(math.rad(self.camRot.x), math.rad(self.camRot.y), 0)
self.camMinDist = self.distanceMin or 3
if self.cameraResetted == 0 then
self.preResetPos = vec3(self.camLastTargetPos2)
self.cameraResetted = 3
function C:setRotation(rot)
self.camRot = vec3(rot)
end
function C:setOffset(v)
self.orbitOffset = vec3(v)
end
local ref, left, back, dirxy = vec3(), vec3(), vec3(), vec3()
local ref, left, back, dirxy = vec3(), vec3(), vec3(), vec3()
local ref, left, back, dirxy = vec3(), vec3(), vec3(), vec3()
local ref, left, back, dirxy = vec3(), vec3(), vec3(), vec3()
local nx, ny, nz = vec3(), vec3(), vec3()
local nx, ny, nz = vec3(), vec3(), vec3()
local nx, ny, nz = vec3(), vec3(), vec3()
local targetPos, camdir, dir = vec3(), vec3(), vec3()
local targetPos, camdir, dir = vec3(), vec3(), vec3()
local targetPos, camdir, dir = vec3(), vec3(), vec3()
local lastCamPointVec, lastCamLastPerp, moveDir = vec3(), vec3(), vec3()
local lastCamPointVec, lastCamLastPerp, moveDir = vec3(), vec3(), vec3()
local lastCamPointVec, lastCamLastPerp, moveDir = vec3(), vec3(), vec3()
local rot, calculatedCamPos, camPos, updir, rear = vec3(), vec3(), vec3(), vec3(), vec3()
local rot, calculatedCamPos, camPos, updir, rear = vec3(), vec3(), vec3(), vec3(), vec3()
local rot, calculatedCamPos, camPos, updir, rear = vec3(), vec3(), vec3(), vec3(), vec3()
local rot, calculatedCamPos, camPos, updir, rear = vec3(), vec3(), vec3(), vec3(), vec3()
local rot, calculatedCamPos, camPos, updir, rear = vec3(), vec3(), vec3(), vec3(), vec3()
local resultPos, resultRot, tempQuatB = vec3(), quat(), quat()
local bbCenter, bbHalfAxis1 = vec3(), vec3()
local bbCenter, bbHalfAxis1 = vec3(), vec3()
-- if a reload hasn't just happened
self.camRot = vec3(self.defaultRotation)
self.camDist = self.defaultDistance
if self.offset and self.offset.x and nx:length() ~= 0 and ny:length() ~= 0 then
self.camBase = vec3(self.offset.x, self.offset.y, self.offset.z)
self.camOffset2 = nx * self.camBase.x + ny * self.camBase.y + nz * self.camBase.z
else
if not self.camOffset2 then self.camOffset2 = vec3() end
self.camOffset2:set(push3(nx) * self.camBase.x + push3(ny) * self.camBase.y + push3(nz) * self.camBase.z)
@/lua/ge/extensions/flowgraph/nodes/environment/directionalGravity.lua
local origin = veh:getPosition()
local off = vec3(self.pinIn.direction.value)
off = off:normalized()
if veh then
local center = vec3(self.planet.origin)
local vehPos = veh:getPosition()
local origin = veh:getPosition()
local off = vec3(self.pinIn.direction.value):normalized() * 5
@/lua/ge/extensions/util/export.lua
-- p1 = vec3(veh:getOriginalNodePositionRelative(id1))
-- p2 = vec3(veh:getOriginalNodePositionRelative(id2))
-- p1 = vec3(veh:getOriginalNodePositionRelative(id1))
-- p2 = vec3(veh:getOriginalNodePositionRelative(id2))
-- length = (p1 - p2):length()
p1 = vec3(veh:getNodePosition(id1))
p2 = vec3(veh:getNodePosition(id2))
p1 = vec3(veh:getNodePosition(id1))
p2 = vec3(veh:getNodePosition(id2))
length = (p1 - p2):length()
elseif fieldInfo.type == "Point3F" then
return vec3():fromString(value):toTable()
else
@/lua/ge/extensions/editor/gen/exp_frame.lua
local an = {
f_r = {vec3(0,0,0),vec3(0,0,0)},
f_l = {vec3(0,0,0),vec3(0,0,0)},
local an = {
f_r = {vec3(0,0,0),vec3(0,0,0)},
f_l = {vec3(0,0,0),vec3(0,0,0)},
f_r = {vec3(0,0,0),vec3(0,0,0)},
f_l = {vec3(0,0,0),vec3(0,0,0)},
i_r = vec3(0,0,0),
f_r = {vec3(0,0,0),vec3(0,0,0)},
f_l = {vec3(0,0,0),vec3(0,0,0)},
i_r = vec3(0,0,0),
f_l = {vec3(0,0,0),vec3(0,0,0)},
i_r = vec3(0,0,0),
i_l = vec3(0,0,0),
i_r = vec3(0,0,0),
i_l = vec3(0,0,0),
}
local ddir = {
-- i = vec3(1,0,0), -- ilium
sternum = vec3(0,0,1), -- sternum
-- i = vec3(1,0,0), -- ilium
sternum = vec3(0,0,1), -- sternum
f_r = vec3(0,0,1), -- femur right
sternum = vec3(0,0,1), -- sternum
f_r = vec3(0,0,1), -- femur right
f_l = vec3(0,0,1), -- femur left
f_r = vec3(0,0,1), -- femur right
f_l = vec3(0,0,1), -- femur left
}
local body = {
-- b = {frto={'f_b_r', 'p_r'}, len=1, dir=vec3(0,0,1)},
tibia_r = {frto={'t_b_r','f_b_r'}, len = 0.6, ac={0,0,1}, dir=1},
--- tibia
t_b_r = vec3(body.pelvic.len/2,0,0),-- vec3(dlen.pelvic/2,0,0),
t_b_l = -vec3(body.pelvic.len/2,0,0),--vec3(dlen.pelvic/2,0,0),
--- tibia
t_b_r = vec3(body.pelvic.len/2,0,0),-- vec3(dlen.pelvic/2,0,0),
t_b_l = -vec3(body.pelvic.len/2,0,0),--vec3(dlen.pelvic/2,0,0),
t_b_r = vec3(body.pelvic.len/2,0,0),-- vec3(dlen.pelvic/2,0,0),
t_b_l = -vec3(body.pelvic.len/2,0,0),--vec3(dlen.pelvic/2,0,0),
--- femur
t_b_r = vec3(body.pelvic.len/2,0,0),-- vec3(dlen.pelvic/2,0,0),
t_b_l = -vec3(body.pelvic.len/2,0,0),--vec3(dlen.pelvic/2,0,0),
--- femur
--- femur
f_b_r = nil, -- vec3(body.pelvic.len/2,0,0),-- vec3(dlen.pelvic/2,0,0),
f_b_l = nil, -- -vec3(body.pelvic.len/2,0,0),--vec3(dlen.pelvic/2,0,0),
--- femur
f_b_r = nil, -- vec3(body.pelvic.len/2,0,0),-- vec3(dlen.pelvic/2,0,0),
f_b_l = nil, -- -vec3(body.pelvic.len/2,0,0),--vec3(dlen.pelvic/2,0,0),
f_b_r = nil, -- vec3(body.pelvic.len/2,0,0),-- vec3(dlen.pelvic/2,0,0),
f_b_l = nil, -- -vec3(body.pelvic.len/2,0,0),--vec3(dlen.pelvic/2,0,0),
-- middle (pelvic)
f_b_r = nil, -- vec3(body.pelvic.len/2,0,0),-- vec3(dlen.pelvic/2,0,0),
f_b_l = nil, -- -vec3(body.pelvic.len/2,0,0),--vec3(dlen.pelvic/2,0,0),
-- middle (pelvic)
-- normalize directions
local v = vec3(d.ac[1],d.ac[2],d.ac[3]):normalized()
d.ac = {v.x,v.y,v.z}
a,b,c = body.femur_r.ac[1],body.femur_r.ac[2],body.femur_r.ac[3]
body.femur_r.r = vec3(a,b,c):normalized()
body.femur_r.dir = cfix == 'r' and 1 or -1
-- acp = body.femur_r.hist[1]
-- v1,v2 = vec3(acp[1],acp[2],acp[3]),vec3(ac[1],ac[2],ac[3])
-- U.vturn3D(body.tibia_r.r,v1,v2)
-- acp = body.femur_r.hist[1]
-- v1,v2 = vec3(acp[1],acp[2],acp[3]),vec3(ac[1],ac[2],ac[3])
-- U.vturn3D(body.tibia_r.r,v1,v2)
a,b,c = body.femur_l.ac[1],body.femur_l.ac[2],body.femur_l.ac[3]
body.femur_l.r = vec3(a,b,c):normalized()
body.femur_l.dir = cfix == 'r' and -1 or 1
-- acp = body.femur_l.hist[1]
-- v1,v2 = vec3(acp[1],acp[2],acp[3]),vec3(ac[1],ac[2],ac[3])
-- U.vturn3D(body.tibia_l.r,v1,v2)
-- acp = body.femur_l.hist[1]
-- v1,v2 = vec3(acp[1],acp[2],acp[3]),vec3(ac[1],ac[2],ac[3])
-- U.vturn3D(body.tibia_l.r,v1,v2)
a,b,c = body.tibia_r.ac[1],body.tibia_r.ac[2],body.tibia_r.ac[3]
body.tibia_r.r = vec3(a,b,c):normalized()
-- body.tibia_r.r = body.femur_r.r -- vec3(a,b,c):normalized()
body.tibia_r.r = vec3(a,b,c):normalized()
-- body.tibia_r.r = body.femur_r.r -- vec3(a,b,c):normalized()
body.tibia_r.dir = cfix == 'r' and 1 or -1
a,b,c = body.tibia_l.ac[1],body.tibia_l.ac[2],body.tibia_l.ac[3]
body.tibia_l.r = vec3(a,b,c):normalized()
-- body.tibia_l.r = body.femur_l.r -- vec3(a,b,c):normalized()
body.tibia_l.r = vec3(a,b,c):normalized()
-- body.tibia_l.r = body.femur_l.r -- vec3(a,b,c):normalized()
body.tibia_l.dir = cfix == 'r' and -1 or 1
b = body.pelvic.ac[1]
body.pelvic.r = vec3(math.cos(b), math.sin(b))
body.pelvic.dir = cfix == 'r' and -1 or 1
a,b,c = body.sternum.ac[1],body.sternum.ac[2],body.sternum.ac[3]
body.sternum.r = vec3(a,b,c):normalized()
-- body.sternum.r = vec3(math.sin(a)*math.cos(b), math.sin(a)*math.sin(b), math.cos(a))
body.sternum.r = vec3(a,b,c):normalized()
-- body.sternum.r = vec3(math.sin(a)*math.cos(b), math.sin(a)*math.sin(b), math.cos(a))
-- body.pelvic.dir = 1
-- facing
vec3(4,4.4,0)
-- turn
-- turn
-- vec3(6,4.6,0)
-- turn back
-- turn back
-- vec3(4,-2.6,0)
, ptarget=vec3(4,4.4,0), cb =function(ind)
-- vec3(4,-2.6,0)
, ptarget=vec3(4,4.4,0), cb =function(ind)
cind = ind
ac = body.femur_l.hist[1]
v = vec3(ac[1],ac[2],ac[3]) --:cross(body.femur_l.r)
else
ac = body.femur_r.hist[1]
v = vec3(ac[1],ac[2],ac[3]) --:cross(body.femur_r.r)
else
--?? step symmetry
-- a = math.abs(U.vang(body.femur_l.r,vec3(0,0,1)) - U.vang(body.femur_r.r,vec3(0,0,1)))
-- s = s + bang(3*a)
--?? step symmetry
-- a = math.abs(U.vang(body.femur_l.r,vec3(0,0,1)) - U.vang(body.femur_r.r,vec3(0,0,1)))
-- s = s + bang(3*a)
-- W.dmove[cmove].cp = pnew
-- W.dmove[cmove].cp = W.dmove[cmove].cp -- vec3(0,4,0) -- pnew
-- W.dmove[cmove].p = pmid + (W.dmove[cmove].p - pos):normalized()*4
-- if true then return end
-- local d = U.toLine(vec3(-3.999866668e-05,0.003999733339,0),
-- {vec3(-0.2,-0,-0),vec3(0.1999200027,0.007999466677,0)})
-- local d = U.toLine(vec3(-3.999866668e-05,0.003999733339,0),
-- {vec3(-0.2,-0,-0),vec3(0.1999200027,0.007999466677,0)})
-- lo('?? if_TL:'..tostring(d))
-- local d = U.toLine(vec3(-3.999866668e-05,0.003999733339,0),
-- {vec3(-0.2,-0,-0),vec3(0.1999200027,0.007999466677,0)})
-- lo('?? if_TL:'..tostring(d))
if false then
dnode.f_b_l = vec3(-0.2007216725,-0.521615368,-0.4015124751855)
dnode.f_b_r = vec3(0.2081584476,-0.550730404,-0.4016076190196)
dnode.f_b_l = vec3(-0.2007216725,-0.521615368,-0.4015124751855)
dnode.f_b_r = vec3(0.2081584476,-0.550730404,-0.4016076190196)
--[[
--[[
p_r = vec3(0.2030650826,1.370226297,0.9390350613),
s_t = vec3(0.003122641294,1.365428364,1.739035061),
p_r = vec3(0.2030650826,1.370226297,0.9390350613),
s_t = vec3(0.003122641294,1.365428364,1.739035061),
p_l = vec3(-0.1968198,1.36063043,0.9390350613),
s_t = vec3(0.003122641294,1.365428364,1.739035061),
p_l = vec3(-0.1968198,1.36063043,0.9390350613),
s_b = vec3(0.003122641294,1.365428364,0.9390350613),
p_l = vec3(-0.1968198,1.36063043,0.9390350613),
s_b = vec3(0.003122641294,1.365428364,0.9390350613),
]]
local anode = {
b_t = vec3(0,0,2), -- body top
b_b = vec3(0,0,1), -- body bottom
b_t = vec3(0,0,2), -- body top
b_b = vec3(0,0,1), -- body bottom
-- i_r = vec3(0,0,1), -- ilium right
b_b = vec3(0,0,1), -- body bottom
-- i_r = vec3(0,0,1), -- ilium right
-- i_l = vec3(0,0,1), -- ilium left
-- i_r = vec3(0,0,1), -- ilium right
-- i_l = vec3(0,0,1), -- ilium left
}
}
anode.i_r = anode.b_b + 0.2*vec3(1,0,0)
anode.i_l = anode.b_b - 0.2*vec3(1,0,0)
anode.i_r = anode.b_b + 0.2*vec3(1,0,0)
anode.i_l = anode.b_b - 0.2*vec3(1,0,0)
-- anode.f_t = anode.
local v = rayCast.pos
-- vec3(-1.079253912,3.426138163,0)
-- vec3(-0.03866410255,2.875142813,0)
-- vec3(-1.079253912,3.426138163,0)
-- vec3(-0.03866410255,2.875142813,0)
-- vec3(-1.160513639,2.066551685,0)
-- vec3(-0.03866410255,2.875142813,0)
-- vec3(-1.160513639,2.066551685,0)
-- vec3(-2.053774118,4.923738956,0)
-- vec3(-1.160513639,2.066551685,0)
-- vec3(-2.053774118,4.923738956,0)
-- v = vec3(0,4,0)
-- vec3(-2.053774118,4.923738956,0)
-- v = vec3(0,4,0)
dmove[cmove].cp = v
@/lua/common/jbeam/utils.lua
local tmpMat1, tmpMat2 = MatrixF(true), MatrixF(true)
local tmpVec1 = vec3()
@/lua/ge/extensions/flowgraph/nodes/gameplay/traffic/trafficSpawnGroup.lua
local shuffle = self.pinIn.shuffle.value and true or false
local pos = self.pinIn.startPos.value and vec3(self.pinIn.startPos.value)
local rot = self.pinIn.startRot.value and quat(self.pinIn.startRot.value)
@/lua/ge/extensions/core/cameraModes/unicycle.lua
local function castRayLocation(origin, target)
local result = vec3()
local dir = target-origin
local result
local resultUp = pos+vec3(0, 0, getHipHeight(crouching))
local resultDown = pos+vec3(0, 0,-5)
local resultUp = pos+vec3(0, 0, getHipHeight(crouching))
local resultDown = pos+vec3(0, 0,-5)
local resultGround = castRayLocation(resultUp, resultDown)
if resultGround then
result = resultGround + vec3(0,0,getHumanHeight())
else
if prevCamPos then camPos.z = prevCamPos.z end
local oldGround = camPos+vec3(0, 0, -getHumanHeight(crouching))
local hip = oldGround+vec3(0, 0, getHipHeight(crouching))
local oldGround = camPos+vec3(0, 0, -getHumanHeight(crouching))
local hip = oldGround+vec3(0, 0, getHipHeight(crouching))
local target = oldGround+vec3(0, 0, -maxFallHeight)
local hip = oldGround+vec3(0, 0, getHipHeight(crouching))
local target = oldGround+vec3(0, 0, -maxFallHeight)
local newGround = castRayLocation(hip, target)
newGround.z = max(oldGround.z + gravity*dt, newGround.z)
newCamPos = newGround + vec3(0,0,getHumanHeight(crouching))
else
--dump("ground known, immediately climbing it")
newCamPos = newGround + vec3(0,0,getHumanHeight(crouching))
end
--newCamPos = prevCamPos
newCamPos = camPos + vec3(0,0, gravity*dt)
else
--dump("ground unknown, falling into the abyss?")
newCamPos = camPos + vec3(0,0, gravity*dt)
end
if prevCamPos then
local newKnee = newCamPos+vec3(0,0, -getHumanHeight(crouching)+getHipHeight(crouching))
local prevKnee = prevCamPos+vec3(0,0, -getHumanHeight(crouching)+getHipHeight(crouching))
local newKnee = newCamPos+vec3(0,0, -getHumanHeight(crouching)+getHipHeight(crouching))
local prevKnee = prevCamPos+vec3(0,0, -getHumanHeight(crouching)+getHipHeight(crouching))
local hipCollisionPoint = castRayLocation(prevKnee, newKnee)
hipCollisionPoint = hipCollisionPoint + diff:normalized()*dist -- stay 20cm away from collision point
newKnee = vec3(hipCollisionPoint.x, hipCollisionPoint.y, newKnee.z)
newCamPos = newKnee+vec3(0,0,-getHipHeight(crouching)+getHumanHeight(crouching))
newKnee = vec3(hipCollisionPoint.x, hipCollisionPoint.y, newKnee.z)
newCamPos = newKnee+vec3(0,0,-getHipHeight(crouching)+getHumanHeight(crouching))
--newCamPos = prevCamPos
local rotEuler = initialLookDir:toEulerYXZ()
local rotVec = vec3(math.deg(rotEuler.x), 180, 0) -- look horizontally, cause the math below is broken :(
--local rotVec = vec3(math.deg(rotEuler.x), 180+math.deg(rotEuler.y), math.deg(rotEuler.z))
local rotVec = vec3(math.deg(rotEuler.x), 180, 0) -- look horizontally, cause the math below is broken :(
--local rotVec = vec3(math.deg(rotEuler.x), 180+math.deg(rotEuler.y), math.deg(rotEuler.z))
--dump(string.format("%5.3f, %5.3f, %5.3f", rotVec.x, rotVec.y, rotVec.z))
log("W", "", "Unicycle camera cannot provide a position or a rotation: "..dumps(self.pos).." / "..dumps(self.rotVec))
return vec3(), quat()
end
else
self.rotVec = self.rotVec + (dt>0 and 7 or 0)*vec3(rdx, rdy, 0)
self.rotVec.y = clamp(self.rotVec.y, 180-89.9, 180+89.9) -- limit head pitch, look at floor or roof, but not further than that (adding a 0.1 safety margin to account for float precission issues in later conversions)
local camNodeID = core_camera.getDriverData(data.veh)
local nodePos = vec3(data.veh:getNodePosition(camNodeID or 0))
local carPos = data.pos
@/lua/ge/extensions/editor/api/gizmo.lua
local function setAxisGizmoTransform(matrix, scale)
worldEditorCppApi.setAxisGizmoTransform(matrix, matrix:getColumn(3), scale or vec3(1, 1, 1))
end
if not endPoint then
endPoint = startPoint - vec3(0,0,100)
end
end
local res = Engine.castRay((startPoint + vec3(0,0,1)), endPoint, true, false)
if not res then
if not res then
res = Engine.castRay((startPoint + vec3(0,0,100)), (startPoint - vec3(0,0,1000)), true, false)
end
if not res then
res = Engine.castRay((startPoint + vec3(0,0,100)), (startPoint - vec3(0,0,1000)), true, false)
end
local bbox = Box3F()
bbox:setExtents(vec3(-1e10 - 1e10, -1e10 - 1e10, -1e10 - 1e10))
bbox:setCenter(vec3(0, 0, 0))
bbox:setExtents(vec3(-1e10 - 1e10, -1e10 - 1e10, -1e10 - 1e10))
bbox:setCenter(vec3(0, 0, 0))
end
local rayCastRes = castRayDown(gizmoPos + vec3(0, 0, selectionBox.maxExtents.z), gizmoPos - vec3(0, 0, selectionBox.maxExtents.z + 50))
end
local rayCastRes = castRayDown(gizmoPos + vec3(0, 0, selectionBox.maxExtents.z), gizmoPos - vec3(0, 0, selectionBox.maxExtents.z + 50))
initialGizmoTerrainOffset = 0
initialGizmoTerrainNormal = vec3(0, 1, 0)
lastGizmoTerrainHeight = 0
if editor.getPreference("snapping.terrain.useRayCast") then
local rayCastStart = vec3(objPos)
rayCastStart.z = rayCastStart.z + objectHeights[index]
rayCastStart.z = rayCastStart.z + objectHeights[index]
local rayCastRes = castRayDown(rayCastStart, objPos - vec3(0,0,50))
objectTerrainOffsets[index] = 0
objectTerrainNormals[index] = vec3(0, 1, 0)
end
local rayCastRes = castRayDown(rayStart + vec3(0, 0, selectionBox.maxExtents.z), rayStart - vec3(0, 0, selectionBox.maxExtents.z + 50))
if rayCastRes then
local rayCastRes = castRayDown(rayStart + vec3(0, 0, selectionBox.maxExtents.z), rayStart - vec3(0, 0, selectionBox.maxExtents.z + 50))
if rayCastRes then
newGizmoTerrainHeight = 0
newGizmoTerrainNormal = vec3(0, 1, 0)
end
local objectTerrainHeight = core_terrain.getTerrainHeight(newPos) or 0
local objectTerrainNormal = core_terrain.getTerrainSmoothNormal(newPos) or vec3(0, 1, 0)
local skipTranslation = false
if editor.getPreference("snapping.terrain.useRayCast") then
local rayCastStart = vec3(newPos)
rayCastStart.z = rayCastStart.z + objectHeights[index]
rayCastStart.z = rayCastStart.z + objectHeights[index]
local rayCastRes = castRayDown(rayCastStart, newPos - vec3(0,0,50))
@/lua/ge/extensions/tech/openStreetMapExporter.lua
for k, p in pairs(coords3d) do
coords2d[k] = vec3(p.x, p.y, 0.0)
end
keysToNodeMap[k] = ctr
local coord = vec3(v.x * scaleFactor + 45.0, v.y * scaleFactor + 45.0, v.z)
nodes[ctr] = coord
@/lua/ge/extensions/gameplay/sites/zone.lua
self.name = name or "Zone " .. self.id
self.color = vec3(1,1,1)
self.vertices = {}
self.vertices = {}
self.center = vec3(0,0,0)
self.labelPos = vec3(0,0,-math.huge)
self.center = vec3(0,0,0)
self.labelPos = vec3(0,0,-math.huge)
self._drawMode = 'faded'
self.aabb = {xMin = -math.huge, xMax = math.huge, yMin = -math.huge, yMax = math.huge, zMin = -math.huge, zMax = math.huge, invalid = true}
self.top = {pos = vec3(0,0,10), normal = vec3(0,0,1), active = false}
self.bot = {pos = vec3(0,0,-10), normal = vec3(0,0,-1), active = false}
self.aabb = {xMin = -math.huge, xMax = math.huge, yMin = -math.huge, yMax = math.huge, zMin = -math.huge, zMax = math.huge, invalid = true}
self.top = {pos = vec3(0,0,10), normal = vec3(0,0,1), active = false}
self.bot = {pos = vec3(0,0,-10), normal = vec3(0,0,-1), active = false}
self.top = {pos = vec3(0,0,10), normal = vec3(0,0,1), active = false}
self.bot = {pos = vec3(0,0,-10), normal = vec3(0,0,-1), active = false}
self.fenceDown = 0
self.top = {pos = vec3(0,0,10), normal = vec3(0,0,1), active = false}
self.bot = {pos = vec3(0,0,-10), normal = vec3(0,0,-1), active = false}
self.fenceDown = 0
self.name = data.name
self.color = vec3(data.color)
self.vertices = {}
for i, v in ipairs(data.vertices) do
table.insert(self.vertices,{pos = vec3(v)})
end
if data.top then
self.top.pos = vec3(data.top.pos)
self.top.normal = vec3(data.top.normal)
self.top.pos = vec3(data.top.pos)
self.top.normal = vec3(data.top.normal)
self.top.active = data.top.active or false
if data.bot then
self.bot.pos = vec3(data.bot.pos)
self.bot.normal = vec3(data.bot.normal)
self.bot.pos = vec3(data.bot.pos)
self.bot.normal = vec3(data.bot.normal)
self.bot.active = data.bot.active or false
function C:addVertex(pos, index)
table.insert(self.vertices,index or (#self.vertices+1),{pos = vec3(pos), radius = 5})
self:processVertices()
function C:processVertices()
self.center = vec3(0,0,-100000)
self.labelPos = vec3(0,0,-math.huge)
self.center = vec3(0,0,-100000)
self.labelPos = vec3(0,0,-math.huge)
self.aabb = {
self.labelPos = vec3(self.center)
self.labelPos.z = self.aabb.zMax + 5
function C:validPlanes()
return self.top.active and self.top.normal:dot(vec3(0,0, 1)) > 0
and self.bot.active and self.bot.normal:dot(vec3(0,0,-1)) > 0
return self.top.active and self.top.normal:dot(vec3(0,0, 1)) > 0
and self.bot.active and self.bot.normal:dot(vec3(0,0,-1)) > 0
end
self.top = {
pos = vec3(self.center.x, self.center.y, zMax + 5),
normal = vec3(0,0,1),
pos = vec3(self.center.x, self.center.y, zMax + 5),
normal = vec3(0,0,1),
active = true
self.bot = {
pos = vec3(self.center.x, self.center.y, zMin - 5),
normal = vec3(0,0,-1),
pos = vec3(self.center.x, self.center.y, zMin - 5),
normal = vec3(0,0,-1),
active = true
end
local l = vec3(0,0,1)
local ln = l:dot(plane.normal)
local d = (plane.pos - vertex):dot(plane.normal) / ln
return vertex + vec3(0,0,d)
end
for _, v in ipairs(self.vertices) do
local a, b, c, d = vec3(), vec3(), vec3(), vec3()
a:set(v.pos) a.z = a.z+self.fenceDown
for _, v in ipairs(self.vertices) do
local a, b, c, d = vec3(), vec3(), vec3(), vec3()
a:set(v.pos) a.z = a.z+self.fenceDown
for _, v in ipairs(self.vertices) do
local a, b, c, d = vec3(), vec3(), vec3(), vec3()
a:set(v.pos) a.z = a.z+self.fenceDown
for _, v in ipairs(self.vertices) do
local a, b, c, d = vec3(), vec3(), vec3(), vec3()
a:set(v.pos) a.z = a.z+self.fenceDown
for i, v in ipairs(self.vertices) do
debugDrawer:drawLine((self.labelPos), (v.pos+vec3(0,0,5)), ColorF(clr[1],clr[2],clr[3],shapeAlpha))
end
for i, v in ipairs(self.vertices) do
debugDrawer:drawCylinder((v.pos), (v.pos+vec3(0,0,5)), 0.5, ColorF(clr[1],clr[2],clr[3],shapeAlpha))
end
end
local t1, t2 = vec3(), vec3()
function C:drawMinimap(td)
end
local t1, t2 = vec3(), vec3()
function C:drawMinimap(td)
local fullAlphaDistance = defaultDrawDistance * 0.75
local a, b, c, d = vec3(), vec3(), vec3(), vec3()
local fullAlphaDistance = defaultDrawDistance * 0.75
local a, b, c, d = vec3(), vec3(), vec3(), vec3()
local fullAlphaDistance = defaultDrawDistance * 0.75
local a, b, c, d = vec3(), vec3(), vec3(), vec3()
local fullAlphaDistance = defaultDrawDistance * 0.75
local a, b, c, d = vec3(), vec3(), vec3(), vec3()
local cur, nex = v.pos, self.vertices[v.next].pos
local dist = (vec3(cur):z0() - vec3(nex):z0()):length()
local steps = math.max(math.floor((dist-0.1) / (maxStep)), 1)
local cur, nex = v.pos, self.vertices[v.next].pos
local dist = (vec3(cur):z0() - vec3(nex):z0()):length()
local steps = math.max(math.floor((dist-0.1) / (maxStep)), 1)
@/lua/ge/extensions/flowgraph/nodes/mission/knockAwayCheck.lua
if getObjectByID(id) and not string.find(getObjectByID(id):getInternalName() or "",'ignore') then
table.insert(wps, {name = id, pos = val.pos + vec3(0,0,self.data.zOffset), radius = 1})
modes[id] = 'default'
@/lua/ge/extensions/gameplay/rally/notebook/path.lua
-- Create waypoints
local wp_cs = pn.pacenoteWaypoints:create('corner start', vec3(corner.pos))
local wp_ce = pn.pacenoteWaypoints:create('corner end', vec3(corner.posEnd))
local wp_cs = pn.pacenoteWaypoints:create('corner start', vec3(corner.pos))
local wp_ce = pn.pacenoteWaypoints:create('corner end', vec3(corner.posEnd))
@/lua/ge/extensions/core/cameraModes/free.lua
function C:reset()
self.angularVelocity = vec3(0,0,0)
self.velocity = vec3(0,0,0)
self.angularVelocity = vec3(0,0,0)
self.velocity = vec3(0,0,0)
self.manualzoom = manualzoom()
self.translationDrag = 2
self.angularVelocity = vec3(0,0,0)
else
self.pos = vec3(0,0,0)
self.rot = vec3(0,0,0)
self.pos = vec3(0,0,0)
self.rot = vec3(0,0,0)
self.newtonTranslation = true
local inputVec, acc, forceVec, tempVec = vec3(), vec3(), vec3(), vec3()
local qdir, qdirLook = quat(), quat()
local inputVec, acc, forceVec, tempVec = vec3(), vec3(), vec3(), vec3()
local qdir, qdirLook = quat(), quat()
local inputVec, acc, forceVec, tempVec = vec3(), vec3(), vec3(), vec3()
local qdir, qdirLook = quat(), quat()
local inputVec, acc, forceVec, tempVec = vec3(), vec3(), vec3(), vec3()
local qdir, qdirLook = quat(), quat()
@/lua/ge/extensions/career/modules/tether.lua
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
vehId = vehId,
p1 = p1, r1 = r1, p2 = vec3(), r2 = r2,
callback = callback,
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/editor/objectTool.lua
{
vec3(-0.5, -0.5, -0.5),
vec3(-0.5, -0.5, 0.5),
vec3(-0.5, -0.5, -0.5),
vec3(-0.5, -0.5, 0.5),
vec3(-0.5, 0.5, -0.5),
vec3(-0.5, -0.5, 0.5),
vec3(-0.5, 0.5, -0.5),
vec3(-0.5, 0.5, 0.5),
vec3(-0.5, 0.5, -0.5),
vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5),
vec3(-0.5, 0.5, 0.5),
vec3(0.5, -0.5, -0.5),
vec3(0.5, -0.5, 0.5),
vec3(0.5, -0.5, -0.5),
vec3(0.5, -0.5, 0.5),
vec3(0.5, 0.5, -0.5),
vec3(0.5, -0.5, 0.5),
vec3(0.5, 0.5, -0.5),
vec3(0.5, 0.5, 0.5)
vec3(0.5, 0.5, -0.5),
vec3(0.5, 0.5, 0.5)
}
for i = 1, 8 do
pts[i] = objMat:mulP3F(vec3(cubePoints[i].x, cubePoints[i].y, cubePoints[i].z))
end
debugDrawer:drawSphere(pos, 0.3 * scl, ColorF(1, 0, 1, 1 * alpha))
debugDrawer:drawCylinder(pos, pos + (rot * vec3(0, -2 * scl, 0)), 0.1 * scl, ColorF(1, 0, 0, 1 * alpha))
debugDrawer:drawCylinder(pos, pos + (rot * vec3(0, 0, 2 * scl)), 0.1 * scl, ColorF(0, 0, 1, 1 * alpha))
debugDrawer:drawCylinder(pos, pos + (rot * vec3(0, -2 * scl, 0)), 0.1 * scl, ColorF(1, 0, 0, 1 * alpha))
debugDrawer:drawCylinder(pos, pos + (rot * vec3(0, 0, 2 * scl)), 0.1 * scl, ColorF(0, 0, 1, 1 * alpha))
debugDrawer:drawCylinder(pos, pos + (rot * vec3(2 * scl, 0, 0)), 0.1 * scl, ColorF(0, 1, 0, 1 * alpha))
debugDrawer:drawCylinder(pos, pos + (rot * vec3(0, 0, 2 * scl)), 0.1 * scl, ColorF(0, 0, 1, 1 * alpha))
debugDrawer:drawCylinder(pos, pos + (rot * vec3(2 * scl, 0, 0)), 0.1 * scl, ColorF(0, 1, 0, 1 * alpha))
return
local initialGizmoScale = vec3(1, 1, 1)
local function updateObjectSelectionAxisGizmo()
if editor.selection.object and editor.selection.object[1] then
local camDir = core_camera.getQuat() * vec3(0,1,0)
camDir = camDir * 10
-- Calculates new positions and prepares history action data
local camDir = core_camera.getQuat() * vec3(0,1,0)
camDir = camDir * 10
local function drawFrustumRect(frustum)
local topLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local topRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearTop() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomLeftFrustum = vec3(frustum:getNearLeft() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
local bottomRightFrustum = vec3(frustum:getNearRight() * 2, frustum:getNearDist() * 2, frustum:getNearBottom() * 2)
-- I need to add this 90deg x axis correction, dont know why quatFromDir doesnt properly create the rotation at default up (0,0,1)
mtxCorrection:setFromEuler(vec3((90 * math.pi) / 180.0, 0, 0))
angleAroundUpValue = angleAroundUpValue + imgui.GetIO().MouseWheel * 5 -- TODO: add this to prefs
angleAroundUpValue = angleAroundUpValue + imgui.GetIO().MouseWheel * 5 -- TODO: add this to prefs
mtxAngleAroundUp:setFromEuler(vec3(0, 0, (angleAroundUpValue * math.pi) / 180.0))
mtx:setFromQuatF(QuatF(rot.x, rot.y, rot.z, rot.w))
local topLeft2I = editor.screenToClient(Point2I(mouseDragStartPos.x, mouseDragStartPos.y))
local topLeft = vec3(topLeft2I.x, topLeft2I.y, 0)
local bottomRight = (topLeft + vec3(delta.x, delta.y, 0))
local topLeft = vec3(topLeft2I.x, topLeft2I.y, 0)
local bottomRight = (topLeft + vec3(delta.x, delta.y, 0))
@/lua/ge/extensions/flowgraph/nodes/vehicle/spawnVehicle.lua
local licenseText = self.pinIn.licenseText.value
local spawnPos = self.pinIn.pos.value and vec3(self.pinIn.pos.value)
local spawnRot = self.pinIn.rot.value and quat(self.pinIn.rot.value)
@/lua/ge/extensions/editor/slotTrafficEditor.lua
local upVector = vec3(0, 0, 1)
local downVector = vec3(0, 0, -1)
local upVector = vec3(0, 0, 1)
local downVector = vec3(0, 0, -1)
local linkLineColor = ColorF(0, 1, 0, 1)
local linkLineOffset = vec3(0, 0, 0.5)
local mouseButtonHeldOnNode = false
local dragMouseStartPos = vec3(0, 0, 0)
local dragStartPosition
nid = nid or getNewNodeName("manual", "")
mapNodes[nid] = {pos = vec3(pos), radius = radius, normal = map.surfaceNormal(pos, radius * 0.5), links = {}}
updateQt = true
local tailPos = n1.pos + right1 * offset1
local tipPos = vec3()
for j = 1, k do
mapNodes[nid] = {
pos = vec3(node.pos),
radius = node.radius,
radius = node.radius,
normal = vec3(node.normal or upVector),
links = {} -- Keep links temporarily for road tracing
end
node.pos = vec3(node.pos)
node.normal = vec3(node.normal)
node.pos = vec3(node.pos)
node.normal = vec3(node.normal)
end
-- Find the center of the road
local centerPos = vec3(0, 0, 0)
local count = 0
editor.setCameraPositionRotation(
centerPos + vec3(10, 10, 10), -- Position slightly offset from the center
Quat(0, 0, 0, 1) -- Default rotation
local perpendicularDir = linkDir:normalized():cross(upVector)
local p1 = node.pos + perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p2 = node.pos + -perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p1 = node.pos + perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p2 = node.pos + -perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p3 = mapNodes[otherNid].pos + -perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local p2 = node.pos + -perpendicularDir * node.radius + vec3(0, 0, 0.5)
local p3 = mapNodes[otherNid].pos + -perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local p4 = mapNodes[otherNid].pos + perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local p3 = mapNodes[otherNid].pos + -perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local p4 = mapNodes[otherNid].pos + perpendicularDir * mapNodes[otherNid].radius + vec3(0, 0, 0.5)
local hitDist1 = intersectsRay_Triangle(camPos, rayDir, p1, p2, p3)
if im.IsMouseClicked(0) and not (im.IsAnyItemHovered() or im.IsWindowHovered(im.HoveredFlags_AnyWindow)) then
dragMouseStartPos = vec3(im.GetMousePos().x, im.GetMousePos().y, 0)
if not editor.keyModifiers.alt then
for i, nodeId in ipairs(tempNodes) do
table.insert(nodeInfos, {nid = nodeId, pos = vec3(mapNodes[nodeId].pos), radius = mapNodes[nodeId].radius, links = deepcopy(mapNodes[nodeId].links)})
nodeIds[nodeId] = true
for nid, _ in pairs(editor.selection.stNode) do
newValues[nid] = vec3(mapNodes[nid].pos)
end
local cursorPosImVec = im.GetMousePos()
local cursorPos = vec3(cursorPosImVec.x, cursorPosImVec.y, 0)
local rayDist = castRayStatic(nodeOldPositions[nodeId] + nodeOffset + upVector, downVector, 10)
local newPos = nodeOldPositions[nodeId] + nodeOffset + vec3(0, 0, 1 - math.min(rayDist, 10))
setNodePosition(nodeId, newPos, true)
oldValues[nid] = node.pos
newValues[nid] = vec3(posArray[0], posArray[1], posArray[2])
editor.history:commitAction("PositionstNode", {nids = deepcopy(editor.selection.stNode), fieldName = "pos", oldValues = oldValues, newValues = newValues}, changeNodeFieldActionUndo, changeNodeFieldActionRedo)
for nid, _ in pairs(editor.selection.stNode) do
local nodeInfo = {nid = nid, pos = vec3(mapNodes[nid].pos), radius = mapNodes[nid].radius, links = deepcopy(mapNodes[nid].links)}
table.insert(nodeInfos, nodeInfo)
@/lua/ge/extensions/flowgraph/nodes/debug/debugPrism.lua
debugDrawer:drawSquarePrism(
vec3(self.pinIn.posA.value),
vec3(self.pinIn.posB.value),
vec3(self.pinIn.posA.value),
vec3(self.pinIn.posB.value),
Point2F(self.pinIn.heightA.value or 1, self.pinIn.widthA.value or 1),
@/gameplay/missionTypes/scatterPickup/customNodes/scatterCollectNode.lua
self:setDurationState('started')
self.origin = vec3(self.pinIn.pos.value)
self.radius = maxInitialRadius
if gameplay_walk.isWalking() then
self.origin =core_camera.getPosition() + core_camera.getQuat()*vec3(0,walkingOffset,0)
self.radius = walkingRadius
@/lua/ge/extensions/flowgraph/nodes/gameplay/rally/rallyMoveVehicleTo.lua
-- make copies so we dont clobber memory
local targetPos = vec3(self.pinIn.pos.value)
local targetRot = quat(self.pinIn.rot.value)
-- Get vehicle OOBB points to calculate local offset (like calculateVehiclePosRot)
local fl = vec3(veh:getSpawnWorldOOBB():getPoint(0))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local fl = vec3(veh:getSpawnWorldOOBB():getPoint(0))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local flU = vec3(veh:getSpawnWorldOOBB():getPoint(1))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local flU = vec3(veh:getSpawnWorldOOBB():getPoint(1))
local posOffset = pos - frontBottom
local localOffset = vec3(xVeh:dot(posOffset), yVeh:dot(posOffset), zVeh:dot(posOffset))
-- Calculate new coordinate axes from target rotation
local xLine = targetRot * vec3(1, 0, 0)
local yLine = targetRot * vec3(0, 1, 0)
local xLine = targetRot * vec3(1, 0, 0)
local yLine = targetRot * vec3(0, 1, 0)
local zLine = targetRot * vec3(0, 0, 1)
local yLine = targetRot * vec3(0, 1, 0)
local zLine = targetRot * vec3(0, 0, 1)
@/lua/common/tech/techUtils.lua
-- first, try a reasonable position for the raycast - two meters above the object
local topPos = vec3(pos.x, pos.y, pos.z + 2)
local height = get:getSurfaceHeightBelow(topPos)
if type(tbl.x) == 'number' and type(tbl.y) == 'number' and type(tbl.z) == 'number' then
if tbl.w == nil then return vec3(tbl.x, tbl.y, tbl.z) end
if type(tbl.w) == 'number' then return quat(tbl.x, tbl.y, tbl.z, tbl.w) end
@/lua/ge/extensions/flowgraph/nodes/gameplay/rally/vehicleStoppedNearPlane.lua
self.pos = vec3()
self.rot = quat()
self.isStagedValue = false
self.pos = vec3()
self.rot = quat()
local veh, vehicleData
local vehPos, vehVel = vec3(), vec3()
-- Reusable temporary vectors for core calculations (avoid per-frame allocations)
local veh, vehicleData
local vehPos, vehVel = vec3(), vec3()
-- Reusable temporary vectors for core calculations (avoid per-frame allocations)
-- Reusable temporary vectors for core calculations (avoid per-frame allocations)
local tmpVec1, tmpVec2 = vec3(), vec3()
-- Reusable temporary vectors for core calculations (avoid per-frame allocations)
local tmpVec1, tmpVec2 = vec3(), vec3()
local tmpPlaneNormal = vec3()
local tmpToVehicle = vec3()
local tmpPlaneNormal = vec3()
local tmpToVehicle = vec3()
local tmpClosestPoint = vec3()
local tmpToVehicle = vec3()
local tmpClosestPoint = vec3()
local tmpMidPoint = vec3()
local tmpClosestPoint = vec3()
local tmpMidPoint = vec3()
@/lua/ge/extensions/editor/rallyEditor/measurementsTab.lua
-- Convert table to vec3
table.insert(deserializedPoints, vec3(point.x, point.y, point.z))
end
-- Draw intersection plane
local normal = vec3(0, 1, 0) -- default forward direction
if snapPoint and snapPoint.next and snapPoint.next.pos then
normal = (vec3(snapPoint.next.pos) - pos):normalized()
end
local midWidth = plane_radius * 2
local side = normal:cross(vec3(0, 0, 1)) * (plane_radius - (midWidth / 2))
if measurement.id == self.selectedMeasurementId then
local labelPos = pos + vec3(0, 0, 2) -- offset upward for visibility
if i == 1 or i == #measurement.points then
local measurementLabelPos = pos + vec3(0, 0, 4) -- higher up for visibility
local distanceText = string.format("%s | %.2fm", measurement.name, measurement.totalDistance)
debugDrawer:drawSquarePrism(
point1, vec3(seg1P2.pos),
Point2F(ROUTE_PRISM_SIZE, ROUTE_PRISM_SIZE),
if drivelinePoints[j] and drivelinePoints[j+1] then
local pos1 = vec3(drivelinePoints[j].pos)
local pos2 = vec3(drivelinePoints[j+1].pos)
local pos1 = vec3(drivelinePoints[j].pos)
local pos2 = vec3(drivelinePoints[j+1].pos)
debugDrawer:drawSquarePrism(
debugDrawer:drawSquarePrism(
vec3(seg2P1.pos), point2,
Point2F(ROUTE_PRISM_SIZE, ROUTE_PRISM_SIZE),
debugDrawer:drawSquarePrism(
point1, vec3(seg1P1.pos),
Point2F(ROUTE_PRISM_SIZE, ROUTE_PRISM_SIZE),
if drivelinePoints[j] and drivelinePoints[j+1] then
local pos1 = vec3(drivelinePoints[j].pos)
local pos2 = vec3(drivelinePoints[j+1].pos)
local pos1 = vec3(drivelinePoints[j].pos)
local pos2 = vec3(drivelinePoints[j+1].pos)
debugDrawer:drawSquarePrism(
debugDrawer:drawSquarePrism(
point2, vec3(seg2P2.pos),
Point2F(ROUTE_PRISM_SIZE, ROUTE_PRISM_SIZE),
if measurement then
local pos = vec3(point)
-- Both points on the same segment
local segmentLength = (vec3(seg1P2.pos) - vec3(seg1P1.pos)):length()
distance = segmentLength * math.abs(xnorm2 - xnorm1)
-- Both points on the same segment
local segmentLength = (vec3(seg1P2.pos) - vec3(seg1P1.pos)):length()
distance = segmentLength * math.abs(xnorm2 - xnorm1)
-- Distance from point1 to end of its segment
local seg1Length = (vec3(seg1P2.pos) - vec3(seg1P1.pos)):length()
distance = distance + seg1Length * (1 - xnorm1)
-- Distance from point1 to end of its segment
local seg1Length = (vec3(seg1P2.pos) - vec3(seg1P1.pos)):length()
distance = distance + seg1Length * (1 - xnorm1)
if drivelinePoints[j] and drivelinePoints[j+1] then
local pos1 = vec3(drivelinePoints[j].pos)
local pos2 = vec3(drivelinePoints[j+1].pos)
local pos1 = vec3(drivelinePoints[j].pos)
local pos2 = vec3(drivelinePoints[j+1].pos)
distance = distance + (pos2 - pos1):length()
-- Distance from start of point2's segment to point2
local seg2Length = (vec3(seg2P2.pos) - vec3(seg2P1.pos)):length()
distance = distance + seg2Length * xnorm2
-- Distance from start of point2's segment to point2
local seg2Length = (vec3(seg2P2.pos) - vec3(seg2P1.pos)):length()
distance = distance + seg2Length * xnorm2
-- Distance from point1 back to start of its segment
local seg1Length = (vec3(seg1P2.pos) - vec3(seg1P1.pos)):length()
distance = distance + seg1Length * xnorm1
-- Distance from point1 back to start of its segment
local seg1Length = (vec3(seg1P2.pos) - vec3(seg1P1.pos)):length()
distance = distance + seg1Length * xnorm1
if drivelinePoints[j] and drivelinePoints[j+1] then
local pos1 = vec3(drivelinePoints[j].pos)
local pos2 = vec3(drivelinePoints[j+1].pos)
local pos1 = vec3(drivelinePoints[j].pos)
local pos2 = vec3(drivelinePoints[j+1].pos)
distance = distance + (pos2 - pos1):length()
-- Distance from point2 to end of its segment
local seg2Length = (vec3(seg2P2.pos) - vec3(seg2P1.pos)):length()
distance = distance + seg2Length * (1 - xnorm2)
-- Distance from point2 to end of its segment
local seg2Length = (vec3(seg2P2.pos) - vec3(seg2P1.pos)):length()
distance = distance + seg2Length * (1 - xnorm2)
self.draggedPointIndex = self.hoverPointIndex
self.lastMousePos = vec3(pos_rayCast) -- Store initial mouse position
local xnorm = pos_rayCast:xnormOnLine(bestP1.pos, bestP2.pos)
continuousPos = vec3(lerp(bestP1.pos, bestP2.pos, clamp(xnorm, 0, 1)))
end
-- Calculate mouse movement delta (XY only)
local deltaXY = vec3(pos_rayCast.x - self.lastMousePos.x,
pos_rayCast.y - self.lastMousePos.y,
local newPos = lerp(bestP1.pos, bestP2.pos, clamp(xnorm, 0, 1))
selectedMeasurement.points[self.draggedPointIndex] = vec3(newPos)
else
else
selectedMeasurement.points[self.draggedPointIndex] = vec3(targetPos)
end
else
selectedMeasurement.points[self.draggedPointIndex] = vec3(targetPos)
end
self.lastMousePos = vec3(pos_rayCast)
self:calculateMeasurementDistance(self.selectedMeasurementId)
local xnorm = pos_rayCast:xnormOnLine(bestP1.pos, bestP2.pos)
continuousPos = vec3(lerp(bestP1.pos, bestP2.pos, clamp(xnorm, 0, 1)))
end
-- Draw label for adding new point
local labelPos = continuousPos + vec3(0, 0, 2)
debugDrawer:drawTextAdvanced(
@/lua/ge/extensions/editor/rayCastTest.lua
local rayCastModes = {"Gameengine Raycast", "Physics Raycast"}
local upVec = vec3(0,0,1)
local maxRayDist = 200
debugDrawer:drawSphere(pos, 0.2, ColorF(1, 0.5, 0.2, 0.25))
debugDrawer:drawLine(pos, (vec3(pos) + vec3(0, 0, 4)), ColorF(1, 0, 0, 0.25))
debugDrawer:drawSphere((vec3(pos) + vec3(0, 0, 4)), 0.2, ColorF(0, 1, 0.2, 0.25))
debugDrawer:drawSphere(pos, 0.2, ColorF(1, 0.5, 0.2, 0.25))
debugDrawer:drawLine(pos, (vec3(pos) + vec3(0, 0, 4)), ColorF(1, 0, 0, 0.25))
debugDrawer:drawSphere((vec3(pos) + vec3(0, 0, 4)), 0.2, ColorF(0, 1, 0.2, 0.25))
debugDrawer:drawLine(pos, (vec3(pos) + vec3(0, 0, 4)), ColorF(1, 0, 0, 0.25))
debugDrawer:drawSphere((vec3(pos) + vec3(0, 0, 4)), 0.2, ColorF(0, 1, 0.2, 0.25))
end
debugDrawer:drawLine(pos, (vec3(pos) + vec3(0, 0, 4)), ColorF(1, 0, 0, 0.25))
debugDrawer:drawSphere((vec3(pos) + vec3(0, 0, 4)), 0.2, ColorF(0, 1, 0.2, 0.25))
end
if rayCastInfo and rayCastInfo.object then
helperTransform:setPosition(vec3(rayCastInfo.pos.x, rayCastInfo.pos.y, rayCastInfo.pos.z))
end
if core_forest.getForestObject() then core_forest.getForestObject():disableCollision() end
local hit = Engine.castRay((vec3(pos) + vec3(0, 0, 4)), (vec3(pos) + vec3(0, 0, -4)), true, false)
if core_forest.getForestObject() then core_forest.getForestObject():enableCollision() end
if core_forest.getForestObject() then core_forest.getForestObject():disableCollision() end
local hit = Engine.castRay((vec3(pos) + vec3(0, 0, 4)), (vec3(pos) + vec3(0, 0, -4)), true, false)
if core_forest.getForestObject() then core_forest.getForestObject():enableCollision() end
if core_forest.getForestObject() then core_forest.getForestObject():disableCollision() end
local hit = Engine.castRay((vec3(pos) + vec3(0, 0, 4)), (vec3(pos) + vec3(0, 0, -4)), true, false)
if core_forest.getForestObject() then core_forest.getForestObject():enableCollision() end
if core_forest.getForestObject() then core_forest.getForestObject():disableCollision() end
local hit = Engine.castRay((vec3(pos) + vec3(0, 0, 4)), (vec3(pos) + vec3(0, 0, -4)), true, false)
if core_forest.getForestObject() then core_forest.getForestObject():enableCollision() end
debugDrawer:drawSphere(hit.pt, 0.1, ColorF(0, 1, 0, 1))
debugDrawer:drawLine(hit.pt, (vec3(hit.pt) + vec3(hit.norm)), ColorF(0, 1, 1, 1))
debugDrawer:drawSphere((vec3(hit.pt) + vec3(hit.norm)), 0.08, ColorF(0, 1, 1, 1))
debugDrawer:drawSphere(hit.pt, 0.1, ColorF(0, 1, 0, 1))
debugDrawer:drawLine(hit.pt, (vec3(hit.pt) + vec3(hit.norm)), ColorF(0, 1, 1, 1))
debugDrawer:drawSphere((vec3(hit.pt) + vec3(hit.norm)), 0.08, ColorF(0, 1, 1, 1))
debugDrawer:drawLine(hit.pt, (vec3(hit.pt) + vec3(hit.norm)), ColorF(0, 1, 1, 1))
debugDrawer:drawSphere((vec3(hit.pt) + vec3(hit.norm)), 0.08, ColorF(0, 1, 1, 1))
end
debugDrawer:drawLine(hit.pt, (vec3(hit.pt) + vec3(hit.norm)), ColorF(0, 1, 1, 1))
debugDrawer:drawSphere((vec3(hit.pt) + vec3(hit.norm)), 0.08, ColorF(0, 1, 1, 1))
end
elseif editor.getPreference("raycastTest.general.rayCastMode") == 1 then
local camPos = vec3(camMouseRay.pos)
local camMouseRayDir = vec3(camMouseRay.dir)
local camPos = vec3(camMouseRay.pos)
local camMouseRayDir = vec3(camMouseRay.dir)
local camRot = core_camera.getQuat()
@/lua/ge/extensions/util/groundModelDebug.lua
-- mouse
local focusPos = vec3(Lua.lastDebugFocusPos)
if mouseFocus[0] then
--if res.object then res.object:delete() end
focusPos = vec3(res.pos)
debugDrawer:drawSphere(focusPos, 0.03, ColorF(0,1,0,1))
data.color = ColorF(1, 0, 0, 0.75)
data.forwardVec = vec3(0, 1, 0)
data.scale = (vec3(1,1,1) * distance[0])
data.forwardVec = vec3(0, 1, 0)
data.scale = (vec3(1,1,1) * distance[0])
Engine.Render.DynamicDecalMgr.addDecal(data)
@/lua/ge/extensions/freeroam/crashCamMode.lua
local startPathTimer -- timing offset for starting the path cam
local seed = vec3(math.random(), math.random(), math.random())
local zVec = vec3(0,0,1)
local seed = vec3(math.random(), math.random(), math.random())
local zVec = vec3(0,0,1)
local function rotateAroundVec(point, rotationVec, angle)
local res = vec3(point)
rotMtx:setFromEuler(vec3(0,0,angle))
local res = vec3(point)
rotMtx:setFromEuler(vec3(0,0,angle))
local localToWorldSpace = rotationVec:getRotationTo(zVec)
hitPoint = hitPoint or (crashCamData.futureBB1Center + crashCamData.futureBB2:getCenter()) * 0.5
local camOffset = vec3(0,0,5) + seed:getBluePointInCircle(2)
return hitPoint, camOffset
local startPos = core_camera.getPosition()
local offset1 = crashCamData.velocity:cross(vec3(0,0,1)):normalized() * 6
local offset2 = crashCamData.velocity:normalized() * 6
local playerBBCenter = vec3()
local playerPos = vec3()
local playerPosLast = vec3()
local playerPos = vec3()
local playerPosLast = vec3()
local playerVel = vec3()
local playerPosLast = vec3()
local playerVel = vec3()
local playerVelLast = vec3()
local playerVel = vec3()
local playerVelLast = vec3()
local futurePlayerBBCenter = vec3()
local playerVelLast = vec3()
local futurePlayerBBCenter = vec3()
local playerAxis0, playerAxis1, playerAxis2 = vec3(), vec3(), vec3()
local futurePlayerBBCenter = vec3()
local playerAxis0, playerAxis1, playerAxis2 = vec3(), vec3(), vec3()
local playerBBHalfAxis0, playerBBHalfAxis1, playerBBHalfAxis2 = vec3(), vec3(), vec3()
local futurePlayerBBCenter = vec3()
local playerAxis0, playerAxis1, playerAxis2 = vec3(), vec3(), vec3()
local playerBBHalfAxis0, playerBBHalfAxis1, playerBBHalfAxis2 = vec3(), vec3(), vec3()
local futurePlayerBBCenter = vec3()
local playerAxis0, playerAxis1, playerAxis2 = vec3(), vec3(), vec3()
local playerBBHalfAxis0, playerBBHalfAxis1, playerBBHalfAxis2 = vec3(), vec3(), vec3()
local playerAxis0, playerAxis1, playerAxis2 = vec3(), vec3(), vec3()
local playerBBHalfAxis0, playerBBHalfAxis1, playerBBHalfAxis2 = vec3(), vec3(), vec3()
local playerAxis0, playerAxis1, playerAxis2 = vec3(), vec3(), vec3()
local playerBBHalfAxis0, playerBBHalfAxis1, playerBBHalfAxis2 = vec3(), vec3(), vec3()
local playerAxis0, playerAxis1, playerAxis2 = vec3(), vec3(), vec3()
local playerBBHalfAxis0, playerBBHalfAxis1, playerBBHalfAxis2 = vec3(), vec3(), vec3()
local playerVelNormalized = vec3()
local otherVehPos = vec3()
local otherVel = vec3()
local otherVehPos = vec3()
local otherVel = vec3()
local otherBBHalfAxis0, otherBBHalfAxis1, otherBBHalfAxis2 = vec3(), vec3(), vec3()
local otherVel = vec3()
local otherBBHalfAxis0, otherBBHalfAxis1, otherBBHalfAxis2 = vec3(), vec3(), vec3()
local futureOtherBBCenter = vec3()
local otherVel = vec3()
local otherBBHalfAxis0, otherBBHalfAxis1, otherBBHalfAxis2 = vec3(), vec3(), vec3()
local futureOtherBBCenter = vec3()
local otherVel = vec3()
local otherBBHalfAxis0, otherBBHalfAxis1, otherBBHalfAxis2 = vec3(), vec3(), vec3()
local futureOtherBBCenter = vec3()
local otherBBHalfAxis0, otherBBHalfAxis1, otherBBHalfAxis2 = vec3(), vec3(), vec3()
local futureOtherBBCenter = vec3()
local trafficVehicleIds = {}
-- Choose a candidate
local candidate = vec3(startPos)
candidate = startPos + vec3(0,0,5) + seed:getBluePointInCircle(2)
local candidate = vec3(startPos)
candidate = startPos + vec3(0,0,5) + seed:getBluePointInCircle(2)
-- place bottomPoints "staticCollisionRayCastOffset" m apart
if not bottomPoints[1] then bottomPoints[1] = vec3() end
bottomPoints[1]:set(push3(playerBBCenter) - push3(playerAxis1) * (halfExtentsY - 0.2))
for offset = staticCollisionRayCastOffset, halfExtentsX - outerPointsOffsetFromEdge, staticCollisionRayCastOffset do
if not bottomPoints[counter] then bottomPoints[counter] = vec3() end
bottomPoints[counter]:set(push3(bottomPoints[1]) - push3(playerAxis0) * offset)
if not bottomPoints[counter] then bottomPoints[counter] = vec3() end
bottomPoints[counter]:set(push3(bottomPoints[1]) + push3(playerAxis0) * offset)
local playerUpVec = vec3()
local function rolloverCheck(dtSim)
local bbCenter = vec3()
local function crashCheckBasedOnVelocity(dtSim)
crashCamData.hitPoint = vec3(crashPos)
end
playerVelAtLastCheckpoint = playerVelAtLastCheckpoint or vec3()
playerVelAtLastCheckpoint:set(playerVel)
@/lua/ge/extensions/editor/crawlEditor/boundaries.lua
self.currentPlane = nil
self._prevGizmoPos = vec3(0, 0, 0)
self._prevVerticesPos = {}
if im.Button("Add Vertex") then
local pos = vec3(0, 0, 0)
if #boundary.vertices > 0 then
local lastVertex = boundary.vertices[#boundary.vertices]
pos = lastVertex.pos + vec3(10, 0, 0)
end
if #self.currentVertices > 0 then
local centroid = vec3(0, 0, 0)
for _, vertex in ipairs(self.currentVertices) do
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
local q = quatFromDir(quatFromEuler(0, math.pi / 2, 0) * self.currentPlane.normal, vec3(0, 0, 1))
rotation = QuatF(q.x, q.y, q.z, q.w)
function C:beginDrag()
self._prevGizmoPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
if self.currentPlane then
self.beginDragRotation = deepcopy(quatFromDir(quatFromEuler(0, math.pi / 2, 0) * self.currentPlane.normal, vec3(0, 0, 1)))
end
local posOffset = (vec3(editor.getAxisGizmoTransform():getColumn(3)) - self._prevGizmoPos) / 2
end
debugDrawer:drawLine((vertex.pos + vec3(0, 0, -1000)), (vertex.pos + vec3(0, 0, 1000)), ColorF(0, 0, 1, 1))
end
end
debugDrawer:drawLine((vertex.pos + vec3(0, 0, -1000)), (vertex.pos + vec3(0, 0, 1000)), ColorF(0, 0, 1, 1))
end
if self.currentPlane then
self.currentPlane.pos = vec3(editor.getAxisGizmoTransform():getColumn(3))
end
if #self.currentVertices > 1 then
local centroid = vec3(0, 0, 0)
for _, vertex in ipairs(self.currentVertices) do
if editor.getAxisGizmoAlignment() == editor.AxisGizmoAlignment_Local then
self.currentPlane.normal = quat(rotation) * vec3(0, 0, 1)
else
else
self.currentPlane.normal = self.beginDragRotation * quat(rotation) * vec3(0, 0, 1)
end
self._prevGizmoPos = vec3(editor.getAxisGizmoTransform():getColumn(3))
end
function C:dropToTerrain(pos)
local p = vec3(pos)
if core_terrain then
local tbl = {self.fields[name][0],self.fields[name][1],self.fields[name][2]}
fields.values[name] = vec3(tbl)
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veNodeTriSelfCollisionDetector.lua
local tempNodePositionsUpdated = {}
local tempTriPos = vec3()
if not tempNodePositions[nodeId] then
tempNodePositions[nodeId] = vec3()
end
@/lua/ge/extensions/editor/api/dynamicDecals.lua
lyr["blendMode"] = layer.blendMode
lyr["decalPos"] = layer.decalPos and vec3(layer.decalPos.x, layer.decalPos.y, layer.decalPos.z) or nil
lyr["decalNorm"] = layer.decalNorm and vec3(layer.decalNorm.x, layer.decalNorm.y, layer.decalNorm.z) or nil
lyr["decalPos"] = layer.decalPos and vec3(layer.decalPos.x, layer.decalPos.y, layer.decalPos.z) or nil
lyr["decalNorm"] = layer.decalNorm and vec3(layer.decalNorm.x, layer.decalNorm.y, layer.decalNorm.z) or nil
lyr["camDirection"] = vec3(layer.camDirection.x, layer.camDirection.y, layer.camDirection.z)
lyr["decalNorm"] = layer.decalNorm and vec3(layer.decalNorm.x, layer.decalNorm.y, layer.decalNorm.z) or nil
lyr["camDirection"] = vec3(layer.camDirection.x, layer.camDirection.y, layer.camDirection.z)
lyr["camPosition"] = vec3(layer.camPosition.x, layer.camPosition.y, layer.camPosition.z)
lyr["camDirection"] = vec3(layer.camDirection.x, layer.camDirection.y, layer.camDirection.z)
lyr["camPosition"] = vec3(layer.camPosition.x, layer.camPosition.y, layer.camPosition.z)
lyr["color"] = Point4F.fromTable(layer.color)
lyr["decalRoughnessTexturePath"] = layer.decalRoughnessTexturePath
lyr["decalScale"] = vec3(layer.decalScale.x, layer.decalScale.y, layer.decalScale.z)
lyr["decalSkew"] = Point2F.fromTable(layer.decalSkew)
lyr["useLockedSurfaceNormal"] = layer.useLockedSurfaceNormal or false
lyr["surfaceNormal"] = layer.surfaceNormal and vec3(layer.decalPos.x, layer.decalPos.y, layer.decalPos.z) or vec3(0, 0, 0)
-- sdf
lyr["useLockedSurfaceNormal"] = layer.useLockedSurfaceNormal or false
lyr["surfaceNormal"] = layer.surfaceNormal and vec3(layer.decalPos.x, layer.decalPos.y, layer.decalPos.z) or vec3(0, 0, 0)
-- sdf
lyr["blendMode"] = layer.blendMode
lyr["camDirection"] = vec3(layer.camDirection.x, layer.camDirection.y, layer.camDirection.z)
lyr["camPosition"] = vec3(layer.camPosition.x, layer.camPosition.y, layer.camPosition.z)
lyr["camDirection"] = vec3(layer.camDirection.x, layer.camDirection.y, layer.camDirection.z)
lyr["camPosition"] = vec3(layer.camPosition.x, layer.camPosition.y, layer.camPosition.z)
lyr["color"] = Point4F.fromTable(layer.color)
lyr["decalRoughnessTexturePath"] = layer.decalRoughnessTexturePath
lyr["decalScale"] = vec3(layer.decalScale.x, layer.decalScale.y, layer.decalScale.z)
lyr["decalSkew"] = Point2F.fromTable(layer.decalSkew)
lyr["blendMode"] = layer.blendMode
lyr["camDirection"] = vec3(layer.camDirection.x, layer.camDirection.y, layer.camDirection.z)
lyr["camPosition"] = vec3(layer.camPosition.x, layer.camPosition.y, layer.camPosition.z)
lyr["camDirection"] = vec3(layer.camDirection.x, layer.camDirection.y, layer.camDirection.z)
lyr["camPosition"] = vec3(layer.camPosition.x, layer.camPosition.y, layer.camPosition.z)
lyr["color"] = Point4F.fromTable(layer.color)
lyr["decalRoughnessTexturePath"] = layer.decalRoughnessTexturePath
lyr["decalScale"] = vec3(layer.decalScale.x, layer.decalScale.y, layer.decalScale.z)
lyr["decalSkew"] = Point2F.fromTable(layer.decalSkew)
decalProjection:setWorldTransform(veh:getRefNodeMatrix())
decalProjection:setRenderTransform(veh:getRefNodeMatrix():copy():setPosition(vec3(0, 0, 0)):inverse())
decalProjection:setMirrorOffset(veh:getSpawnLocalAABB():getCenter().x + mirrorPlaneOffset)
local change = (step_number or sizeStep) * (increase_bool and 1 or -1)
decalProjection.decalScale = vec3(scale.x + change, scale.y, scale.z + change)
end
local dotVal = -delta_vec3.y
local rotUpvec = vec3(math.sin(dotVal), 0, math.cos(dotVal)):normalized()
local oldTransform = decalProjection:getDecalWorldTransform(layer)
local newTransform = MatrixF(true)
newTransform:setColumn(0, vec3(0, 1, 0):cross(rotUpvec):normalized())
newTransform:setColumn(1, vec3(0, 1, 0))
newTransform:setColumn(0, vec3(0, 1, 0):cross(rotUpvec):normalized())
newTransform:setColumn(1, vec3(0, 1, 0))
newTransform:setColumn(2, rotUpvec)
local newTransform = oldTransform:copy()
newTransform:scale(vec3(1, 1, 1) + delta_vec3)
decalProjection:setDecalWorldTransform(newLayer, newTransform)
@/gameplay/missionTypes/cannon/customNodes/cannonBallInfoNode.lua
local pos = scenetree.findObjectById(id):getPosition()
local dist = (pos - vec3(self.pinIn.ballPos.value)):length()
if dist < insideThreshold then
local targetCamPos = pos - (pos - core_camera.getPosition()):normalized() * 15 --pos + (targetCamOff:normalized()) * camDist
local targetCamRot = quatFromDir(pos - targetCamPos, vec3(0,0,1))
self.pinOut.camOffsetPos.value = (pos - targetCamPos):toTable()
@/lua/ge/extensions/freeroam/bigMapMode.lua
local xVector = vec3(1,0,0)
local yVector = vec3(0,1,0)
local xVector = vec3(1,0,0)
local yVector = vec3(0,1,0)
local zVector = vec3(0,0,1)
local yVector = vec3(0,1,0)
local zVector = vec3(0,0,1)
local invisibleColor = ColorI(255,255,255,0)
local pureWhite = ColorI(255,255,255,255)
local upVector = vec3(0,0,1)
local extents = mapBoundaries:getExtents()
local edgePoint1 = vec3((mapBoundaries.maxExtents.x + mapBoundaries.minExtents.x) / 2, mapBoundaries.minExtents.y, mapBoundaries.maxExtents.z)
local rayMaxDist = extents.z * 1.1
local rayMaxDist = extents.z * 1.1
local rayDist = castRayStatic(edgePoint1, vec3(0,0,-1), rayMaxDist)
if rayDist < rayMaxDist then
end
local edgePoint2 = vec3(mapBoundaries.minExtents.x, (mapBoundaries.maxExtents.y + mapBoundaries.minExtents.y) / 2, mapBoundaries.maxExtents.z)
local rayDist = castRayStatic(edgePoint2, vec3(0,0,-1), rayMaxDist)
local edgePoint2 = vec3(mapBoundaries.minExtents.x, (mapBoundaries.maxExtents.y + mapBoundaries.minExtents.y) / 2, mapBoundaries.maxExtents.z)
local rayDist = castRayStatic(edgePoint2, vec3(0,0,-1), rayMaxDist)
if rayDist < rayMaxDist then
end
local edgePoint3 = vec3((mapBoundaries.maxExtents.x + mapBoundaries.minExtents.x) / 2, mapBoundaries.maxExtents.y, mapBoundaries.maxExtents.z)
local rayDist = castRayStatic(edgePoint3, vec3(0,0,-1), rayMaxDist)
local edgePoint3 = vec3((mapBoundaries.maxExtents.x + mapBoundaries.minExtents.x) / 2, mapBoundaries.maxExtents.y, mapBoundaries.maxExtents.z)
local rayDist = castRayStatic(edgePoint3, vec3(0,0,-1), rayMaxDist)
if rayDist < rayMaxDist then
end
local edgePoint4 = vec3(mapBoundaries.maxExtents.x, (mapBoundaries.maxExtents.y + mapBoundaries.minExtents.y) / 2, mapBoundaries.maxExtents.z)
local rayDist = castRayStatic(edgePoint4, vec3(0,0,-1), rayMaxDist)
local edgePoint4 = vec3(mapBoundaries.maxExtents.x, (mapBoundaries.maxExtents.y + mapBoundaries.minExtents.y) / 2, mapBoundaries.maxExtents.z)
local rayDist = castRayStatic(edgePoint4, vec3(0,0,-1), rayMaxDist)
if rayDist < rayMaxDist then
end
local rot1 = quatFromDir(vec3(-1,0,0), vec3(0,0.6,1))
local rot2 = quatFromDir(vec3(0,1,0), vec3(0.6,0,1))
end
local rot1 = quatFromDir(vec3(-1,0,0), vec3(0,0.6,1))
local rot2 = quatFromDir(vec3(0,1,0), vec3(0.6,0,1))
local rot1 = quatFromDir(vec3(-1,0,0), vec3(0,0.6,1))
local rot2 = quatFromDir(vec3(0,1,0), vec3(0.6,0,1))
local rot3 = quatFromDir(vec3(1,0,0), vec3(0,-0.6,1))
local rot1 = quatFromDir(vec3(-1,0,0), vec3(0,0.6,1))
local rot2 = quatFromDir(vec3(0,1,0), vec3(0.6,0,1))
local rot3 = quatFromDir(vec3(1,0,0), vec3(0,-0.6,1))
local rot2 = quatFromDir(vec3(0,1,0), vec3(0.6,0,1))
local rot3 = quatFromDir(vec3(1,0,0), vec3(0,-0.6,1))
local rot4 = quatFromDir(vec3(0,-1,0), vec3(-0.6,0,1))
local rot2 = quatFromDir(vec3(0,1,0), vec3(0.6,0,1))
local rot3 = quatFromDir(vec3(1,0,0), vec3(0,-0.6,1))
local rot4 = quatFromDir(vec3(0,-1,0), vec3(-0.6,0,1))
local rot3 = quatFromDir(vec3(1,0,0), vec3(0,-0.6,1))
local rot4 = quatFromDir(vec3(0,-1,0), vec3(-0.6,0,1))
mapBoundsFogPool[1]:setPosRot(edgePoint1.x, edgePoint1.y, edgePoint1.z, rot1.x, rot1.y, rot1.z, rot1.w)
local rot3 = quatFromDir(vec3(1,0,0), vec3(0,-0.6,1))
local rot4 = quatFromDir(vec3(0,-1,0), vec3(-0.6,0,1))
mapBoundsFogPool[1]:setPosRot(edgePoint1.x, edgePoint1.y, edgePoint1.z, rot1.x, rot1.y, rot1.z, rot1.w)
mapBoundsFogPool[4]:setPosRot(edgePoint4.x, edgePoint4.y, edgePoint4.z, rot4.x, rot4.y, rot4.z, rot4.w)
mapBoundsFogPool[1]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.x/1000 * 6, 1))
mapBoundsFogPool[2]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.y/1000 * 6, 1))
mapBoundsFogPool[1]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.x/1000 * 6, 1))
mapBoundsFogPool[2]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.y/1000 * 6, 1))
mapBoundsFogPool[3]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.x/1000 * 6, 1))
mapBoundsFogPool[2]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.y/1000 * 6, 1))
mapBoundsFogPool[3]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.x/1000 * 6, 1))
mapBoundsFogPool[4]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.y/1000 * 6, 1))
mapBoundsFogPool[3]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.x/1000 * 6, 1))
mapBoundsFogPool[4]:setScale(vec3(camHeightAboveTerrain * 0.001, extents.y/1000 * 6, 1))
end
yaw = yaw or camMode.rotAngle
local upperEdgePoint = vec3((bbox.maxExtents.x + bbox.minExtents.x) / 2, bbox.maxExtents.y, bbox.maxExtents.z)
local lowerEdgePoint = vec3((bbox.maxExtents.x + bbox.minExtents.x) / 2, bbox.minExtents.y, bbox.minExtents.z)
local upperEdgePoint = vec3((bbox.maxExtents.x + bbox.minExtents.x) / 2, bbox.maxExtents.y, bbox.maxExtents.z)
local lowerEdgePoint = vec3((bbox.maxExtents.x + bbox.minExtents.x) / 2, bbox.minExtents.y, bbox.minExtents.z)
local lowerCamFovAngle = pitch + (camMode.fovMax - (camMode.fovMax * cameraAdditionalHeightFactor))/2
local camMode = core_camera.getGlobalCameras().bigMap
bigMapCamRotation = quatFromDir(vec3(0,0,-1), yVector)
bigMapCamRotation = quatFromAxisAngle(xVector, -(90 - camMode.angle) / 180 * math.pi):__mul(bigMapCamRotation)
local camPos = vec3(0,0,0)
local bbox
bbox = Box3F()
bbox:setExtents(vec3(1000, 1000, 1000))
bbox:setCenter(playerVehicle and playerVehicle:getPosition() + vec3(0,0,500) or vec3(0, 0, 0))
bbox:setExtents(vec3(1000, 1000, 1000))
bbox:setCenter(playerVehicle and playerVehicle:getPosition() + vec3(0,0,500) or vec3(0, 0, 0))
includeClustersInBbox(bbox)
bbox:setExtents(vec3(1000, 1000, 1000))
bbox:setCenter(playerVehicle and playerVehicle:getPosition() + vec3(0,0,500) or vec3(0, 0, 0))
includeClustersInBbox(bbox)
bbox:setExtents(extents)
bbox:scale3F(vec3(1.1,1.1,1))
bbox:setCenter(bboxCenter)
navigationBoundaries.maxExtents = mapBoundaries.maxExtents
navigationBoundaries:scale3F(vec3(navigationBoundariesFactor, navigationBoundariesFactor, 1))
camMode.mapBoundaries = navigationBoundaries
local camDir = core_camera.getQuat() * yVector
local downwardsRot = quatFromDir(vec3(0,0,-1), camDir)
local m1 = { fov = core_camera.getFovDeg(), movingEnd = true, movingStart = false, positionSmooth = 0.5, pos = startPos, rot = core_camera.getQuat(), time = 0, trackPosition = false, nearClip = previousNearClip }
local playerCamDir = endMarkerData.rot * yVector
local downwardsRot = quatFromDir(vec3(0,0,-1), playerCamDir)
local m1 = { fov = core_camera.getFovDeg(), movingEnd = true, movingStart = false, positionSmooth = 0.5, pos = startPos, rot = core_camera.getQuat(), time = 0, trackPosition = false, nearClip = camMode.nearClipValue }
local vehicleDirLocalX, vehicleDirLocalY = vehDir:dot(core_camera.getRight()), vehDir:dot(core_camera.getUp())
local vehicleDirXYLocal = vec3(vehicleDirLocalX,vehicleDirLocalY,0)
local det = vehicleDirLocalX * yVector.y - vehicleDirLocalY * yVector.x
local playerVehicle = getPlayerVehicle(0)
iconRenderer:addIcon("playerVehicle", "player_marker", playerVehicle and playerVehicle:getPosition() or vec3(0,0,0))
local iconInfo = iconRenderer:getIconByName("playerVehicle")
iconInfo.color = pureWhite
iconRenderer:addIcon("navigationMarker", "navigation_marker", vec3(0,0,0))
local iconInfo = iconRenderer:getIconByName("navigationMarker")
extensions.hook("onBigmapStartTransition",activateBigMap, closeEscMenu)
endMarkerData.pos = vec3(endMarkerData.pos)
endMarkerData.rot = quat(endMarkerData.rot.x, endMarkerData.rot.y, endMarkerData.rot.z, endMarkerData.rot.w)
@/lua/ge/extensions/flowgraph/nodes/debug/debugCylinder.lua
local defaultColor = {0.91,0.05,0.48,0.5}
local posA = vec3()
local posB = vec3()
local posA = vec3()
local posB = vec3()
function C:work()
@/lua/ge/extensions/flowgraph/nodes/vehicle/touchingStatic.lua
function C:_executionStarted()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
function C:_executionStarted()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
function C:_executionStarted()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
function C:_executionStarted()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
function C:_executionStarted()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
function C:_executionStarted()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
function C:_executionStarted()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
function C:_executionStarted()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
end
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
end
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
end
self.points = {FL = {pos = vec3()}, FR = {pos = vec3()}, BR = {pos = vec3()}, BL = {pos = vec3()}, F = {pos = vec3()}, R = {pos = vec3()}, B = {pos = vec3()}, L = {pos = vec3()}}
self.center, self.xOffset, self.yOffset, self.zOffset = vec3(), vec3(), vec3(), vec3()
end
@/lua/ge/extensions/editor/createObjectTool.lua
local offs = offsetFromSurface[currentClassInstance:getClassName()] or 0
local finalPos = vec3(
rayCastInfo.pos.x + rayCastInfo.normal.x * offs,
-- I need to add this 90deg x axis correction, dont know why quatFromDir doesnt properly create the rotation at default up (0,0,1)
mtxCorrection:setFromEuler(vec3((90 * math.pi) / 180.0, 0, 0))
editor.disableModifyFadeIconsDistance = false
mtxAngleAroundUp:setFromEuler(vec3(0, 0, (angleAroundUpValue * math.pi) / 180.0))
mtx:setFromQuatF(QuatF(rot.x, rot.y, rot.z, rot.w))
if not placeAtCameraPos then
local pos = vec3(worldEditorCppApi.snapPositionToGrid(rayCastInfo.pos))
local lineWidth = editor.getPreference("gizmos.general.lineThicknessScale") * 4
local lineWidth = editor.getPreference("gizmos.general.lineThicknessScale") * 4
debugDrawer:drawLineInstance((pos - vec3(2, 0, 0)), (pos + vec3(2, 0, 0)), lineWidth, ColorF(1, 0, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 2, 0)), (pos + vec3(0, 2, 0)), lineWidth, ColorF(0, 1, 0, 1))
local lineWidth = editor.getPreference("gizmos.general.lineThicknessScale") * 4
debugDrawer:drawLineInstance((pos - vec3(2, 0, 0)), (pos + vec3(2, 0, 0)), lineWidth, ColorF(1, 0, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 2, 0)), (pos + vec3(0, 2, 0)), lineWidth, ColorF(0, 1, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(2, 0, 0)), (pos + vec3(2, 0, 0)), lineWidth, ColorF(1, 0, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 2, 0)), (pos + vec3(0, 2, 0)), lineWidth, ColorF(0, 1, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 0, 2)), (pos + vec3(0, 0, 2)), lineWidth, ColorF(0, 0, 1, 1))
debugDrawer:drawLineInstance((pos - vec3(2, 0, 0)), (pos + vec3(2, 0, 0)), lineWidth, ColorF(1, 0, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 2, 0)), (pos + vec3(0, 2, 0)), lineWidth, ColorF(0, 1, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 0, 2)), (pos + vec3(0, 0, 2)), lineWidth, ColorF(0, 0, 1, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 2, 0)), (pos + vec3(0, 2, 0)), lineWidth, ColorF(0, 1, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 0, 2)), (pos + vec3(0, 0, 2)), lineWidth, ColorF(0, 0, 1, 1))
else
debugDrawer:drawLineInstance((pos - vec3(0, 2, 0)), (pos + vec3(0, 2, 0)), lineWidth, ColorF(0, 1, 0, 1))
debugDrawer:drawLineInstance((pos - vec3(0, 0, 2)), (pos + vec3(0, 0, 2)), lineWidth, ColorF(0, 0, 1, 1))
else
else
local pos = core_camera.getPosition() + vec3(core_camera.getForward():normalized())
debugDrawer:drawTextAdvanced(pos, "CLICK ANYWHERE TO CREATE AT CAMERA", ColorF(1, 1, 1, 1), true, false, ColorI(100, 100, 155, 255), false, false)
@/lua/ge/extensions/campaign/photoSafari.lua
local sceneObject = scenetree.findObject(M.targetObj)
local pos = vec3(sceneObject:getPosition())
local campos = core_camera.getPosition()
local camTriggerPos = camTriggerObj:getPosition()
local camdis = (campos - vec3(camTriggerObj:getPosition())):length()
if camdis > M.cameraDistanceToObject then
local sceneObject = scenetree.findObject(M.targetObj)
local pos = vec3(sceneObject:getPosition())
local campos = core_camera.getPosition()
@/lua/ge/extensions/flowgraph/nodes/gameplay/race/raceMarkers.lua
if pn.hasNormal then
local side = vec3(pn.normal.y, -pn.normal.x, 0):normalized() * pn.radius
self.minimapMarkers[pn.id].left = pn.pos + side
@/lua/ge/extensions/util/trackBuilder/obstaclePlacer.lua
elseif o.offset == 0 then
pos = piece.points[1].position + vec3(0,0,piece.points[1].zOffset)
rot = piece.points[1].finalRot
if piece.points[i].length <= targetLen then
pos = piece.points[i].position + vec3(0,0,piece.points[i].zOffset)
rot = piece.points[i].finalRot
obj:setField('shapeName', 0, shapeNames[obstacleType])
obj:setPosition(vec3(0,0,0))
obj.scale = vec3(1,1,1)
obj:setPosition(vec3(0,0,0))
obj.scale = vec3(1,1,1)
obj:setField('rotation', 0, '0 0 1 0')
local m = #list
list[m].scale = vec3(0,0,0)
list[m]:delete()
local pos, rot, width = getAdjustedPosRotWidth(o,segment)
proc:setPosition((pos + rot:__mul(o.position + vec3(width/2 * (o.anchor-1),0,0))))
local quat = (turn90:__mul(o.rotation:__mul(rot))):toTorqueQuat()
proc:setField('rotation', 0, quat.x .. ' ' ..quat.y..' '..quat.z..' '..quat.w)
proc.scale = vec3(1,1,1)
end
obstacleType = name,
position = pos + rot:__mul(o.position + vec3(width/2 * (o.anchor-1),0,0)),
rotation = turn90:__mul(o.rotation:__mul(rot)),
rotation = turn90:__mul(o.rotation:__mul(rot)),
scale = vec3(o.scale.y,o.scale.x,o.scale.z),
material = o.material
@/lua/ge/extensions/gameplay/sites/parkingSpot.lua
local xVector = vec3(1,0,0)
local yVector = vec3(0,1,0)
local xVector = vec3(1,0,0)
local yVector = vec3(0,1,0)
local zVector = vec3(0,0,1)
local yVector = vec3(0,1,0)
local zVector = vec3(0,0,1)
local zeroVector = vec3(0,0,0)
local zeroQuat = quat(0,0,0,1)
self.name = name or "Parking " .. self.id
self.color = vec3(1, 1, 1)
self.vertices = {}
self.vertices = {}
self.pos = vec3()
self.rot = quat(0, 0, 0, 1)
self.rot = quat(0, 0, 0, 1)
self.scl = vec3()
self.isMultiSpot = false
self.name = data.name
self.color = vec3(data.color)
self.pos = vec3(data.pos)
self.color = vec3(data.color)
self.pos = vec3(data.pos)
self.rot = quat(data.rot)
self.rot = quat(data.rot)
self.scl = vec3(data.scl)
self.isMultiSpot = data.isMultiSpot
if pos then
self.pos = vec3(pos)
end
if scl then
self.scl = vec3(scl)
end
if self.multiSpotData.spotDirection == "Left" then
dirVec = rot * vec3(-i * (self.scl.x + self.multiSpotData.spotOffset), 0, 0)
elseif self.multiSpotData.spotDirection == "Right" then
elseif self.multiSpotData.spotDirection == "Right" then
dirVec = rot * vec3(i * (self.scl.x + self.multiSpotData.spotOffset), 0, 0)
elseif self.multiSpotData.spotDirection == "Front" then
elseif self.multiSpotData.spotDirection == "Front" then
dirVec = rot * vec3(0, i * (self.scl.y + self.multiSpotData.spotOffset), 0)
elseif self.multiSpotData.spotDirection == "Back" then
elseif self.multiSpotData.spotDirection == "Back" then
dirVec = rot * vec3(0, -i * (self.scl.y + self.multiSpotData.spotOffset), 0)
end
local pos = self.pos + dirVec
local x, y, z = rot * vec3(self.scl.x / 2, 0, 0), rot * vec3(0, self.scl.y / 2, 0), rot * vec3(0, 0, self.scl.z / 2)
local clrI
local pos = self.pos + dirVec
local x, y, z = rot * vec3(self.scl.x / 2, 0, 0), rot * vec3(0, self.scl.y / 2, 0), rot * vec3(0, 0, self.scl.z / 2)
local clrI
local pos = self.pos + dirVec
local x, y, z = rot * vec3(self.scl.x / 2, 0, 0), rot * vec3(0, self.scl.y / 2, 0), rot * vec3(0, 0, self.scl.z / 2)
local clrI
debugDrawer:drawTriSolid(
vec3(pos + x + y),
vec3(pos + x - y),
vec3(pos + x + y),
vec3(pos + x - y),
vec3(pos - x - y),
vec3(pos + x - y),
vec3(pos - x - y),
clrI)
debugDrawer:drawTriSolid(
vec3(pos - x - y),
vec3(pos - x + y),
vec3(pos - x - y),
vec3(pos - x + y),
vec3(pos + x + y),
vec3(pos - x + y),
vec3(pos + x + y),
clrI)
debugDrawer:drawTriSolid(
vec3(pos - x - y + z / 2),
vec3(pos + y + z / 2),
vec3(pos - x - y + z / 2),
vec3(pos + y + z / 2),
vec3(pos + x - y + z / 2),
vec3(pos + y + z / 2),
vec3(pos + x - y + z / 2),
clrI)
debugDrawer:drawTriSolid(
vec3(a),
vec3(a + z),
vec3(a),
vec3(a + z),
vec3(b + z),
vec3(a + z),
vec3(b + z),
clrI)
debugDrawer:drawTriSolid(
vec3(b + z),
vec3(b),
vec3(b + z),
vec3(b),
vec3(a),
vec3(b),
vec3(a),
clrI)
debugDrawer:drawTriSolid(
vec3(a),
vec3(b + z),
vec3(a),
vec3(b + z),
vec3(a + z),
vec3(b + z),
vec3(a + z),
clrI)
debugDrawer:drawTriSolid(
vec3(b + z),
vec3(a),
vec3(b + z),
vec3(a),
vec3(b),
vec3(a),
vec3(b),
clrI)
if self.multiSpotData.spotDirection == "Left" then
dirVec = self.rotOrig * vec3(-j * (self.scl.x + self.multiSpotData.spotOffset), 0, 0)
elseif self.multiSpotData.spotDirection == "Right" then
elseif self.multiSpotData.spotDirection == "Right" then
dirVec = self.rotOrig * vec3(j * (self.scl.x + self.multiSpotData.spotOffset), 0, 0)
elseif self.multiSpotData.spotDirection == "Front" then
elseif self.multiSpotData.spotDirection == "Front" then
dirVec = self.rotOrig * vec3(0, j * (self.scl.y + self.multiSpotData.spotOffset), 0)
elseif self.multiSpotData.spotDirection == "Back" then
elseif self.multiSpotData.spotDirection == "Back" then
dirVec = self.rotOrig * vec3(0, -j * (self.scl.y + self.multiSpotData.spotOffset), 0)
end
local b = i <= 2 and 1 or -1
local x = self.rot * vec3(self.scl.x / 2, 0, 0)
local y = self.rot * vec3(0, self.scl.y / 2, 0)
local x = self.rot * vec3(self.scl.x / 2, 0, 0)
local y = self.rot * vec3(0, self.scl.y / 2, 0)
table.insert(self.vertices, self.pos + x * a + y * b)
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local p1, p2, p3, p4, p5, p6, p7, p8 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local bbPoints = {}
local bbPointIdsAlt = { 7, 4, 0, 3 }
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
local bbPointIdsAlt = { 7, 4, 0, 3 }
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
local bbPointIdsAlt = { 7, 4, 0, 3 }
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
local bbPointIdsAlt = { 7, 4, 0, 3 }
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
local bbPointIdsAlt = { 7, 4, 0, 3 }
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
function C:checkParking(vehId, precision, drivingSpeed, parkingSpeed)
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
function C:checkParking(vehId, precision, drivingSpeed, parkingSpeed)
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
function C:checkParking(vehId, precision, drivingSpeed, parkingSpeed)
local velocity, bbCenter, bbAxis0, bbAxis1, bbAxis2 = vec3(), vec3(), vec3(), vec3(), vec3()
local parkingSpotDir, vehicleDir, tempPos1, tempPos2 = vec3(), vec3(), vec3(), vec3()
function C:checkParking(vehId, precision, drivingSpeed, parkingSpeed)
local posOffset = (pos - fl)
local localOffset = vec3(xVeh:dot(posOffset), yVeh:dot(posOffset), zVeh:dot(posOffset))
if not veh then return end
local fl = vec3(veh:getSpawnWorldOOBB():getPoint(0))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local fl = vec3(veh:getSpawnWorldOOBB():getPoint(0))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local fr = vec3(veh:getSpawnWorldOOBB():getPoint(3))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local flU = vec3(veh:getSpawnWorldOOBB():getPoint(1))
local bl = vec3(veh:getSpawnWorldOOBB():getPoint(4))
local flU = vec3(veh:getSpawnWorldOOBB():getPoint(1))
local normalTip = center + (bl-fl)
normalTip = vec3(normalTip.x, normalTip.y, core_terrain.getTerrainHeight(normalTip))
self.rot = quatFromDir((center - normalTip):normalized(), (flU-bl):normalized())
@/lua/console/test.lua
BeamEngine:deleteAllObjects()
BeamEngine:spawnObject(1, "vehicles/pickup", nil, vec3(0, 0, 0))
end
@/lua/ge/extensions/core/camera.lua
local resPos, resTargetPos, resRot = vec3(), vec3(), quat()
local resPos, resTargetPos, resRot = vec3(), vec3(), quat()
local camData = { veh = 0, vid = 0, dtSim = 0.0001, dtReal = 0.0001, dtRaw = 0.0001, dt = 0.0001, speed = 30, pos=vec3(), prevPos = vec3(), vehPos=vec3(), prevVehPos=vec3(), vel=vec3(), prevVel=vec3(), res = {pos = resPos, targetPos = resTargetPos, rot = resRot, fov = 60} }
local camData = { veh = 0, vid = 0, dtSim = 0.0001, dtReal = 0.0001, dtRaw = 0.0001, dt = 0.0001, speed = 30, pos=vec3(), prevPos = vec3(), vehPos=vec3(), prevVehPos=vec3(), vel=vec3(), prevVel=vec3(), res = {pos = resPos, targetPos = resTargetPos, rot = resRot, fov = 60} }
local camData = { veh = 0, vid = 0, dtSim = 0.0001, dtReal = 0.0001, dtRaw = 0.0001, dt = 0.0001, speed = 30, pos=vec3(), prevPos = vec3(), vehPos=vec3(), prevVehPos=vec3(), vel=vec3(), prevVel=vec3(), res = {pos = resPos, targetPos = resTargetPos, rot = resRot, fov = 60} }
local camData = { veh = 0, vid = 0, dtSim = 0.0001, dtReal = 0.0001, dtRaw = 0.0001, dt = 0.0001, speed = 30, pos=vec3(), prevPos = vec3(), vehPos=vec3(), prevVehPos=vec3(), vel=vec3(), prevVel=vec3(), res = {pos = resPos, targetPos = resTargetPos, rot = resRot, fov = 60} }
local camData = { veh = 0, vid = 0, dtSim = 0.0001, dtReal = 0.0001, dtRaw = 0.0001, dt = 0.0001, speed = 30, pos=vec3(), prevPos = vec3(), vehPos=vec3(), prevVehPos=vec3(), vel=vec3(), prevVel=vec3(), res = {pos = resPos, targetPos = resTargetPos, rot = resRot, fov = 60} }
local camData = { veh = 0, vid = 0, dtSim = 0.0001, dtReal = 0.0001, dtRaw = 0.0001, dt = 0.0001, speed = 30, pos=vec3(), prevPos = vec3(), vehPos=vec3(), prevVehPos=vec3(), vel=vec3(), prevVel=vec3(), res = {pos = resPos, targetPos = resTargetPos, rot = resRot, fov = 60} }
local nodePos = vec3()
local function isWithinRadius(cameraName, camPos, veh, vdata, radius)
local bbCenter, bbHalfAxis0, bbHalfAxis1, bbHalfAxis2 = vec3(), vec3(), vec3(), vec3()
local function isCameraInside(player, camPos)
local bbCenter, bbHalfAxis0, bbHalfAxis1, bbHalfAxis2 = vec3(), vec3(), vec3(), vec3()
local function isCameraInside(player, camPos)
local bbCenter, bbHalfAxis0, bbHalfAxis1, bbHalfAxis2 = vec3(), vec3(), vec3(), vec3()
local function isCameraInside(player, camPos)
local bbCenter, bbHalfAxis0, bbHalfAxis1, bbHalfAxis2 = vec3(), vec3(), vec3(), vec3()
local function isCameraInside(player, camPos)
local finalCameraData = {pos = vec3(), rot = quat(), fovDeg = 0}
local validData
local lastValidData = { fov=60, pos=vec3(), rot=quat() } -- protect against getting NaNs on the very first frame
-- guard against sending NaN and inf to C++, which will put it in an unrecoverable state
if not commands.isFreeCamera() then return end
core_camera.setPosition(pid, vec3(px, py, pz))
if rx and ry and rz and rw then
local upVec = vec3(0, 0, 1)
local fwdVec = vec3(0, 1, 0)
local upVec = vec3(0, 0, 1)
local fwdVec = vec3(0, 1, 0)
local rightVec = vec3(1, 0, 0)
local fwdVec = vec3(0, 1, 0)
local rightVec = vec3(1, 0, 0)
local function getPosition()
return vec3(finalCameraData.pos)
end
local function getUp()
local res = vec3(upVec)
res:setRotate(finalCameraData.rot)
local function getRight()
local res = vec3(rightVec)
res:setRotate(finalCameraData.rot)
local function getForward()
local res = vec3(fwdVec)
res:setRotate(finalCameraData.rot)
local resVec = vec3()
local function getForwardXYZ()
@/lua/ge/extensions/util/showroom.lua
local function getSuitablePosition()
return vec3(0,0,1000)
end
local function getPosRot()
return localToWorld(vec3(0,0,0)), quat(0,0,0,1)
end
veh:autoplace(false)
--spawn.safeTeleport(veh, localToWorld(vec3(0,0,0)), quat(0,0,0,1))
end
local playerVehicle = getPlayerVehicle(0)
pos = vec3(playerVehicle and playerVehicle:getPosition() or core_camera.getPosition())
end
@/lua/ge/extensions/editor/gen/exp_solidflex.lua
local an,af,auv = {},{},{}
an[0] = vec3(0,0,1)
auv[#auv+1] = {u=0, v=0}
-- lo('?? build:'..#an..':'..tostring(an[0]))
local av = {vec3(0,0,1.5),vec3(0,1,1.5)}
local avp = {{av[1],1},{av[2],2}}
-- lo('?? build:'..#an..':'..tostring(an[0]))
local av = {vec3(0,0,1.5),vec3(0,1,1.5)}
local avp = {{av[1],1},{av[2],2}}
end
-- U.out.atext[1] = {list = {{vec3(0,0,0),'LBL'}}, c={0,0,1}}
if true and U._PRD == 0 then
--[[
local ref = vec3(0,0,0)
list = U.map(alen, function(k,v)
list = U.map(alen, function(k,v)
ref = ref + alen[k]*vec3(math.cos(ac[k]),math.sin(ac[k]))
return ref
end)
table.insert(list, 1, vec3(0,0,0))
-- U.dump(list, '<< loss:')
-- to list
clist[2] = list[1] + alen[1]*vec3(math.cos(cac[1]),math.sin(cac[1]))
cac[2] = U.vang(vec3(1,0),last-clist[2])
clist[2] = list[1] + alen[1]*vec3(math.cos(cac[1]),math.sin(cac[1]))
cac[2] = U.vang(vec3(1,0),last-clist[2])
-- list[3] = list[2] + alen[2]*(last-list[2]):normalized()
-- U.onPLane()
--vec3(1.953447406,1.037545438,1.622391045):vec3(0.9085190297,-0.2558463598,0.3303570989):vec3(3.808987617,5.244136333,0)
-- U.onPLane()
--vec3(1.953447406,1.037545438,1.622391045):vec3(0.9085190297,-0.2558463598,0.3303570989):vec3(3.808987617,5.244136333,0)
-- U.onPLane()
--vec3(1.953447406,1.037545438,1.622391045):vec3(0.9085190297,-0.2558463598,0.3303570989):vec3(3.808987617,5.244136333,0)
tgt = U.map(elast,function(k,v)
return v + vec3(U.rand(-amp,amp),U.rand(-amp,amp),U.rand(-amp,amp))
end)
--[[
tgt = {m.verts[#m.verts-1]-vec3(1,1,0)/2,m.verts[#m.verts]-vec3(1,1,0)/2}
-- tgt = {m.verts[#m.verts-1]+vec3(0,0,1)/2,m.verts[#m.verts]+vec3(0,0,1)/2}
--[[
tgt = {m.verts[#m.verts-1]-vec3(1,1,0)/2,m.verts[#m.verts]-vec3(1,1,0)/2}
-- tgt = {m.verts[#m.verts-1]+vec3(0,0,1)/2,m.verts[#m.verts]+vec3(0,0,1)/2}
tgt = {m.verts[#m.verts-1]-vec3(1,1,0)/2,m.verts[#m.verts]-vec3(1,1,0)/2}
-- tgt = {m.verts[#m.verts-1]+vec3(0,0,1)/2,m.verts[#m.verts]+vec3(0,0,1)/2}
tgt = {
tgt = {m.verts[#m.verts-1]-vec3(1,1,0)/2,m.verts[#m.verts]-vec3(1,1,0)/2}
-- tgt = {m.verts[#m.verts-1]+vec3(0,0,1)/2,m.verts[#m.verts]+vec3(0,0,1)/2}
tgt = {
tgt = {
vec3(1.576736895,1.57155567,1.248280257),
vec3(2.24848145,1.017028218,1.739461035),
vec3(1.576736895,1.57155567,1.248280257),
vec3(2.24848145,1.017028218,1.739461035),
}
tgt = {
vec3(1.626473303,1.632343069,1.294856807),
vec3(2.271661427,1.014781445,1.744690026),
vec3(1.626473303,1.632343069,1.294856807),
vec3(2.271661427,1.014781445,1.744690026),
}
tgt = {
vec3(1.338402191,1.906636857,1.195495456),
vec3(2.205858188,1.59150638,1.580479711),
vec3(1.338402191,1.906636857,1.195495456),
vec3(2.205858188,1.59150638,1.580479711),
}
local av = {
vec3(0,0,0),
vec3(1,0,0),
vec3(0,0,0),
vec3(1,0,0),
}
av[#av+1] = {
vec3(0.5,0.5,0),
}
}
an[#an+1] = vec3(0,0,1)
af[#af+1] = {}
local ac = {0.1, 0.3}
local tgt = vec3(1.2,1.2)
local ref = vec3(0,0,0)
local tgt = vec3(1.2,1.2)
local ref = vec3(0,0,0)
local list = U.map(alen, function(k,v)
local list = U.map(alen, function(k,v)
ref = ref + alen[k]*vec3(math.cos(ac[k]),math.sin(ac[k]))
return ref
end)
table.insert(list, 1, vec3(0,0))
U.out.agraph[1] = {list={list}, w=4}
-- lo('>> loss:')
local ref = vec3(0,0,0)
list = U.map(alen, function(k,v)
list = U.map(alen, function(k,v)
ref = ref + alen[k]*vec3(math.cos(ac[k]),math.sin(ac[k]))
return ref
end)
table.insert(list, 1, vec3(0,0,0))
-- U.dump(list, '<< loss:')
-- to list
clist[2] = list[1] + alen[1]*vec3(math.cos(cac[1]),math.sin(cac[1]))
cac[2] = U.vang(vec3(1,0),last-clist[2])
clist[2] = list[1] + alen[1]*vec3(math.cos(cac[1]),math.sin(cac[1]))
cac[2] = U.vang(vec3(1,0),last-clist[2])
-- list[3] = list[2] + alen[2]*(last-list[2]):normalized()
local dh = U.proj2D(focus-campos):length()/U.proj2D(dir):length()*dir.z
focus = U.proj2D(focus) + vec3(0,0,campos.z+dh)
end
--??
-- pto = m.verts[cvover] + vec3(0,0,-1)*0.05
-- pto = m.verts[cvover] + (m.verts[3] - m.verts[4])*0.1
local r = ccampos - focus
local rnew = U.vturn(U.proj2D(r), 0.02*cclick) + vec3(0,0,r.z)
-- lo('?? turning:'..r:length()..':'..tostring(ccampos)..':'..tostring(focus))
core_camera.setPosition(0, ccampos)
core_camera.setRotation(0, quatFromDir(focus - ccampos, vec3(0,0,1)))
end
local r = campos - focus
local rnew = U.vturn(U.proj2D(r), 0.1*cclick) + vec3(0,0,r.z)
core_camera.setPosition(0, focus + rnew)
core_camera.setPosition(0, focus + rnew)
core_camera.setRotation(0, quatFromDir(focus - core_camera.getPosition(), vec3(0,0,1)))
local ami1,ami2,vmi1,vmi2
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veVehicleSpawner.lua
local startYaw = 90 -- degrees
local startDir = quatFromAxisAngle(vec3(0,0,1), math.rad(startYaw))
local tempStartYaw = startYaw
local tempStartYaw = startYaw
local tempStartDir = quatFromAxisAngle(vec3(0,0,1), math.rad(startYaw))
local spawnPos = startPos + startDir * vec3(10 * (i - 1), 0, 0)
local veh = core_vehicles.spawnNewVehicle(vehData.model.key, {pos = spawnPos, rot = startDir})
table.insert(vehsData, {veh = veh, initPos = vec3(spawnPos), done = false})
end
tempStartYaw = tempStartYaw + io.MouseWheel * 5
tempStartDir = quatFromAxisAngle(vec3(0,0,1), math.rad(tempStartYaw))
end
for i = 1, #vehsList do
local pos = hit.pos + tempStartDir * vec3(10 * (i - 1), 0, 0)
debugDrawer:drawTriSolid(
pos + tempStartDir * vec3(1,0,0),
pos + tempStartDir * vec3(-1,0,0),
pos + tempStartDir * vec3(1,0,0),
pos + tempStartDir * vec3(-1,0,0),
pos + tempStartDir * vec3(0,3,0),
pos + tempStartDir * vec3(-1,0,0),
pos + tempStartDir * vec3(0,3,0),
color(255,0,0,128)
for i = 1, #vehsList do
local pos = startPos + startDir * vec3(10 * (i - 1), 0, 0)
debugDrawer:drawTriSolid(
pos + startDir * vec3(1,0,0),
pos + startDir * vec3(-1,0,0),
pos + startDir * vec3(1,0,0),
pos + startDir * vec3(-1,0,0),
pos + startDir * vec3(0,3,0),
pos + startDir * vec3(-1,0,0),
pos + startDir * vec3(0,3,0),
color(255,0,0,255)
if im.Button(vehData.model.Name) then
--local spawnPos = startPos + startDir * vec3(10 * (i - 1), 0, 0)
local spawnPos = core_camera.getPosition()
--table.insert(vehsData, {veh = veh, initPos = vec3(spawnPos), done = false})
end
@/lua/vehicle/controller/drivingDynamics/sensors/vehicleData.lua
end
M.vehicleStats.refNodePos = vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
M.vehicleStats.mass = totalMass
local function calculateInertiaZ()
local cogZAxis = vec3(M.vehicleStats.cogWithoutWheels.x, M.vehicleStats.cogWithoutWheels.y, 0)
local inertiaZ = 0
for _, v in pairs(v.data.nodes) do
local posNoZ = vec3(v.pos.x, v.pos.y, 0)
local distanceToCOG = (cogZAxis - posNoZ):length()
local avgWheelPos = vec3(0, 0, 0)
local refNodes = v.data.refNodes[0]
local vectorForward = vec3(v.data.nodes[refNodes.ref].pos) - vec3(v.data.nodes[refNodes.back].pos)
local vectorUp = vec3(v.data.nodes[refNodes.up].pos) - vec3(v.data.nodes[refNodes.ref].pos)
local refNodes = v.data.refNodes[0]
local vectorForward = vec3(v.data.nodes[refNodes.ref].pos) - vec3(v.data.nodes[refNodes.back].pos)
local vectorUp = vec3(v.data.nodes[refNodes.up].pos) - vec3(v.data.nodes[refNodes.ref].pos)
local vectorForward = vec3(v.data.nodes[refNodes.ref].pos) - vec3(v.data.nodes[refNodes.back].pos)
local vectorUp = vec3(v.data.nodes[refNodes.up].pos) - vec3(v.data.nodes[refNodes.ref].pos)
local vectorRight = vectorForward:cross(vectorUp)
local vectorForward = vec3(v.data.nodes[refNodes.ref].pos) - vec3(v.data.nodes[refNodes.back].pos)
local vectorUp = vec3(v.data.nodes[refNodes.up].pos) - vec3(v.data.nodes[refNodes.ref].pos)
local vectorRight = vectorForward:cross(vectorUp)
if cornerWheels[wheel.name] then
local wheelNodePos = vec3(v.data.nodes[wheel.node1].pos)
local wheelVector = wheelNodePos - avgWheelPos
@/lua/ge/extensions/editor/trafficManager.lua
local mousePos, anchorPos, tempVec = vec3(), vec3(), vec3()
local confirmData = {}
local mousePos, anchorPos, tempVec = vec3(), vec3(), vec3()
local confirmData = {}
local mousePos, anchorPos, tempVec = vec3(), vec3(), vec3()
local confirmData = {}
local validVehTypes = {Car = 1, Truck = 1, Automation = 1, Traffic = 1}
local vecUp = vec3(0, 0, 1)
local vecY = vec3(0, 1, 0)
local vecUp = vec3(0, 0, 1)
local vecY = vec3(0, 1, 0)
local imDefaultPos = im.ImVec2(60, 180) -- places new windows below the main window
if rayCast then rayCastHit = vec3(rayCast.pos) end
return rayCastHit
currTransform = {pos = vec3(), rot = quat(), scl = 0}
currSelection = {vehicle = 0, light = 0, sign = 0}
elseif aiType == "target" then
aiData = {aggression = 0.35, speed = 16.7, useSpeedLimit = false, driveInLane = true, avoidCars = true, targetPos = vec3(), directRadius = 0} -- directRadius is unused
elseif aiType == "user" then
vehData.stats = {timer = 0, prevPos = vec3(), prevVel = vec3(), gForce = 0, distance = 0, avgSpeed = 0, maxSpeed = 0} -- reset stats
vehData.stats = {timer = 0, prevPos = vec3(), prevVel = vec3(), gForce = 0, distance = 0, avgSpeed = 0, maxSpeed = 0} -- reset stats
if currInstance.road then
currInstance.dir = vec3(currInstance.road.dir)
end
if mouseHandler("Click and drag to move light to here") then
currInstance.pos = vec3(anchorPos)
currInstance.road = currInstance:getBestRoad(currInstance.pos, vec3())
currInstance.pos = vec3(anchorPos)
currInstance.road = currInstance:getBestRoad(currInstance.pos, vec3())
if currInstance.road then
if currInstance.road then
currInstance.dir = vec3(currInstance.road.dir)
end
if im.Button("Use Default") then -- NOTE: only works for right side of road
local pos = vec3(currInstance.road and currInstance.road.pos or currInstance.pos)
local offset = currInstance.road and currInstance.road.radius or 5
if sessionData then
sessionData.home.pos = vec3(sessionData.home.pos)
sessionData.home.rot = quat(sessionData.home.rot)
for _, instance in ipairs(signalsData.instances or {}) do
instance.pos = vec3(instance.pos)
instance.dir = vec3(instance.dir)
instance.pos = vec3(instance.pos)
instance.dir = vec3(instance.dir)
local obj = core_trafficSignals.newSignal(instance)
if sessionData.aiData.targetPos then
debugDrawer:drawCylinder(sessionData.aiData.targetPos, sessionData.aiData.targetPos + vec3(0, 0, 25), 0.2, debugColors.main)
end
@/lua/ge/extensions/editor/toolUtilities/splineMaskExport.lua
local tmpPoint2I = Point2I(0, 0)
local tmp1, tmp2 = vec3(), vec3()
local tmpPoint2I = Point2I(0, 0)
local tmp1, tmp2 = vec3(), vec3()
@/lua/ge/extensions/util/vehicleRopeDebug.lua
local draggedNode = nil -- {ropeId, nodeIndex} or nil
local dragPlaneNormal = vec3(0, 0, 1) -- Plane normal for dragging
local dragPlaneDist = 0 -- Plane distance for dragging
local rayOrigin = vec3(ray.pos.x, ray.pos.y, ray.pos.z)
local rayDir = vec3(ray.dir.x, ray.dir.y, ray.dir.z)
local rayOrigin = vec3(ray.pos.x, ray.pos.y, ray.pos.z)
local rayDir = vec3(ray.dir.x, ray.dir.y, ray.dir.z)
local rayOrigin = vec3(ray.pos.x, ray.pos.y, ray.pos.z)
local rayDir = vec3(ray.dir.x, ray.dir.y, ray.dir.z)
local rayOrigin = vec3(ray.pos.x, ray.pos.y, ray.pos.z)
local rayDir = vec3(ray.dir.x, ray.dir.y, ray.dir.z)
rope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
rope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
rope.baseDirA = vec3(uiPtrs.baseDirAX[0], uiPtrs.baseDirAY[0], uiPtrs.baseDirAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
rope.baseDirA = vec3(uiPtrs.baseDirAX[0], uiPtrs.baseDirAY[0], uiPtrs.baseDirAZ[0])
rope.baseDirB = vec3(uiPtrs.baseDirBX[0], uiPtrs.baseDirBY[0], uiPtrs.baseDirBZ[0])
rope.baseDirA = vec3(uiPtrs.baseDirAX[0], uiPtrs.baseDirAY[0], uiPtrs.baseDirAZ[0])
rope.baseDirB = vec3(uiPtrs.baseDirBX[0], uiPtrs.baseDirBY[0], uiPtrs.baseDirBZ[0])
rope.nodeCount = uiPtrs.nodeCount[0]
-- rope gravity is set to level's gravity on creation...
--rope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
rope.youngsModulus = uiPtrs.youngsModulus[0]
selectedRope = rope
rope.basePosA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
rope.basePosB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
rope.basePosA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
rope.basePosB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
if rope.gravity then
if nodes and nodes[draggedNode.nodeIndex] then
dragPlaneNormal = vec3(0, 0, 1) -- XY plane normal
dragPlaneDist = nodes[draggedNode.nodeIndex].pos.z -- Z height of the node
if im.InputFloat("##BasePosAX", uiPtrs.anchorAX, 0.001, 0.01, "%.4f") then
selectedRope.basePosA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
end
if im.InputFloat("##BasePosAY", uiPtrs.anchorAY, 0.001, 0.01, "%.4f") then
selectedRope.basePosA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
end
if im.InputFloat("##BasePosAZ", uiPtrs.anchorAZ, 0.001, 0.01, "%.4f") then
selectedRope.basePosA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
end
if im.InputFloat("##BasePosBX", uiPtrs.anchorBX, 0.001, 0.01, "%.4f") then
selectedRope.basePosB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
end
if im.InputFloat("##BasePosBY", uiPtrs.anchorBY, 0.001, 0.01, "%.4f") then
selectedRope.basePosB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
end
if im.InputFloat("##BasePosBZ", uiPtrs.anchorBZ, 0.001, 0.01, "%.4f") then
selectedRope.basePosB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
end
if im.InputFloat("##BaseDirAX", uiPtrs.baseDirAX, 0.001, 0.01, "%.4f") then
if selectedRope.baseDirA then selectedRope.baseDirA = vec3(uiPtrs.baseDirAX[0], uiPtrs.baseDirAY[0], uiPtrs.baseDirAZ[0]) end
end
if im.InputFloat("##BaseDirAY", uiPtrs.baseDirAY, 0.001, 0.01, "%.4f") then
if selectedRope.baseDirA then selectedRope.baseDirA = vec3(uiPtrs.baseDirAX[0], uiPtrs.baseDirAY[0], uiPtrs.baseDirAZ[0]) end
end
if im.InputFloat("##BaseDirAZ", uiPtrs.baseDirAZ, 0.001, 0.01, "%.4f") then
if selectedRope.baseDirA then selectedRope.baseDirA = vec3(uiPtrs.baseDirAX[0], uiPtrs.baseDirAY[0], uiPtrs.baseDirAZ[0]) end
end
if im.InputFloat("##BaseDirBX", uiPtrs.baseDirBX, 0.001, 0.01, "%.4f") then
if selectedRope.baseDirB then selectedRope.baseDirB = vec3(uiPtrs.baseDirBX[0], uiPtrs.baseDirBY[0], uiPtrs.baseDirBZ[0]) end
end
if im.InputFloat("##BaseDirBY", uiPtrs.baseDirBY, 0.001, 0.01, "%.4f") then
if selectedRope.baseDirB then selectedRope.baseDirB = vec3(uiPtrs.baseDirBX[0], uiPtrs.baseDirBY[0], uiPtrs.baseDirBZ[0]) end
end
if im.InputFloat("##BaseDirBZ", uiPtrs.baseDirBZ, 0.001, 0.01, "%.4f") then
if selectedRope.baseDirB then selectedRope.baseDirB = vec3(uiPtrs.baseDirBX[0], uiPtrs.baseDirBY[0], uiPtrs.baseDirBZ[0]) end
end
if im.InputFloat("##GravityX", uiPtrs.gravityX, 0, 0, "%.2f") then
selectedRope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
end
if im.InputFloat("##GravityY", uiPtrs.gravityY, 0, 0, "%.2f") then
selectedRope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
end
if im.InputFloat("##GravityZ", uiPtrs.gravityZ, 0, 0, "%.2f") then
selectedRope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
end
@/lua/vehicle/controller/drivingDynamics/actuators/activeDiffBias.lua
--calculate avg wheel positions for both diff sides (a diff could have more than one wheel attached per side)
local avgWheelPositions = {[-1] = vec3(), [1] = vec3()}
for wheelSideIndex, wheelSide in pairs(relevantWheels) do
--calculate avg wheel positions for both diff sides (a diff could have more than one wheel attached per side)
local avgWheelPositions = {[-1] = vec3(), [1] = vec3()}
for wheelSideIndex, wheelSide in pairs(relevantWheels) do
for _, wheel in ipairs(wheelSide.wheels) do
avgWheelPositions[wheelSideIndex] = avgWheelPositions[wheelSideIndex] + vec3(v.data.nodes[wheel.node1].pos)
end
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos)
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos)
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos)
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
local vectorForward = vec3(v.data.nodes[v.data.refNodes[0].ref].pos) - vec3(v.data.nodes[v.data.refNodes[0].back].pos)
local vectorUp = vec3(v.data.nodes[v.data.refNodes[0].up].pos) - vec3(v.data.nodes[v.data.refNodes[0].ref].pos)
@/lua/common/jbeam/sections/nodeBeam.lua
local x, y, z = jbeamUtils.getPosAfterNodeRotateOffsetMove(v, v.posX, v.posY, v.posZ)
vehicle.nodes[k]['pos'] = vec3(x, y, z)
hydro.beam = jbeamUtils.addBeamWithOptions(vehicle, nil, nil, BEAM_HYDRO, hydro)
local bL = vec3(vehicle.nodes[hydro.id1].pos):distance(vehicle.nodes[hydro.id2].pos)
-- figure out where the rope is going
local startPos = vec3(vehicle.nodes[rope.id1].pos)
local endPos = startPos + vec3(rope.length, 0, 0)
local startPos = vec3(vehicle.nodes[rope.id1].pos)
local endPos = startPos + vec3(rope.length, 0, 0)
if rope.id2 then
if rope.id2 then
endPos = vec3(vehicle.nodes[rope.id2].pos)
rope.length = (endPos - startPos):length()
local vecDiff = (endPos - startPos) / rope.segments
local nPos = vec3(startPos)
@/lua/ge/extensions/core/ropeVisualTest.lua
local draggedNode = nil -- {ropeId, nodeIndex} or nil
local dragPlaneNormal = vec3(0, 0, 1) -- Plane normal for dragging
local dragPlaneDist = 0 -- Plane distance for dragging
local rayOrigin = vec3(ray.pos.x, ray.pos.y, ray.pos.z)
local rayDir = vec3(ray.dir.x, ray.dir.y, ray.dir.z)
local rayOrigin = vec3(ray.pos.x, ray.pos.y, ray.pos.z)
local rayDir = vec3(ray.dir.x, ray.dir.y, ray.dir.z)
local rayOrigin = vec3(ray.pos.x, ray.pos.y, ray.pos.z)
local rayDir = vec3(ray.dir.x, ray.dir.y, ray.dir.z)
local rayOrigin = vec3(ray.pos.x, ray.pos.y, ray.pos.z)
local rayDir = vec3(ray.dir.x, ray.dir.y, ray.dir.z)
if animationType == 0 then -- none
return vec3(0, 0, 0)
elseif animationType == 1 then -- wiggle
elseif animationType == 1 then -- wiggle
return vec3(math.sin(time * 8) * 0.3, math.sin(time * 6) * 0.2, math.sin(time * 4) * 0.1)
elseif animationType == 2 then -- circle
local radius = 0.4
return vec3(math.cos(time * 2) * radius, math.sin(time * 2) * radius, 0)
elseif animationType == 3 then -- bumpy ride
elseif animationType == 3 then -- bumpy ride
return vec3(math.sin(time * 3) * 0.3, math.sin(time * 5) * 0.2, math.abs(math.sin(time * 4)) * 0.3)
elseif animationType == 4 then -- rectangle
if phase == 0 then
return vec3(math.fmod(t, 1) * size * 2 - size, -size, 0)
elseif phase == 1 then
elseif phase == 1 then
return vec3(size, math.fmod(t, 1) * size * 2 - size, 0)
elseif phase == 2 then
elseif phase == 2 then
return vec3(size - math.fmod(t, 1) * size * 2, size, 0)
else
else
return vec3(-size, size - math.fmod(t, 1) * size * 2, 0)
end
local seed3 = math.floor(time * 6) % 100
return vec3((seed1 / 100 - 0.5) * 0.8, (seed2 / 100 - 0.5) * 0.8, (seed3 / 100 - 0.5) * 0.8)
elseif animationType == 6 then -- sin wave
elseif animationType == 6 then -- sin wave
return vec3(math.sin(time) * 0.4, math.sin(time * 1.5) * 0.3, math.sin(time * 0.5) * 0.2)
end
end
return vec3(0, 0, 0)
end
local cosEl = math.cos(elevation)
return vec3(math.cos(azimuth) * cosEl, math.sin(azimuth) * cosEl, math.sin(elevation))
end
-- Use current UI parameters for cloning, with position offset
rope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0] + yOffset, uiPtrs.anchorAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0] + yOffset, uiPtrs.anchorBZ[0])
rope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0] + yOffset, uiPtrs.anchorAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0] + yOffset, uiPtrs.anchorBZ[0])
rope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0] + yOffset, uiPtrs.anchorBZ[0])
rope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
rope.dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
rope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
rope.dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
rope.nodeCount = uiPtrs.nodeCount[0]
rope.iterations = uiPtrs.iterations[0]
rope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
rope.youngsModulus = uiPtrs.youngsModulus[0]
ropeBasePositions[id] = {
anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0] + yOffset, uiPtrs.anchorAZ[0]),
anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0] + yOffset, uiPtrs.anchorBZ[0]),
anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0] + yOffset, uiPtrs.anchorAZ[0]),
anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0] + yOffset, uiPtrs.anchorBZ[0]),
dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0]),
anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0] + yOffset, uiPtrs.anchorBZ[0]),
dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0]),
dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0]),
dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
}
rope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
rope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
rope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
rope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
rope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
rope.dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
rope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
rope.dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
rope.nodeCount = uiPtrs.nodeCount[0]
-- rope gravity is set to level's gravity on creation...
--rope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
rope.youngsModulus = uiPtrs.youngsModulus[0]
ropeBasePositions[id] = {
anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0]),
anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0]),
anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0]),
anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0]),
dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0]),
anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0]),
dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0]),
dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0]),
dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
}
end
ropeBasePositions[selectedRope.id].anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
ropeBasePositions[selectedRope.id].anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
ropeBasePositions[selectedRope.id].anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
ropeBasePositions[selectedRope.id].anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
ropeBasePositions[selectedRope.id].dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
ropeBasePositions[selectedRope.id].anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
ropeBasePositions[selectedRope.id].dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
ropeBasePositions[selectedRope.id].dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
ropeBasePositions[selectedRope.id].dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
ropeBasePositions[selectedRope.id].dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
end
else
rope.dirA = vec3(0, 0, 0)
end
else
rope.dirB = vec3(0, 0, 0)
end
if nodes and nodes[draggedNode.nodeIndex] then
dragPlaneNormal = vec3(0, 0, 1) -- XY plane normal
dragPlaneDist = nodes[draggedNode.nodeIndex].pos.z -- Z height of the node
-- Create rotation looking toward the rope center from the front
local cameraPos = vec3(centerX, centerY + cameraDist, centerZ + cameraDist * 0.3)
local lookDir = (vec3(centerX, centerY, centerZ) - cameraPos):normalized()
local cameraPos = vec3(centerX, centerY + cameraDist, centerZ + cameraDist * 0.3)
local lookDir = (vec3(centerX, centerY, centerZ) - cameraPos):normalized()
local camLookFrontRot = quatFromDir(lookDir)
if im.InputFloat("##AnchorAX", uiPtrs.anchorAX, 0, 0, "%.1f") then
selectedRope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
if im.InputFloat("##AnchorAY", uiPtrs.anchorAY, 0, 0, "%.1f") then
selectedRope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
end
if im.InputFloat("##AnchorAZ", uiPtrs.anchorAZ, 0, 0, "%.1f") then
selectedRope.anchorA = vec3(uiPtrs.anchorAX[0], uiPtrs.anchorAY[0], uiPtrs.anchorAZ[0])
end
if im.InputFloat("##AnchorBX", uiPtrs.anchorBX, 0, 0, "%.1f") then
selectedRope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
end
if im.InputFloat("##AnchorBY", uiPtrs.anchorBY, 0, 0, "%.1f") then
selectedRope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
end
if im.InputFloat("##AnchorBZ", uiPtrs.anchorBZ, 0, 0, "%.1f") then
selectedRope.anchorB = vec3(uiPtrs.anchorBX[0], uiPtrs.anchorBY[0], uiPtrs.anchorBZ[0])
end
local prevLength = selectedRope.dirA:length()
selectedRope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
local newLength = selectedRope.dirA:length()
local prevLength = selectedRope.dirA:length()
selectedRope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
local newLength = selectedRope.dirA:length()
local prevLength = selectedRope.dirA:length()
selectedRope.dirA = vec3(uiPtrs.dirAX[0], uiPtrs.dirAY[0], uiPtrs.dirAZ[0])
local newLength = selectedRope.dirA:length()
uiPtrs.dirAZ[0] = 0
selectedRope.dirA = vec3(0, 0, 0)
selectedRope:rebuild()
local prevLength = selectedRope.dirB:length()
selectedRope.dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
local newLength = selectedRope.dirB:length()
local prevLength = selectedRope.dirB:length()
selectedRope.dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
local newLength = selectedRope.dirB:length()
local prevLength = selectedRope.dirB:length()
selectedRope.dirB = vec3(uiPtrs.dirBX[0], uiPtrs.dirBY[0], uiPtrs.dirBZ[0])
local newLength = selectedRope.dirB:length()
uiPtrs.dirBZ[0] = 0
selectedRope.dirB = vec3(0, 0, 0)
selectedRope:rebuild()
if im.InputFloat("##GravityX", uiPtrs.gravityX, 0, 0, "%.2f") then
selectedRope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
end
if im.InputFloat("##GravityY", uiPtrs.gravityY, 0, 0, "%.2f") then
selectedRope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
end
if im.InputFloat("##GravityZ", uiPtrs.gravityZ, 0, 0, "%.2f") then
selectedRope.gravity = vec3(uiPtrs.gravityX[0], uiPtrs.gravityY[0], uiPtrs.gravityZ[0])
end
ropeBasePositions[ropeId] = {
anchorA = vec3(rope.anchorA.x, rope.anchorA.y, rope.anchorA.z),
anchorB = vec3(rope.anchorB.x, rope.anchorB.y, rope.anchorB.z),
anchorA = vec3(rope.anchorA.x, rope.anchorA.y, rope.anchorA.z),
anchorB = vec3(rope.anchorB.x, rope.anchorB.y, rope.anchorB.z),
dirA = vec3(rope.dirA.x, rope.dirA.y, rope.dirA.z),
anchorB = vec3(rope.anchorB.x, rope.anchorB.y, rope.anchorB.z),
dirA = vec3(rope.dirA.x, rope.dirA.y, rope.dirA.z),
dirB = vec3(rope.dirB.x, rope.dirB.y, rope.dirB.z)
dirA = vec3(rope.dirA.x, rope.dirA.y, rope.dirA.z),
dirB = vec3(rope.dirB.x, rope.dirB.y, rope.dirB.z)
}
@/lua/ge/extensions/statistics/statistics.lua
local distanceSource = entry.source or vehicleName
local distanceData = {label='ui.stats.distance', initialPos=vec3(0,0,0), value=0.0, decimals=2, enabled=true, source=distanceSource}
distanceData.maxValue = entry.maxValue
local distanceSource = distanceProperties.source or vehicleName
local distanceData = {label='ui.stats.distance', initialPos=vec3(0,0,0), value=0.0, decimals=2, enabled=true, source=distanceSource}
distanceData.maxPoints = distanceProperties.maxPoints
local tempPos = vec3()
@/lua/ge/extensions/gameplay/markers/parkingMarker.lua
local vecZero = vec3(0,0,0)
local vecOne = vec3(1,1,1)
local vecZero = vec3(0,0,0)
local vecOne = vec3(1,1,1)
local quatZero = quat(0,0,0,0)
local quatZero = quat(0,0,0,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecX = vec3(1,0,0)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local vecY = vec3(0,1,0)
local vecZ = vec3(0,0,1)
local outlinePrefix = "ParkingMarkerOutline_"
local iconRendererObj
local tmpVec = vec3()
local idCounter = 0
if self.mode == "contained" then
self.boxScl = vec3(math.max(self.scl.x + 1, 1), math.max(self.scl.y +1, 1), self.scl.z+20)
elseif self.mode == "overlap" then
elseif self.mode == "overlap" then
self.boxScl = vec3(1,1, self.scl.z)
end
self.iconInfo.color = ColorI(255,255,255,0)
self.iconInfo.customSize = vec3(1,1,1)
self.iconInfo.drawIconShadow = false
position = self.pos,
forwardVec = self.rot * vec3(0, 1, 0),
color = ColorF(1,1,1,0.35 ),
color = ColorF(1,1,1,0.35 ),
scale = vec3(self.scl.x, self.scl.y, 1),
fadeStart = self.focus and decalFadeStartFocus or decalFadeStart,
}
self.iconOff = vec3(0,0,0)
self.iconPos = vec3(0,0,0)
self.iconOff = vec3(0,0,0)
self.iconPos = vec3(0,0,0)
self.lastAlpha = -1
end
local xVector = vec3(1,0,0)
local yVector = vec3(0,1,0)
local xVector = vec3(1,0,0)
local yVector = vec3(0,1,0)
local zVector = vec3(0,0,1)
local yVector = vec3(0,1,0)
local zVector = vec3(0,0,1)
local garbages = {}
local garbages = {}
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
local garbages = {}
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
local garbages = {}
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
local garbages = {}
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
local tmpCorner, tmpX, tmpY, tmpZ = vec3(), vec3(), vec3(), vec3()
local tmpNormal = vec3()
function C:update(data)
* (0.5 + 0.5*cruisingFactor), data.dt)
self.iconPos = self.pos + vec3(0,0,iconHeight)
else
--simpleDebugText3d(string.format("%0.1f %0.1f %0.1f %0.1f",lineColorF.r, lineColorF.g, lineColorF.b, lineColorF.alpha), self.pos + vec3(0,0,iconHeight), 0.25)
obj:setField('shapeName', 0, shapeName)
obj:setPosition(vec3(0, 0, 0))
obj.scale = vec3(1, 1, 1)
obj:setPosition(vec3(0, 0, 0))
obj.scale = vec3(1, 1, 1)
obj:setField('rotation', 0, '1 0 0 0')
local angle = math.rad(topAngle + i * 60)
table.insert(hexagonVertices, vec3(math.sin(angle), math.cos(angle), 0))
end
end
local center = vec3()
local a, b, c = vec3(), vec3(), vec3()
local center = vec3()
local a, b, c = vec3(), vec3(), vec3()
local fillOrange = color(255,165,0,255)
local center = vec3()
local a, b, c = vec3(), vec3(), vec3()
local fillOrange = color(255,165,0,255)
local center = vec3()
local a, b, c = vec3(), vec3(), vec3()
local fillOrange = color(255,165,0,255)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner+a+b),
vec3(corner+a ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner+a ),
vec3(corner ),
vec3(corner+a ),
vec3(corner ),
vec3(corner+a+b),
vec3(corner ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(corner ),
vec3(corner+b ),
vec3(corner ),
vec3(corner+b ),
vec3(corner+a+b),
vec3(corner+b ),
vec3(corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner+a+b),
vec3(c+corner+a ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a ),
vec3(c+corner ),
vec3(c+corner+a+b),
vec3(c+corner ),
vec3(c+corner+a+b),
clr)
debugDrawer:drawTriSolid(
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner ),
vec3(c+corner+b ),
vec3(c+corner+a+b),
vec3(c+corner+b ),
vec3(c+corner+a+b),
clr)
@/lua/ge/extensions/util/trackBuilder/pieces.lua
local function getHdgVector(hdg)
return vec3(math.sin(hdg), math.cos(hdg), 0)
end
return {
position = p and p.position or vec3(0,0,0),
hdg = p and p.hdg or 0,
position = tipPiece.position + off * length,
origin = vec3(tipPiece.position),
controlPointA = off * 0.25 * length,
radius = radius * radiusMult
local off = vec3(direction *(1-math.cos(angle)), math.sin(angle),0) * radius
--rotate the offset by the hdg of the previous piece.
position = tipPiece.position + off,
origin = vec3(tipPiece.position),
controlPointA = M.getHdgVector(tipPiece.hdg) * bzLength * radius,
radius = radius * radiusMult
local off = vec3(direction *(1-math.cos(angle)), math.sin(angle),0) * radius
--rotate the offset by the hdg of the previous piece.
position = tipPiece.position + off,
origin = vec3(tipPiece.position),
radius = radius,
end
local off = vec3(
math.sin(tipPiece.hdg) * len + math.cos(tipPiece.hdg) * xOffset * (isHex and math.sqrt(3)/2 or 1),
position = tipPiece.position + off,
origin = vec3(tipPiece.position),
controlPointA = M.getHdgVector(tipPiece.hdg) * cpLength,
local pos= {position = vec3(tipPiece.position), hdg = tipPiece.hdg}
local tp = M.splineTrack.getTrackPosition()
if absolute then
pos.position = vec3(tp.x,tp.y,tp.z)
pos.hdg = tp.hdg
local hdg = absolute and pos.hdg or tipPiece.hdg
local off = vec3(
math.sin(hdg) * yOff + math.cos(hdg) * xOff * (isHex and math.sqrt(3)/2 or 1),
local localUnitX = vec3(
math.sin(tipPiece.hdg) * 0 + math.cos(tipPiece.hdg) * 1 * (isHex and math.sqrt(3)/2 or 1),
)
local localUnitY = vec3(
math.sin(tipPiece.hdg) * 1 + math.cos(tipPiece.hdg) * 0 * (isHex and math.sqrt(3)/2 or 1),
local tg = tipPiece.position - vec3(tp.x,tp.y,tp.z)
local globalPos = (pos.position + off) - vec3(tp.x,tp.y,tp.z)
local tg = tipPiece.position - vec3(tp.x,tp.y,tp.z)
local globalPos = (pos.position + off) - vec3(tp.x,tp.y,tp.z)
local localPos = (pos.position + off) - tipPiece.position
noPoints = empty or false,
globalPosition = vec3(globalPos:dot(tp.unitX ), globalPos:dot(tp.unitY )),
localPosition = vec3(localPos:dot(localUnitX), localPos:dot(localUnitY)),
globalPosition = vec3(globalPos:dot(tp.unitX ), globalPos:dot(tp.unitY )),
localPosition = vec3(localPos:dot(localUnitX), localPos:dot(localUnitY)),
globalHdg = pos.hdg + dirOff - tp.hdg,
local off = vec3(absSize * math.sqrt(3)/2, absSize * 2.5, 0)
position = tipPiece.position + off,
origin = vec3(tipPiece.position),
controlPointA = M.getHdgVector(tipPiece.hdg) *hexForwardCPLength,
local off = vec3(absSize * 2, absSize * 1, 0)
position = tipPiece.position + off,
origin = vec3(tipPiece.position),
controlPointA = M.getHdgVector(tipPiece.hdg) *hexForwardCPLength,
local off = vec3(1,0.5,0) - vec3(-math.cos(math.pi + angle), math.sin(math.pi + angle) , 0)
local off = vec3(1,0.5,0) - vec3(-math.cos(math.pi + angle), math.sin(math.pi + angle) , 0)
position = tipPiece.position + off,
origin = vec3(tipPiece.position),
controlPointA = M.getHdgVector(tipPiece.hdg) *forwardCPLength,
local off = vec3(
math.sin(tipPiece.hdg) * radius + math.cos(tipPiece.hdg) * offset,
local p = {
position = vec3(
0,
customPoints[1] = {
position = vec3(-offset, -radius, 0),
rot = quatFromEuler(0,0,0)
customPoints[#customPoints+1] = {
position = vec3(0,0, 0),
rot = quatFromEuler(0,0,0)
position = tipPiece.position + off,
origin = vec3(tipPiece.position),
hdg = tipPiece.hdg,
local tp = M.splineTrack.getTrackPosition()
tipPiece.position = vec3(tp.x,tp.y,tp.z)
tipPiece.hdg = tp.hdg
end
local off = vec3(
math.sin(tipPiece.hdg) * adjustedYOff + math.cos(tipPiece.hdg) * xOff * (isHex and math.sqrt(3)/2 or 1),
position = tipPiece.position + off,
origin = vec3(tipPiece.position),
hdg = tipPiece.hdg + dirOff * math.pi / (isHex and 3 or 2),
@/lua/ge/extensions/campaign/exploration.lua
marker.instanceColor = ColorF(0.7, 1, 0.7, 1):asLinear4F()
destinationMarker:setToCheckpoint({pos = vec3(marker:getPosition()), radius = 5})
destinationMarker:setMode('default')
-- log('I',logTag, 'queryRoadNodeToPosition called...')
local pos = vec3(position)
local first, second, distance = map.findClosestRoad(pos)
data.texture = 'art/arrow_decal.dds'
data.position = vec3(0, 1, 0)
data.color = ColorF(1, 0, 0, 0.75)
data.color = ColorF(1, 0, 0, 0.75)
data.forwardVec = vec3(0, 1, 0)
data.scale = vec3(2, 1, 1)
data.forwardVec = vec3(0, 1, 0)
data.scale = vec3(2, 1, 1)
Engine.Render.DynamicDecalMgr.addDecal(data)
data.texture = 'art/arrow_decal.dds'
data.position = vec3(0, 2, 0)
data.color = ColorF(0, 1, 0, 0.75)
data.color = ColorF(0, 1, 0, 0.75)
data.forwardVec = vec3(0, 1, 0)
data.scale = vec3(2, 1, 1)
data.forwardVec = vec3(0, 1, 0)
data.scale = vec3(2, 1, 1)
Engine.Render.DynamicDecalMgr.addDecal(data)
data.texture = 'art/arrow_decal.dds'
data.position = vec3(0, 3, 0)
data.color = ColorF(0, 0, 1, 0.75)
data.color = ColorF(0, 0, 1, 0.75)
data.forwardVec = vec3(0, 1, 0)
data.scale = vec3(2, 1, 1)
data.forwardVec = vec3(0, 1, 0)
data.scale = vec3(2, 1, 1)
Engine.Render.DynamicDecalMgr.addDecal(data)
@/lua/ge/extensions/editor/terraform/fetchSources.lua
local min, max = math.min, math.max
local up = vec3(0, 0, 1)
-- Module state.
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
-- Module state.
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
-- Module state.
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
-- Module state.
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
@/lua/ge/extensions/gameplay/rally/recceApp.lua
if playerVehicle then
spawn.safeTeleport(playerVehicle, vec3(pos), quat(rot))
end
@/lua/ge/extensions/core/cameraModes/trackir.lua
local trans = vec3(-t.nx, -t.nz, t.ny) * move_sensitivity
trans = data.res.rot * trans
@/lua/ge/extensions/career/modules/delivery/general.lua
clusterId = container.nodeId and veh:getNodeClusterId(container.nodeId),
position = (container.nodeId and veh:getNodePosition(container.nodeId) or vec3(0,0,0)) + veh:getPosition(),
}
@/lua/vehicle/ai.lua
local g = obj:getGravity() -- standard gravity is negative
local gravityDir = vec3(0, 0, sign2(g))
g = max(1e-30, abs(g)) -- prevent divivion by 0 gravity
upVec = obj:getDirectionVectorUp(),
rightVec = vec3(),
width = nil,
currentSegment = {},
vel = vec3(obj:getSmoothRefVelocityXYZ()),
speed = vec3(obj:getSmoothRefVelocityXYZ()):length(),
vel = vec3(obj:getSmoothRefVelocityXYZ()),
speed = vec3(obj:getSmoothRefVelocityXYZ()):length(),
staticFrictionCoef = 1,
dirState = {0, 0}, -- direction, steer
posTable = {vec3(), vec3(), vec3(), vec3()},
dirTable = {vec3(), vec3(), vec3(), vec3()},
dirState = {0, 0}, -- direction, steer
posTable = {vec3(), vec3(), vec3(), vec3()},
dirTable = {vec3(), vec3(), vec3(), vec3()},
dirState = {0, 0}, -- direction, steer
posTable = {vec3(), vec3(), vec3(), vec3()},
dirTable = {vec3(), vec3(), vec3(), vec3()},
dirState = {0, 0}, -- direction, steer
posTable = {vec3(), vec3(), vec3(), vec3()},
dirTable = {vec3(), vec3(), vec3(), vec3()},
posTable = {vec3(), vec3(), vec3(), vec3()},
dirTable = {vec3(), vec3(), vec3(), vec3()},
minRay = "",
posTable = {vec3(), vec3(), vec3(), vec3()},
dirTable = {vec3(), vec3(), vec3(), vec3()},
minRay = "",
posTable = {vec3(), vec3(), vec3(), vec3()},
dirTable = {vec3(), vec3(), vec3(), vec3()},
minRay = "",
posTable = {vec3(), vec3(), vec3(), vec3()},
dirTable = {vec3(), vec3(), vec3(), vec3()},
minRay = "",
local function calculateWheelBase()
local avgWheelNodePos, numOfWheels = vec3(), 0
for _, wheel in pairs(wheels.wheels) do
local dirVec = obj:getDirectionVector()
local avgFrontWheelPos, frontWheelCount = vec3(), 0
local avgBackWheelPos, backWheelCount = vec3(), 0
local avgFrontWheelPos, frontWheelCount = vec3(), 0
local avgBackWheelPos, backWheelCount = vec3(), 0
for _, wheel in pairs(wheels.wheels) do
twt.OBBinRange[i+4] = obj:getObjectDirectionVectorUp(id) -- z
twt.OBBinRange[i+3] = twt.OBBinRange[i+3] or vec3()
twt.OBBinRange[i+3]:setCross(twt.OBBinRange[i+4], twt.OBBinRange[i+2]); twt.OBBinRange[i+3]:normalize() -- y (left)
populateOBBinRange(rayDist)
local tmpVec = vec3()
local RRPicks = max(1, min(floor(150 * dt + 0.5), 8)) -- x * dt where x/fps is the numer of samples
local targetPos = vec3(plan[plan.planCount].pos)
local targetSeg = max(1, plan.planCount-1)
local segVec, segLen = vec3(), nil
for i = 2, plan.planCount do
local invDist = 1 / (dist + 1e-30)
local curDist, normalDispVec = 0, vec3()
for i = 2, plan.planCount do
for i = 1, #newPositions do
newPositionsDebug[i] = vec3(newPositions[i])
end
local inRadiuswp2, inRadiuswp1 = mapData:getEdgeRadii(wp2, wp1)
local inEdgeDir = vec3(); inEdgeDir:setSub2(mapData:getEdgePositions(wp2, wp1)); inEdgeDir:normalize()
local laneFlow = mapData.graph[wp1][wp2].drivability * 4 * min(inRadiuswp2, inRadiuswp1) / #inLaneConfig
local inBackFlow = inLaneCountOpposite * laneFlow
local outEdgeDir, maxOutflow, minNode = vec3(), 0, nil
for k, v in pairs(mapData.graph[wp2]) do
local newEdgeVec, newNodeWidthVec, dirVec = vec3(), vec3(), vec3()
if plan then
local newEdgeVec, newNodeWidthVec, dirVec = vec3(), vec3(), vec3()
if plan then
local newEdgeVec, newNodeWidthVec, dirVec = vec3(), vec3(), vec3()
if plan then
node = table.new(0, 30)
node.posOrig = vec3()
node.pos = vec3()
node.posOrig = vec3()
node.pos = vec3()
node.vec = vec3()
node.pos = vec3()
node.vec = vec3()
node.dirVec = vec3()
node.vec = vec3()
node.dirVec = vec3()
node.turnDir = vec3()
node.dirVec = vec3()
node.turnDir = vec3()
node.biNormal = vec3()
node.turnDir = vec3()
node.biNormal = vec3()
node.normal = vec3()
node.biNormal = vec3()
node.normal = vec3()
end
else
newNode.inEdgeNormal = vec3(0, 0, 0)
end
else
newNode.outEdgeNormal = vec3(0, 0, 0)
end
-- Initialize n1 node data table
local n1 = {name = nil, posOrig = plan1.posOrig, radiusOrig = plan1.radiusOrig, biNormal = plan1.biNormal, normal = vec3()}
-- Initialize n2 node data table
local n2 = {normal = vec3()}
-- placeholder for segment direction vector
local dirVec, dirVecNext = vec3(), vec3()
-- placeholder for segment direction vector
local dirVec, dirVecNext = vec3(), vec3()
local distOnPlan = - plan[1].length * plan.egoXnormOnSeg -- 0
local segDirVec, segVx, segC, segVz, segVy = vec3(), vec3(), vec3(), vec3(), vec3()
local stopFlag = false
local distOnPlan = - plan[1].length * plan.egoXnormOnSeg -- 0
local segDirVec, segVx, segC, segVz, segVy = vec3(), vec3(), vec3(), vec3(), vec3()
local stopFlag = false
local distOnPlan = - plan[1].length * plan.egoXnormOnSeg -- 0
local segDirVec, segVx, segC, segVz, segVy = vec3(), vec3(), vec3(), vec3(), vec3()
local stopFlag = false
local distOnPlan = - plan[1].length * plan.egoXnormOnSeg -- 0
local segDirVec, segVx, segC, segVz, segVy = vec3(), vec3(), vec3(), vec3(), vec3()
local stopFlag = false
local distOnPlan = - plan[1].length * plan.egoXnormOnSeg -- 0
local segDirVec, segVx, segC, segVz, segVy = vec3(), vec3(), vec3(), vec3(), vec3()
local stopFlag = false
local dist = 0
local tempVec = vec3()
-- apply offset and update other geometrical quantities
newPlan.targetSeg = tab2copy.targetSeg
newPlan.targetPos = vec3(tab2copy.targetPos)
newPlan.egoDeviation = tab2copy.egoDeviation
local egoLength, c_base, T_close, c_base_away, margin_static = ego.length, 0.3, 0.8, 0.3, 0.2
local dP, dV, nvec = vec3(), vec3(), vec3()
nvec:setScaled2(ego.rightVec, -1)
local egoLength, c_base, T_close, c_base_away, margin_static = ego.length, 0.3, 0.8, 0.3, 0.2
local dP, dV, nvec = vec3(), vec3(), vec3()
nvec:setScaled2(ego.rightVec, -1)
local egoLength, c_base, T_close, c_base_away, margin_static = ego.length, 0.3, 0.8, 0.3, 0.2
local dP, dV, nvec = vec3(), vec3(), vec3()
nvec:setScaled2(ego.rightVec, -1)
plan[i] = {
posOrig = vec3(n.posOrig),
pos = vec3(n.pos),
posOrig = vec3(n.posOrig),
pos = vec3(n.pos),
vec = vec3(n.vec),
pos = vec3(n.pos),
vec = vec3(n.vec),
dirVec = vec3(n.dirVec),
vec = vec3(n.vec),
dirVec = vec3(n.dirVec),
turnDir = vec3(n.turnDir),
dirVec = vec3(n.dirVec),
turnDir = vec3(n.turnDir),
biNormal = vec3(n.biNormal),
turnDir = vec3(n.turnDir),
biNormal = vec3(n.biNormal),
normal = vec3(n.normal),
biNormal = vec3(n.biNormal),
normal = vec3(n.normal),
radiusOrig = n.radiusOrig,
plan.targetSeg = bsrPlan.targetSeg
plan.targetPos = vec3(bsrPlan.targetPos)
plan.egoSeg = bsrPlan.egoSeg
if not plan[1] then
local posOrig = vec3(ego.pos)
local radiusOrig = 2
local radiusOrig = 2
local normal = vec3(0, 0, 0)
local latXnorm = 0
local rangeLaneCount = lanes and numOfLanesInDirection(lanes, "+") or 1 -- numOfLanesFromRadius(radiusOrig)
local vec = vec3(-8 * ego.dirVec.x, -8 * ego.dirVec.y, 0)
posOrig = posOrig,
pos = vec3(ego.pos),
vec = vec,
dirVec = vec:normalized(),
turnDir = vec3(0,0,0),
biNormal = biNormal,
local targetDist = square(ego.speed) / (2 * g * aggression) + max(30, ego.speed * 3) -- longer adjustment at higher speeds
local tmpVec = vec3()
for i = 2, plan.planCount - 1 do
else
forces[i] = vec3()
end
local nforce = vec3()
--profilerPushEvent("ai_smoothness_integration")
local tmpVec = vec3()
local roadWidthMargin = ego.width * 0.8
--profilerPushEvent("ai_calculate_curvature")
local len, n3vec = 0, vec3()
plan[1].curvature = plan[1].curvature or inCurvature(plan[1].vec, plan[2].vec)
--profilerPushEvent('ai_speedProfile')
local gT = vec3()
for i = 1, plan.planCount-1 do -- curvature is not defined on the last plan node
plan[i] = {
posOrig = vec3(n.posOrig),
pos = vec3(n.pos),
posOrig = vec3(n.posOrig),
pos = vec3(n.pos),
vec = vec3(n.vec),
pos = vec3(n.pos),
vec = vec3(n.vec),
dirVec = vec3(n.dirVec),
vec = vec3(n.vec),
dirVec = vec3(n.dirVec),
turnDir = vec3(n.turnDir),
dirVec = vec3(n.dirVec),
turnDir = vec3(n.turnDir),
biNormal = vec3(n.biNormal),
turnDir = vec3(n.turnDir),
biNormal = vec3(n.biNormal),
normal = vec3(n.normal),
biNormal = vec3(n.biNormal),
normal = vec3(n.normal),
radiusOrig = n.radiusOrig,
plan.targetSeg = bsrPlan.targetSeg
plan.targetPos = vec3(bsrPlan.targetPos)
plan.egoSeg = bsrPlan.egoSeg
if not plan[1] then
local posOrig = vec3(ego.pos)
local radiusOrig = 2
local radiusOrig = 2
local normal = vec3(0, 0, 0)
local latXnorm = 0
local rangeLaneCount = lanes and numOfLanesInDirection(lanes, "+") or 1 -- numOfLanesFromRadius(radiusOrig)
local vec = vec3(-8 * ego.dirVec.x, -8 * ego.dirVec.y, 0)
dirVec = vec:normalized(),
turnDir = vec3(0, 0, 0),
biNormal = biNormal,
-- calculate spring forces
local nforce = vec3()
if opt.trajMethod ~= 'springDampers' then
else
forces[i] = vec3()
end
else
forces[i] = vec3()
end
else
velocities[i] = vec3()
end
local dforce = vec3()
local stiff = 400
--local sideColor = color(clamp(sqrt(dispLeft) * 255, 0, 255), 0, clamp(sqrt(dispRight) * 255, 0, 255), 160)
--obj.debugDrawProxy:drawSphere(0.4, midPos + vec3(0,0,2), sideColor)
--end
local tmpVec = vec3()
for i = 2, plan.planCount - 1 do
local minTrafficDir = 1
local nDir, forceVec = vec3(), vec3()
nDir:setSub2(plan[2].pos, plan[1].pos); nDir:setScaled(1 / (plan[1].length + 1e-30))
local minTrafficDir = 1
local nDir, forceVec = vec3(), vec3()
nDir:setSub2(plan[2].pos, plan[1].pos); nDir:setScaled(1 / (plan[1].length + 1e-30))
local xnorm = plPosFront:xnormOnLine(n1ext, n2ext) * rlen
local v1 = vec3()
if xnorm > 0 and xnorm < rlen then
--profilerPushEvent("ai_smoothness_integration")
local tmpVec = vec3()
local roadWidthMargin = ego.width * 0.5
--profilerPushEvent("ai_calculate_curvature")
local len, n3vec = 0, vec3()
plan[1].curvature = plan[1].curvature or inCurvature(plan[1].vec, plan[2].vec)
len = 0
local v1z, v2z, v3z = vec3(), vec3(), vec3()
for i = 2, plan.planCount - 1 do
len = 0
local v1z, v2z, v3z = vec3(), vec3(), vec3()
for i = 2, plan.planCount - 1 do
len = 0
local v1z, v2z, v3z = vec3(), vec3(), vec3()
for i = 2, plan.planCount - 1 do
if speedProfileMode then
local gT = vec3()
for i = 1, plan.planCount-1 do -- curvature is not defined on the last plan node
else -- Use standard algotihm with curvature
local gT = vec3()
for i = plan.planCount-1, 1, -1 do
local segDir = playerNodePos1 - positions[plwp1]
local targetLineDir = vec3(-segDir.y, segDir.x, 0); targetLineDir:normalize()
local xnorm1 = closestLinePoints(playerNodePos1, playerNodePos1 + targetLineDir, player.pos, player.pos + player.dirVec)
local relativePosOtherVehicle = vec3()
local posRelativeToPolice = vec3()
local relativePosOtherVehicle = vec3()
local posRelativeToPolice = vec3()
local function trafficActions()
-- Get Direction Vector of edge exiting nid1
local linkDir = vec3(); linkDir:setSub2(mapData:getEdgePositions(nid2, nid1))
linkDir.z = 0
local prevNode = path[i-1] or plan[1].wp
local nDir = vec3()
local drivability = 1
--obj.debugDrawProxy:drawSphere(1, tSi.pos, sColor)
--obj.debugDrawProxy:drawText(tSi.pos + vec3(0, 0, 1), color(0,0,0,255), tostring(tSi.turn))
local vehicleInRange = false
local vPosF = vec3()
local egoCenterPos = getObjectBoundingBox(objectId)
local egoSqspeed = ego.speed * ego.speed
local n = vec3(-ego.dirVec.y, ego.dirVec.x, 0); n:normalize()
local rearEgoPos2TargetPos = (ego.length * push3(ego.dirVec) + mainPlan.targetPos - ego.pos):copy()
local rearEgoPos2TargetPos = (ego.length * push3(ego.dirVec) + mainPlan.targetPos - ego.pos):copy()
local d = vec3()
else
internalState.crash.dir = vec3(ego.dirVec)
internalState.crash.manoeuvre = 1
debugDrawer:drawSphere(4, p, color(255,0,0,100))
debugDrawer:drawText(p + vec3(0, 0, 4), color(0,0,0,255), 'Destination')
end
last = 1 + last % maxCount
visDebug.routeRec[last] = vec3(ego.pos)
count = min(count+1, maxCount)
local tmpVec = vec3(0.7, ego.width, 0.7)
local black = color(0, 0, 0, 128)
local path = currentRoute.path
tmpVec:setAdd(vec3(0, ego.width, 0))
local transparentRed = color(255, 0, 0, 120)
if thisPathLastNode == winner then
debugDrawer:drawCylinder(mapData.positions[thisPathLastNode], mapData.positions[thisPathLastNode] + vec3(0, 0, 8), 2, color(0, 0, 0, 255))
end
local txt = thisPathLastNode.." -> "..strFormat("%0.4f", thisScore)
debugDrawer:drawText(mapData.positions[thisPathLastNode] + vec3(0, 0, 2), color(0, 0, 0, 255), txt)
end
debugDrawer:drawSphere(4, p, color(255, 0, 0, 100))
debugDrawer:drawText(p + vec3(0, 0, 4), color(0, 0, 0, 255), 'Destination')
end
if altPlan and plan.buildN then
debugDrawer:drawSphere(0.1, altPlan.targetPos + vec3(0,0,0.5), color(0,255,255,255))
for j = 1, altPlan.planCount do
local speed = point.speed or 0
debugDrawer:drawSphere(0.1, point.pos + vec3(0,0,0.5), color(255,255,255,255))
debugDrawer:drawSphere(0.1, point.pos + vec3(0,0,speed*0.2), color(255,255,255,255))
debugDrawer:drawSphere(0.1, point.pos + vec3(0,0,0.5), color(255,255,255,255))
debugDrawer:drawSphere(0.1, point.pos + vec3(0,0,speed*0.2), color(255,255,255,255))
debugDrawer:drawText(point.pos + vec3(0,0,speed*0.2), color(0, 0, 0, 255), strFormat("%2.0f", speed*3.6).." kph")
debugDrawer:drawSphere(0.1, point.pos + vec3(0,0,speed*0.2), color(255,255,255,255))
debugDrawer:drawText(point.pos + vec3(0,0,speed*0.2), color(0, 0, 0, 255), strFormat("%2.0f", speed*3.6).." kph")
if j > 1 then
local prevSpeed = altPlan[j-1].speed or 0
debugDrawer:drawCylinder(altPlan[j-1].pos + vec3(0,0,0.5), point.pos + vec3(0,0,0.5), 0.05, color(255, 255, 255, 100))
debugDrawer:drawCylinder(altPlan[j-1].pos + vec3(0,0,prevSpeed*0.2), point.pos + vec3(0,0,speed*0.2), 0.05, color(255*clamp(k-2, 0, 1), 255*clamp(k-1,0,1), 255, 100))
local prevSpeed = altPlan[j-1].speed or 0
debugDrawer:drawCylinder(altPlan[j-1].pos + vec3(0,0,0.5), point.pos + vec3(0,0,0.5), 0.05, color(255, 255, 255, 100))
debugDrawer:drawCylinder(altPlan[j-1].pos + vec3(0,0,prevSpeed*0.2), point.pos + vec3(0,0,speed*0.2), 0.05, color(255*clamp(k-2, 0, 1), 255*clamp(k-1,0,1), 255, 100))
debugDrawer:drawCylinder(altPlan[j-1].pos + vec3(0,0,0.5), point.pos + vec3(0,0,0.5), 0.05, color(255, 255, 255, 100))
debugDrawer:drawCylinder(altPlan[j-1].pos + vec3(0,0,prevSpeed*0.2), point.pos + vec3(0,0,speed*0.2), 0.05, color(255*clamp(k-2, 0, 1), 255*clamp(k-1,0,1), 255, 100))
end
debugDrawer:drawCylinder(altPlan[j-1].pos + vec3(0,0,0.5), point.pos + vec3(0,0,0.5), 0.05, color(255, 255, 255, 100))
debugDrawer:drawCylinder(altPlan[j-1].pos + vec3(0,0,prevSpeed*0.2), point.pos + vec3(0,0,speed*0.2), 0.05, color(255*clamp(k-2, 0, 1), 255*clamp(k-1,0,1), 255, 100))
end
last = 1 + last % maxCount
visDebug.trajecRec[last] = {vec3(ego.pos), ego.speed, targetSpeed, lastCommand.brake, lastCommand.throttle}
count = min(count+1, maxCount)
local tmpVec1 = vec3(0.7, ego.width, 0.7)
for i = 1, count-1 do
local prevEntry
local zOffSet = vec3(0, 0, 0.4)
local yellow, blue = color(255,255,0,200), color(0,0,255,200)
local yellow, blue = color(255,255,0,200), color(0,0,255,200)
local tmpVec2 = vec3()
for i = 1, count-1 do
local prevPoint_ = plan[1].pos
local tmpVec = vec3()
for i = 1, #plan do
local prevPointOrig = plan[1].posOrig
local tmpVec = vec3(1, 1, 1)
local tmpVec1 = vec3(0.5, 0.5, 0.5)
local tmpVec = vec3(1, 1, 1)
local tmpVec1 = vec3(0.5, 0.5, 0.5)
local pos = newPositionsDebug[i]
local p1 = pos + vec3(0, 0, 2)
debugDrawer:drawCylinder(pos, p1, 0.03, green)
-- local scaledV = abs(1000 * v)
-- debugDrawer:drawCylinder(p, p + vec3(0, 0, scaledV), 0.06, color(abs(min(sign(v),0))*255,max(sign(v),0)*255,0,200))
-- debugDrawer:drawText(p + vec3(0, 0, scaledV), color(0,0,0,255), strFormat("%5.4e", v))
-- debugDrawer:drawCylinder(p, p + vec3(0, 0, scaledV), 0.06, color(abs(min(sign(v),0))*255,max(sign(v),0)*255,0,200))
-- debugDrawer:drawText(p + vec3(0, 0, scaledV), color(0,0,0,255), strFormat("%5.4e", v))
-- debugDrawer:drawCylinder(prevPoint, p + vec3(0, 0, scaledV), 0.06, col)
-- debugDrawer:drawText(p + vec3(0, 0, scaledV), color(0,0,0,255), strFormat("%5.4e", v))
-- debugDrawer:drawCylinder(prevPoint, p + vec3(0, 0, scaledV), 0.06, col)
-- prevPoint = p + vec3(0, 0, scaledV)
-- debugDrawer:drawCylinder(prevPoint, p + vec3(0, 0, scaledV), 0.06, col)
-- prevPoint = p + vec3(0, 0, scaledV)
-- end
local v = (n.speed >= 0 and n.speed) or prevSpeed
local p1 = p + vec3(0, 0, v*0.2)
--debugDrawer:drawLine(p + vec3(0, 0, v*0.2), (n.pos + n.turnDir) + vec3(0, 0, v*0.2), col)
local p1 = p + vec3(0, 0, v*0.2)
--debugDrawer:drawLine(p + vec3(0, 0, v*0.2), (n.pos + n.turnDir) + vec3(0, 0, v*0.2), col)
debugDrawer:drawCylinder(p, p1, 0.03, col)
local p1 = p + vec3(0, 0, v*0.2)
--debugDrawer:drawLine(p + vec3(0, 0, v*0.2), (n.pos + n.turnDir) + vec3(0, 0, v*0.2), col)
debugDrawer:drawCylinder(p, p1, 0.03, col)
last = 1 + last % maxCount
visDebug.trajecRec[last] = {vec3(ego.pos), lastCommand.throttle, lastCommand.brake}
count = min(count+1, maxCount)
local tmpVec = vec3(0.7, ego.width, 0.7)
for i = 1, count-1 do
populateOBBinRange(rayDist)
local tmpVec = vec3()
local helperVec = vec3()
local tmpVec = vec3()
local helperVec = vec3()
local rounds = twt.idx - 1
obj.debugDrawProxy:drawSphere(0.2, v.pos, color(0, 0, 255, 255))
local vPos = vec3(obj:getObjectFrontPosition(k))
obj.debugDrawProxy:drawSphere(0.2, vPos, color(0, 0, 255, 255))
-- calculated spawn pos (from script front pos)
debugDrawer:drawSphere(0.1, vec3(736.8858419,102.6078886,0.1169999319), color(0, 0, 255, 255))
-- script first pos (ground truth)
debugDrawer:drawSphere(0.1, vec3(734.9434413112983, 102.21897064457461, 1.0), color(255, 0, 255, 255))
-- Draw world reference Frame
debugDrawer:drawSphere(0.1, vec3(0, 0, 0), color(0, 255, 0, 255)) -- World 0
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(1, 0, 0), 0.05, color(0, 255, 0, 255)) -- x (green)
debugDrawer:drawSphere(0.1, vec3(0, 0, 0), color(0, 255, 0, 255)) -- World 0
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(1, 0, 0), 0.05, color(0, 255, 0, 255)) -- x (green)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 1, 0), 0.05, color(255, 0, 0, 255)) -- y (red)
debugDrawer:drawSphere(0.1, vec3(0, 0, 0), color(0, 255, 0, 255)) -- World 0
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(1, 0, 0), 0.05, color(0, 255, 0, 255)) -- x (green)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 1, 0), 0.05, color(255, 0, 0, 255)) -- y (red)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(1, 0, 0), 0.05, color(0, 255, 0, 255)) -- x (green)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 1, 0), 0.05, color(255, 0, 0, 255)) -- y (red)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 0, 1), 0.05, color(0, 0, 255, 255)) -- z (blue)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(1, 0, 0), 0.05, color(0, 255, 0, 255)) -- x (green)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 1, 0), 0.05, color(255, 0, 0, 255)) -- y (red)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 0, 1), 0.05, color(0, 0, 255, 255)) -- z (blue)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 1, 0), 0.05, color(255, 0, 0, 255)) -- y (red)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 0, 1), 0.05, color(0, 0, 255, 255)) -- z (blue)
end
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 1, 0), 0.05, color(255, 0, 0, 255)) -- y (red)
debugDrawer:drawCylinder(vec3(0, 0, 0), 5 * vec3(0, 0, 1), 0.05, color(0, 0, 255, 255)) -- z (blue)
end
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
dir = vec3(script[1].dir)
up = vec3(script[1].up or mapmgr.surfaceNormalBelow(vec3(script[1])))
local vy = dir:cross(up) * -frontPosRelOrig.x
pos = vec3(script[1]) - vx - vz - vy
local dH = require('scriptai').wheelToGroundDist(pos, dir, up)
local p1 = vec3(script[1])
local p1z0 = p1:z0()
local p1z0 = p1:z0()
local scriptPosi = vec3()
local k
if k then
local p2 = vec3(script[k])
dir = p2 - p1; dir:normalize()
local node = 'wp_'..tostring(i)
pathMap:setPointPositionRadius(node, vec3(arg.script[i].x, arg.script[i].y, arg.script[i].z), arg.script[i].r or radius)
path[i] = node
@/lua/ge/extensions/editor/tech/roadArchitect/profiles.lua
local min, max, floor, random = math.min, math.max, math.floor, math.random
local pView = vec3(-24.02901173, 0.8800626756, 1007.733115)
local pRot = quat(0.1090148618, -0.114031973, 0.7137778829, 0.6823735069)
@/lua/ge/extensions/ui/uiNavi.lua
local function findClosestRoad (x, y, z)
return map.findClosestRoad(vec3(x, y, z))
end
end
tmp.pos = vec3(o:getPosition()):toTable()
table.insert(res, tmp)
if o then
table.insert(pois, {name = o.name, pos = vec3(o:getPosition()):toTable(), desc = o.desc, title = o.title, type = o.type})
end
destination = wp
destinationPos = vec3(pos[1], pos[2], pos[3])
end
local function planRoute (posX, posY)
local x = vec3(posX[1], posX[2], posX[3])
local y = vec3(posY[1], posY[2], posY[3])
local x = vec3(posX[1], posX[2], posX[3])
local y = vec3(posY[1], posY[2], posY[3])
if o and o.type == 'busstop' then
table.insert(interm, vec3(o:getPosition()))
end
local camPos = vec3()
local camPosPrev = vec3()
local camPos = vec3()
local camPosPrev = vec3()
local mapObjects = {}
local mapObjectsTblPool = {}
local xPlus, yMinus = vec3(1,0,0), vec3(0,-1,0)
local controlId, cameraHandler
local mapObjectsTblPool = {}
local xPlus, yMinus = vec3(1,0,0), vec3(0,-1,0)
local controlId, cameraHandler
{
size = vec3(blockSize, blockSize, terr.maxHeight):toTable(),
offset = vec3(terr:getPosition().x, terr:getPosition().y + blockSize, 0):toTable(),
size = vec3(blockSize, blockSize, terr.maxHeight):toTable(),
offset = vec3(terr:getPosition().x, terr:getPosition().y + blockSize, 0):toTable(),
file = minimapImage
@/lua/ge/extensions/editor/tech/roadArchitect/roads.lua
local twoPi = math.pi * 2.0
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local twoPi = math.pi * 2.0
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local twoPi = math.pi * 2.0
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local twoPi = math.pi * 2.0
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local tmp0, tmp1, tmp2, tmp3 = vec3(0, 0), vec3(0, 0), vec3(0, 0), vec3(0, 0)
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local camRotAngle = 0.0
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local camRotAngle = 0.0
local temp_P1, temp_P2 = vec3(-10, 0, auditionHeight), vec3(10, 0, auditionHeight)
local gView, auditionVec, auditionCamPos = vec3(0, 0), vec3(0, 0, auditionHeight), vec3(0, 0)
local camRotAngle = 0.0
tree:insert(r.name, xMin, yMin, xMax, yMax) -- Update the tree.
r.aabb = vec3((xMin + xMax) * 0.5, (yMin + yMax) * 0.5) -- Set the latest AABB on the road, for later tree-removal usage.
end
r.nodes[#r.nodes + 1] = {
p = vec3(pos.x, pos.y, pos.z), -- The node world-space position.
isLocked = false, -- Indicates if node is locked or unlocked (ie if can be moved by the user).
local newNode = {
p = vec3(pos.x, pos.y, pos.z), -- The node world-space position.
isLocked = false, -- Indicates if node is locked or unlocked (ie if can be moved by the user).
return {
p = vec3(pos.x, pos.y, pos.z),
isLocked = n.isLocked,
local midX, midY = (xMin + xMax) * 0.5, (yMin + yMax) * 0.5 -- Midpoint of axis-aligned bounding box.
local tmp0 = vec3(midX, midY, 0.0)
local tmp1 = vec3(xMax, yMax, 0.0)
local tmp0 = vec3(midX, midY, 0.0)
local tmp1 = vec3(xMax, yMax, 0.0)
local groundDist = tmp0:distance(tmp1) -- The largest distance from the center of the box to the outside.
local height = groundDist / tan(halfFov) + zMax + 5.0 -- The height that the camera should be to fit all the trajectory in view.
local rot = quatFromDir(vec3(0, 0, -1))
if r.aabb then
aabb = vec3(r.aabb.x, r.aabb.y)
end
treatAsInvisibleInEdit = false,
aabb = vec3((n1.p.x + n2.p.x) * 0.5, (n1.p.y + n2.p.y) * 0.5),
isDrivable = false,
local p = gPolygon[i]
poly2D[i] = vec3(p.x, p.y, 0.0)
end
end
return vec3((xMin + xMax) * 0.5, (yMin + yMax) * 0.5, (zMin + zMax) * 0.5)
end
return { -- Now de-serialise the node container.
p = vec3(nSer.posX, nSer.posY, nSer.posZ),
isLocked = nSer.isLocked or false,
@/lua/ge/extensions/gameplay/traffic/trafficUtils.lua
local rolesCache = {}
local tempPos, tempDir = vec3(), vec3() -- general temporary vectors
local p1, p2 = vec3(), vec3() -- map node positions
local rolesCache = {}
local tempPos, tempDir = vec3(), vec3() -- general temporary vectors
local p1, p2 = vec3(), vec3() -- map node positions
local tempPos, tempDir = vec3(), vec3() -- general temporary vectors
local p1, p2 = vec3(), vec3() -- map node positions
local tempPos, tempDir = vec3(), vec3() -- general temporary vectors
local p1, p2 = vec3(), vec3() -- map node positions
local newPos, newDir = vec3(), vec3()
options = options or {}
local newPos, newDir = vec3(), vec3()
options = options or {}
if not dir or options.legalDirection then
if not dir then dir = vec3() end
dir:setSub2(p2, p1)
local spawnData = {pos = vec3(), dir = vec3()}
local valid = false
local spawnData = {pos = vec3(), dir = vec3()}
local valid = false
local spawnData = {pos = vec3(), dir = vec3()}
local valid = false
local spawnData = {pos = vec3(), dir = vec3()}
local valid = false
local spawnData = {pos = vec3(), dir = vec3()}
local valid = false
local spawnData = {pos = vec3(), dir = vec3()}
local valid = false
@/lua/vehicle/extensions/scenario/shiftBooster.lua
end
obj.debugDrawProxy:drawSphere(boostTime, obj:getPosition() + vec3(0, 0, 2), color(math.sin(boostTime) * 255, math.cos(boostTime * 2) * 255, 0, 255))
end
@/lua/ge/extensions/editor/tech/sensorConfiguration/conversions.lua
pos = nil,
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
size = { 200, 200 },
pos = nil,
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
verticalResolution = 64,
pos = nil,
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
size = { 200, 200 },
pos = nil,
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
size = { 200, 200 },
pos = nil,
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
physicsUpdateTime = 0.01,
pos = nil,
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
dir = vec3(1, 0, 0),
up = vec3(0, 0, 1),
physicsUpdateTime = 0.01,
@/lua/ge/extensions/gameplay/drag/utils.lua
for k, wheel in pairs(racer.wheelsCenter) do
racer._wheelDistances[k] = racer._wheelDistances[k] or vec3()
racer._wheelDistances[k]:set(wheel.pos)
end
local x, y, z = boundary.rotation * vec3(boundary.scale.x,0,0), boundary.rotation * vec3(0,boundary.scale.y,0), boundary.rotation * vec3(0,0,boundary.scale.z)
return containsOBB_point(boundary.position, x, y, z, racer.vehPos )
end
local x, y, z = boundary.rotation * vec3(boundary.scale.x,0,0), boundary.rotation * vec3(0,boundary.scale.y,0), boundary.rotation * vec3(0,0,boundary.scale.z)
return containsOBB_point(boundary.position, x, y, z, racer.vehPos )
end
local x, y, z = boundary.rotation * vec3(boundary.scale.x,0,0), boundary.rotation * vec3(0,boundary.scale.y,0), boundary.rotation * vec3(0,0,boundary.scale.z)
return containsOBB_point(boundary.position, x, y, z, racer.vehPos )
if not racer.vehPos then racer.vehPos = vec3() end
if not racer.vehDirectionVector then racer.vehDirectionVector = vec3() end
if not racer.vehPos then racer.vehPos = vec3() end
if not racer.vehDirectionVector then racer.vehDirectionVector = vec3() end
if not racer.vehDirectionVectorUp then racer.vehDirectionVectorUp = vec3() end
if not racer.vehDirectionVector then racer.vehDirectionVector = vec3() end
if not racer.vehDirectionVectorUp then racer.vehDirectionVectorUp = vec3() end
if not racer.vehVelocity then racer.vehVelocity = vec3() end
if not racer.vehDirectionVectorUp then racer.vehDirectionVectorUp = vec3() end
if not racer.vehVelocity then racer.vehVelocity = vec3() end
racer.wheelsCenter[k] = {
pos = vec3(),
wheelCountInv = 1/#offset
@/lua/ge/extensions/flowgraph/nodes/gameplay/sites/locationsByTag.lua
-- otherwise we have to query the quadtree and then check for tags ourselves.
for _, elem in ipairs(self.pinIn.sitesData.value:getRadialLocations(vec3(self.pinIn.pos.value), self.pinIn.minDist.value, self.pinIn.maxDist.value)) do
local loc = elem.loc
table.sort(locs, function(a, b)
return (vec3(self.pinIn.pos.value) - a.pos):length() < (vec3(self.pinIn.pos.value) - b.pos):length()
end)
table.sort(locs, function(a, b)
return (vec3(self.pinIn.pos.value) - a.pos):length() < (vec3(self.pinIn.pos.value) - b.pos):length()
end)
@/lua/ge/extensions/editor/mapSensorEditor.lua
local sensorIcon = im.ImVec2(32, 32) -- Some commonly-used Imgui icon size vectors.
local beginDragRotation = vec3(0, 0)
local lookAtSensorOffset = vec3(0.5, 0.5, 5)
local beginDragRotation = vec3(0, 0)
local lookAtSensorOffset = vec3(0.5, 0.5, 5)
core_camera.setPosition(0, from)
local rot = quatFromDir(sensor.pos - from, vec3(0, 0, 1))
core_camera.setRotation(0, rot)
@/lua/ge/extensions/flowgraph/nodes/vehicle/moveTo.lua
if self.data.useWheelCenter then
local wCenter = vec3(0,0,0)
local wCount = veh:getWheelCount()-1
local nodePos = veh:getNodePosition(axisNodes[1])
local wheelNodePos = vec3(nodePos.x, nodePos.y, nodePos.z)
wCenter = wCenter + wheelNodePos
local correctedRot = quat(rot) * quat(0,0,-1,0)
spawn.safeTeleport(veh, vec3(pos), quat(correctedRot))
-- Vehicle is repaired, trigger reset hook for DNF penalty
local correctedRot = quat(rot) * quat(0,0,-1,0)
spawn.safeTeleport(veh, vec3(pos), quat(correctedRot), nil, nil, nil, nil, false)
-- Vehicle is moved without repair, trigger flip upright hook
@/lua/ge/extensions/core/audioRibbon.lua
local sfxEmitters = { {}, {}, {}, {}, {} }
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local sfxEmitters = { {}, {}, {}, {}, {} }
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local sfxEmitters = { {}, {}, {}, {}, {} }
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local sfxEmitters = { {}, {}, {}, {}, {} }
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local sfxEmitters = { {}, {}, {}, {}, {} }
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local sfxEmitters = { {}, {}, {}, {}, {} }
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local tmpEmitP, tmpBlueP = vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local tmpEmitP, tmpBlueP = vec3(), vec3()
local tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local tmpEmitP, tmpBlueP = vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local tmpEmitP, tmpBlueP = vec3(), vec3()
local lPosition, lForward, lRight = vec3(), vec3(), vec3()
local tmpAxis1, tmpAxis2, tmpList = vec3(), vec3(), vec3()
local tmpEmitP, tmpBlueP = vec3(), vec3()
local lPosition, lForward, lRight = vec3(), vec3(), vec3()
local tmpEmitP, tmpBlueP = vec3(), vec3()
local lPosition, lForward, lRight = vec3(), vec3(), vec3()
local tmpEmitP, tmpBlueP = vec3(), vec3()
local lPosition, lForward, lRight = vec3(), vec3(), vec3()
local tmpEmitP, tmpBlueP = vec3(), vec3()
local lPosition, lForward, lRight = vec3(), vec3(), vec3()
axisCache[emit.eventNameStr] = axisCache[emit.eventNameStr] or { pos = vec3() }
if axis[emit.eventNameStr] == nil then
axisCache[emit.eventNameStr] = axisCache[emit.eventNameStr] or { pos = vec3() }
if axis[emit.eventNameStr] == nil then
texture = 0.0,
pos = vec3(0.0, 0.0) }
end
vol = 0,
pos = vec3(huge, huge, huge),
bN = 0,
for _, nd in ipairs(ribbonData.nodes) do
table.insert(ribbon.nodes, vec3(nd.x, nd.y, nd.z))
table.insert(ribbon.depths, nd.depth)
local nd = ribbon.nodes[j]
nodesCopy[j] = vec3(nd.x, nd.y, nd.z)
end
@/lua/ge/extensions/ui/apps/minimap/minimap.lua
local centerX, centerY -- center of the minimap in imgui coordinates
local camPos, camRot, camRotInverse = vec3(), quat(), quat() -- camera transform
local cameraLook = vec3()
local camPos, camRot, camRotInverse = vec3(), quat(), quat() -- camera transform
local cameraLook = vec3()
local scaleSetting = 0.5 -- px/m
-- Unoptimized
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
local centerLocal = vec3()
-- Unoptimized
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
local centerLocal = vec3()
-- Unoptimized
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
local centerLocal = vec3()
-- Unoptimized
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
local centerLocal = vec3()
local tmp1, tmp2, tmp3, tmp4 = vec3(), vec3(), vec3(), vec3()
local centerLocal = vec3()
local worldYDirection = vec3(0,1,0)
local centerLocal = vec3()
local worldYDirection = vec3(0,1,0)
local directionLocal = vec3()
local worldYDirection = vec3(0,1,0)
local directionLocal = vec3()
local intersectionLocal = vec3()
local directionLocal = vec3()
local intersectionLocal = vec3()
local leftTop, leftBottom, rightTop, rightBottom, diagonalTop, diagonalBottom = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local intersectionLocal = vec3()
local leftTop, leftBottom, rightTop, rightBottom, diagonalTop, diagonalBottom = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local function drawCompass(offsetX, offsetY)
local intersectionLocal = vec3()
local leftTop, leftBottom, rightTop, rightBottom, diagonalTop, diagonalBottom = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local function drawCompass(offsetX, offsetY)
local intersectionLocal = vec3()
local leftTop, leftBottom, rightTop, rightBottom, diagonalTop, diagonalBottom = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local function drawCompass(offsetX, offsetY)
local intersectionLocal = vec3()
local leftTop, leftBottom, rightTop, rightBottom, diagonalTop, diagonalBottom = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local function drawCompass(offsetX, offsetY)
local intersectionLocal = vec3()
local leftTop, leftBottom, rightTop, rightBottom, diagonalTop, diagonalBottom = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local function drawCompass(offsetX, offsetY)
local intersectionLocal = vec3()
local leftTop, leftBottom, rightTop, rightBottom, diagonalTop, diagonalBottom = vec3(), vec3(), vec3(), vec3(), vec3(), vec3()
local function drawCompass(offsetX, offsetY)
local border = 0
local up = vec3(0,1,0)
local camRotInverse = quat()
local imVec01 = im.ImVec2(0,1)
local lookWithoutZ = vec3()
local function drawMinimap(sizeX, sizeY, dtReal, dtSim)
@/lua/ge/extensions/core/cameraModes/shake.lua
self.hidden = true
self.amp = vec3(0.08, 0.05, 0.03)
self.freq = vec3(0.05, 0.04, 0.03)
self.amp = vec3(0.08, 0.05, 0.03)
self.freq = vec3(0.05, 0.04, 0.03)
self.timeOffset = vec3(0, math.random(), math.random())
self.freq = vec3(0.05, 0.04, 0.03)
self.timeOffset = vec3(0, math.random(), math.random())
self.time = 0
self.time = self.time + data.dt
local offset = vec3(
self.amp.x * math.sin(math.pi * 2 * (self.timeOffset.x + self.time) * self.freq.x),
local rotEuler = vec3(
offset.x * 10 * math.pi / 180,
@/lua/ge/extensions/scenario/waypoints.lua
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local vRot = quatFromDir(vehicle:getDirectionVector(), vehicle:getDirectionVectorUp())
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
local x,y,z = vRot * vec3(1,0,0),vRot * vec3(0,1,0),vRot * vec3(0,0,1)
--local oobbz = vec3(vehicle:getSpawnWorldOOBB():getHalfExtents()).z/2
for i=0, wCount do
local axisNodes = vehicle:getWheelAxisNodes(i)
local nodePos = vec3(vehicle:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
local nodePos = vec3(vehicle:getNodePosition(axisNodes[1]))
local pos = vec3(nodePos:dot(x), nodePos:dot(y), nodePos:dot(z))
table.insert(vData.wheelOffsets, pos)
local node = scenario.nodes[wp]
table.insert(wpList, {name = wp, pos = vec3(node.pos), radius = node.radius, normal = node.rot, up = node.up })
local pn = require('/lua/ge/extensions/gameplay/race/pathnode')(nil, wp, -1)
local pn = require('/lua/ge/extensions/gameplay/race/pathnode')(nil, wp, -1)
pn.pos = vec3(node.pos)
pn.radius = node.radius
if lastWp then
raceMarker.setFinalMarkerPosition(vec3(lastWp.pos), lastWp.radius, waypointsConfigData.lastWaypointColor)
end
for i = 1, #vehWpData.previousCorners do
debugDrawer:drawLine(vec3(vehWpData.previousCorners[i]), vec3(vehWpData.currentCorners[i]), ColorF(1,0,0,1))
debugDrawer:drawSphere(vec3(vehWpData.currentCorners[i]), 0.025, ColorF(1,0,0,0.25))
for i = 1, #vehWpData.previousCorners do
debugDrawer:drawLine(vec3(vehWpData.previousCorners[i]), vec3(vehWpData.currentCorners[i]), ColorF(1,0,0,1))
debugDrawer:drawSphere(vec3(vehWpData.currentCorners[i]), 0.025, ColorF(1,0,0,0.25))
debugDrawer:drawLine(vec3(vehWpData.previousCorners[i]), vec3(vehWpData.currentCorners[i]), ColorF(1,0,0,1))
debugDrawer:drawSphere(vec3(vehWpData.currentCorners[i]), 0.025, ColorF(1,0,0,0.25))
end
@/lua/ge/extensions/gameplay/discover/newPlayerExperience.lua
local vehs = {
{ vec3(189.2717133,-375.0607605,194.2601013), quat(0,0,0.7038784663,0.710320424), "vivace", "vehicles/vivace/vivace_230S_DCT.pc" },
}
gameplay_traffic.setActiveAmount(0)
freeroam_bigMapMode.setNavFocus(vec3(310.2650452,1816.934692,207.3096924))
return true
local vehs = {
{ vec3(-1270.672607,-79.58815765,121.6928101), quat(-0.02186222721,0.0009984752378,0.7260386731,0.6873055297), "pickup", "vehicles/pickup/deserttruck_crawler_A.pc" },
{ vec3(-1273.283325,-83.95053864,121.7670593), quat(0.01025221426,-0.02570453177,0.8734151899,0.4861893409), "racetruck", "vehicles/racetruck/tt2_spec.pc" },
{ vec3(-1270.672607,-79.58815765,121.6928101), quat(-0.02186222721,0.0009984752378,0.7260386731,0.6873055297), "pickup", "vehicles/pickup/deserttruck_crawler_A.pc" },
{ vec3(-1273.283325,-83.95053864,121.7670593), quat(0.01025221426,-0.02570453177,0.8734151899,0.4861893409), "racetruck", "vehicles/racetruck/tt2_spec.pc" },
--{ vec3(-574.324,-404.611,132.277), quat(-0.004031204019,-0.03853915852,-0.4529694097,0.8906835558), "rockbouncer", "vehicles/rockbouncer/rock_crawler.pc" },
{ vec3(-1273.283325,-83.95053864,121.7670593), quat(0.01025221426,-0.02570453177,0.8734151899,0.4861893409), "racetruck", "vehicles/racetruck/tt2_spec.pc" },
--{ vec3(-574.324,-404.611,132.277), quat(-0.004031204019,-0.03853915852,-0.4529694097,0.8906835558), "rockbouncer", "vehicles/rockbouncer/rock_crawler.pc" },
--{ vec3(-574.530,-404.151,132.347), quat(-0.004031204019,-0.03853915852,-0.4529694097,0.8906835558), "roamer", "vehicles/roamer/adventure.pc" },
--{ vec3(-574.324,-404.611,132.277), quat(-0.004031204019,-0.03853915852,-0.4529694097,0.8906835558), "rockbouncer", "vehicles/rockbouncer/rock_crawler.pc" },
--{ vec3(-574.530,-404.151,132.347), quat(-0.004031204019,-0.03853915852,-0.4529694097,0.8906835558), "roamer", "vehicles/roamer/adventure.pc" },
{ vec3(-1272.337158,-74.02603149,121.4899216), quat(-0.007339913527,0.003215354856,0.4619465262,0.886871577), "utv", "vehicles/utv/plus.pc" },
--{ vec3(-574.530,-404.151,132.347), quat(-0.004031204019,-0.03853915852,-0.4529694097,0.8906835558), "roamer", "vehicles/roamer/adventure.pc" },
{ vec3(-1272.337158,-74.02603149,121.4899216), quat(-0.007339913527,0.003215354856,0.4619465262,0.886871577), "utv", "vehicles/utv/plus.pc" },
}
local vehs = {
{ vec3(-455.5000305,374.7161865,25.23128128), quat(6.270791814e-05,0.0005269290997,0.9929929419,-0.1181724831), vehChoices[1][1], vehChoices[1][2] },
{ vec3(-446.6066589,361.14505,25.16402245), quat(3.034665428e-05,0.0002429556407,0.9922893041,-0.123943039), vehChoices[2][1], vehChoices[2][2] },
{ vec3(-455.5000305,374.7161865,25.23128128), quat(6.270791814e-05,0.0005269290997,0.9929929419,-0.1181724831), vehChoices[1][1], vehChoices[1][2] },
{ vec3(-446.6066589,361.14505,25.16402245), quat(3.034665428e-05,0.0002429556407,0.9922893041,-0.123943039), vehChoices[2][1], vehChoices[2][2] },
{ vec3(-438.1695862,346.2776184,25.1306839), quat(-0.0001477062226,-0.001071917166,0.9906386067,-0.1365063375), vehChoices[3][1], vehChoices[3][2] },
{ vec3(-446.6066589,361.14505,25.16402245), quat(3.034665428e-05,0.0002429556407,0.9922893041,-0.123943039), vehChoices[2][1], vehChoices[2][2] },
{ vec3(-438.1695862,346.2776184,25.1306839), quat(-0.0001477062226,-0.001071917166,0.9906386067,-0.1365063375), vehChoices[3][1], vehChoices[3][2] },
{ vec3(-429.155426,333.7767334,25.10681915), quat(-8.45975059e-05,-0.0007574605165,0.9938206113,-0.1109955479), vehChoices[4][1], vehChoices[4][2] },
{ vec3(-438.1695862,346.2776184,25.1306839), quat(-0.0001477062226,-0.001071917166,0.9906386067,-0.1365063375), vehChoices[3][1], vehChoices[3][2] },
{ vec3(-429.155426,333.7767334,25.10681915), quat(-8.45975059e-05,-0.0007574605165,0.9938206113,-0.1109955479), vehChoices[4][1], vehChoices[4][2] },
{ vec3(-420.4411316,319.9455872,25.14068985), quat(0,-0,0.9944942508,-0.10479115), vehChoices[5][1], vehChoices[5][2] },
{ vec3(-429.155426,333.7767334,25.10681915), quat(-8.45975059e-05,-0.0007574605165,0.9938206113,-0.1109955479), vehChoices[4][1], vehChoices[4][2] },
{ vec3(-420.4411316,319.9455872,25.14068985), quat(0,-0,0.9944942508,-0.10479115), vehChoices[5][1], vehChoices[5][2] },
}
local vehs = {
{ vec3(-143.3728027,83.48352814,35.11228561), quat(-0.004508387994,0.0001588892785,0.03522081038,0.999369373), "van", "vehicles/van/h25_worker.pc" },
{ vec3(-171.8866425,127.8188705,34.96841812), quat(0.02066615241,-0.008679200679,0.387113079,0.9217597548), "cannon", "vehicles/cannon/cannon.pc" },
{ vec3(-143.3728027,83.48352814,35.11228561), quat(-0.004508387994,0.0001588892785,0.03522081038,0.999369373), "van", "vehicles/van/h25_worker.pc" },
{ vec3(-171.8866425,127.8188705,34.96841812), quat(0.02066615241,-0.008679200679,0.387113079,0.9217597548), "cannon", "vehicles/cannon/cannon.pc" },
{ vec3(-158.3771362,143.2392883,35.22563553), quat(-0.001331452813,-0.001542004732,-0.7568890667,0.6535401978), "caravan", "vehicles/caravan/default.pc" },
{ vec3(-171.8866425,127.8188705,34.96841812), quat(0.02066615241,-0.008679200679,0.387113079,0.9217597548), "cannon", "vehicles/cannon/cannon.pc" },
{ vec3(-158.3771362,143.2392883,35.22563553), quat(-0.001331452813,-0.001542004732,-0.7568890667,0.6535401978), "caravan", "vehicles/caravan/default.pc" },
{ vec3(-144.6221008,157.9118805,35.99853516), quat(-1.780725942e-06,-5.771057474e-06,0.9555452647,-0.2948444456), "fridge", "vehicles/fridge/standard.pc" },
{ vec3(-158.3771362,143.2392883,35.22563553), quat(-0.001331452813,-0.001542004732,-0.7568890667,0.6535401978), "caravan", "vehicles/caravan/default.pc" },
{ vec3(-144.6221008,157.9118805,35.99853516), quat(-1.780725942e-06,-5.771057474e-06,0.9555452647,-0.2948444456), "fridge", "vehicles/fridge/standard.pc" },
{ vec3(-150.1018219,158.1330872,36.21847534), quat(1.766898486e-06,-1.028953559e-05,0.985574711,0.1692409196), "porta_potty", "vehicles/porta_potty/default.pc" },
{ vec3(-144.6221008,157.9118805,35.99853516), quat(-1.780725942e-06,-5.771057474e-06,0.9555452647,-0.2948444456), "fridge", "vehicles/fridge/standard.pc" },
{ vec3(-150.1018219,158.1330872,36.21847534), quat(1.766898486e-06,-1.028953559e-05,0.985574711,0.1692409196), "porta_potty", "vehicles/porta_potty/default.pc" },
{ vec3(-146.2707825,159.0570221,36.05832672), quat(0.0001382667643,1.267887785e-06,-0.009169481016,0.9999579499), "piano", "vehicles/piano/standard.pc" },
{ vec3(-150.1018219,158.1330872,36.21847534), quat(1.766898486e-06,-1.028953559e-05,0.985574711,0.1692409196), "porta_potty", "vehicles/porta_potty/default.pc" },
{ vec3(-146.2707825,159.0570221,36.05832672), quat(0.0001382667643,1.267887785e-06,-0.009169481016,0.9999579499), "piano", "vehicles/piano/standard.pc" },
{ vec3(-138.2297058,102.0587769,34.79919434), quat(-0.0001324840225,0.0001432935834,0.7342591574,0.6788692449), "tv", "vehicles/tv/25inch.pc" },
{ vec3(-146.2707825,159.0570221,36.05832672), quat(0.0001382667643,1.267887785e-06,-0.009169481016,0.9999579499), "piano", "vehicles/piano/standard.pc" },
{ vec3(-138.2297058,102.0587769,34.79919434), quat(-0.0001324840225,0.0001432935834,0.7342591574,0.6788692449), "tv", "vehicles/tv/25inch.pc" },
{ vec3(-136.6850739,104.0551834,34.89838409), quat(-1.370823688e-06,-2.668151342e-06,0.8894732678,-0.4569872053), "couch", "vehicles/couch/couch_free.pc" },
{ vec3(-138.2297058,102.0587769,34.79919434), quat(-0.0001324840225,0.0001432935834,0.7342591574,0.6788692449), "tv", "vehicles/tv/25inch.pc" },
{ vec3(-136.6850739,104.0551834,34.89838409), quat(-1.370823688e-06,-2.668151342e-06,0.8894732678,-0.4569872053), "couch", "vehicles/couch/couch_free.pc" },
{ vec3(-135.8791656,101.8557205,34.79919052), quat(0.0002344426654,0.0001473668705,-0.5321790558,0.8466317829), "couch", "vehicles/couch/armchair_free.pc" },
{ vec3(-136.6850739,104.0551834,34.89838409), quat(-1.370823688e-06,-2.668151342e-06,0.8894732678,-0.4569872053), "couch", "vehicles/couch/couch_free.pc" },
{ vec3(-135.8791656,101.8557205,34.79919052), quat(0.0002344426654,0.0001473668705,-0.5321790558,0.8466317829), "couch", "vehicles/couch/armchair_free.pc" },
{ vec3(-135.1573334,102.8125229,34.79919434), quat(4.743933507e-05,1.696156212e-05,-0.3366698313,0.94162276), "barrels", "vehicles/barrels/empty.pc" },
{ vec3(-135.8791656,101.8557205,34.79919052), quat(0.0002344426654,0.0001473668705,-0.5321790558,0.8466317829), "couch", "vehicles/couch/armchair_free.pc" },
{ vec3(-135.1573334,102.8125229,34.79919434), quat(4.743933507e-05,1.696156212e-05,-0.3366698313,0.94162276), "barrels", "vehicles/barrels/empty.pc" },
{ vec3(-131.6051788,157.0005493,36.81754684), quat(0.0001472245881,0.01930025774,0.9997846345,-0.007626472298), "steel_coil", "vehicles/steel_coil/20ton.pc" },
{ vec3(-135.1573334,102.8125229,34.79919434), quat(4.743933507e-05,1.696156212e-05,-0.3366698313,0.94162276), "barrels", "vehicles/barrels/empty.pc" },
{ vec3(-131.6051788,157.0005493,36.81754684), quat(0.0001472245881,0.01930025774,0.9997846345,-0.007626472298), "steel_coil", "vehicles/steel_coil/20ton.pc" },
{ vec3(-131.9969635,153.5990143,35.00673676), quat(-2.599318111e-05,-0.003242814254,0.9999626183,-0.008015324778), "pigeon", "vehicles/pigeon/base.pc" }
{ vec3(-131.6051788,157.0005493,36.81754684), quat(0.0001472245881,0.01930025774,0.9997846345,-0.007626472298), "steel_coil", "vehicles/steel_coil/20ton.pc" },
{ vec3(-131.9969635,153.5990143,35.00673676), quat(-2.599318111e-05,-0.003242814254,0.9999626183,-0.008015324778), "pigeon", "vehicles/pigeon/base.pc" }
}
local vehs = {
{ vec3(-926.2694092,-530.4829712,105.0409012), quat(0.02295934544,0.03978534072,0.5222144473,0.8515762245), "us_semi", "vehicles/us_semi/t82_ramplow.pc" },
}
@/lua/ge/extensions/gameplay/markers/zoneMarker.lua
self.cluster = cluster
self.pos2d = vec3(cluster.visibilityPos.x, cluster.visibilityPos.y, 0)
self.radius = cluster.visibilityRadius
@/lua/vehicle/controller/tech/GPS.lua
-- Properties which are updated regularly.
local pos = vec3(0, 0)
@/lua/console/unittests.lua
function test_vec3_function()
a = vec3(0,0,0)
assert(tostring(a) == "(0, 0, 0)", "vec3 constructor test failed")
assert(tostring(a) == "(0, 0, 0)", "vec3 constructor test failed")
a = vec3(1.234,2.134,3.124)
assert(tostring(a) == "(1.234, 2.134, 3.124)", "vec3 float point test failed")
assert(tostring(a) == "(1.234, 2.134, 3.124)", "vec3 float point test failed")
a = vec3(0,1337.13371337,-1)
assert(tostring(a) == "(0, 1337.134, -1)", "vec3 float point test 2 failed")
assert(tostring(a) == "(0, 1337.134, -1)", "vec3 float point test 2 failed")
a = vec3(0,133007.133,-1)
assert(tostring(a) == "(0, 133007.141, -1)", "vec3 float point precision test failed")
a = vec3(1,0,3)
b = vec3(2,2,-2)
a = vec3(1,0,3)
b = vec3(2,2,-2)
c = a + b
@/lua/ge/extensions/editor/gen/network.lua
local x, y = U.lineCross(a1, a2, b1, b2)
local p = vec3(x, y, 0)
local eps = 0.01
U.vnorm = function(v)
return vec3(-v.y, v.x, 0):normalized()
end
if dbg == true then
adbg[#adbg+1] = {p+vec3(0,0,0), ColorF(1,0,1,1), 0.2}
adbg[#adbg+1] = {decal:getMiddleEdgePosition(start)+vec3(0,0,0), ColorF(1,1,0,1), 0.5}
adbg[#adbg+1] = {p+vec3(0,0,0), ColorF(1,0,1,1), 0.2}
adbg[#adbg+1] = {decal:getMiddleEdgePosition(start)+vec3(0,0,0), ColorF(1,1,0,1), 0.5}
end
adbg[#adbg+1] = {
(1 - api/(api + apip))*(decal:getMiddleEdgePosition(i)+vec3(0,0,1))+
api/(api + apip)*(decal:getMiddleEdgePosition(i+1)+vec3(0,0,1)),
(1 - api/(api + apip))*(decal:getMiddleEdgePosition(i)+vec3(0,0,1))+
api/(api + apip)*(decal:getMiddleEdgePosition(i+1)+vec3(0,0,1)),
ColorF(0,1,1,1), 0.2}
local wa, wb = 0.5, 0.5
local massCenter = vec3(0, 0, 0)
local v = U.vturn({x=x, y=y}, ang)
v = c1.pos + vn*(c1.r + dmiddle) + vec3(v.x, v.y, 0)
local vflip = U.vturn({x=x, y=-y}, ang)
local vflip = U.vturn({x=x, y=-y}, ang)
vflip = c1.pos + vn*(c1.r + dmiddle) + vec3(vflip.x, vflip.y, 0)
--TODO: massCenter role?
local nd = {
pos = c1.pos + vn*(c1.r + dmiddle) + vec3(v.x, v.y, 0),
r = r,
v = U.vturn({x=-x, y=y}, ang)
nd.pos = c1.pos + vn*(c1.r + dmiddle) + vec3(v.x, v.y, 0)
-- print('!! sign: x:'..x..' y:'..y..' vn:'..tostring(vn)..' ang:'..ang..':'..tostring(spos)..'>'..tostring(nd.pos)..':'..math.abs((spos - c1.pos):length()/(c1.r + nd.r)))
local function circleSeed(nnode, pos, r, mode)
if not pos then pos = vec3(0,0,0) end
if r then circleMax = r end
if r then circleMax = r end
-- massCenter = vec3(pos.x, pos.y)
local h = core_terrain.getTerrainHeight(pos)
state[#state+1] = {
pos = vec3(a[1],a[2],a[3]),
r = a[4],
anode = {}
anode[#anode + 1] = { pos = vec3(0, 0, 0), r = ar[1], stamp = '0_0' }
local ang = 2*math.random()*math.pi
end
anode[#anode + 1] = { pos = U.vturn(vec3(ar[1] + ar[2], 0, 0), ang), r = ar[2], ang = ang, stamp = '0_1' }
-- print('?? FOR_2:'..tostring(ang)..':'..tostring(anode[#anode].pos)..':'..tostring(anode[#anode].ang))
for _,n in pairs(anode) do
n.pos = n.pos + (pos or vec3(0))
-- massCenter = massCenter + n.pos
r = 56.23165287237,
pos = vec3(-260.81,45.77,75.6288681),
stamp = '0_0', },
r = 101.7567088192,
pos = vec3(-211.3173176,-104.2659851,75.6288681),
ang = 5.0310211785822,
r = 73.582018542625,
pos = vec3(-131.1301325,51.66247503,75.6288681),
stamp = '1_2', },
r = 72.271762133914,
pos = vec3(-42.05185778,-63.82945674,75.6288681),
stamp = '2_3', },
r = 93.670418980753,
pos = vec3(32.92513028,84.20857464,75.6288681),
stamp = '3_4', },
r = 103.31101611965,
pos = vec3(-225.411412,201.3360734,75.6288681),
stamp = '1_3', },
r = 94.167013538972,
pos = vec3(-36.466385,258.7586209,75.6288681),
stamp = '5_6', },
r = 106.04398032296,
pos = vec3(-55.40616376,-241.6444351,75.6288681),
stamp = '2_4', },
r = 99.269598795442,
pos = vec3(-295.65,35.83,72.0375061),
stamp = '0_0', },
r = 69.109113803938,
pos = vec3(-393.7719336,172.6637568,72.0375061),
ang = 2.1928993495521,
r = 76.120076604937,
pos = vec3(-470.5163963,49.368156,72.0375061),
stamp = '1_2', },
r = 40.765230543178,
pos = vec3(-503.0901429,161.6228934,72.0375061),
stamp = '2_3', },
r = 103.61538074011,
pos = vec3(-421.2681243,-123.4885544,72.0375061),
stamp = '1_3', },
r = 70.966541858009,
pos = vec3(-246.7261819,-127.2246032,72.0375061),
stamp = '1_5', }
r = 95.86762335677,
pos = vec3(-295.65,35.83,72.0375061),
stamp = '0_0' },
r = 77.168477102244,
pos = vec3(-261.7174646,205.5063835,72.0375061),
ang = 1.3734163015527,
r = 86.985128777978,
pos = vec3(-421.615975,168.3732084,72.0375061),
stamp = '1_2' },
r = 85.265262792207,
pos = vec3(-474.0151165,4.28625779,72.0375061),
stamp = '1_3' },
r = 60.281420603618,
pos = vec3(-561.0384233,120.9515101,72.0375061),
stamp = '3_4' },
r = 55.549801652843,
pos = vec3(-358.595332,296.2192289,72.0375061),
stamp = '2_3' },
massCenter = vec3(0,0,0)
for _,n in pairs(anode) do
r = 56.23165287237,
pos = vec3(-316.1867336,-209.4999149,117.4858208),
stamp = '0_0', },
r = 101.7567088192,
pos = vec3(-266.6940512,-359.5359,117.4858208),
ang = 5.0310211785822,
r = 73.582018542625,
pos = vec3(-186.5068661,-203.6074399,117.4858208),
stamp = '1_2', },
r = 72.271762133914,
pos = vec3(-97.42859134,-319.0993716,117.4858208),
stamp = '2_3', },
r = 93.670418980753,
pos = vec3(-22.45160328,-171.0613403,117.4858208),
stamp = '3_4', },
r = 103.31101611965,
pos = vec3(-280.7881456,-53.9338415,117.4858208),
stamp = '1_3', },
r = 94.167013538972,
pos = vec3(-91.84311856,3.488706003,117.4858208),
stamp = '5_6', },
r = 106.04398032296,
pos = vec3(-110.7828973,-496.91435,117.4858208),
stamp = '2_4', }
}
massCenter = vec3(-1372.682007,-1810.163452,334.8556213)
end
local v = anode[path[i]].pos - anode[path[i - 1]].pos
local vn = vec3(-v.y, v.x, 0):normalized()
--?? massCenter role
local nodeInfo = {
pos = pmiddle + vec3(0, 0, h),
width = w, drivability = 1, index = n }
local nodeInfo = {
pos = anode[path[i]].pos + vec3(0, 0, h),
width = w, drivability = 1, index = n }
local v = anode[path[i]].pos - anode[path[i - 1]].pos
local vn = -vec3(-v.y, v.x, 0):normalized()
--?? massCenter role
local nodeInfo = {
pos = pmiddle + vec3(0, 0, h),
width = w, drivability = 1, index = n }
local nodeInfo = {
pos = anode[path[i]].pos + vec3(0, 0, h),
width = w, drivability = 1, index = n }
end
sc = sc + step*(a*v + b*(vmi+(svmi or vec3(0,0,0))))/(a+b)
if false then
av[#av + 1] = vec3(2, -5, 1)
av[#av + 1] = vec3(0, -5, 1)
av[#av + 1] = vec3(2, -5, 1)
av[#av + 1] = vec3(0, -5, 1)
av, af = Mesh.strip(2, {vec3(2, -7, 1), vec3(0, -7, 1)}, av, af)
av[#av + 1] = vec3(0, -5, 1)
av, af = Mesh.strip(2, {vec3(2, -7, 1), vec3(0, -7, 1)}, av, af)
av[#av + 1] = vec3(0, -5, 1)
av, af = Mesh.strip(2, {vec3(2, -7, 1), vec3(0, -7, 1)}, av, af)
local rdm = createObject("ProceduralMesh")
-- rdm:setPosition(vec3(0, 0, 0))
rdm:setPosition(vec3(0, 0, 0))
-- rdm:setPosition(vec3(0, 0, 0))
rdm:setPosition(vec3(0, 0, 0))
rdm.isMesh = true
local apos = {
-- rd:getLeftEdgePosition(i) - marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h),
-- rd:getLeftEdgePosition(i) - marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h),
-- rd:getRightEdgePosition(i) + marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h),
-- rd:getRightEdgePosition(i) + marginSide*perp + vec3(0, 0, h + 1),
}
apos = {
-- rd:getLeftEdgePosition(i) - marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h - 0.2),
-- rd:getLeftEdgePosition(i) - marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h - 0.2),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h - 0.2),
U.proj2D(rd:getRightEdgePosition(i) + marginSide*perp) + vec3(0, 0, h - 0.2),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h - 0.2),
-- rd:getRightEdgePosition(i) + marginSide*perp + vec3(0, 0, h + 1),
U.proj2D(rd:getLeftEdgePosition(i) - marginSide*perp) + vec3(0, 0, h - 0.2),
-- rd:getRightEdgePosition(i) + marginSide*perp + vec3(0, 0, h + 1),
}
local rdm = createObject("ProceduralMesh")
rdm:setPosition(vec3(0, 0, 0))
rdm.isMesh = true
n.pos.z = hmap[apin[o][1]] + 0.2
-- editor.setNodePosition(rd, o, n.pos + 1*vec3(0, 0, hmap[r.apin[o]] + 0.2))
end
local jo = forOut(roads[brout[1]], ieo, edec) --, nil, true)
adbg[#adbg + 1] = {edec:getLeftEdgePosition(jo)+vec3(0,0,hp), ColorF(0,1,0,1)}
local ji = forIn(roads[brin[1]], iei, edec)
local ji = forIn(roads[brin[1]], iei, edec)
adbg[#adbg + 1] = {edec:getLeftEdgePosition(ji)+vec3(0,0,hp), ColorF(0,1,0,1)}
print('?? eLoop.BE:'..brout[2]..'>'..jo..':'..brin[2]..':'..ji)
local hp = 0
-- adbg[#adbg + 1] = {pout+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppout+vec3(0,0,hp), ColorF(0,0,1,1)}
-- adbg[#adbg + 1] = {pout+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppout+vec3(0,0,hp), ColorF(0,0,1,1)}
-- adbg[#adbg + 1] = {pin+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppout+vec3(0,0,hp), ColorF(0,0,1,1)}
-- adbg[#adbg + 1] = {pin+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppin+vec3(0,0,hp), ColorF(0,0,1,1)}
-- adbg[#adbg + 1] = {pin+vec3(0,0,hp)}
-- adbg[#adbg + 1] = {ppin+vec3(0,0,hp), ColorF(0,0,1,1)}
print('?? ie:'..ieo..'>'..iei..':'..dirout..'>'..dirin..':'..(ppout-pout):length())
local jo = forOut(roads[brout[1]], ieo, edec) --, nil, true)
-- adbg[#adbg + 1] = {edec:getLeftEdgePosition(jo)+vec3(0,0,hp), ColorF(0,1,0,1)}
local ji = forIn(roads[brin[1]], iei, edec)
-- print('?? BE:'..o..':'..brout[2]..'> jo='..jo..':'..brin[2]..'> ji='..ji)
-- adbg[#adbg + 1] = {edec:getLeftEdgePosition(ji)+vec3(0,0,hp), ColorF(0,1,0,1)}
local ro, ri = roads[brout[1]], roads[brin[1]]
debugDrawer:drawLine(anode[l[j-1]].pos, anode[l[j]].pos, ColorF(j/#l,(#l-j)/#l,0,1), w)
-- Render.path({ anode[l[j-1]].pos+vec3(0,0,20), anode[l[j]].pos+vec3(0,0,20) }, c, w)
end
debugDrawer:drawLine(anode[l[j-1]].pos, anode[l[j]].pos, ColorF(j/#l,(#l-j)/#l,0,1), w)
-- Render.path({ anode[l[j-1]].pos+vec3(0,0,20), anode[l[j]].pos+vec3(0,0,20) }, c, w)
end
@/lua/ge/extensions/core/cameraModes/pacenoteOrbit.lua
self.isGlobal = true
self.fixedTargetPos = vec3(0, 0, 0)
self.fov = 65 -- deg
if self.defaultRotation == nil then
self.defaultRotation = vec3(0, -17, 0)
end
end
self.defaultRotation = vec3(self.defaultRotation)
if not self.camRot then self.camRot = vec3(self.defaultRotation) end
self.defaultRotation = vec3(self.defaultRotation)
if not self.camRot then self.camRot = vec3(self.defaultRotation) end
self.camMinDist = 10
if self.cameraResetted == 0 then
self.preResetPos = vec3(self.camLastTargetPos2)
self.cameraResetted = 3
-- Calculate the new camera position based on rotation and distance
local rot = vec3(math.rad(self.camRot.x), math.rad(self.camRot.y), 0)
local calculatedCamPos = vec3(
local rot = vec3(math.rad(self.camRot.x), math.rad(self.camRot.y), 0)
local calculatedCamPos = vec3(
math.sin(rot.x) * math.cos(rot.y),
-- Note: Assuming newPos should be camPos in your context and considering BeamNG's Z-up coordinate system
local terrainHeight = core_terrain.getTerrainHeight(vec3(camPos.x, camPos.y, 0))
@/lua/ge/extensions/flowgraph/nodes/mission/selectHeistMissionSpots.lua
elseif self.state == 2 then
local vPos = vec3(self.pinIn.position.value)
dump((self.start.pos - vPos):length())
@/lua/ge/extensions/gameplay/drift/saveLoad.lua
for _, elem in ipairs(json.stuntZones or {}) do
if elem.pos and type(elem.pos) == "table" and elem.pos.x and elem.pos.y and elem.pos.z then elem.pos = vec3(elem.pos) end
if elem.rot and type(elem.rot) == "table" and elem.rot.x and elem.rot.y and elem.rot.z and elem.rot.w then elem.rot = quat(elem.rot) end
if elem.rot and type(elem.rot) == "table" and elem.rot.x and elem.rot.y and elem.rot.z and elem.rot.w then elem.rot = quat(elem.rot) end
if elem.scl and type(elem.scl) == "table" and elem.scl.x and elem.scl.y and elem.scl.z then elem.scl = vec3(elem.scl) end
if elem.scl and type(elem.scl) == "number" then end
@/lua/ge/extensions/gameplay/rally/snaproad/normals.lua
local normVec = rallyUtil.calculateForwardNormal(prevPoint.pos, nextPoint.pos)
return vec3(normVec.x, normVec.y, normVec.z)
elseif currentPoint and nextPoint then
local normVec = rallyUtil.calculateForwardNormal(currentPoint.pos, nextPoint.pos)
return vec3(normVec.x, normVec.y, normVec.z)
elseif prevPoint and currentPoint then
local normVec = rallyUtil.calculateForwardNormal(prevPoint.pos, currentPoint.pos)
return vec3(normVec.x, normVec.y, normVec.z)
else
@/lua/ge/extensions/editor/roadArchitect.lua
local isAutoJctArmed = false -- A flag which indicates if the auto-junction tool is 'armed', or not.
local autoJctCen = vec3(0, 0) -- The center of the auto-junction, which is being created.
local autoJctRad = 1.0 -- The radius of the auto-junction circle, which is being created.
local gPolygon = {} -- A polygon used when creating new prefab groups.
local mouseLast = vec3(0, 0) -- The last position of the mouse.
local multiCentroidOnLeftHold = nil -- The multi-select region centroid, used when rotating around Z.
local isGimbalActive = false -- A flag which indicates if the (translational) gimbal is being used.
local lastFramePosn = vec3(0, 0) -- The last gimbal/mouse position (from last frame). Used when dragging.
local gimbalDragPre, mouseDragPre = {}, {} -- A table for storing the road state at gimbal/mouse drag start.
local lastAltDown = false -- A flag which indicates if ALT was pressed during the last cycle.
local dragOffset = vec3(0, 0)
local downVec = vec3(0, 0, -1)
local dragOffset = vec3(0, 0)
local downVec = vec3(0, 0, -1)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local tmp0, tmp1 = vec3(0, 0), vec3(0, 0)
local fieldInv = 1.0 / max(1e-7, road.forceField[0]) -- [Force-Field Translation].
node.p = vec3(gPoint.x, gPoint.y, gPoint.z)
lastFramePosn = vec3(gPoint.x, gPoint.y, gPoint.z)
node.p = vec3(gPoint.x, gPoint.y, gPoint.z)
lastFramePosn = vec3(gPoint.x, gPoint.y, gPoint.z)
@/lua/ge/extensions/scenario/raceMarkers/ringMarker.lua
local fwd = self.normal and self.normal or vec3(0,0,1)
local rot = quatFromDir(fwd:z0()):toTorqueQuat()
--debugDrawer:drawText(self.pos, String(string.format("%0.3f %s",t, self.blendState or "non")), ColorF(0, 0, 0, 1))
--debugDrawer:drawLine(vec3(self.pos), vec3(self.pos + self.normal), ColorF(1,0,0,1))
--debugDrawer:drawLine(vec3(self.pos), vec3(self.pos + self.up), ColorF(0,1,0,1))
--debugDrawer:drawText(self.pos, String(string.format("%0.3f %s",t, self.blendState or "non")), ColorF(0, 0, 0, 1))
--debugDrawer:drawLine(vec3(self.pos), vec3(self.pos + self.normal), ColorF(1,0,0,1))
--debugDrawer:drawLine(vec3(self.pos), vec3(self.pos + self.up), ColorF(0,1,0,1))
--debugDrawer:drawLine(vec3(self.pos), vec3(self.pos + self.normal), ColorF(1,0,0,1))
--debugDrawer:drawLine(vec3(self.pos), vec3(self.pos + self.up), ColorF(0,1,0,1))
--debugDrawer:drawLine(vec3(self.pos), vec3(self.pos + self.normal), ColorF(1,0,0,1))
--debugDrawer:drawLine(vec3(self.pos), vec3(self.pos + self.up), ColorF(0,1,0,1))
if self.ring then
self.ring:setScale(vec3(self.radius, self.radius, self.radius))
self.currentColor.a = 1 * a
function C:setToCheckpoint(wp)
self.pos = vec3(wp.pos)
self.radius = wp.radius
self.radius = wp.radius
self.normal = wp.normal and vec3(wp.normal) or nil
self.up = wp.up or vec3(0,0,1)
self.normal = wp.normal and vec3(wp.normal) or nil
self.up = wp.up or vec3(0,0,1)
if self.ring then
if self.ring then
self.ring:setPosition(vec3(self.pos))
self.ring:preApply()
self.ring:postApply()
self.ring:setScale(vec3(self.radius+1.5, self.radius+1.5, self.radius+1.5))
local fwd = self.normal and self.normal or vec3(0,1,0)
self.ring:setScale(vec3(self.radius+1.5, self.radius+1.5, self.radius+1.5))
local fwd = self.normal and self.normal or vec3(0,1,0)
local up = wp.up or vec3(0,0,1)
local fwd = self.normal and self.normal or vec3(0,1,0)
local up = wp.up or vec3(0,0,1)
local rot = quatFromDir(fwd, up):toTorqueQuat()
marker:setField('shapeName', 0, shapeName)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setPosition(vec3(0, 0, 0))
marker.scale = vec3(1, 1, 1)
marker:setField('rotation', 0, '1 0 0 0')
@/lua/ge/extensions/flowgraph/nodes/vehicle/vehicleWheels.lua
local wCenter, wPos = vec3(), vec3()
local wCenter, wPos = vec3(), vec3()
@/lua/ge/extensions/editor/assemblySpline/import.lua
local twoPi, piOver4 = pi * 2.0, pi * 0.25
local globalUp = vec3(0, 0, 1)
local tmpRot = quat()
local tangent, expectedBinormal, actualBinormal = vec3(), vec3(), vec3()
local tmpRot = quat()
local tangent, expectedBinormal, actualBinormal = vec3(), vec3(), vec3()
local tmpRot = quat()
local tangent, expectedBinormal, actualBinormal = vec3(), vec3(), vec3()
for i = 1, #filteredPositions do
spline.nmls[i] = vec3(0, 0, 1) -- Use global Z-axis.
end
@/lua/ge/extensions/editor/toolUtilities/ribbonInput.lua
-- Module state.
local mouseLast, mouseVel2D, pMouse_2D = vec3(), vec3(), vec3()
local isLeftNodePlaced, placedLeftNode, placedLeftDepth = false, vec3(), 1.0
-- Module state.
local mouseLast, mouseVel2D, pMouse_2D = vec3(), vec3(), vec3()
local isLeftNodePlaced, placedLeftNode, placedLeftDepth = false, vec3(), 1.0
-- Module state.
local mouseLast, mouseVel2D, pMouse_2D = vec3(), vec3(), vec3()
local isLeftNodePlaced, placedLeftNode, placedLeftDepth = false, vec3(), 1.0
local mouseLast, mouseVel2D, pMouse_2D = vec3(), vec3(), vec3()
local isLeftNodePlaced, placedLeftNode, placedLeftDepth = false, vec3(), 1.0
local bestCursorSeg = 1
local bestCursorSeg = 1
local cursorPos = vec3()
local cursorBN = 0.0
local isNodeDrag, dragNodeIdx, dragStatePre = false, 1, nil
local dragStartMousePos, dragStartNodePos = vec3(), vec3()
local c1_2D, c2_2D, c3_2D, c4_2D = vec3(), vec3(), vec3(), vec3()
local isNodeDrag, dragNodeIdx, dragStatePre = false, 1, nil
local dragStartMousePos, dragStartNodePos = vec3(), vec3()
local c1_2D, c2_2D, c3_2D, c4_2D = vec3(), vec3(), vec3(), vec3()
local dragStartMousePos, dragStartNodePos = vec3(), vec3()
local c1_2D, c2_2D, c3_2D, c4_2D = vec3(), vec3(), vec3(), vec3()
local lastAltDown, hasDeletePressedRecently = false, false
local dragStartMousePos, dragStartNodePos = vec3(), vec3()
local c1_2D, c2_2D, c3_2D, c4_2D = vec3(), vec3(), vec3(), vec3()
local lastAltDown, hasDeletePressedRecently = false, false
local dragStartMousePos, dragStartNodePos = vec3(), vec3()
local c1_2D, c2_2D, c3_2D, c4_2D = vec3(), vec3(), vec3(), vec3()
local lastAltDown, hasDeletePressedRecently = false, false
local dragStartMousePos, dragStartNodePos = vec3(), vec3()
local c1_2D, c2_2D, c3_2D, c4_2D = vec3(), vec3(), vec3(), vec3()
local lastAltDown, hasDeletePressedRecently = false, false
if not isLeftNodePlaced then
placedLeftNode = vec3(mousePos.x, mousePos.y, mousePos.z + zExtra) -- The user is placing the left node of a new pair.
placedLeftDepth, isLeftNodePlaced = masterDepth, true
local statePre = deepCopyFn()
placePair(mousePos, ribbon, vec3(mousePos.x, mousePos.y, mousePos.z + zExtra), masterDepth) -- The user is placing the right node of a new pair. Add to ribbon.
updateRibbonDataFn(ribbon)
@/lua/ge/extensions/core/funstuff.lua
-- Create a point at the bottom center in local space (Z is up/down)
local localPoint = vec3(math.random()*0.25-0.125, math.random()*0.25-0.125, -halfExtents.z-0.8)
-- Convert to world space