Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Debug2DArea
- DebugBitVectorMap
- DebugCube
- DebugDensityMap
- DebugFlag
- DebugGizmo
- DebugInfoTable
- DebugManager
- DebugPath
- DebugPoint
- DebugText
- DebugUtil
- NoteManager
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
DebugText
Functions- createWithNode
- createWithNodeToCamera
- createWithWorldPosAndRot
- draw
- getRotationToCamera
- new
- setClipDistance
- setColor
- update
createWithNode
DescriptionDefinitioncreateWithNode()Code
67 | function DebugText:createWithNode(node, text, size) |
68 | local x, y, z = getWorldTranslation(node) |
69 | local rotX, rotY, rotZ = getWorldRotation(node) |
70 | |
71 | return self:createWithWorldPosAndRot(x, y, z, rotX, rotY, rotZ, text, size) |
72 | end |
createWithNodeToCamera
DescriptionDefinitioncreateWithNodeToCamera()Code
76 | function DebugText:createWithNodeToCamera(node, yOffset, text, size) |
77 | self.alignToCamera = true |
78 | local x, y, z = localToWorld(node, 0, yOffset, 0) |
79 | |
80 | return self:createWithWorldPosAndRot(x, y, z, 0, self:getRotationToCamera(x, y, z), 0, text, size) |
81 | end |
createWithWorldPosAndRot
DescriptionDefinitioncreateWithWorldPosAndRot()Code
85 | function DebugText:createWithWorldPosAndRot(x, y, z, rotX, rotY, rotZ, text, size) |
86 | self.x, self.y, self.z = x, y, z |
87 | self.rotX, self.rotY, self.rotZ = rotX, rotY, rotZ |
88 | self.text = text |
89 | self.size = size |
90 | |
91 | return self |
92 | end |
draw
DescriptionDefinitiondraw()Code
46 | function DebugText:draw() |
47 | if self.clipDistance ~= nil then |
48 | local x, y, z = getWorldTranslation(getCamera()) |
49 | if MathUtil.vector3Length(x-self.x, y-self.y, z-self.z) > self.clipDistance then |
50 | return |
51 | end |
52 | end |
53 | setTextDepthTestEnabled(false) |
54 | setTextAlignment(self.alignment) |
55 | setTextVerticalAlignment(self.verticalAlignment) |
56 | setTextColor(self.r, self.g, self.b, self.a) |
57 | |
58 | renderText3D(self.x, self.y, self.z, self.rotX, self.rotY, self.rotZ, self.size, self.text) |
59 | |
60 | setTextAlignment(RenderText.ALIGN_LEFT) |
61 | setTextVerticalAlignment(RenderText.VERTICAL_ALIGN_BASELINE) |
62 | setTextDepthTestEnabled(true) |
63 | end |
getRotationToCamera
DescriptionDefinitiongetRotationToCamera()Code
96 | function DebugText:getRotationToCamera(x, y, z) |
97 | local cx, cy, cz = getWorldTranslation(getCamera()) |
98 | local dirX, _, dirZ = MathUtil.vector3Normalize(cx-x, cy-y, cz-z) |
99 | return MathUtil.getYRotationFromDirection(dirX, dirZ) |
100 | end |
new
DescriptionDefinitionnew()Code
15 | function 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_CENTER |
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 | self.alignToCamera = false |
28 | self.clipDistance = nil |
29 | |
30 | return self |
31 | end |
setClipDistance
DescriptionDefinitionsetClipDistance()Code
115 | function DebugText:setClipDistance(clipDistance) |
116 | self.clipDistance = clipDistance |
117 | |
118 | return self |
119 | end |
setColor
DescriptionDefinitionsetColor()Code
104 | function DebugText:setColor(r, g, b, a) |
105 | self.r = r or self.r |
106 | self.g = g or self.g |
107 | self.b = b or self.b |
108 | self.a = a or self.a |
109 | |
110 | return self |
111 | end |
update
DescriptionDefinitionupdate()Code
38 | function DebugText:update(dt) |
39 | if self.alignToCamera then |
40 | self.rotY = self:getRotationToCamera(self.x, self.y, self.z) |
41 | end |
42 | end |