? 久久精品国产亚洲AV久,日本无吗中文字幕免费婷婷,色欲天天天影视欧美视频
聯(lián)系我們

給我們留言

聯(lián)系我們

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

郵箱:info@narkii.com

電話:0595-82682267

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

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

UE4 UDecalComponent用法

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

[UE4]UDecalComponent用法

 

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

 

定義:

 
  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ù)中對(duì)其初始化:

 
  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)友評(píng)論

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

關(guān)閉

全部評(píng)論:0條

推薦
熱門