ALCCSectionPlane:3DGS 剖切面
剖切面 Actor,用一個平面切開 LCC 場景,保留平面的一側。
| 模塊 | LCC4UnrealRuntime |
| 頭文件 | Tools/LCCSectionPlane.h |
| 父類 | AVolume |
| 面板顯示名 | LCC Section Plane |
#include "Tools/LCCSectionPlane.h"
使用步驟、演示效果與屬性面板說明見場景編輯 - 剖切平面。本頁只列接口。
編輯器裏會顯示一個箭頭指示組件,標明平面朝向,箭頭指向的一側就是 Upside。
Properties
| 屬性 | 類型 | 說明 |
|---|---|---|
bEnabled | bool | 是否參與剖切 |
Mode | ESectionType | Upside 切掉平面上方,Downside 切掉平面下方 |
上下是相對平面自身朝向而言,不是世界坐標。旋轉剖切面可以得到任意方向的剖切。取值含義見 ESectionType。
兩個屬性都沒有 Setter,直接賦值即可。運行時改屬性或改變換都會在下一幀自動生效,不需要手動通知渲染側。
Methods
SetUpdateComponent / Refresh(已廢棄)
UFUNCTION(BlueprintCallable, Category = "XGrids", meta = (DeprecatedFunction))
void SetUpdateComponent(ULCCComponentBase* Component);
UFUNCTION(BlueprintCallable, Category = "XGrids", meta = (DeprecatedFunction))
void Refresh();
兩個方法都已廢棄,實現為空操作,調用不會有任何效果也不會報錯。
剖切數據現在每幀讀取,屬性與變換的改動下一幀自動反映到畫面上。舊版本需要先 SetUpdateComponent 建立綁定、改完再調 Refresh() 的那套流程不再需要。
已有代碼中的調用可以直接刪除。藍圖裏這兩個節點會顯示廢棄警告,替換方式就是移除節點。
運行時創建
#include "Tools/LCCSectionPlane.h"
#include "LCCComponentBase.h"
ALCCSectionPlane* AMyTool::CreateSectionPlane(
ULCCComponentBase* Component, const FVector& Location, const FRotator& Rotation)
{
ALCCSectionPlane* Plane = GetWorld()->SpawnActor<ALCCSectionPlane>(
ALCCSectionPlane::StaticClass(), Location, Rotation);
if (!Plane)
{
return nullptr;
}
Plane->Mode = ESectionType::Upside; // 切掉平面上方
Plane->bEnabled = true;
Component->AddSectionPlane(Plane);
return Plane;
}
幾種常見配置:
| 效果 | 位置與旋轉 | Mode |
|---|---|---|
| 俯視看建築內部 | 指定高度,FRotator::ZeroRotator | Upside |
| 豎直剖切看立面 | FRotator(0, 0, 90) 轉成豎直平面 | Upside |
| 只保留中間一層 | 上下各放一個平面 | 下界 Downside,上界 Upside |
移動剖切面就能做出逐層揭開的動畫,每幀直接改位置即可:
FVector Loc = SectionPlane->GetActorLocation();
Loc.Z = FMath::FInterpTo(Loc.Z, TargetHeight, DeltaTime, 1.0f);
SectionPlane->SetActorLocation(Loc);
改屬性同樣直接賦值:
SectionPlane->bEnabled = false;
藍圖節點見場景編輯 - 藍圖方法。
Notes
- 剖切只影響渲染,不影響碰撞。被切掉的部分仍可被射線打中、仍會擋住角色。
Upside與Downside相對平面自身朝向。旋轉過之後要重新確認哪邊是「上」,編輯器裏看箭頭最直觀。- 構造時 Z 軸縮放被設為 0.01(薄片),編輯器裏改縮放也會被壓回該值。運行時改縮放不受這層約束,但一般不需要改。
- 同時生效的剖切面數量有上限,未授權時為 50 個,超出的不參與渲染並輸出警告。剖切面與裁剪體共用這個配額。授權說明見版本與授權。
- 銷毀剖切面只會觸發一次渲染更新,不會從 Component 的
SectionPlanes數組裏移除元素,數組中會殘留失效指針(渲染時會自動跳過)。需要保持數組乾淨的話,銷毀前先調RemoveSectionPlane。
See Also
- 場景編輯:完整使用說明
- ALCCClippingVolume:用有界體積裁剪
- ULCCComponentBase:
AddSectionPlane與RemoveSectionPlane