1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _TILEASSEMBLER_H_ |
---|
22 | #define _TILEASSEMBLER_H_ |
---|
23 | |
---|
24 | // load our modified version first !! |
---|
25 | #include "AABSPTree.h" |
---|
26 | |
---|
27 | #include <G3D/Vector3.h> |
---|
28 | |
---|
29 | #include "CoordModelMapping.h" |
---|
30 | #include "SubModel.h" |
---|
31 | #include "ModelContainer.h" |
---|
32 | |
---|
33 | namespace VMAP |
---|
34 | { |
---|
35 | /** |
---|
36 | This Class is used to convert raw vector data into balanced BSP-Trees. |
---|
37 | To start the conversion call convertWorld(). |
---|
38 | */ |
---|
39 | //=============================================== |
---|
40 | |
---|
41 | class ModelPosition |
---|
42 | { |
---|
43 | private: |
---|
44 | G3D::Matrix3 ixMatrix; |
---|
45 | G3D::Matrix3 iyMatrix; |
---|
46 | G3D::Matrix3 izMatrix; |
---|
47 | public: |
---|
48 | G3D::Vector3 iPos; |
---|
49 | G3D::Vector3 iDir; |
---|
50 | float iScale; |
---|
51 | void init() |
---|
52 | { |
---|
53 | |
---|
54 | // Swap x and y the raw data uses the axis differently |
---|
55 | ixMatrix = G3D::Matrix3::fromAxisAngle(G3D::Vector3::unitY(),-(G3D::pi()*iDir.x/180.0)); |
---|
56 | iyMatrix = G3D::Matrix3::fromAxisAngle(G3D::Vector3::unitX(),-(G3D::pi()*iDir.y/180.0)); |
---|
57 | izMatrix = G3D::Matrix3::fromAxisAngle(G3D::Vector3::unitZ(),-(G3D::pi()*iDir.z/180.0)); |
---|
58 | |
---|
59 | } |
---|
60 | G3D::Vector3 transform(const G3D::Vector3& pIn) const; |
---|
61 | void moveToBasePos(const G3D::Vector3& pBasePos) { iPos -= pBasePos; } |
---|
62 | }; |
---|
63 | //=============================================== |
---|
64 | |
---|
65 | class TileAssembler |
---|
66 | { |
---|
67 | private: |
---|
68 | CoordModelMapping *iCoordModelMapping; |
---|
69 | std::string iDestDir; |
---|
70 | std::string iSrcDir; |
---|
71 | bool (*iFilterMethod)(char *pName); |
---|
72 | G3D::Table<std::string, unsigned int > iUniqueNameIds; |
---|
73 | unsigned int iCurrentUniqueNameId; |
---|
74 | |
---|
75 | public: |
---|
76 | TileAssembler(const std::string& pSrcDirName, const std::string& pDestDirName); |
---|
77 | virtual ~TileAssembler(); |
---|
78 | |
---|
79 | bool fillModelContainerArray(const std::string& pDirFileName, unsigned int pMapId, int pXPos, int pYPos, G3D::Array<ModelContainer*>& pMC); |
---|
80 | ModelContainer* processNames(const G3D::Array<std::string>& pPosFileNames, const char* pDestFileName); |
---|
81 | |
---|
82 | void init(); |
---|
83 | bool convertWorld(); |
---|
84 | |
---|
85 | bool fillModelIntoTree(G3D::AABSPTree<SubModel *> *pMainTree, const G3D::Vector3& pBasePos, std::string& pPosFilename, std::string& pModelFilename); |
---|
86 | void getModelPosition(std::string& pPosString, ModelPosition& pModelPosition); |
---|
87 | bool readRawFile(std::string& pModelFilename, ModelPosition& pModelPosition, G3D::AABSPTree<SubModel *> *pMainTree); |
---|
88 | void addWorldAreaMapId(unsigned int pMapId) { iCoordModelMapping->addWorldAreaMap(pMapId); } |
---|
89 | void setModelNameFilterMethod(bool (*pFilterMethod)(char *pName)) { iFilterMethod = pFilterMethod; } |
---|
90 | std::string getDirEntryNameFromModName(unsigned int pMapId, const std::string& pModPosName); |
---|
91 | unsigned int getUniqueNameId(const std::string pName); |
---|
92 | }; |
---|
93 | //=============================================== |
---|
94 | } // VMAP |
---|
95 | #endif /*_TILEASSEMBLER_H_*/ |
---|