Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# deScene_priv.hpp

Go to the documentation of this file.

    00001 ///////////////////////////////////////////////////////////////////////////////
    00002 /// @file deScene_priv.hpp
    00003 ///
    00004 /// @brief private stuff for deScene
    00005 ///
    00006 /// @author Assassin
    00007 ///
    00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
    00009 /// contents of this file is subject to the Destiny3D Member License which
    00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
    00011 ///
    00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
    00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
    00014 /// for any particular purpose.
    00015 ///
    00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
    00017 ///
    00018 /// <hr>
    00019 ///                                 Change History
    00020 /// <hr>
    00021 ///
    00022 /// @date Mar 2002
    00023 /// @author Assassin
    00024 /// @remarks Creation
    00025 ///
    00026 /// @date Mar 2003
    00027 /// @author Masterg
    00028 /// @remarks Terrain addition
    00029 ///
    00030 ///////////////////////////////////////////////////////////////////////////////
    00031
    00032 #ifndef DESCENE_PRIV_HPP
    00033 #define DESCENE_PRIV_HPP
    00034
    00035 #include "deScene.hpp"
    00036 #include "deOctree.hpp"
    00037 #include "deFileSystem.hpp"
    00038 #include "deBST.hpp"
    00039 #include "dePolyABT.hpp"
    00040 #include "deWorld_Helper.hpp"
    00041 #include "deObjectTree.hpp"
    00042
    00043 #pragma warning (disable : 4512) // assignment operator could not be generated
    00044
    00045 deBoolean IdeSceneRoom_Initialize();
    00046 deBoolean IdeSceneObject_Initialize();
    00047
    00048 void IdeSceneRoom_ShutDown();
    00049 void IdeSceneObject_ShutDown();
    00050
    00051 extern IdeVertexBuffer * s_AABB_VB;
    00052 extern IdeVertexBuffer * s_OBB_VB;
    00053
    00054 //=============================================================
    00055 class deSceneGraph : public IdeSceneGraph
    00056 {
    00057 public:
    00058     deSceneGraph();
    00059     ~deSceneGraph();
    00060
    00061     long Traverse(deSceneTraversal* Params);
    00062     deBoolean   SetCullFlags(long CullFlags);
    00063     long        GetCullFlags();
    00064
    00065     deBoolean   SetDebugFlags(long DebugFlags);
    00066     long        GetDebugFlags();
    00067
    00068     IdeSceneRoom * FindRoomWithID(deWorldID WorldID, deObjectID ObjectID);
    00069     deBoolean AddRoom(IdeSceneRoom * Room);
    00070     deBoolean RemoveRoom(IdeSceneRoom* Room);
    00071     deBoolean AddSceneObject(IdeSceneObject* Object);
    00072     void RemoveSceneObject(IdeSceneObject* Object);
    00073     void RepositionSceneObject(IdeSceneObject* Object);
    00074
    00075     void AddObjectList(deTList <IdeSceneObject*> &list);    // this will destroy the list fed into it
    00076     deBoolean PointsOccluded(deVec3d points[], long num);
    00077     deBoolean PortalOccluded(IdePortal * portal);
    00078
    00079     DWORD     TestIntersection(const deVec3d &Position, const deVec3d *Mins, const deVec3d *Maxs);
    00080     deBoolean TestCollision(const IdeCollision::deCollideParams & Params, IdeCollision * Collision);
    00081     void ObjectExtents(IdeBoundingVolume* volume, IdeCollision * Results);
    00082     long LightExtents(const deVec3d& pos, const deAABB& bbox, IdeSceneLight** outBuffer, long bufferSize);
    00083
    00084 private:
    00085     void BuildSphereCullList(deTList <IdeSceneObject*> &list);
    00086     int DetailCullObjects(deDouble MinPixels);
    00087     int OcclusionSphereCullObjects();
    00088     void CleanUpSphereCullList();
    00089
    00090 private:
    00091     long m_CurrentPassNum;
    00092     long m_CullFlags;
    00093     long m_DebugFlags;
    00094     long m_MinPixelCull;
    00095     deTList <IdeSceneRoom*> m_Rooms;
    00096 //  deSceneOctree * m_Octree; REMOVED
    00097     // below items used on a per-pass basis
    00098     deTList <IdeSceneObject*> m_Objects;
    00099     deObjectTree m_ObjectTree;
    00100     deObjectTree m_LightTree;
    00101     struct cull_sphere_t
    00102     {
    00103     public:
    00104         deVec3d boundcenter, occludecenter;
    00105         deDouble boundradius, occluderadius;
    00106         deDouble zval;
    00107         IdeSceneObject * object;
    00108         void * listptr;
    00109         cull_sphere_t * next;
    00110     };
    00111     int m_NumOccluders;
    00112     cull_sphere_t *m_SphereCullFront, *m_SphereCullBack;
    00113     IdeCamera * m_CurrentCamera;
    00114     deVec3d m_CurrentCamFwd;
    00115 };
    00116
    00117 class deCollision : public IdeCollision
    00118 {
    00119 public:
    00120     deCollision();
    00121     ~deCollision();
    00122
    00123     long Release();
    00124
    00125     void        Reset();
    00126
    00127     long        GetNumCollisions();
    00128     void        GetCollision(long ColNum, deCollideInfo & collision);
    00129
    00130     deBoolean   AddCollision(const deCollideInfo & collision);
    00131
    00132 private:
    00133     deTArray <deCollideInfo> m_Collisions; // sorted by Percent
    00134 };
    00135
    00136
    00137 //=============================================================
    00138 class deSceneRoom : public deWorldObject, virtual public IdeSceneRoom
    00139 {
    00140 public:
    00141     deSceneRoom();
    00142     virtual ~deSceneRoom();
    00143
    00144     WorldObjectClassDef;
    00145     void* GetWOInterface(long interface_id);
    00146     deBoolean DeSerializeLoad();
    00147
    00148     void SetRoomListPtr(void * ptr);
    00149     void*GetRoomListPtr();
    00150
    00151     long Traverse(IdeSceneGraph::deSceneTraversal* Params);
    00152
    00153     deBoolean TestCollision(const IdeCollision::deCollideParams & Params, IdeCollision * Collision);
    00154
    00155     long GetPassNum();
    00156     void GetAABB(deVec3d &Min, deVec3d &Max);
    00157
    00158     void  SetContents(DWORD contents);
    00159     DWORD GetContents();
    00160
    00161     deBoolean AddSceneObject(IdeSceneObject * obj);
    00162     deBoolean AddPortal(IdePortal * portal);
    00163
    00164     deBoolean RemoveSceneObject(IdeSceneObject * obj);
    00165
    00166 protected:
    00167     int ViewCullObjectList(IdeCamera * c, const IdePlaneFrustum* f, deTList <IdeSceneObject*> &inout);
    00168
    00169     deTList <IdePortal*>        m_PortalList;
    00170     deTList <IdeSceneObject*>   m_Objects;
    00171     deVec3d                 m_Min, m_Max;
    00172     DWORD                   m_Contents;
    00173     void*                   m_RoomListPtr;
    00174
    00175 private:
    00176     virtual int TraverseRoom(IdeSceneGraph::deSceneTraversal* /*Params*/ ) { return 0; }
    00177     virtual deBoolean TestRoomCollision(const IdeCollision::deCollideParams & /*Params*/, IdeCollision * /*Collision*/) { return deFALSE; }
    00178     int m_CurrentPassNum;
    00179
    00180     deTArray<deIDPair> m_CachedObjects;
    00181 };
    00182
    00183 //=============================================================
    00184 class deSceneObject : public deWorldObject, virtual public IdeSceneObject
    00185 {
    00186 protected:
    00187     virtual long        TraverseForRender(IdeSceneGraph::deSceneTraversal* Params) = 0;
    00188
    00189 public:
    00190     deSceneObject(interface_t myType);
    00191     virtual ~deSceneObject();
    00192
    00193     IdeSceneObject::interface_t GetSOIType();
    00194     void* GetSOInterface(IdeSceneObject::interface_t i);
    00195     void* GetWOInterface(long interface_id);
    00196     deBoolean Serialize(IdeFile* FS);
    00197     deBoolean DeSerialize(IdeFile* FS, long DataLength, u32 &AmtRead);
    00198     deBoolean DeSerializeLoad();
    00199
    00200     void        PreCache(IdeDriver*) {}
    00201
    00202     long        Traverse(IdeSceneGraph::deSceneTraversal* Params);
    00203     void        SetActivation(activate_t a_type, deBoolean Active);
    00204     deBoolean   GetActivation(activate_t a_type) const;
    00205
    00206     void        SetWorldTransform(const deTransformInfo & mat);
    00207
    00208     deVec3d     GetBoundCenter();
    00209     deVec3d     GetOccludeCenter();
    00210     void        GetWorldTransform(deTransformInfo & mat);
    00211     void        GetWorldPos(deVec3d & PosVector);
    00212
    00213     deVec3d     GetWorldBoundCenter();
    00214     deVec3d     GetWorldOccludeCenter();
    00215     deDouble    GetBoundRadius();
    00216     deDouble    GetOccludeRadius();
    00217
    00218     void        GetLocalAABB(deAABB &bbox);
    00219     void        GetWorldOBB(deOBB &bbox);
    00220     void        GetWorldAABB(deAABB &bbox);
    00221
    00222     deBoolean   IsTransparent();
    00223
    00224     deBoolean   OccludesObject(deVec3d &position, IdeSceneObject *so, deVec3d &NormalizedDisplacement);
    00225
    00226     long        GetCurrentPassNum() const;
    00227     deBoolean   AddRoomReference(IdeSceneRoom * ref, void * ptr);
    00228     void*       GetRoomReference(IdeSceneRoom * ref);
    00229     deBoolean   RemoveRoomReference(IdeSceneRoom * ref);
    00230
    00231 protected:
    00232     void        SetBoundCenter(deVec3d);
    00233     void        SetOccludeCenter(deVec3d);
    00234     void        SetBoundRadius(deDouble);
    00235     void        SetOccludeRadius(deDouble);
    00236
    00237     void        SetWorldCenters();
    00238
    00239     void        SetLocalAABB(deVec3d min, deVec3d max);
    00240
    00241     deVec3d     CalcAverageCenter(deVec3d points[], long count);
    00242     deDouble    CalcBoundRadius(deVec3d points[], long count);
    00243     deDouble    CalcOccludeRadius(deVec3d points[], long count);
    00244     void        CalcLocalAABB(deVec3d points[], long count, deVec3d &min, deVec3d &max);
    00245
    00246     void        CalcAllValues(deVec3d points[], long count);
    00247
    00248     void        SetTransparent(deBoolean Transparent);
    00249
    00250     IdeLineBrush*   GetBoundLine();
    00251
    00252     const deTransformInfo & GetWorldTransform();
    00253
    00254 private:
    00255 protected:
    00256     deTransform m_WorldTransform;
    00257     deDouble    m_BoundRadius;
    00258     deDouble    m_OccludeRadius;
    00259     deVec3d     m_BoundCenter;
    00260     deVec3d     m_OccludeCenter;
    00261     deAABB      m_AABB;
    00262     deVec3d     m_WorldBound, m_WorldOcclude;
    00263     deBoolean   m_Transformed;
    00264     deBoolean   m_Transparent;
    00265     deBoolean   m_Active[activate_count];
    00266     long        m_CurrentPassNum;
    00267     const interface_t m_Interface;
    00268 private:
    00269     IdeLineBrush*   m_BoundLine;
    00270     struct RoomEntry
    00271     {
    00272         IdeSceneRoom* Room;
    00273         void * ptr;
    00274     };
    00275     deTArray<RoomEntry> m_RoomList;
    00276 };
    00277
    00278 //=============================================================
    00279 class deSceneABT : public deSceneObject, public IdeSceneABT
    00280 {
    00281 protected:
    00282     virtual ~deSceneABT();
    00283 public:
    00284     deSceneABT();
    00285
    00286     IdeSceneObject::interface_t GetSOIType();
    00287     void* GetSOInterface(IdeSceneObject::interface_t i);
    00288     WorldObjectClassDef;
    00289     deBoolean DeSerializeLoad();
    00290
    00291     deBoolean AddGeometry(IdeMesh* pMesh, const deTransformInfo & pos);
    00292
    00293 private:
    00294     long TraverseForRender(IdeSceneGraph::deSceneTraversal* Params);
    00295     deBoolean TestRoomCollision(const IdeCollision::deCollideParams & Params, IdeCollision * Collision);
    00296
    00297     dePolyABT m_ABT;
    00298     deBoolean m_Compiled;
    00299 };
    00300
    00301 //=============================================================
    00302 class deSceneTerrain : public deSceneObject, public IdeSceneTerrain
    00303 {
    00304 protected:
    00305     virtual ~deSceneTerrain();
    00306 public:
    00307     deSceneTerrain();
    00308
    00309     IdeSceneObject::interface_t GetSOIType();
    00310     void* GetSOInterface(IdeSceneObject::interface_t i);
    00311     WorldObjectClassDef;
    00312     deBoolean DeSerializeLoad();
    00313
    00314     void PreCache(IdeDriver* pDriver);
    00315
    00316     deBoolean SetTerrainHeightMap(IdeBitmapProxy * bmp);
    00317     deBoolean SetTerrainColorMap(IdeBitmapProxy * bmp);
    00318     deBoolean SetTerrainDetailMap(IdeBitmapProxy * bmp);
    00319
    00320     deVec3d GetTerrainScale();
    00321     void SetTerrainScale(deVec3d vScale);
    00322     void SetTerrainScale(deFloat x, deFloat y, deFloat z);
    00323
    00324     deTexCoord GetDetailRepeat();
    00325     void SetDetailRepeat(deTexCoord Repeat);
    00326     void SetDetailRepeat(deFloat u, deFloat v);
    00327
    00328     void SetHeightAt(unsigned char ucHeight, long x, long y);
    00329     unsigned char GetTrueHeightAt(long x, long y);
    00330     deFloat GetScaledHeightAt(long x, long y);
    00331
    00332     deDouble GetLODBias();
    00333     void SetLODBias(deDouble Bias);
    00334
    00335     deBoolean BuildRenderable();
    00336
    00337     // quadtree routines
    00338     long GetGMMChunkSize();
    00339     void SetGMMChunkSize(long ChunkSize);
    00340     deBoolean BuildGeoMipMap(IdeDriver* pDriver);
    00341
    00342 private:
    00343     long TraverseForRender(IdeSceneGraph::deSceneTraversal* Params);
    00344     deBoolean TestRoomCollision(const IdeCollision::deCollideParams & Params, IdeCollision * Collision);
    00345
    00346     struct deTerrainGMMChunk
    00347     {
    00348         deAABB              BBox;
    00349         deVec3d             ChunkCenterPos;
    00350         deDouble            Diagonal;
    00351         deDouble            UnitError[8];
    00352         IdeVertexBuffer*    Vertices;
    00353         long                XCoord;
    00354         long                ZCoord;
    00355         char                CurrentLOD;
    00356     };
    00357     struct deTerrainGMMQuadrant
    00358     {
    00359         deBoundSphere           BSphere;
    00360         deAABB                  BBox;
    00361         deTerrainGMMQuadrant*   Children[4];
    00362         deTerrainGMMChunk*      Geometry;
    00363     };
    00364
    00365 //  deTransform         m_WorldTransform;
    00366     deVec3d             m_Scale;
    00367     deTexCoord          m_DetailRepeat;
    00368
    00369     IdeBitmapProxy*     m_HeightMap;
    00370     IdeBitmapProxy*     m_ColorMap;
    00371     IdeBitmapProxy*     m_DetailMap;
    00372
    00373     IdeRenderTexture*   m_RenderTexture;
    00374
    00375     deTArray<IdeVertexBuffer*>  m_VBuffers;
    00376     deTArray<IdeVertexBuffer*>  m_IndexBuffers;
    00377
    00378     // quadtree related variables
    00379     deTerrainGMMChunk*      m_GMMChunks;
    00380     deTerrainGMMQuadrant*   m_GMMRoot;
    00381     long m_GMMChunkSize;
    00382     long m_GMMChunksXSide;
    00383     long m_GMMChunksZSide;
    00384     deDouble m_LODBias;
    00385
    00386     // texture stuff
    00387     deBoolean CreateTerrainTexture(IdeDriver * pDriver);
    00388
    00389     // quadtree related private routines
    00390     int GetGMMChunkNumber(long x, long z);
    00391     void ResetGMMChunks();
    00392     deBoolean BuildGMMQuadtree();
    00393     deBoolean BuildGMMQuadrant(deTerrainGMMQuadrant* Parent, long StartX, long StartZ, long StopX, long StopZ);
    00394     void DestroyGMMQuadrant(deTerrainGMMQuadrant* &Quadrant);
    00395
    00396     // individual node routines
    00397     deBoolean RenderGMMChunk(const deTerrainGMMChunk* Chunk, IdeSceneGraph::deSceneTraversal* Params, const deTransform& WorldTransform);
    00398     deBoolean BuildGMMChunk(long x, long z, IdeDriver* pDriver);
    00399     void DestroyGMMChunk(deTerrainGMMChunk* Chunk);
    00400
    00401     // entire collection of node, qtree routines
    00402     deBoolean RenderVisibleGMMChunks(deTerrainGMMQuadrant* Quadrant, IdeSceneGraph::deSceneTraversal* Params, const deTransform& WorldTransform, deBoolean AllVisible);
    00403 };
    00404
    00405 //=============================================================
    00406 class deSceneSky : public deSceneObject, public IdeSceneSky
    00407 {
    00408 protected:
    00409     virtual ~deSceneSky();
    00410 public:
    00411     deSceneSky();
    00412
    00413     IdeSceneObject::interface_t GetSOIType();
    00414     void* GetSOInterface(IdeSceneObject::interface_t i);
    00415     WorldObjectClassDef;
    00416     deBoolean DeSerializeLoad();
    00417     void OnWorldIDSet();
    00418
    00419     deBoolean   IsLockedToCam() const;
    00420     void        LockToCam(deBoolean Lock);
    00421     deBoolean   GetInfo(SkyInfo * info) const;
    00422     deBoolean   SetInfo(const SkyInfo * info);
    00423
    00424 private:
    00425     long TraverseForRender(IdeSceneGraph::deSceneTraversal* Params);
    00426     deBoolean TestRoomCollision(const IdeCollision::deCollideParams & Params, IdeCollision * Collision);
    00427
    00428     deBoolean CreateVBuffers();
    00429     deBoolean CreateTextures();
    00430
    00431     static long                 s_NumSkyRooms;
    00432     static IdeVertexBuffer*     s_VBuffer;
    00433     static IdeVertexBuffer*     s_SubVBs[6];
    00434     IdeRenderTexture*           m_Textures[6];
    00435     IdeSceneSky::SkyInfo        m_Info;
    00436     deBoolean                   m_LockedToCam;
    00437 };
    00438
    00439 //=============================================================
    00440 class deSceneAnimatedMesh : public deSceneObject, public IdeSceneAnimatedMesh
    00441 {
    00442 public:
    00443     deSceneAnimatedMesh();
    00444     virtual ~deSceneAnimatedMesh();
    00445
    00446     IdeSceneObject::interface_t GetSOIType();
    00447     void* GetSOInterface(IdeSceneObject::interface_t i);
    00448     WorldObjectClassDef;
    00449
    00450     long TraverseForRender(IdeSceneGraph::deSceneTraversal* Params);
    00451     void SetMesh(IdeAnimatedMesh * mesh);
    00452
    00453 private:
    00454     IdeAnimatedMesh * pMyMesh;
    00455 };
    00456
    00457 //=============================================================
    00458 class deSceneStaticMesh : public deSceneObject, public IdeSceneStaticMesh
    00459 {
    00460 public:
    00461     deSceneStaticMesh();
    00462     virtual ~deSceneStaticMesh();
    00463
    00464     IdeSceneObject::interface_t GetSOIType();
    00465     void* GetSOInterface(IdeSceneObject::interface_t i);
    00466     WorldObjectClassDef;
    00467     deBoolean DeSerializeLoad();
    00468
    00469     long TraverseForRender(IdeSceneGraph::deSceneTraversal* Params);
    00470     void SetMesh(IdeMesh* mesh);
    00471     void SetTransparent(deBoolean Trans);
    00472
    00473 private:
    00474     IdeMesh * mMesh;
    00475     deIDPair mMeshID;
    00476 };
    00477
    00478 //=============================================================
    00479 class deSceneActor : public deSceneObject, public IdeSceneActor
    00480 {
    00481 public:
    00482     deSceneActor();
    00483     virtual ~deSceneActor();
    00484
    00485     IdeSceneObject::interface_t GetSOIType();
    00486     void* GetSOInterface(IdeSceneObject::interface_t i);
    00487     WorldObjectClassDef;
    00488
    00489     long TraverseForRender(IdeSceneGraph::deSceneTraversal* Params);
    00490     void SetActor(IdeActor* actor);
    00491
    00492 private:
    00493     IdeActor * mActor;
    00494 };
    00495
    00496 //=============================================================
    00497 class deSceneLight : public deSceneObject, public IdeSceneLight
    00498 {
    00499 public:
    00500     deSceneLight();
    00501     virtual ~deSceneLight();
    00502
    00503     IdeSceneObject::interface_t GetSOIType();
    00504     void* GetSOInterface(IdeSceneObject::interface_t i);
    00505     WorldObjectClassDef;
    00506
    00507     void SetWorldTransform(const deTransformInfo& mat);
    00508
    00509     long TraverseForRender(IdeSceneGraph::deSceneTraversal* Params);
    00510     void SetLightData(const IdeRenderLight::LightData& lightdata);
    00511     const IdeRenderLight::LightData* GetLightData();
    00512     const IdeRenderLight* GetRenderLight();
    00513
    00514 private:
    00515     IdeRenderLight* m_RenderLight;
    00516 };
    00517
    00518 #endif