SA-MP Forums Archive
How to get 2D pos from 3D pos (mouse system) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to get 2D pos from 3D pos (mouse system) (/showthread.php?tid=312983)



How to get 2D pos from 3D pos (mouse system) - TheGamer! - 23.01.2012

Hy, anyone can help me? I want to make a mouse system calculated from CameraFrontVector's changes, but i don't know how to do the calculations...

Any functions? Or anything else?


Re: How to get 2D pos from 3D pos (mouse system) - Jack_Fox - 23.01.2012

Could you explain a bit more about what you're trying to do?

Do you want to be able to click on the ground or on a player/vehicle or anything in 3D space?


Re: How to get 2D pos from 3D pos (mouse system) - TheGamer! - 23.01.2012

No i want to simply move the mouse... without any dialogs...


Re: How to get 2D pos from 3D pos (mouse system) - TheGamer! - 23.01.2012

I'm trying to make a textdraw-mouse with an TXD mouse...


Re: How to get 2D pos from 3D pos (mouse system) - Jack_Fox - 23.01.2012

It is possible but it's complicated.
You need to get the player camera vector, I've checked the values it gives, when you look completely up, it gives 0.707106 (to the sky) and completely down (to the ground) it gives -0.964372 as Z coordinates. You need this to set the Y coordinates for the textdraw, on 0.707106 the mouse is at the edge above in the screen, and on -0.96 its at the edge below of the screen.

for the X coordinates of the textdraw you need to use the X and Y coordinates of the camera vector. This is more complicated because you can turn the camera all around, looking north gives X=0 and Y=1, East gives X=1 and Y =0, South is X=0 and Y=-1 and West gives X=-1 and Y = 0.

The calculation about checking in what direction it changed (to find the X for the textdraw) is quite complicated...


Re: How to get 2D pos from 3D pos (mouse system) - TheGamer! - 23.01.2012

Thank you i'll check your post at saturday...


Re: How to get 2D pos from 3D pos (mouse system) - TheGamer! - 27.01.2012

There's any function that help?


Re: How to get 2D pos from 3D pos (mouse system) - TheGamer! - 04.02.2012

Any func?


Re: How to get 2D pos from 3D pos (mouse system) - T0pAz - 04.02.2012

GetPlayerCameraPos.
GetPlayerCameraFrontVector.


Re: How to get 2D pos from 3D pos (mouse system) - TheGamer! - 04.02.2012

i knew... but more? or codes?