TrinityCore
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 <G3D/Matrix3.h>
22#include <G3D/Vector3.h>
23#include <G3D/AABox.h>
24#include <G3D/Ray.h>
25
26#include "Define.h"
27#include <memory>
28
29namespace G3D
30{
31class Quat;
32}
33
34namespace VMAP
35{
36 class WorldModel;
37 struct AreaInfo;
38 struct LocationInfo;
39 enum class ModelIgnoreFlags : uint32;
40}
41
42class GameObject;
43class PhaseShift;
45
47{
48public:
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 float GetScale() const = 0;
58 virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const = 0;
59};
60
61class TC_COMMON_API GameObjectModel /*, public Intersectable*/
62{
63 GameObjectModel() : _collisionEnabled(false), iInvScale(0), iScale(0), iModel(nullptr) { }
64public:
65 const G3D::AABox& getBounds() const { return iBound; }
66
68
69 const G3D::Vector3& getPosition() const { return iPos;}
70
71 /* Enables/disables collision */
72 void enableCollision(bool enable) { _collisionEnabled = enable; }
73 bool isCollisionEnabled() const { return _collisionEnabled; }
74 bool isMapObject() const;
75 uint8 GetNameSetId() const { return owner->GetNameSetId(); }
76
77 bool intersectRay(G3D::Ray const& ray, float& maxDist, bool stopAtFirstHit, PhaseShift const& phaseShift, VMAP::ModelIgnoreFlags ignoreFlags) const;
78 bool GetLocationInfo(G3D::Vector3 const& point, VMAP::LocationInfo& info, PhaseShift const& phaseShift) const;
79 bool GetLiquidLevel(G3D::Vector3 const& point, VMAP::LocationInfo& info, float& liqHeight) const;
80
81 static GameObjectModel* Create(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
82
83 bool UpdatePosition();
84
85private:
86 bool initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
87
89 G3D::AABox iBound;
90 G3D::Matrix3 iInvRot;
91 G3D::Vector3 iPos;
92 float iInvScale;
93 float iScale;
95 std::unique_ptr<GameObjectModelOwnerBase> owner;
96};
97
98TC_COMMON_API bool LoadGameObjectModelList(std::string const& dataPath);
99
100#endif // _GAMEOBJECT_MODEL_H
uint8_t uint8
Definition: Define.h:144
#define TC_COMMON_API
Definition: Define.h:99
uint32_t uint32
Definition: Define.h:142
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
uint8 GetNameSetId() const
G3D::Vector3 iPos
const G3D::AABox & getBounds() const
const G3D::Vector3 & getPosition() const
G3D::Matrix3 iInvRot
VMAP::WorldModel * iModel
G3D::AABox iBound
void enableCollision(bool enable)
bool isCollisionEnabled() const
std::unique_ptr< GameObjectModelOwnerBase > owner
std::unique_ptr< VignetteData > Create(VignetteEntry const *vignetteData, WorldObject const *owner)
Definition: Vignette.cpp:72