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 <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 VMAP
30{
31 class WorldModel;
32 struct AreaInfo;
33 struct LocationInfo;
34 enum class ModelIgnoreFlags : uint32;
35}
36
37class GameObject;
39
41{
42public:
43 virtual ~GameObjectModelOwnerBase() = default;
44
45 virtual bool IsSpawned() const = 0;
46 virtual uint32 GetDisplayId() const = 0;
47 virtual uint32 GetPhaseMask() const = 0;
48 virtual G3D::Vector3 GetPosition() const = 0;
49 virtual float GetOrientation() const = 0;
50 virtual float GetScale() const = 0;
51 virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const = 0;
52};
53
54class TC_COMMON_API GameObjectModel /*, public Intersectable*/
55{
56 GameObjectModel() : phasemask(0), iInvScale(0), iScale(0), iModel(nullptr), isWmo(false) { }
57public:
58 std::string name;
59
60 const G3D::AABox& getBounds() const { return iBound; }
61
63
64 const G3D::Vector3& getPosition() const { return iPos;}
65
67 void disable() { phasemask = 0;}
68 void enable(uint32 ph_mask) { phasemask = ph_mask;}
69
70 bool isEnabled() const {return phasemask != 0;}
71 bool isMapObject() const { return isWmo; }
72
73 bool intersectRay(const G3D::Ray& Ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask, VMAP::ModelIgnoreFlags ignoreFlags) const;
74 bool GetLocationInfo(G3D::Vector3 const& point, VMAP::LocationInfo& info, uint32 ph_mask) const;
75 bool GetLiquidLevel(G3D::Vector3 const& point, VMAP::LocationInfo& info, float& liqHeight) const;
76
77 static GameObjectModel* Create(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
78
79 bool UpdatePosition();
80
81private:
82 bool initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
83
85 G3D::AABox iBound;
86 G3D::Matrix3 iInvRot;
87 G3D::Vector3 iPos;
88 float iInvScale;
89 float iScale;
91 std::unique_ptr<GameObjectModelOwnerBase> owner;
92 bool isWmo;
93};
94
95TC_COMMON_API void LoadGameObjectModelList(std::string const& dataPath);
96
97#endif // _GAMEOBJECT_MODEL_H
#define TC_COMMON_API
Definition Define.h:96
uint32_t uint32
Definition Define.h:133
TC_COMMON_API void LoadGameObjectModelList(std::string const &dataPath)
virtual ~GameObjectModelOwnerBase()=default
virtual float GetOrientation() const =0
virtual uint32 GetPhaseMask() const =0
virtual G3D::Vector3 GetPosition() const =0
virtual float GetScale() const =0
virtual void DebugVisualizeCorner(G3D::Vector3 const &) const =0
virtual bool IsSpawned() const =0
virtual uint32 GetDisplayId() const =0
G3D::Vector3 iPos
bool isEnabled() const
const G3D::AABox & getBounds() const
const G3D::Vector3 & getPosition() const
G3D::Matrix3 iInvRot
VMAP::WorldModel * iModel
void enable(uint32 ph_mask)
bool isMapObject() const
std::unique_ptr< GameObjectModelOwnerBase > owner