Graphics::world3dToScreen2d: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
(yay)
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><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.
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">graphics.world3dToScreen2d(worldX, worldY, worldZ, screenX, screenY);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.graphics.world3dToScreen2d(worldX, worldY, worldZ, screenX, screenY);</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
*'''worldX:''' float
*'''worldX:''' float
Line 12: Line 12:
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
todo
// todo
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
{{Graphics_function_c}}
{{Graphics_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Revision as of 21:13, 6 May 2017

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

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.


For .NET users...

VB:
Public Shared Function World3DToScreen2d(pos as vector3) As Vector2

Dim x2dp, y2dp As New Native.OutputArgument

Native.Function.Call(Of Boolean)(Native.Hash.GET_SCREEN_COORD_FROM_WORLD_COORD , pos.x, pos.y, pos.z, x2dp, y2dp)
Return New Vector2(x2dp.GetResult(Of Single), y2dp.GetResult(Of Single))

End Function

C#:
Vector2 World3DToScreen2d(Vector3 pos)
{
var x2dp = new OutputArgument();
var y2dp = new OutputArgument();

Function.Call<bool>(Hash.GET_SCREEN_COORD_FROM_WORLD_COORD , pos.X, pos.Y, pos.Z, x2dp, y2dp);
return new Vector2(x2dp.GetResult<float>(), y2dp.GetResult<float>());
}
//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.

Used to be called _WORLD3D_TO_SCREEN2D

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.

Syntax

mp.game.graphics.world3dToScreen2d(worldX, worldY, worldZ, screenX, screenY);

Required Arguments

  • worldX: float
  • worldY: float
  • worldZ: float
  • screenX: float
  • screenY: float

Return value

  • object: screenX, screenY

Example

// todo

See also