Код:
inline void DrawBoundingBox (UCanvas* Canvas, APawn* Target) { FVector X,Y,Z,D,E,top,bottom;; float width, Left, Right, Top, Bot; GetAxes(MyCameraRotation,X,Y,Z); D.X = Target->Location.X - MyCameraLocation.X; D.Y = Target->Location.Y - MyCameraLocation.Y; D.Z = Target->Location.Z - MyCameraLocation.Z; if(Dot(D,X) <= cos(90 * 3.14159265 / 180)) return; FBoxSphereBounds Player = Target->Mesh->Bounds; top = Target->Location; top = WorldToScreen(Canvas,top); bottom = Player.BoxExtent; bottom = WorldToScreen(Canvas,bottom); width = ((top.Y - bottom.Y) / 3); Left = top.X + width; Right = top.X - width; Top = top.Y; Bot = bottom.Y; Canvas->Draw2DLine(Left, Top, Left, Bot, Green); Canvas->Draw2DLine(Left, Bot, Right, Bot, Green); Canvas->Draw2DLine(Right, Bot, Right, Top, Green); Canvas->Draw2DLine(Right, Top, Left, Top, Green)
Код:
float Size (FVector &v) { return sqrt(v.x*v.x + v.y*v.y + v.z*v.z); } void Normalize (FVector &v) { float size = Size(v); if ( !size ) { v.x = v.y = v.z = 1; } else { v.x /= size; v.y /= size; v.z /= size; } } void inline GetAxes (FRotator R, FVector &X, FVector &Y, FVector &Z) { X = RotToVec(R); X.Normalize(); R.Yaw += 16384; FRotator R2 = R; R2.Pitch = 0.f; Y = RotToVec(R2); Y.Normalize(); Y.Z = 0.f; R.Yaw -= 16384; R.Pitch += 16384; Z = RotToVec(R); Z.Normalize(); } float inline Dot (const FVector& V1,const FVector& V2) { return ( V1.X*V2.X + V1.Y*V2.Y + V1.Z*V2.Z ); }
Код:
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; }
Код:
void DrawPlayerESP( UCanvas* pCanvas ) { if (pPC == NULL || pPC->Pawn == NULL || pPC->WorldInfo == NULL ) return; APawn* Target = pPC->Pawn->WorldInfo->PawnList; while ( Target != NULL ) { if ( Target != NULL && !Target->bDeleteMe && Target->Health >0 && Target != pPC->Pawn && !Target->IsA(AVehicle::StaticClass())) { DrawBoundingBox (pCanvas, Target); } Target = Target->NextPawn; } }
Код:
ok my tutorial on the UE3 for apb by the1domo @ The Defaced //------------------------------------------------------- FColor MakeColor(int R, int G, int B, int A) { FColor ReturnedColor; ReturnedColor.R = R; ReturnedColor.G = G; ReturnedColor.B = B; ReturnedColor.A = A; return ReturnedColor; } //------------------------------------------------------- FColor Green = MakeColor(0,255,0,255); FColor Red = MakeColor(255,0,0,255); //------------------------------------------------------- you need to define PI and URotationToRadians //------------------------------------------------------- #define PI 3.1415926 #define URotationToRadians PI / 32768 //------------------------------------------------------- Heres some stuff from the SDK you need for apb //------------------------------------------------------- APlayerController* pPC = NULL; APlayerController* PlayerController = NULL; APlayerController* MPC = NULL; UObject* pCallObject = NULL; AcAPBPlayerController* pPlayerController = NULL; FVector MyCameraLocation = FVector(); FRotator MyCameraRotation = FRotator(); //------------------------------------------------------- you need this to get all of your pointers Credits go to uNrEaL //------------------------------------------------------- UObject* GetInstanceOf ( UClass* Class ) { static UObject* ObjectInstance; ObjectInstance = NULL; for ( int i = 0; i < UObject::GObjObjects()->Count; ++i ) { UObject* CheckObject = ( *UObject::GObjObjects() )( i ); if ( CheckObject && CheckObject->IsA( Class ) ) { if ( !strstr( CheckObject->GetFullName(), "Default" ) ) ObjectInstance = CheckObject; } } return ObjectInstance; }; //------------------------------------------------------- to get the Size of a FVector //------------------------------------------------------- float Size (FVector &v) { return sqrt(v.X*v.X + v.Y*v.Y + v.Z*v.Z); } //------------------------------------------------------- Normalize is a vector //------------------------------------------------------- void Normalize (FVector &v) { float size = Size(v); if ( !size ) { v.x = v.y = v.z = 1; } else { v.x /= size; v.y /= size; v.z /= size; } } //------------------------------------------------------- ok use thie to get GetAxes //------------------------------------------------------- void inline GetAxes (FRotator R, FVector &X, FVector &Y, FVector &Z) { X = RotToVec(R); X.Normalize(); R.Yaw += 16384; FRotator R2 = R; R2.Pitch = 0.f; Y = RotToVec(R2); Y.Normalize(); Y.Z = 0.f; R.Yaw -= 16384; R.Pitch += 16384; Z = RotToVec(R); Z.Normalize(); } //------------------------------------------------------- you need this to use WorldToScreen and Draw Boxs //------------------------------------------------------- float inline Dot (const FVector& V1,const FVector& V2) { return ( V1.X*V2.X + V1.Y*V2.Y + V1.Z*V2.Z ); } //------------------------------------------------------- Quote: Originally Posted by Tamimego You can only call Project in HUD.PostRender. It's pretty much the only time the game has the ViewScene in Canvas or whatever set. Some games it is different though, like FFOW had a function called CachedProject where they stored the Projection and View Matrixes from the last frame. //------------------------------------------------------- WorldToScreen is wot you uses to Draw on the Screen //------------------------------------------------------- FVector WorldToScreen (UCanvas* Canvas, FVector WorldLocation)//Helios { FVector X,Y,Z,D,Out; GetAxes(MyCameraRotation,X,Y,Z); //D = WorldLocation - MyCameraLocation; D.X = WorldLocation.X - MyCameraLocation.X; D.Y = WorldLocation.Y - MyCameraLocation.Y; D.Z = WorldLocation.Z - MyCameraLocation.Z; 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; } //------------------------------------------------------- Credits to Tamimego R00T88 x22 HOOAH07 //------------------------------------------------------- ok it is my Draw Box ESP Credits to SystemFiles for help me fix it you use it to Draw Boxs on the Screen //------------------------------------------------------- inline void DrawBoundingBox (UCanvas* Canvas, APawn* Target) { FVector X,Y,Z,D,E,top,bottom;; float width, Left, Right, Top, Bot; GetAxes(MyCameraRotation,X,Y,Z); D.X = Target->Location.X - MyCameraLocation.X; D.Y = Target->Location.Y - MyCameraLocation.Y; D.Z = Target->Location.Z - MyCameraLocation.Z; if(Dot(D,X) <= cos(90 * 3.14159265 / 180)) return; FBoxSphereBounds Player = Target->Mesh->Bounds; top = Target->Location; top = WorldToScreen(Canvas,top); bottom = Player.BoxExtent; bottom = WorldToScreen(Canvas,bottom); width = ((top.Y - bottom.Y) / 3); Left = top.X + width; Right = top.X - width; Top = top.Y; Bot = bottom.Y; Canvas->Draw2DLine(Left, Top, Left, Bot, Green); Canvas->Draw2DLine(Left, Bot, Right, Bot, Green); Canvas->Draw2DLine(Right, Bot, Right, Top, Green); Canvas->Draw2DLine(Right, Top, Left, Top, Green); } //------------------------------------------------------- how we need to itert tho the Player list //------------------------------------------------------- void DrawPlayerESP( UCanvas* pCanvas ) { if (pPC == NULL || pPC->Pawn == NULL || pPC->WorldInfo == NULL ) return; APawn* Target = pPC->Pawn->WorldInfo->PawnList; while ( Target != NULL ) { if ( Target != NULL && !Target->bDeleteMe && Target->Health >0 && Target != pPC->Pawn && !Target->IsA(AVehicle::StaticClass())) { DrawBoundingBox (pCanvas, Target); } Target = Target->NextPawn; } } //------------------------------------------------------- PostRender is your main thread //------------------------------------------------------- void PostRender(UCanvas* pCanvas) { if(pCanvas) { pPlayerController = ( AcAPBPlayerController* )GetInstanceOf( AcAPBPlayerController::StaticClass() ); pPlayerController->GetPlayerViewPoint( &MyCameraLocation, &MyCameraRotation ); DrawPlayerESP(pCanvas); } } //------------------------------------------------------- your hook Function you need it to get the Canvas and pCallObject for the hook Credits go to uNrEaL //------------------------------------------------------- void hkProcessEvent ( UFunction* pFunction, void* pParms, void* pResult ) { _asm pushad;w _asm mov pCallObject, ecx; if ( pFunction ) { strcpy( FunctionName, pFunction->GetFullName() ); if ( !strcmp( FunctionName, "Function Engine.GameViewportClient.PostRender" )) { PostRender(((UGameViewportClient_eventPostRender_Parms*)pParms)->Canvas ); } if ( !strcmp( FunctionName, "Function Engine.PlayerController.PlayerTick" )) { pPC = (APlayerController*)pCallObject; } else if ( !strcmp( FunctionName, "Function APBGame.cAPBPlayerController.Destroyed" )) { if(pPC == pCallObject) { pPC = NULL; } } } _asm popad; pProcessEvent( pFunction, pParms, pResult ); } //------------------------------------------------------- your Detour Function for the hack //------------------------------------------------------- void OnAttach () { pProcessEvent = ( tProcessEvent )DetourFunction( ( PBYTE )ProcessEvent, ( PBYTE )hkProcessEvent ); } //------------------------------------------------------- DllMain you need this for the dll //------------------------------------------------------- BOOL WINAPI DllMain ( HMODULE hModule, DWORD dwReason, LPVOID lpReserved ) { if ( dwReason == DLL_PROCESS_ATTACH ) OnAttach (); return TRUE; } //-------------------------------------------------------
Отредактировано Dok33 (2012-12-20 01:20:12)