TrinityCore
Loading...
Searching...
No Matches
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 "Define.h"
22#include <memory>
23#include <G3D/AABox.h>
24#include <G3D/Matrix3.h>
25#include <G3D/Ray.h>
26#include <G3D/Vector3.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,
39 MOD_PATH_ONLY = 1 << 2
40 };
41
43 {
44 //Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi
48 G3D::Vector3 iPos;
49 float iScale;
50 G3D::AABox iBound;
51#ifdef VMAP_DEBUG
52 std::string name;
53#endif
54
55 bool operator==(ModelMinimalData const& other) const { return ID == other.ID; }
56 G3D::AABox const& getBounds() const { return iBound; }
57 };
58
60 {
61 G3D::Vector3 iRot;
62#ifndef VMAP_DEBUG
63 std::string name;
64#endif
65
66 static bool readFromFile(FILE* rf, ModelSpawn& spawn);
67 static bool writeToFile(FILE* rw, ModelSpawn const& spawn);
68 };
69
71 {
72 public:
73 ModelInstance() : iInvScale(0.0f), iModel(nullptr), referencingTiles(0) { }
74 ModelInstance(ModelSpawn const& spawn, std::shared_ptr<WorldModel> model);
75 void setUnloaded() { iModel = nullptr; }
76 bool intersectRay(G3D::Ray const& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const;
77 bool GetLocationInfo(G3D::Vector3 const& p, LocationInfo& info) const;
78 bool GetLiquidLevel(G3D::Vector3 const& p, LocationInfo& info, float& liqHeight) const;
79 G3D::Matrix3 const& GetInvRot() const { return iInvRot; }
80 WorldModel const* getWorldModel() const { return iModel.get(); }
81 void AddTileReference() { ++referencingTiles; }
82 uint32 RemoveTileReference() { return --referencingTiles; }
83 protected:
84 G3D::Matrix3 iInvRot;
85 float iInvScale;
86 std::shared_ptr<WorldModel> iModel;
88 };
89} // namespace VMAP
90
91#endif // _MODELINSTANCE
uint8_t uint8
Definition Define.h:156
#define TC_COMMON_API
Definition Define.h:99
uint32_t uint32
Definition Define.h:154
G3D::Matrix3 const & GetInvRot() const
std::shared_ptr< WorldModel > iModel
WorldModel const * getWorldModel() const
uint32 RemoveTileReference()
G3D::Matrix3 iInvRot
ModelInstanceFlags
@ MOD_PATH_ONLY
@ MOD_HAS_BOUND
@ MOD_PARENT_SPAWN
bool operator==(ModelMinimalData const &other) const
G3D::AABox const & getBounds() const
std::string name
G3D::Vector3 iRot