zoukankan      html  css  js  c++  java
  • UE4 VR中血条的做法 3d widget

    本文地址:https://www.cnblogs.com/LynnVon/p/14113249.html

    项目需要要在VR中标记物体的位置及距离等,正常情况我们做血条之类的我们可以用Widget然后Space为screen就可以,VR里就不可以了。

    VR里我们将widget的space切换为world,然后还需要widget的scale跟随其与camera的距离变化(maprange)

    float scale = UKismetMathLibrary::MapRangeClamped(Dis, MAXDis, MINDis, Out1, Out2);
    	this->SetWorldScale3D(FVector(scale, scale, scale));
    

    然后我们使widget始终面向camera

    void UDistanceMsgComponent::LookAtPlayer()
    {
        FRotator WidgetComponentRotator = GetComponentRotation();
        FRotator CameraRotator = UGameplayStatics::GetPlayerCameraManager(this, 0)->GetCameraRotation();
    
        this->SetWorldRotation(FRotator(-CameraRotator.Pitch, CameraRotator.Yaw + 180, WidgetComponentRotator.Roll));
    }

    再然后,我们需要使widget始终处于其他物体的前方,也就是渲染在最上方,否则会被其他物体挡住,可以参考https://answers.unrealengine.com/questions/207400/3d-widget-ztest-off.html

    其中一下方法我觉得是最好的一个

    Another option is copying the Material Widget3DPassThrough.asset from the Engine Content to your Project Content (rename it to something else like Widget3DPassThrough_2.asset), then edit the Material Widget3DPassThrough_Translucent.asset (your 3d widget material) changing its parent to Widget3DPassThrough_2.asset and disable the ZTest on Widget3DPassThrough_2.asset.

  • 相关阅读:
    CSS3中制作倒影box-reflect
    JS中==与===区别
    CSS3-Animation
    CSS3-transform
    CSS3-transition
    CSS盒模型-box-sizing
    css兼容处理-hack
    CSS3-rgba
    CSS3-文本-word-wrap,word-break,white-space
    CSS3-文本-text-shadow
  • 原文地址:https://www.cnblogs.com/LynnVon/p/14113249.html
Copyright © 2011-2022 走看看