AW: Respuesta: Screen to World vice versa -
Nero_3D - 14.06.2014
Quote:
Originally Posted by adri1
ScreenToWorld not works!
|
If my code isn't working for you for any reason I can't image because it does for me try Vinnyy's code
Quote:
Originally Posted by Vinnyy
|
I should take a look into it once again if I got some time left
Re: Screen to World vice versa -
VladimirMark - 14.06.2014
Good job and it's really useful
Re: Screen to World vice versa -
MacT - 18.06.2014
Quote:
Originally Posted by kvann
Aww... This is so great. I already have an use for this.
|
And just remake and claimed its your on scripted in your rp server? Like Furniture system preview.
Respuesta: Screen to World vice versa -
adri1 - 21.06.2014
I use this:
pawn Код:
public OnCursorPositionChange(NewX, NewY)
{
if(var == 1)
{
new Float:p[3];
new Float:MX = (floatdiv(NewX, ScreenWidth) * 640.0);
new Float:MY = (floatdiv(NewY, ScreenHeight) * 448.0);
ScreenToWorld(0, MX, MY, p[0], p[1], p[2]);
new Float:pp[3];
//GetObjectPos(obj, pp[0], pp[1], pp[2]);
SetObjectPos(obj, p[0], p[1], p[2]);
//printf("%f, %f, %f", p[0], p[1], p[2]);
}
return 1;
}
and return this:
pawn Код:
[23:33:39] 0.114388, -1.017790, 0.300795
[23:33:39] 0.116575, -1.017659, 0.298849
[23:33:39] 0.119490, -1.017521, 0.296903
[23:33:39] 0.121676, -1.017390, 0.294958
[23:33:40] 0.120220, -1.017570, 0.297876
[23:33:40] 0.118034, -1.017812, 0.301767
[23:33:40] 0.117305, -1.017819, 0.301767
...
...
EDIT:
Example::
pawn Код:
ScreenToWorld(0, 600, 200, p[0], p[1], p[2]);
returns: 0.998540, -0.610018, -0.094856
Player ID 0 it's connected!.
AW: Screen to World vice versa -
Nero_3D - 21.06.2014
I never stated it but ScreenToWorld actully returns a vector (returning a position would need a distance parameter)
Since I use the front vector as base, it also starts at the camera pos
pawn Код:
// I think NewX and NewY are normal textdraw coordinates ?
// Than they need to be float and we just insert them directly in StW
public OnCursorPositionChange(Float: NewX, Float: NewY)
{
if(var == 1)
{
const playerid = 0;
new pos[6];
GetPlayerCameraPos(playerid, p[0], p[1], p[2]);
ScreenToWorld(playerid, NewX, NewY, p[3], p[4], p[5]);
const Float: distance = 25.0;
p[0] += p[3] * distance;
p[1] += p[4] * distance;
p[2] += p[5] * distance;
SetObjectPos(obj, p[0], p[1], p[2]);
printf("%f, %f, %f", p[0], p[1], p[2]);
}
}
Respuesta: Screen to World vice versa -
adri1 - 22.06.2014
It's possible only for X, Y object position? Z using MapAndreas.
AW: Respuesta: Screen to World vice versa -
Nero_3D - 22.06.2014
Quote:
Originally Posted by adri1
It's possible only for X, Y object position? Z using MapAndreas.
|
It converts X, Y and Z in game position into X and Y of the screen (WorldToScreen)
And X and Y of the screen in an vector (starting at the camera pos) with X, Y and Z (ScreenToWorld)
Respuesta: Screen to World vice versa -
adri1 - 22.06.2014
Can you make an example? please.
Re: Screen to World vice versa -
iRaiDeN - 22.06.2014
Nhhh... Was better to post this filter and Include, not at all useful.
AW: Respuesta: Screen to World vice versa -
Nero_3D - 23.06.2014
Quote:
Originally Posted by adri1
Can you make an example? please.
|
First ScreenToWorld and how to calculate the position with a specific distance
Afterwards WorldToScreen which just takes a position in 3d and returns the x and y of the screen
pawn Код:
const
Float: distance = 25.0
;
new
Float: TextDrawX = 400.0,
Float: TextDrawY = 300.0,
Float: cameraX,
Float: cameraY,
Float: cameraZ,
Float: vectorX,
Float: vectorY,
Float: vectorZ
;
// ScreenToWorld
GetPlayerCameraPos(playerid, cameraX, cameraY, cameraZ);
ScreenToWorld(playerid, TextDrawX, TextDrawY, vectorX, vectorY, vectorZ);
cameraX += vectorX * distance;
cameraY += vectorY * distance;
cameraZ += vectorZ * distance;
printf("%f %f %f", cameraX, cameraY, cameraZ);
// WorldToScreen
WorldToScreen(playerid, cameraX, cameraY, cameraZ, TextDrawX, TextDrawY);
printf("%f %f", TextDrawX, TextDrawY);
Re: Screen to World vice versa -
codectile - 04.06.2015
What about this feature? ColWorldSnapShot ?
It generates a bitmap file of the collision world of san andreas.
The main drawback of this function is, it can only generate the image in the server files.
This is why I need, client side plugins.
It's quite messed up but I am finding a way to to this. Though, you can guess which location is this

.
EDIT: Close.
EDIT2:
New Image