? 一本无码久本草在线中文字幕,久99久爱精品视频,91精品国产91次久久次福制
聯(lián)系我們

給我們留言

聯(lián)系我們

地址:福建省晉江市青陽街道洪山路國際工業(yè)設(shè)計(jì)園納金網(wǎng)

郵箱:info@narkii.com

電話:0595-82682267

(周一到周五, 周六周日休息)

當(dāng)前位置:主頁 > 3D教程 > 圖文教程

UE4 UDecalComponent用法

來源: 52vr | 責(zé)任編輯:傳說的落葉 | 發(fā)布時間: 2019-06-06 08:25 | 瀏覽量:

[UE4]UDecalComponent用法

 

4.11的TopDown Sample Project中,增加了一個新功能:用UDecalComponent顯示印花圖案,特點(diǎn)是可以在非平面的地形上,按照地面的凹凸地勢自動貼緊地面。

 

定義:

 
  1. /** A decal that projects to the cursor location. */  
  2. UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))  
  3. class UDecalComponent* CursorToWorld;  

 

構(gòu)造函數(shù)中對其初始化:

 
  1. // Create a decal in the world to show the cursor's location  
  2. CursorToWorld = CreateDefaultSubobject<UDecalComponent>("CursorToWorld");  
  3. CursorToWorld->AttachTo(RootComponent);  
  4. static ConstructorHelpers::FObjectFinder<UMaterial> DecalMaterialAsset(TEXT("Material'/Game/TopDownCPP/Blueprints/M_Cursor_Decal.M_Cursor_Decal'"));  
  5. if (DecalMaterialAsset.Succeeded())  
  6. {  
  7.     CursorToWorld->SetDecalMaterial(DecalMaterialAsset.Object);  
  8. }  
  9. CursorToWorld->DecalSize = FVector(16.0f, 32.0f, 32.0f);  
  10. CursorToWorld->SetRelativeRotation(FRotator(90.0f, 0.0f, 0.0f).Quaternion());  

 

跟隨鼠標(biāo)位置在地面上繪制:

 
  1. void ANetworkTestCharacter::Tick(float DeltaSeconds)  
  2. {  
  3.     if (CursorToWorld != nullptr)  
  4.     {  
  5.         if (APlayerController* PC = Cast<APlayerController>(GetController()))  
  6.         {  
  7.             FHitResult TraceHitResult;  
  8.             PC->GetHitResultUnderCursor(ECC_Visibility, true, TraceHitResult);  
  9.             FVector CursorFV = TraceHitResult.ImpactNormal;  
  10.             FRotator CursorR = CursorFV.Rotation();  
  11.             CursorToWorld->SetWorldLocation(TraceHitResult.Location);  
  12.             CursorToWorld->SetWorldRotation(CursorR);  
  13.         }  
  14.     }  
  15. }  


相關(guān)文章
網(wǎng)友評論

您需要登錄后才可以發(fā)帖 登錄 | 立即注冊

關(guān)閉

全部評論:0條

推薦
熱門