TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GameObjectModel.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _GAMEOBJECT_MODEL_H
20 #define _GAMEOBJECT_MODEL_H
21 
22 #include <G3D/Matrix3.h>
23 #include <G3D/Vector3.h>
24 #include <G3D/AABox.h>
25 #include <G3D/Ray.h>
26 
27 #include "Define.h"
28 #include <memory>
29 
30 namespace VMAP
31 {
32  class WorldModel;
33 }
34 
35 class GameObject;
37 
39 {
40 public:
41  virtual bool IsSpawned() const { return false; }
42  virtual uint32 GetDisplayId() const { return 0; }
43  virtual uint32 GetPhaseMask() const { return 0; }
44  virtual G3D::Vector3 GetPosition() const { return G3D::Vector3::zero(); }
45  virtual float GetOrientation() const { return 0.0f; }
46  virtual float GetScale() const { return 1.0f; }
47  virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const { }
48 };
49 
50 class TC_COMMON_API GameObjectModel /*, public Intersectable*/
51 {
52  GameObjectModel() : phasemask(0), iInvScale(0), iScale(0), iModel(NULL) { }
53 public:
54  std::string name;
55 
56  const G3D::AABox& getBounds() const { return iBound; }
57 
58  ~GameObjectModel();
59 
60  const G3D::Vector3& getPosition() const { return iPos;}
61 
63  void disable() { phasemask = 0;}
64  void enable(uint32 ph_mask) { phasemask = ph_mask;}
65 
66  bool isEnabled() const {return phasemask != 0;}
67 
68  bool intersectRay(const G3D::Ray& Ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const;
69 
70  static GameObjectModel* Create(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
71 
72  bool UpdatePosition();
73 
74 private:
75  bool initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
76 
81  float iInvScale;
82  float iScale;
84  std::unique_ptr<GameObjectModelOwnerBase> owner;
85 };
86 
87 TC_COMMON_API void LoadGameObjectModelList(std::string const& dataPath);
88 
89 #endif // _GAMEOBJECT_MODEL_H
G3D::Matrix3 iInvRot
Definition: GameObjectModel.h:79
TC_COMMON_API void LoadGameObjectModelList(std::string const &dataPath)
Definition: GameObjectModel.cpp:43
uint32 phasemask
Definition: GameObjectModel.h:77
virtual bool IsSpawned() const
Definition: GameObjectModel.h:41
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: GameObjectModel.h:38
virtual float GetScale() const
Definition: GameObjectModel.h:46
Definition: IVMapManager.h:31
virtual uint32 GetPhaseMask() const
Definition: GameObjectModel.h:43
Definition: Vector3.h:58
const G3D::Vector3 & getPosition() const
Definition: GameObjectModel.h:60
G3D::AABox iBound
Definition: GameObjectModel.h:78
virtual float GetOrientation() const
Definition: GameObjectModel.h:45
virtual uint32 GetDisplayId() const
Definition: GameObjectModel.h:42
static const Vector3 & zero()
Definition: Vector3.cpp:119
void disable()
Definition: GameObjectModel.h:63
bool isEnabled() const
Definition: GameObjectModel.h:66
VMAP::WorldModel * iModel
Definition: GameObjectModel.h:83
Definition: WorldModel.h:106
void enable(uint32 ph_mask)
Definition: GameObjectModel.h:64
virtual G3D::Vector3 GetPosition() const
Definition: GameObjectModel.h:44
GameObjectModel()
Definition: GameObjectModel.h:52
Definition: DBCStructure.h:487
uint32_t uint32
Definition: Define.h:150
std::unique_ptr< GameObjectModelOwnerBase > owner
Definition: GameObjectModel.h:84
const G3D::AABox & getBounds() const
Definition: GameObjectModel.h:56
Definition: GameObject.h:880
Definition: Ray.h:24
Definition: AABox.h:32
#define TC_COMMON_API
Definition: Define.h:116
Definition: Matrix3.h:37
G3D::Vector3 iPos
Definition: GameObjectModel.h:80
Definition: GameObjectModel.h:50
float iScale
Definition: GameObjectModel.h:82
virtual void DebugVisualizeCorner(G3D::Vector3 const &) const
Definition: GameObjectModel.h:47
float iInvScale
Definition: GameObjectModel.h:81
std::string name
Definition: GameObjectModel.h:54