Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FMatrix UDoWSkeletalMeshComponent::GetRenderMatrix() const
- {
- /* UT3's implementation for reference
- const FMatrix LocalToView = LocalToWorld * View->ViewMatrix;
- const FMatrix ViewToWarpedView = FPerspectiveMatrix(FOV * PI / 360.0f, View->SizeX, View->SizeY, View->NearClippingDistance) * View->ProjectionMatrix.Inverse();
- OutLocalToWorld = LocalToView * ViewToWarpedView * View->ViewMatrix.Inverse();
- OutWorldToLocal = OutLocalToWorld.Inverse();
- */
- // Get references
- ADoWWeapon* Weapon = Cast<ADoWWeapon>(GetOuter());
- if (false)//Weapon)
- {
- ADoWCharacter * Character = Cast<ADoWCharacter>(Weapon->GetOwner());
- if (Character)
- {
- // The FOV we actually want to apply to the mesh
- float FOV = 70.0f;
- const FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY());
- ADoWPlayerController *PC = Cast<ADoWPlayerController>(Character->GetController());
- if (PC)
- {
- ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(PC->Player);
- if (LocalPlayer != NULL && LocalPlayer->ViewportClient != NULL && LocalPlayer->ViewportClient->Viewport != NULL)
- {
- FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
- LocalPlayer->ViewportClient->Viewport,
- PC->GetWorld()->Scene,
- LocalPlayer->ViewportClient->EngineShowFlags).SetRealtimeUpdate(true));
- FVector ViewLocation;
- FRotator ViewRotation;
- FSceneView* View = LocalPlayer->CalcSceneView(&ViewFamily, ViewLocation, ViewRotation, LocalPlayer->ViewportClient->Viewport);
- //SceneView->ViewMatrices.ProjMatrix.SetIdentity();
- const FMatrix LocalToView = ComponentToWorld.ToMatrixWithScale() * View->ViewMatrices.ViewMatrix;
- const FMatrix ViewToWarpedView = FPerspectiveMatrix(FOV * PI / 360.0f, ViewportSize.X, ViewportSize.Y, View->NearClippingDistance) * View->ViewMatrices.ProjMatrix.Inverse();
- FMatrix OutLocalToWorld = LocalToView * ViewToWarpedView * View->ViewMatrices.ViewMatrix.Inverse();
- FMatrix OutWorldToLocal = OutLocalToWorld.Inverse();
- return OutWorldToLocal;
- }
- }
- /*
- // Get current FOV
- float currFovFull = (Cast<APlayerController>(Character->Controller))->PlayerCameraManager->GetFOVAngle();
- // Calc radial FOV to pass into FPerspectiveMatrix
- float engineFovHalf = currFovFull * PI / 360.0f;// PI / (180.0f / (currFovFull * 0.5f));
- float requiredFovHalf = FOV * PI / 360.0f; //PI / (180.0f / (requiredFovFull * 0.5f));
- // Get perspective matrix that will be applied after we send our data and invert it - inversion will allow us to pre-emptively remove the camera FOV
- FPerspectiveMatrix enginePerspective = FPerspectiveMatrix(engineFovHalf, ViewportSize.X, ViewportSize.Y, 1.0f);
- FMatrix invEnginePerspective = enginePerspective.Inverse();
- // Set up perspective matrix we want to apply
- FPerspectiveMatrix requiredPerspective = FPerspectiveMatrix(requiredFovHalf, ViewportSize.X, ViewportSize.Y, 1.0f);
- // Get world transform for this comp and apply inverse and required transforms to it
- FMatrix adjTransform = invEnginePerspective * requiredPerspective * ComponentToWorld.ToMatrixWithScale();
- return adjTransform;
- */
- }
- }
- return Super::GetRenderMatrix();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement