TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ModelInstance.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _MODELINSTANCE_H_
20 #define _MODELINSTANCE_H_
21 
22 #include <G3D/Matrix3.h>
23 #include <G3D/Vector3.h>
24 #include <G3D/AABox.h>
25 #include <G3D/Ray.h>
26 
27 #include "Define.h"
28 
29 namespace VMAP
30 {
31  class WorldModel;
32  struct AreaInfo;
33  struct LocationInfo;
34 
36  {
37  MOD_M2 = 1,
40  };
41 
43  {
44  public:
45  //mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name
51  float iScale;
53  std::string name;
54  bool operator==(const ModelSpawn &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, const ModelSpawn &spawn);
61  };
62 
64  {
65  public:
66  ModelInstance(): iInvScale(0.0f), iModel(nullptr) { }
67  ModelInstance(const ModelSpawn &spawn, WorldModel* model);
68  void setUnloaded() { iModel = nullptr; }
69  bool intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const;
70  void intersectPoint(const G3D::Vector3& p, AreaInfo &info) const;
71  bool GetLocationInfo(const G3D::Vector3& p, LocationInfo &info) const;
72  bool GetLiquidLevel(const G3D::Vector3& p, LocationInfo &info, float &liqHeight) const;
73  WorldModel* getWorldModel() { return iModel; }
74  protected:
76  float iInvScale;
78  };
79 } // namespace VMAP
80 
81 #endif // _MODELINSTANCE
G3D::Vector3 iPos
Definition: ModelInstance.h:49
WorldModel * getWorldModel()
Definition: ModelInstance.h:73
ModelInstance()
Definition: ModelInstance.h:66
Definition: ModelInstance.h:38
Definition: MapTree.h:32
float iInvScale
Definition: ModelInstance.h:76
const G3D::AABox & getBounds() const
Definition: ModelInstance.h:57
Definition: IVMapManager.h:31
float iScale
Definition: ModelInstance.h:51
void setUnloaded()
Definition: ModelInstance.h:68
Definition: Vector3.h:58
Definition: ModelInstance.h:37
bool operator==(const ModelSpawn &other) const
Definition: ModelInstance.h:54
ModelFlags
Definition: ModelInstance.h:35
Definition: MapTree.h:90
G3D::AABox iBound
Definition: ModelInstance.h:52
Definition: WorldModel.h:106
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: Ray.h:24
uint32 ID
Definition: ModelInstance.h:48
Definition: ModelInstance.h:39
Definition: AABox.h:32
#define TC_COMMON_API
Definition: Define.h:116
Definition: Matrix3.h:37
WorldModel * iModel
Definition: ModelInstance.h:77
Definition: ModelInstance.h:42
uint32 flags
Definition: ModelInstance.h:46
std::string name
Definition: ModelInstance.h:53
uint16 adtId
Definition: ModelInstance.h:47
G3D::Vector3 iRot
Definition: ModelInstance.h:50
G3D::Matrix3 iInvRot
Definition: ModelInstance.h:75
Definition: ModelInstance.h:63