UE3 에서 씬 관리를 어떤 식으로 하는지에 대한 소스레벨에서의 정리
<box> 원문 : An interface to the private scene manager implementatin of a scene. Use AllocateScene to create the scene. </box>
씬을 관리하기 위한 인터페이스가 선언된 super class 쯤으로 생각하면 된다.
다음과 같은 method가 있다.
// Engine/Inc/Scene.h class FSceneInterface { // Primitive Component virtual void AddPrimitive( UPrimitiveComponent* Primitive ) = 0; // Scene에 Primitive Component 추가 virtual void RemovePrimitive( UPrimitiveComponent* Primitive ) = 0; // Scene에 Primitive Component 제거 virtual void UpdatePrimitiveTransform( UPrimitiveComponent ) = 0; // 이미 Scene에 추가된 Primitive Component 의 Transform 업데이트 // 이하 Light, SceneCapture, FluidSurface, HeightFog, FogVolume, WindSource 등에 관련해서도 위와 비슷한 형식의 Method가 존재 };
<box> 원문 : 없음 </box>
3D공간상 씬 관리 로직이 정의된 실질적 클래스
다음과 같은 특징이 있다.
대략 코드는 다음과 같다.
// Engine/Src/ScenePrivate.h class FScene : public FSceneInterface { UWorld* World; // 현재 Level에 관련된 월드 인스턴스 TSparseArray<FPrimitiveSceneInfo*> Primitives; // Primitive 리스트 ... TArray<UFluidSurfaceComponent*> FluidSurfaces; // FluidSurface 리스트 FSceneLightOctree LightOctree; // Lights 에 관련한 옥트리 FScenePrimitiveOctree PrimitiveOctree; // Primitives 에 관련한 옥트리 // 이하 모든 FSceneInterface 의 순수가상 함수에 대한 정의 };
<box> 원문 : A simple scene setup for rendering primitives on the canvas. Uses an FScene internally </box>
2D로 랜더링하기 위한 scene manager 쯤에 해당하고, 내부적으로 FScene을 사용하고 있다.
대략 코드는 다음과 같다.
// Engine/inc/CanvasScene.h class FCanvasScene : public FSceneInterface { public: void SetViewLocation( const FVector& InCameraOffset ); // 카메라 위치 세팅 for ViewMatrix void SetFOV( float InFOV ); // field of view 세팅 for ProjectionMatrix // 이하 무든 FSceneInterface 의 순수가상 함수에 대한 정의 private: FSceneInterface* Scene; // 내부적으로 사용될 FScene 의 인스턴스 };
<box> 원문 : Dummy NULL scene interface used by dedicated servers. </box>
Dedicated 서버를 위한 텅 빈 SceneManager. 모든 Method를 비어있는 brace {} 로 정의해 놓고 있다.
대략 코드는 다음과 같다.
// Engine/Src/Scene.cpp class FNULLSceneInterface : public FSceneInterface { ... virtual void AddPrimitive( UPrimitiveComponent* Primitive ) {} virtual void RemovePrimitive( UPrimitiveComponent* Primitive ) {} ... };
1. 랜더링쓰레드에서 Command 하나 꺼낸 후 ->Execute(); (Engine/Src/RenderingThread.cpp) 2. FScene::AddPrimitive 3. FScene::AddPrimitiveSceneInfo_RenderThread 4. FPrimitiveSceneInfo::AddToScene 5. TOctree<ElementType,OctreeSemantics>::AddElement 6. TOctree<ElementType,OctreeSemantics>::AddElementToNode