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 <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_M2 = 1,
39 MOD_HAS_BOUND = 1<<2
40 };
41
43 {
44 public:
45 //mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name
49 G3D::Vector3 iPos;
50 G3D::Vector3 iRot;
51 float iScale;
52 G3D::AABox iBound;
53 std::string name;
54 bool operator==(ModelSpawn const& other) const { return ID == other.ID; }
55 //uint32 hashCode() const { return ID; }
56 // temp?
57 const G3D::AABox& getBounds() const { return iBound; }
58
59 static bool readFromFile(FILE* rf, ModelSpawn &spawn);
60 static bool writeToFile(FILE* rw, ModelSpawn const& spawn);
61 };
62
64 {
65 public:
66 ModelInstance(): iInvScale(0.0f), iModel(nullptr) { }
67 ModelInstance(ModelSpawn const& spawn, WorldModel* model);
68 void setUnloaded() { iModel = nullptr; }
69 bool intersectRay(G3D::Ray const& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const;
70 bool GetLocationInfo(G3D::Vector3 const& p, LocationInfo &info) const;
71 bool GetLiquidLevel(G3D::Vector3 const& p, LocationInfo &info, float &liqHeight) const;
72 WorldModel* getWorldModel() { return iModel; }
73 protected:
74 G3D::Matrix3 iInvRot;
75 float iInvScale;
77 };
78} // namespace VMAP
79
80#endif // _MODELINSTANCE
#define TC_COMMON_API
Definition Define.h:96
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
WorldModel * getWorldModel()
G3D::Matrix3 iInvRot
WorldModel * iModel
std::string name
G3D::Vector3 iRot
bool operator==(ModelSpawn const &other) const
G3D::Vector3 iPos
G3D::AABox iBound
const G3D::AABox & getBounds() const
@ MOD_WORLDSPAWN
@ MOD_HAS_BOUND