Cafu Engine
Ca3DEWorld.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_CA3DECOMMONWORLD_HPP_INCLUDED
8 #define CAFU_CA3DECOMMONWORLD_HPP_INCLUDED
9 
10 #include "Templates/Pointer.hpp"
11 #include "PhysicsWorld.hpp"
12 #include "../Common/World.hpp"
13 
14 
15 namespace cf { namespace ClipSys { class ClipWorldT; } }
16 namespace cf { namespace GameSys { class EntityT; } }
17 namespace cf { class UniScriptStateT; }
18 class EngineEntityT;
19 
20 
21 // Ca3DEWorldT implementiert die Eigenschaften, die eine CaServerWorld und eine CaClientWorld gemeinsam haben.
23 {
24  public:
25 
26  Ca3DEWorldT(const char* FileName, ModelManagerT& ModelMan, cf::GuiSys::GuiResourcesT& GuiRes, bool InitForGraphics, WorldT::ProgressFunctionT ProgressFunction) /*throw (WorldT::LoadErrorT)*/;
27  ~Ca3DEWorldT();
28 
29  const WorldT& GetWorld() const { return *m_World; }
30 
31  /// Returns a "good" ambient light color for an arbitrary object (i.e. a model) of size Dimensions at Origin.
32  /// The return value is derived from the worlds lightmap information "close" to the Dimensions at Origin.
33  Vector3fT GetAmbientLightColorFromBB(const BoundingBox3T<double>& Dimensions, const VectorT& Origin) const;
34 
35 
36  protected:
37 
38  /// Creates a new entity that is added to the m_EngineEntities array.
39  ///
40  /// - This is called in the constructor (and thus both on the client *and* the server, whenever a new world has
41  /// been loaded) with the parameters from the `.cw` world file.
42  /// - On the server, this method is also called if the Think() code auto-detects that an entity was newly created.
43  /// - Third, this is called by `ServerWorldT::InsertHumanPlayerEntity()` for creating human player entities for
44  /// newly joined clients or after a world-change for the existing clients.
45  void CreateNewEntityFromBasicInfo(IntrusivePtrT<cf::GameSys::EntityT> Ent, unsigned long CreationFrameNr);
46 
47  const WorldT* m_World;
48  cf::ClipSys::ClipWorldT* m_ClipWorld;
49  PhysicsWorldT m_PhysicsWorld;
50  cf::UniScriptStateT* m_ScriptState;
51  IntrusivePtrT<cf::GameSys::WorldT> m_ScriptWorld; ///< The "script world" contains the entity hierarchy and their components.
52  ArrayT<EngineEntityT*> m_EngineEntities;
53 
54 
55  private:
56 
57  Ca3DEWorldT(const Ca3DEWorldT&); ///< Use of the Copy Constructor is not allowed.
58  void operator = (const Ca3DEWorldT&); ///< Use of the Assignment Operator is not allowed.
59 };
60 
61 #endif
Definition: EngineEntity.hpp:20
Definition: PhysicsWorld.hpp:158
Definition: Ca3DEWorld.hpp:22
void CreateNewEntityFromBasicInfo(IntrusivePtrT< cf::GameSys::EntityT > Ent, unsigned long CreationFrameNr)
Creates a new entity that is added to the m_EngineEntities array.
Definition: Ca3DEWorld.cpp:241
Vector3fT GetAmbientLightColorFromBB(const BoundingBox3T< double > &Dimensions, const VectorT &Origin) const
Returns a "good" ambient light color for an arbitrary object (i.e.
Definition: Ca3DEWorld.cpp:174
IntrusivePtrT< cf::GameSys::WorldT > m_ScriptWorld
The "script world" contains the entity hierarchy and their components.
Definition: Ca3DEWorld.hpp:51
Definition: World.hpp:85
This class is used for managing model instances.
Definition: ModelManager.hpp:31
The clip world manages all the clip models that exist in a world (their "union"). ...
Definition: ClipWorld.hpp:27
This class represents the state of a script: the underlying Lua state, pending coroutines, metatables for C++ class hierarchies, etc.
Definition: UniScriptState.hpp:214
This class manages and provides resources (fonts and models) for GuiImplT instances.
Definition: GuiResources.hpp:26