Updated Copyright year to 2013
[getmangos.git] / src / game / vmap / TileAssembler.h
blob8e3ce04365c48b710461ea2fc30c855d107b59bb
1 /*
2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef _TILEASSEMBLER_H_
20 #define _TILEASSEMBLER_H_
22 #include <G3D/Vector3.h>
23 #include <G3D/Matrix3.h>
24 #include <map>
26 #include "ModelInstance.h"
28 namespace VMAP
30 /**
31 This Class is used to convert raw vector data into balanced BSP-Trees.
32 To start the conversion call convertWorld().
34 //===============================================
36 class ModelPosition
38 private:
39 G3D::Matrix3 iRotation;
40 public:
41 G3D::Vector3 iPos;
42 G3D::Vector3 iDir;
43 float iScale;
44 void init()
46 iRotation = G3D::Matrix3::fromEulerAnglesZYX(G3D::pi() * iDir.y / 180.f, G3D::pi() * iDir.x / 180.f, G3D::pi() * iDir.z / 180.f);
48 G3D::Vector3 transform(const G3D::Vector3& pIn) const;
49 void moveToBasePos(const G3D::Vector3& pBasePos) { iPos -= pBasePos; }
52 typedef std::map<uint32, ModelSpawn> UniqueEntryMap;
53 typedef std::multimap<uint32, uint32> TileMap;
55 struct MapSpawns
57 UniqueEntryMap UniqueEntries;
58 TileMap TileEntries;
61 typedef std::map<uint32, MapSpawns*> MapData;
62 //===============================================
64 class TileAssembler
66 private:
67 std::string iDestDir;
68 std::string iSrcDir;
69 bool (*iFilterMethod)(char* pName);
70 G3D::Table<std::string, unsigned int > iUniqueNameIds;
71 unsigned int iCurrentUniqueNameId;
72 MapData mapData;
74 public:
75 TileAssembler(const std::string& pSrcDirName, const std::string& pDestDirName);
76 virtual ~TileAssembler();
78 bool convertWorld2();
79 bool readMapSpawns();
80 bool calculateTransformedBound(ModelSpawn& spawn);
82 bool convertRawFile(const std::string& pModelFilename);
83 void setModelNameFilterMethod(bool (*pFilterMethod)(char* pName)) { iFilterMethod = pFilterMethod; }
84 std::string getDirEntryNameFromModName(unsigned int pMapId, const std::string& pModPosName);
85 unsigned int getUniqueNameId(const std::string pName);
88 } // VMAP
89 #endif /*_TILEASSEMBLER_H_*/