GetCameraFacingAngle? -
De4dpOol - 25.02.2015
Hello, is there a possible way to get the facing of the camera?
I am in need of the camera facing angle or a function like GetCameraFacingAngle.
Thanks.
Re: GetCameraFacingAngle? -
Golf - 25.02.2015
mybe this can help you
https://sampwiki.blast.hk/wiki/GetPlayerCameraFrontVector
depending on what you're trying to accomplish
Re: GetCameraFacingAngle? -
De4dpOol - 25.02.2015
Quote:
Originally Posted by Golf
|
Well I am trying to get a Float value just like GetPlayerFacingAngle.
Is there anyway to do it with GetPlayerCameraFrontVector?
Re: GetCameraFacingAngle? -
Gammix - 25.02.2015
GetPlayerCameraFrontVector
This function returns a vector X, Y, Z of the place where the player is aiming in 3D space from 2D. Yes, you may call this a sort of facing angle.
GetPlayerCameraPos
This generally gives the player camera pos in 3D space.
For making a generall camera for class selection, use those ^^ for reading the cordinates. And then use
SetPlayerCameraPos and
SetPlayerCameraLookAt for facing angle*.
TIP: you may use map editor for the same purpose. There is camera options at the top in VIEW sub window.
Re: GetCameraFacingAngle? -
-=Dar[K]Lord=- - 25.02.2015
http://www.geom.uiuc.edu/docs/refere...as/node52.html
Have a look at it it gives you the angle made by vectornwith x y z coords in 3d space
Ps. Its not a coding site its all about vectors...
Re: GetCameraFacingAngle? -
BroZeus - 25.02.2015
Something like this, didnt tested it :
pawn Код:
stock Float:GetCameraFacingAngle(playerid)
{
new Float:pos1[3], Float:pos2[3];
GetPlayerCameraPos(playerid, pos1[0], pos1[1], pos1[2]);
GetPlayerCameraFrontVector(playerid, pos2[0], pos2[1], pos2[2]);
return atan2(pos1[0] - pos2[0], pos1[1] - pos2[1]) * (180 / 3.14);
}
Re: GetCameraFacingAngle? -
Pottus - 25.02.2015
@BroZeus - Doesn't seem correct too much math here is Nero's solution from some time ago.
pawn Код:
Float: GetPlayerCameraFacingAngle(playerid)
{
new Float: vX, Float: vY;
if(GetPlayerCameraFrontVector(playerid, vX, vY, Float: playerid))
{
if((vX = -atan2(vX, vY)) < 0.0) return vX + 360.0;
return vX;
}
return 0.0;
}
Texture studio uses this in flymode when creating the texture viewer.
Re: GetCameraFacingAngle? -
BroZeus - 26.02.2015
Quote:
Originally Posted by Pottus
@BroZeus - Doesn't seem correct too much math here is Nero's solution from some time ago.
pawn Код:
Float: GetPlayerCameraFacingAngle(playerid) { new Float: vX, Float: vY; if(GetPlayerCameraFrontVector(playerid, vX, vY, Float: playerid)) { if((vX = -atan2(vX, vY)) < 0.0) return vX + 360.0; return vX; } return 0.0; }
Texture studio uses this in flymode when creating the texture viewer.
|
@Pottus
ok tested ig looks like you are right..
AW: Re: GetCameraFacingAngle? -
Nero_3D - 26.02.2015
Quote:
Originally Posted by BroZeus
As far as I know the formula i gave should work, too lazy to go in game and test
|
The camera pos doesn't matter if you only want to know the direction because the native is called CameraFront
Vector and not Front
Pos (or something similar)
You should have tested the code instead of drawing and uploading that image
Re: AW: Re: GetCameraFacingAngle? -
BroZeus - 26.02.2015
Quote:
Originally Posted by Nero_3D
The camera pos doesn't matter if you only want to know the direction because the native is called CameraFrontVector and not FrontPos (or something similar)
You should have tested the code instead of drawing and uploading that image
|
Thanks for that, looks like I was wrong :-/ I thought it returned coords of the point at which camera is pointing at