3 #include "util/unordered_array.hpp" 4 #include "SortedFaceGroups.h" 5 #include "util/ParaMemPool.h" 6 #include "IRefObject.h" 7 #include "ParaXModel/ParticleSystemRef.h" 8 #include "BillBoardViewInfo.h" 9 #include "BaseObject.h" 16 class IBatchedElementDraw;
17 class CParaWorldAsset;
18 class CContainerObject;
24 class CSortedFaceGroups;
32 RENDER_GLOBAL_TERRAIN = 0x1 << 1,
33 RENDER_MESH_FRONT_TO_BACK = 0x1 << 2,
34 RENDER_MESH_BACK_TO_FRONT = 0x1 << 3,
35 RENDER_MESH_TRANSPARENT = 0x1 << 4,
36 RENDER_CHARACTERS = 0x1 << 5,
37 RENDER_PLAYER = 0x1 << 6,
38 RENDER_SPRITES = 0x1 << 7,
39 RENDER_MISSILES = 0x1 << 8,
40 RENDER_PARTICLES = 0x1 << 9,
41 RENDER_BOUNDINGBOX = 0x1 << 10,
42 RENDER_GEN_SM_TERRAIN = 0x1 << 11,
43 RENDER_TRANSLUCENT_FACE_GROUPS = 0x1 << 12,
44 RENDER_PORTAL_SYSTEM = 0x1 << 13,
45 RENDER_SELECTION = 0x1 << 14,
46 RENDER_SHADOWMAP = 0x1 << 15,
47 RENDER_TRANSPARENT_CHARACTERS = 0x1 << 16,
48 RENDER_OWNER_DRAW = 0x1 << 17,
49 RENDER_POST_RENDER_LIST = 0x1 << 18,
52 #define CHECK_SELECTION(x) ((dwSelection&(x))>0) 56 PIPELINE_ORDER_PRE_SCENE = 0,
57 PIPELINE_3D_SCENE = 1,
60 PIPELINE_POST_UI_3D_SCENE = 51,
61 PIPELINE_COLOR_PICKING = 100,
70 float m_fObjectToCameraDistance;
78 :m_pRenderObject(pRenderObject), m_fObjectToCameraDistance(fObjectToCameraDistance), m_nOccluded(nOccluded) {};
90 float m_fObjectToCameraDistance;
139 int nLeftTech = _Left.m_pRenderObject->GetPrimaryTechniqueHandle();
140 int nRightTech = _Right.m_pRenderObject->GetPrimaryTechniqueHandle();
142 #ifdef DONOT_SORT_BY_ASSET 143 return ( (nLeftTech < nRightTech) ||
144 ((nLeftTech == nRightTech) && ((_Left.m_fObjectToCameraDistance) < (_Right.m_fObjectToCameraDistance))) );
146 AssetEntity* LeftAsset = _Left.m_pRenderObject->GetPrimaryAsset();
147 AssetEntity* RightAsset = _Right.m_pRenderObject->GetPrimaryAsset();
148 return ((nLeftTech < nRightTech) ||
149 ((nLeftTech == nRightTech) && (LeftAsset < RightAsset)) ||
150 ((nLeftTech == nRightTech) && (LeftAsset == RightAsset) && ((_Left.m_fObjectToCameraDistance) < (_Right.m_fObjectToCameraDistance))));
158 inline bool operator()(
163 return (_Left.m_fObjectToCameraDistance) < (_Right.m_fObjectToCameraDistance);
171 inline bool operator()(
176 int nLeftRenderImportance = _Left.m_pRenderObject->GetRenderImportance();
177 int nRightRenderImportance = _Right.m_pRenderObject->GetRenderImportance();
178 return (nLeftRenderImportance > nRightRenderImportance) ||
179 ((nLeftRenderImportance == nRightRenderImportance) && ((_Left.m_fObjectToCameraDistance) < (_Right.m_fObjectToCameraDistance)));
187 inline bool operator()(
192 float leftOrder = _Left.m_pRenderObject->GetRenderOrder();
193 float rightOrder = _Right.m_pRenderObject->GetRenderOrder();
194 return (leftOrder < rightOrder) ||
195 ((leftOrder == rightOrder) && ((_Left.m_pRenderObject->GetPrimaryTechniqueHandle()) < (_Right.m_pRenderObject->GetPrimaryTechniqueHandle())));
207 int nLeftTech = _Left.m_pRenderObject->GetPrimaryTechniqueHandle();
208 int nRightTech = _Right.m_pRenderObject->GetPrimaryTechniqueHandle();
210 #ifdef DONOT_SORT_BY_ASSET 211 return ( (nLeftTech < nRightTech) ||
212 ((nLeftTech == nRightTech) && ((_Left.m_fObjectToCameraDistance) > (_Right.m_fObjectToCameraDistance))) );
214 AssetEntity* LeftAsset = _Left.m_pRenderObject->GetPrimaryAsset();
215 AssetEntity* RightAsset = _Right.m_pRenderObject->GetPrimaryAsset();
216 return ((nLeftTech < nRightTech) ||
217 ((nLeftTech == nRightTech) && (LeftAsset < RightAsset)) ||
218 ((nLeftTech == nRightTech) && (LeftAsset == RightAsset) && ((_Left.m_fObjectToCameraDistance) > (_Right.m_fObjectToCameraDistance))));
226 inline bool operator()(
231 return (_Left.m_fObjectToCameraDistance) > (_Right.m_fObjectToCameraDistance);
244 int nLeftTech = _Left->GetPrimaryTechniqueHandle();
245 int nRightTech = _Right->GetPrimaryTechniqueHandle();
246 return ((nLeftTech < nRightTech) ||
247 ((nLeftTech == nRightTech) && (_Left->GetPrimaryAsset()) < (_Right->GetPrimaryAsset())));
254 RenderState_Standard,
256 RenderState_Shadowmap,
258 RenderState_Overlay_ZPass,
260 RenderState_Overlay_Picking,
294 ATTRIBUTE_METHOD1(
SceneState, GetCurrentRenderPipeline_s,
int*) { *p1 = cls->GetCurrentRenderPipeline();
return S_OK; }
295 ATTRIBUTE_METHOD1(
SceneState, SetCurrentRenderPipeline_s,
int) { cls->SetCurrentRenderPipeline(p1);
return S_OK; }
297 ATTRIBUTE_METHOD1(
SceneState, GetRenderState_s,
int*) { *p1 = (int)cls->GetRenderState();
return S_OK; }
300 ATTRIBUTE_METHOD1(
SceneState, GetCameraToCurObjectDistance_s,
float*) { *p1 = cls->GetCameraToCurObjectDistance();
return S_OK; }
301 ATTRIBUTE_METHOD1(
SceneState, SetCameraToCurObjectDistance_s,
float) { cls->SetCameraToCurObjectDistance(p1);
return S_OK; }
303 ATTRIBUTE_METHOD1(
SceneState, GetGlobalTime_s,
int*) { *p1 = cls->GetGlobalTime();
return S_OK; }
304 ATTRIBUTE_METHOD1(
SceneState, SetGlobalTime_s,
int) { cls->SetGlobalTime(p1);
return S_OK; }
317 void SetCameraToCurObjectDistance(
float fDist);
320 float GetCameraToCurObjectDistance();
326 void SetShadowMapCameraToCurObjectDistance(
float fDist);
329 float GetShadowMapCameraToCurObjectDistance();;
335 void SetShadowPass(
bool bShadowPass);
347 void SetGlobalTime(
int nGlobalTime);
351 void SetIgnoreTransparent(
bool bIgnore);
363 void EnableLocalMaterial(
bool bEnable =
true);
366 bool HasLocalMaterial();
369 Vector3& GetCurrentLightStrength();
376 bool IsDeferredShading()
const;
379 void SetDeferredShading(
bool val);
385 int GetCurrentRenderPipeline()
const;
387 void SetCurrentRenderPipeline(
int val);
389 void AddToDeferredLightPool(
CLightObject * lightObject);
391 bool IsGlobalLODEnabled()
const;
392 void EnableGlobalLOD(
bool val);
395 IScene* GetScene(){
return m_pScene; }
413 bool m_bUseLocalMaterial : 1;
415 bool bIsBatchRender : 1;
416 bool m_bCameraMoved : 1;
417 bool m_bGlobalLOD : 1;
427 DWORD m_dwD3D_CULLMODE;
442 FLOAT fViewCullingRadius;
450 enum TOUCH_METHOD{ LButton, RButton, None }touchMethod;
457 stage_UserInputHandling = 1,
458 stage_EnvironmentSim = 2,
459 stage_AISimulator = 3,
460 stage_RootSceneAnimate = 4,
461 stage_RootGUIAnimate = 5,
464 stage_SetCamera = 101,
465 stage_AdvanceScene = 102,
466 stage_AdvanceGUI = 103
472 typedef std::vector<PostRenderObject> List_PostRenderObject_Type;
473 typedef std::vector<CSpriteObject*> List_CSpriteObjectPtr_Type;
475 typedef std::vector<AlphaPostRenderObject> List_AlphaPostRenderObject_Type;
476 typedef std::vector<PostRenderObjectWeakPtr> List_HeadOnRenderObject_Type;
477 typedef std::vector<CLightObject*> List_LightObject_Type;
512 #ifdef USE_DIRECTX_RENDERER 513 SceneState::List_CSpriteObjectPtr_Type listPRSprite;
520 SceneState::List_PostRenderObject_Type listShadowCasters;
521 SceneState::List_PostRenderObject_Type listShadowReceivers;
524 SceneState::List_HeadOnRenderObject_Type listHeadonDisplayObject;
530 SceneState::List_AlphaPostRenderObject_Type listPRMissiles;
533 SceneState::List_PostRenderObject_Type listZones;
534 SceneState::List_PostRenderObject_Type listPortals;
535 SceneState::List_PostRenderObject_Type listBoundingBox;
536 SceneState::List_PostRenderObject_Type listSelections;
537 SceneState::List_LightObject_Type listDeferredLightObjects;
546 bool m_bOuterWorldZoneVisible;
557 void SetMaxRenderCount(
int nRenderImportance,
int nCount);
560 bool CheckAddRenderCount(
int nRenderImportance);
566 typename T::value_type* FindObject(T& renderlist,
CBaseObject* pObject)
568 typename T::iterator itCur, itEnd = renderlist.end();
569 for (itCur = renderlist.begin(); itCur != itEnd; ++itCur)
571 if (itCur->m_pRenderObject == pObject)
583 void CleanupSceneState();
595 HRESULT InitDeviceObjects();
596 HRESULT RestoreDeviceObjects();
597 HRESULT InvalidateDeviceObjects();
598 HRESULT DeleteDeviceObjects();
608 float m_fCameraToObjectDistance;
612 float m_fShadowMapCameraToObjectDistance;
615 bool m_bIgnoreTransparent;
618 bool m_bIsShadowPass;
bool IsOccluded() const
return true if occluded
Definition: SceneState.h:81
this is an independent local light scene object.
Definition: LightObject.h:13
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
It's used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
ProcessingStage
At what stage is the scene currently being processed, ascending order.
Definition: SceneState.h:453
PostRenderObjectWeakPtr(CBaseObject *pRenderObject, float fObjectToCameraDistance, int nOccluded=0)
create a new post render object with the Object surface to camera distance.
Definition: SceneState.h:77
Vector3 vEye
projection transform of the current camera
Definition: SceneState.h:438
Definition: combase.h:159
Basic scene interface: implemented by the CSceneObject and CMiniScenegraph class. ...
Definition: IScene.h:12
different physics engine has different winding order.
Definition: EventBinding.h:32
int m_nOccluded
whether this object is occluded. default to 0, which means undetermined.
Definition: SceneState.h:74
increase the alpha value, if it is 1.0f, it will be removed from the list.
Definition: SceneState.h:118
SceneStateRenderState
which render state the current render pipeline is in.
Definition: SceneState.h:252
int m_nOccluded
whether this object is occluded. default to 0, which means undetermined.
Definition: SceneState.h:94
CSortedFaceGroups m_SortedFaceGroups
face groups.
Definition: SceneState.h:580
BillBoardViewInfo m_BillBoardInfo
camera look at position
Definition: SceneState.h:440
bool m_bEnableTranslucentFaceSorting
translucent face sorting is enabled.
Definition: SceneState.h:420
int GetRenderFrameCount()
get the current frame render number
Definition: SceneState.h:563
SceneState::List_PostRenderObject_TrackRef_Type listPostRenderingObjects
listPostRenderingObjects: this is the general post rendering list.
Definition: SceneState.h:511
Definition: SceneState.h:224
a very thin wrapper to DirectX device with a portable version of openGL implementation.
Definition: RenderDeviceDirectX.h:10
CParaWorldAsset * pAssetManager
pointer to the asset manager
Definition: SceneState.h:403
push a render state
Definition: SceneState.h:266
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
ALPHA_ANIM
alpha animation
Definition: SceneState.h:116
Definition: BaseCamera.h:70
Matrix4 mxProj
view transform of the current camera
Definition: SceneState.h:437
first sort from large to small by render importance and if render importance are same from near camer...
Definition: SceneState.h:185
decrease the alpha value, if it is 0.0f, it will be removed from the list.
Definition: SceneState.h:119
double dTimeDelta
time advance delta
Definition: SceneState.h:409
first sort from large to small by render importance and if render importance are same from near camer...
Definition: SceneState.h:169
SceneState::List_PostRenderObject_TrackRef_Type listPRTransparentBiped
list of Post Rendering object: biped
Definition: SceneState.h:516
IParaDebugDraw draw interface draws line based primitives for debugging purposes. ...
Definition: IBatchedElementDraw.h:12
vector< int > m_MaxRenderCount
m_MaxRenderCount[RenderImportance] is the max number of objects to be rendered of a given render impo...
Definition: SceneState.h:551
Vector3 m_curLightStrength
x is the sun light strength, y is local light strength.
Definition: SceneState.h:448
The particle class keeps a list of all of its instances.A particle system instance is always associat...
Definition: particle.h:99
RENDER_PIPELINE_ORDER
general render pipeline order.
Definition: SceneState.h:55
SceneState::List_AlphaPostRenderObject_Type listPRTransparentObject
transparent meshes (object) are usually rendered from back to front(far to near). ...
Definition: SceneState.h:529
bool IsIgnoreTransparent()
ignore all globally transparent and particle object
Definition: SceneState.h:350
DWORD m_nCurRenderGroup
bitwise fields of RENDER_GROUP
Definition: SceneState.h:470
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
It's used as parameter to Render method of each GUI object.
Definition: GUIState.h:16
Definition: RenderCore.h:50
for post rendering Object.
Definition: SceneState.h:87
for post rendering object with alpha.
Definition: SceneState.h:110
Vector3 vLookAt
camera position
Definition: SceneState.h:439
bool IsOccluded() const
return true if occluded
Definition: SceneState.h:104
Definition: effect_file.h:323
SceneState::List_PostRenderObject_TrackRef_Type listPRBiped
list of general post rendering object
Definition: SceneState.h:515
A common interface for all classes implementing IAttributeFields By implementing this class's virtual...
Definition: IAttributeFields.h:59
Definition: SceneState.h:200
ParaMaterial m_matGlobalMaterial
default material
Definition: SceneState.h:411
SceneState::List_PostRenderObject_Type listPRSolidObject
list of Post Rendering object: biped with alpha blending
Definition: SceneState.h:519
int m_nCurrentRenderPipeline
one of the enum RENDER_PIPELINE_ORDER
Definition: SceneState.h:406
vector< int > m_RenderCount
m_RenderCount[RenderImportance] is the max number of objects that has already been rendered of a give...
Definition: SceneState.h:554
IScene * m_pScene
rendering device pointer
Definition: SceneState.h:399
for post rendering Object.
Definition: SceneState.h:67
current billboard info is here.
Definition: BillBoardViewInfo.h:8
float fAlphaFactor
the frame number that this object is last accessed.
Definition: SceneState.h:426
Defines the base class of all scene elements:CBaseObject for Parallel World Engine.
Definition: BaseObject.h:230
the asset manager class in ParaEngine.
Definition: ParaWorldAsset.h:44
ALPHA_ANIM m_nAlphaAnimMethod
alpha animation method.
Definition: SceneState.h:122
int m_nOccluded
the default value of Occluded property when new objects are added to it.
Definition: SceneState.h:433
Same as IRefObject except that it tracks references of the object.
Definition: SceneState.h:481
Definition: SceneState.h:156
SceneState::List_AlphaPostRenderObject_Type listPRSmallObject
smaller objects are rendered after bigger objects are drawn for better occlusion.They are rendered fr...
Definition: SceneState.h:523
This class provides sorting and rendering of translucent face groups.
Definition: SortedFaceGroups.h:102
compare two post rendering object by its object to camera distance Type must be pointer to PostRender...
Definition: SceneState.h:132
int m_nRenderCount
how many times the scene has been rendered since its creation.
Definition: SceneState.h:422
GUIState * pGUIState
the GUI rendering state
Definition: SceneState.h:401
compare two object's primary asset
Definition: SceneState.h:237
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25
bool m_bDeferredShading
whether we are currently using deferred shading
Definition: SceneState.h:548
anything that makes references to other objects.
Definition: IRefObject.h:65