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 GroupModel;
32 class WorldModel;
33 struct LocationInfo;
34 enum class ModelIgnoreFlags : uint32;
35}
36
37class GameObject;
38class PhaseShift;
40
42{
43public:
49 virtual ~GameObjectModelOwnerBase() = default;
50
51 virtual bool IsSpawned() const = 0;
52 virtual uint32 GetDisplayId() const = 0;
53 virtual uint8 GetNameSetId() const = 0;
54 virtual bool IsInPhase(PhaseShift const& /*phaseShift*/) const = 0;
55 virtual G3D::Vector3 GetPosition() const = 0;
56 virtual G3D::Quat GetRotation() const = 0;
57 virtual int64 GetPackedRotation() const = 0;
58 virtual float GetScale() const = 0;
59 virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const = 0;
60};
61
62class TC_COMMON_API GameObjectModel /*, public Intersectable*/
63{
64 GameObjectModel() : iCollisionEnabled(false), iLosBlockingDisabled(false), iIncludeInNavMesh(false), iInvScale(0), iScale(0), iModel(nullptr) { }
65public:
66 const G3D::AABox& getBounds() const { return iBound; }
67
69
70 uint32 GetDisplayId() const { return owner->GetDisplayId(); }
71 G3D::Vector3 const& GetPosition() const { return iPos; }
72 G3D::Quat GetRotation() const { return owner->GetRotation(); }
73 G3D::Matrix3 const& GetInvRot() const { return iInvRot; }
74 int64 GetPackedRotation() const { return owner->GetPackedRotation(); }
75 float GetScale() const { return iScale; }
76
77 /* Enables/disables collision */
78 void EnableCollision(bool enable) { iCollisionEnabled = enable; }
79 bool IsCollisionEnabled() const { return iCollisionEnabled; }
80 void DisableLosBlocking(bool enable) { iLosBlockingDisabled = enable; }
81 bool IsLosBlockingDisabled() const { return iLosBlockingDisabled; }
82 void IncludeInNavMesh(bool enable) { iIncludeInNavMesh = enable; }
83 bool IsIncludedInNavMesh() const { return iIncludeInNavMesh; }
84 bool IsMapObject() const;
85 uint8 GetNameSetId() const { return owner->GetNameSetId(); }
86
87 bool IntersectRay(G3D::Ray const& ray, float& maxDist, bool stopAtFirstHit, PhaseShift const& phaseShift, VMAP::ModelIgnoreFlags ignoreFlags) const;
88 bool GetLocationInfo(G3D::Vector3 const& point, VMAP::LocationInfo& info, PhaseShift const& phaseShift) const;
89 bool GetLiquidLevel(G3D::Vector3 const& point, VMAP::GroupModel const* model, float& liqHeight) const;
90
91 static std::unique_ptr<GameObjectModel> Create(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
92
93 bool UpdatePosition();
94
95 std::shared_ptr<VMAP::WorldModel const> GetWorldModel() const { return iModel; }
96
97private:
98 bool initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
99
103 G3D::AABox iBound;
104 G3D::Matrix3 iInvRot;
105 G3D::Vector3 iPos;
107 float iScale;
108 std::shared_ptr<VMAP::WorldModel> iModel;
109 std::unique_ptr<GameObjectModelOwnerBase> owner;
110};
111
112TC_COMMON_API bool LoadGameObjectModelList(std::string const& dataPath);
113
114#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
GameObjectModelOwnerBase()=default
virtual ~GameObjectModelOwnerBase()=default
GameObjectModelOwnerBase & operator=(GameObjectModelOwnerBase const &other)=delete
GameObjectModelOwnerBase & operator=(GameObjectModelOwnerBase &&other) noexcept=delete
virtual G3D::Vector3 GetPosition() const =0
GameObjectModelOwnerBase(GameObjectModelOwnerBase const &other)=delete
virtual float GetScale() const =0
virtual void DebugVisualizeCorner(G3D::Vector3 const &) const =0
virtual uint8 GetNameSetId() const =0
GameObjectModelOwnerBase(GameObjectModelOwnerBase &&other) noexcept=delete
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