LUADOC - Farming Simulator 19

DebugText

Functions

createWithNode

Description
Definition
createWithNode()
Code
54function DebugText:createWithNode(node, text, size)
55 local x, y, z = getWorldTranslation(node)
56 local rotX, rotY, rotZ = getWorldRotation(node)
57
58 self:createWithWorldPosAndRot(x, y, z, rotX, rotY, rotZ, text, size)
59end

createWithNodeToCamera

Description
Definition
createWithNodeToCamera()
Code
63function DebugText:createWithNodeToCamera(node, yOffset, text, size)
64 local x, y, z = localToWorld(node, 0, yOffset, 0)
65 local cx, cy, cz = getWorldTranslation(getCamera())
66 local dirX, _, dirZ = MathUtil.vector3Normalize(cx-x, cy-y, cz-z)
67 local rotY = MathUtil.getYRotationFromDirection(dirX, dirZ)
68
69 self:createWithWorldPosAndRot(x, y, z, 0, rotY, 0, text, size)
70end

createWithWorldPosAndRot

Description
Definition
createWithWorldPosAndRot()
Code
74function DebugText:createWithWorldPosAndRot(x, y, z, rotX, rotY, rotZ, text, size)
75 self.x, self.y, self.z = x, y, z
76 self.rotX, self.rotY, self.rotZ = rotX, rotY, rotZ
77 self.text = text
78 self.size = size
79end

draw

Description
Definition
draw()
Code
39function DebugText:draw()
40 setTextDepthTestEnabled(false)
41 setTextAlignment(self.alignment)
42 setTextVerticalAlignment(self.verticalAlignment)
43 setTextColor(self.r, self.g, self.b, self.a)
44
45 renderText3D(self.x, self.y, self.z, self.rotX, self.rotY, self.rotZ, self.size, self.text)
46
47 setTextAlignment(RenderText.ALIGN_LEFT)
48 setTextVerticalAlignment(RenderText.VERTICAL_ALIGN_BASELINE)
49 setTextDepthTestEnabled(true)
50end

new

Description
Definition
new()
Code
15function DebugText:new(customMt)
16 local self = setmetatable({}, customMt or DebugText_mt)
17
18 self.x, self.y, self.z = 0, 0, 0
19 self.rotX, self.rotY, self.rotZ = 0, 0, 0
20 self.alignment = RenderText.ALIGN_LEFT;
21 self.verticalAlignment = RenderText.VERTICAL_ALIGN_MIDDLE;
22 self.r, self.g, self.b, self.a = 1, 1, 1, 1
23 self.size = 0.1
24
25 self.text = nil
26 self.alignToGround = false
27
28 return self
29end