LUADOC - Farming Simulator 19

DebugGizmo

Functions

createWithNode

Description
Definition
createWithNode()
Code
59function DebugGizmo:createWithNode(node, text, alignToGround)
60 local x, y, z = getWorldTranslation(node)
61 local upX, upY, upZ = localDirectionToWorld(node, 0, 1, 0)
62 local dirX, dirY, dirZ = localDirectionToWorld(node, 0, 0, 1)
63
64 self:createWithWorldPosAndDir(x, y, z, dirX, dirY, dirZ, upX, upY, upZ, text, alignToGround)
65end

createWithWorldPosAndDir

Description
Definition
createWithWorldPosAndDir()
Code
69function DebugGizmo:createWithWorldPosAndDir(x, y, z, dirX, dirY, dirZ, upX, upY, upZ, text, alignToGround)
70
71 if alignToGround and g_currentMission.terrainRootNode ~= nil then
72 y = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x, 0, z) + 0.1
73 end
74
75 self.x, self.y, self.z = x, y, z
76 self.dirX, self.dirY, self.dirZ = dirX, dirY, dirZ
77 self.upX, self.upY, self.upZ = upX, upY, upZ
78 self.normX, self.normY, self.normZ = MathUtil.crossProduct(upX, upY, upZ, dirX, dirY, dirZ)
79 self.text = text
80 self.alignToGround = alignToGround
81end

draw

Description
Definition
draw()
Code
42function DebugGizmo:draw()
43 local x, y, z = self.x, self.y, self.z
44 local normX, normY, normZ = self.normX, self.normY, self.normZ
45 local upX, upY, upZ = self.upX, self.upY, self.upZ
46 local dirX, dirY, dirZ = self.dirX, self.dirY, self.dirZ
47
48 drawDebugLine(x, y, z, 1, 0, 0, x + normX, y + normY, z + normZ, 1, 0, 0)
49 drawDebugLine(x, y, z, 0, 1, 0, x + upX, y + upY, z + upZ, 0, 1, 0)
50 drawDebugLine(x, y, z, 0, 0, 1, x + dirX, y + dirY, z + dirZ, 0, 0, 1)
51
52 if self.text ~= nil then
53 Utils.renderTextAtWorldPosition(x, y, z, tostring(self.text), getCorrectTextSize(0.012), 0)
54 end
55end

new

Description
Definition
new()
Code
15function DebugGizmo:new(customMt)
16 local self = setmetatable({}, customMt or DebugGizmo_mt)
17
18-- Y Z
19-- ^ /
20-- | /
21-- |/____> X
22
23 self.x, self.y, self.z = 0, 0, 0
24 self.normX, self.normY, self.normZ = 1, 0, 0
25 self.upX, self.upY, self.upZ = 0, 1, 0
26 self.dirX, self.dirY, self.dirZ = 0, 0, 1
27
28 self.text = nil
29 self.alignToGround = false
30
31 return self
32end