America's Army 3:Calculate Screen Coordinate
From UnKnoWnCheaTs Game Hacking Wiki
by: SystemFiles
Source
Here is my calculate screen coordinate function aka world to screen function:
FVector2D CalculateScreenCoordinate( UCanvas* Canvas, FVector Location ) { FVector2D Return; FVector AxisX, AxisY, AxisZ, Delta, Transformed; GetAxes( MyCameraRotation, AxisX, AxisY, AxisZ ); VectorSubtract( &Delta, &Location, &MyCameraLocation ); Transformed.X = VectorDotProduct( &Delta, &AxisY ); Transformed.Y = VectorDotProduct( &Delta, &AxisZ ); Transformed.Z = VectorDotProduct( &Delta, &AxisX ); if( Transformed.Z < 1.00f ) Transformed.Z = 1.00f; Return.X = ( Canvas->ClipX / 2.0f ) + Transformed.X * ( ( Canvas->ClipX / 2.0f ) / tan( PlayerController->FOVAngle * UCONST_Object_Pi / 360.0f ) ) / Transformed.Z; Return.Y = ( Canvas->ClipY / 2.0f ) + -Transformed.Y * ( ( Canvas->ClipX / 2.0f ) / tan( PlayerController->FOVAngle * UCONST_Object_Pi / 360.0f ) ) / Transformed.Z; return Return; }
This can be used to make a ESP and convert a FVector to screen coordinate. Useage:
FVector2D Location2D = GameManager::CalculateScreenCoordinate( Canvas, Pawn->Location );