TrinityCore
Loading...
Searching...
No Matches
GameObjectModel.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _GAMEOBJECT_MODEL_H
19#define _GAMEOBJECT_MODEL_H
20
21#include "Define.h"
22#include <G3D/AABox.h>
23#include <G3D/Matrix3.h>
24#include <G3D/Quat.h>
25#include <G3D/Ray.h>
26#include <G3D/Vector3.h>
27#include <memory>
28
29namespace VMAP
30{
31 class WorldModel;
32 struct AreaInfo;
33 struct LocationInfo;
34 enum class ModelIgnoreFlags : uint32;
35}
36
37class GameObject;
38class PhaseShift;
40
42{
43public:
44 virtual ~GameObjectModelOwnerBase() = default;
45
46 virtual bool IsSpawned() const = 0;
47 virtual uint32 GetDisplayId() const = 0;
48 virtual uint8 GetNameSetId() const = 0;
49 virtual bool IsInPhase(PhaseShift const& /*phaseShift*/) const = 0;
50 virtual G3D::Vector3 GetPosition() const = 0;
51 virtual G3D::Quat GetRotation() const = 0;
52 virtual int64 GetPackedRotation() const = 0;
53 virtual float GetScale() const = 0;
54 virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const = 0;
55};
56
57class TC_COMMON_API GameObjectModel /*, public Intersectable*/
58{
59 GameObjectModel() : iCollisionEnabled(false), iLosBlockingDisabled(false), iIncludeInNavMesh(false), iInvScale(0), iScale(0), iModel(nullptr) { }
60public:
61 const G3D::AABox& getBounds() const { return iBound; }
62
64
65 uint32 GetDisplayId() const { return owner->GetDisplayId(); }
66 G3D::Vector3 const& GetPosition() const { return iPos; }
67 G3D::Quat GetRotation() const { return owner->GetRotation(); }
68 G3D::Matrix3 const& GetInvRot() const { return iInvRot; }
69 int64 GetPackedRotation() const { return owner->GetPackedRotation(); }
70 float GetScale() const { return iScale; }
71
72 /* Enables/disables collision */
73 void EnableCollision(bool enable) { iCollisionEnabled = enable; }
74 bool IsCollisionEnabled() const { return iCollisionEnabled; }
75 void DisableLosBlocking(bool enable) { iLosBlockingDisabled = enable; }
76 bool IsLosBlockingDisabled() const { return iLosBlockingDisabled; }
77 void IncludeInNavMesh(bool enable) { iIncludeInNavMesh = enable; }
78 bool IsIncludedInNavMesh() const { return iIncludeInNavMesh; }
79 bool IsMapObject() const;
80 uint8 GetNameSetId() const { return owner->GetNameSetId(); }
81
82 bool IntersectRay(G3D::Ray const& ray, float& maxDist, bool stopAtFirstHit, PhaseShift const& phaseShift, VMAP::ModelIgnoreFlags ignoreFlags) const;
83 bool GetLocationInfo(G3D::Vector3 const& point, VMAP::LocationInfo& info, PhaseShift const& phaseShift) const;
84 bool GetLiquidLevel(G3D::Vector3 const& point, VMAP::LocationInfo& info, float& liqHeight) const;
85
86 static std::unique_ptr<GameObjectModel> Create(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
87
88 bool UpdatePosition();
89
90 std::shared_ptr<VMAP::WorldModel const> GetWorldModel() const { return iModel; }
91
92private:
93 bool initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
94
98 G3D::AABox iBound;
99 G3D::Matrix3 iInvRot;
100 G3D::Vector3 iPos;
102 float iScale;
103 std::shared_ptr<VMAP::WorldModel> iModel;
104 std::unique_ptr<GameObjectModelOwnerBase> owner;
105};
106
107TC_COMMON_API bool LoadGameObjectModelList(std::string const& dataPath);
108
109#endif // _GAMEOBJECT_MODEL_H
uint8_t uint8
Definition Define.h:156
int64_t int64
Definition Define.h:149
#define TC_COMMON_API
Definition Define.h:99
uint32_t uint32
Definition Define.h:154
TC_COMMON_API bool LoadGameObjectModelList(std::string const &dataPath)
virtual G3D::Quat GetRotation() const =0
virtual bool IsInPhase(PhaseShift const &) const =0
virtual ~GameObjectModelOwnerBase()=default
virtual G3D::Vector3 GetPosition() const =0
virtual float GetScale() const =0
virtual void DebugVisualizeCorner(G3D::Vector3 const &) const =0
virtual uint8 GetNameSetId() const =0
virtual bool IsSpawned() const =0
virtual uint32 GetDisplayId() const =0
virtual int64 GetPackedRotation() const =0
uint8 GetNameSetId() const
void IncludeInNavMesh(bool enable)
int64 GetPackedRotation() const
bool iCollisionEnabled
Is model ignored in all checks.
void DisableLosBlocking(bool enable)
float GetScale() const
bool iIncludeInNavMesh
Is model included when generating navigation mesh.
G3D::Vector3 iPos
std::shared_ptr< VMAP::WorldModel > iModel
uint32 GetDisplayId() const
const G3D::AABox & getBounds() const
bool IsCollisionEnabled() const
G3D::Matrix3 iInvRot
G3D::Vector3 const & GetPosition() const
std::shared_ptr< VMAP::WorldModel const > GetWorldModel() const
G3D::Quat GetRotation() const
bool IsIncludedInNavMesh() const
void EnableCollision(bool enable)
G3D::Matrix3 const & GetInvRot() const
bool IsLosBlockingDisabled() const
bool iLosBlockingDisabled
Is model ignored during line of sight checks (but is always included in location/height checks)
std::unique_ptr< GameObjectModelOwnerBase > owner