Get the projected display space position of a 3D world position. Returns nil if the world position is behind the camera view. @function GetDisplayPosition @tparam Vec3 worldPos 3D world position. @treturn Vec2 Projected display space position in percent. @usage -- Example: Display a string at the player's position. local displayPos = TEN.Util.GetDisplayPosition(Lara:GetPosition()) local str = TEN.
| 78 | // local str = TEN.Strings.DisplayString('You are here!', displayPos) |
| 79 | // TEN.Strings.ShowString(str, 4) |
| 80 | static sol::optional<Vec2> GetDisplayPosition(const Vec3& worldPos) |
| 81 | { |
| 82 | auto displayPos = g_Renderer.Get2DPosition(worldPos.ToVector3()); |
| 83 | if (!displayPos.has_value()) |
| 84 | return sol::nullopt; |
| 85 | |
| 86 | return Vec2( |
| 87 | (displayPos->x / DISPLAY_SPACE_RES.x) * 100, |
| 88 | (displayPos->y / DISPLAY_SPACE_RES.y) * 100); |
| 89 | } |
| 90 | |
| 91 | /// Translate a pair display position coordinates to pixel coordinates.<br> |
| 92 | // To be used with `Strings.DisplayString` and `Strings.DisplayString:SetPosition`. |
nothing calls this directly
no test coverage detected