TrinityCore
ModelInstance.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 _MODELINSTANCE_H_
19#define _MODELINSTANCE_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
28namespace VMAP
29{
30 class WorldModel;
31 struct AreaInfo;
32 struct LocationInfo;
33 enum class ModelIgnoreFlags : uint32;
34
36 {
37 MOD_HAS_BOUND = 1 << 0,
38 MOD_PARENT_SPAWN = 1 << 1
39 };
40
42 {
43 //Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi
47 G3D::Vector3 iPos;
48 float iScale;
49 G3D::AABox iBound;
50#ifdef VMAP_DEBUG
51 std::string name;
52#endif
53
54 bool operator==(ModelMinimalData const& other) const { return ID == other.ID; }
55 G3D::AABox const& getBounds() const { return iBound; }
56 };
57
59 {
60 G3D::Vector3 iRot;
61#ifndef VMAP_DEBUG
62 std::string name;
63#endif
64
65 static bool readFromFile(FILE* rf, ModelSpawn& spawn);
66 static bool writeToFile(FILE* rw, ModelSpawn const& spawn);
67 };
68
70 {
71 public:
72 ModelInstance() : iInvScale(0.0f), iModel(nullptr) { }
73 ModelInstance(ModelSpawn const& spawn, WorldModel* model);
74 void setUnloaded() { iModel = nullptr; }
75 bool intersectRay(G3D::Ray const& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const;
76 bool GetLocationInfo(G3D::Vector3 const& p, LocationInfo& info) const;
77 bool GetLiquidLevel(G3D::Vector3 const& p, LocationInfo& info, float& liqHeight) const;
78 G3D::Matrix3 const& GetInvRot() const { return iInvRot; }
79 WorldModel const* getWorldModel() const { return iModel; }
80 protected:
81 G3D::Matrix3 iInvRot;
82 float iInvScale;
84 };
85} // namespace VMAP
86
87#endif // _MODELINSTANCE
uint8_t uint8
Definition: Define.h:144
#define TC_COMMON_API
Definition: Define.h:99
uint32_t uint32
Definition: Define.h:142
G3D::Matrix3 const & GetInvRot() const
Definition: ModelInstance.h:78
WorldModel const * getWorldModel() const
Definition: ModelInstance.h:79
G3D::Matrix3 iInvRot
Definition: ModelInstance.h:81
WorldModel * iModel
Definition: ModelInstance.h:83
ModelInstanceFlags
Definition: ModelInstance.h:36
@ MOD_HAS_BOUND
Definition: ModelInstance.h:37
@ MOD_PARENT_SPAWN
Definition: ModelInstance.h:38
bool operator==(ModelMinimalData const &other) const
Definition: ModelInstance.h:54
G3D::AABox const & getBounds() const
Definition: ModelInstance.h:55
std::string name
Definition: ModelInstance.h:62
G3D::Vector3 iRot
Definition: ModelInstance.h:60