Graphics::world3dToScreen2d: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
m (inverted function reference)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Convert a world coordinate into its relative screen coordinate.  (WorldToScreen)<br><br>Returns a boolean; whether or not the operation was successful. It will return false if the coordinates given are not visible to the rendering camera.<br><br><br>For .NET users...<br><br>VB:<br>Public Shared Function World3DToScreen2d(pos as vector3) As Vector2<br><br>        Dim x2dp, y2dp As New Native.OutputArgument<br><br>        Native.Function.Call(Of Boolean)(Native.Hash.GET_SCREEN_COORD_FROM_WORLD_COORD , pos.x, pos.y, pos.z, x2dp, y2dp)<br>        Return New Vector2(x2dp.GetResult(Of Single), y2dp.GetResult(Of Single))<br>      <br>    End Function<br><br>C#:<br>Vector2 World3DToScreen2d(Vector3 pos)<br>    {<br>        var x2dp = new OutputArgument();<br>        var y2dp = new OutputArgument();<br><br>        Function.Call&lt;bool&gt;(Hash.GET_SCREEN_COORD_FROM_WORLD_COORD , pos.X, pos.Y, pos.Z, x2dp, y2dp);<br>        return new Vector2(x2dp.GetResult&lt;float&gt;(), y2dp.GetResult&lt;float&gt;());<br>    }<br>//USE VERY SMALL VALUES FOR THE SCALE OF RECTS/TEXT because it is dramatically larger on screen than in 3D, e.g '0.05' small.<br><br>Used to be called _WORLD3D_TO_SCREEN2D<br><br>I thought we lost you from the scene forever. It does seem however that calling SET_DRAW_ORIGIN then your natives, then ending it. Seems to work better for certain things such as keeping boxes around people for a predator missile e.g.
Convert a world coordinate into its relative screen coordinate.  (WorldToScreen)<br>
 
Inverted function:[[Graphics::screen2dToWorld3d]]
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.graphics.world3dToScreen2d(worldX, worldY, worldZ, screenX, screenY);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.graphics.world3dToScreen2d(new mp.Vector3(worldX, worldY, worldZ));</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
*'''worldX:''' float
*'''worldX:''' float
*'''worldY:''' float
*'''worldY:''' float
*'''worldZ:''' float
*'''worldZ:''' float
*'''screenX:''' float
*'''screenY:''' float
===Return value===
===Return value===
*'''object:''' screenX, screenY
*'''object:''' x, y
*OR '''undefined''' if the given coordinate is not in view.
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">

Latest revision as of 19:26, 22 August 2020

Convert a world coordinate into its relative screen coordinate. (WorldToScreen)

Inverted function:Graphics::screen2dToWorld3d

Syntax

mp.game.graphics.world3dToScreen2d(new mp.Vector3(worldX, worldY, worldZ));

Required Arguments

  • worldX: float
  • worldY: float
  • worldZ: float

Return value

  • object: x, y
  • OR undefined if the given coordinate is not in view.

Example

// todo

See also