Thumbs up2D Radar

Posts 13 of 3 · Page 1 of 1
2D Radar
i wanted to share the 2d radar
Code:
FVector2D WorldToRadar( FVector Location , FLOAT PosX, FLOAT PosY , INT Size )
{
/*Credits to ********* community | xCyniu | r4z8r when you use this ;)*/
	FVector2D Coord;
	FVector2D Return;

	 FLOAT cY = cos(URotationToRadians( MyCameraRotation.Yaw )); 
	 FLOAT sY = sin(URotationToRadians( MyCameraRotation.Yaw ));

	 FLOAT dX = Location.X - MyCameraLocation.X;
	 FLOAT dY = Location.Y - MyCameraLocation.Y;

	 Coord.X = ( dY * cY - dX * sY ) / 150.0f;
	 Coord.Y = ( dX * cY + dY * sY ) / 150.0f;
 
	 Return.X = Coord.X + PosX + (Size / 2.0f);
	 Return.Y = -Coord.Y + PosY + (Size / 2.0f);
        /*Thanks to r4z8r for clamp :)*/
	 if(Return.X > (PosX + Size) )
		 Return.X = (PosX + Size);
	 else if(Return.X < (PosX) ) 
		 Return.X = PosX;

	 if(Return.Y > (PosY + Size) )
		 Return.Y = (PosY + Size);
	 else if(Return.Y < (PosY) ) 
		 Return.Y = PosY;

	 return Return;
}
Usage :
Code:
FVector2D Position = WorldToRadar(Target->Location, cVars.Radar.PosX, cVars.Radar.PosY,150);
Thanks to R4z8r for clamp function.

P.S Size is the size of the radar : example : width = 150 , height = 150
Credits by xCyniu
Oh, so you're leeching now

Add credits in the post.
Code:
FVector WorldToScreen (UCanvas* Canvas, FVector WorldLocation)//Helios
{
    FVector X,Y,Z,D,Out;
	GetAxes(MyCameraRotation,X,Y,Z);
	D = WorldLocation - MyCameraLocation;
	Out.X = (Canvas->ClipX/2)+( Dot(D,Y))*((Canvas->ClipX/2)/tan(Me->FovAngle*PI/360))/Dot(D,X);
	Out.Y = (Canvas->ClipY/2)+(-Dot(D,Z))*((Canvas->ClipX/2)/tan(Me->FovAngle*PI/360))/Dot(D,X);
	Out.Z = 0;
	return Out;
}
I need defines of red marked words. Can any1 help?

DOT:
Code:
FLOAT VectorDotProduct( FVector* pV1, FVector* pV2 )
{
    return ( ( pV1->X * pV2->X ) + ( pV1->Y * pV2->Y ) + ( pV1->Z * pV2->Z ) );
}
Camera's:
Code:
FVector CameraLocation = FVector();
FRotator CameraRotation = FRotator();
Posts 13 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?