23.06.2014, 16:07
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
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);