root/trunk/src/shared/vmap/TileAssembler.h @ 40

Revision 2, 3.8 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#ifndef _TILEASSEMBLER_H_
20#define _TILEASSEMBLER_H_
21
22// load our modified version first !!
23#include "AABSPTree.h"
24
25#include <G3D/Vector3.h>
26
27#include "CoordModelMapping.h"
28#include "SubModel.h"
29#include "ModelContainer.h"
30
31namespace VMAP
32{
33    /**
34    This Class is used to convert raw vector data into balanced BSP-Trees.
35    To start the conversion call convertWorld().
36    */
37    //===============================================
38
39    class ModelPosition
40    {
41        private:
42            G3D::Matrix3 ixMatrix;
43            G3D::Matrix3 iyMatrix;
44            G3D::Matrix3 izMatrix;
45        public:
46            G3D::Vector3 iPos;
47            G3D::Vector3 iDir;
48            float iScale;
49            void init()
50            {
51
52                // Swap x and y the raw data uses the axis differently
53                ixMatrix = G3D::Matrix3::fromAxisAngle(G3D::Vector3::unitY(),-(G3D::pi()*iDir.x/180.0));
54                iyMatrix = G3D::Matrix3::fromAxisAngle(G3D::Vector3::unitX(),-(G3D::pi()*iDir.y/180.0));
55                izMatrix = G3D::Matrix3::fromAxisAngle(G3D::Vector3::unitZ(),-(G3D::pi()*iDir.z/180.0));
56
57            }
58            G3D::Vector3 transform(const G3D::Vector3& pIn) const;
59            void moveToBasePos(const G3D::Vector3& pBasePos) { iPos -= pBasePos; }
60    };
61    //===============================================
62
63    class TileAssembler
64    {
65        private:
66            CoordModelMapping *iCoordModelMapping;
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
73        public:
74            TileAssembler(const std::string& pSrcDirName, const std::string& pDestDirName);
75            virtual ~TileAssembler();
76
77            bool fillModelContainerArray(const std::string& pDirFileName, unsigned int pMapId, int pXPos, int pYPos, G3D::Array<ModelContainer*>& pMC);
78            ModelContainer* processNames(const G3D::Array<std::string>& pPosFileNames, const char* pDestFileName);
79
80            void init();
81            bool convertWorld();
82
83            bool fillModelIntoTree(G3D::AABSPTree<SubModel *> *pMainTree, const G3D::Vector3& pBasePos, std::string& pPosFilename, std::string& pModelFilename);
84            void getModelPosition(std::string& pPosString, ModelPosition& pModelPosition);
85            bool readRawFile(std::string& pModelFilename,  ModelPosition& pModelPosition, G3D::AABSPTree<SubModel *> *pMainTree);
86            void addWorldAreaMapId(unsigned int pMapId) { iCoordModelMapping->addWorldAreaMap(pMapId); }
87            void setModelNameFilterMethod(bool (*pFilterMethod)(char *pName)) { iFilterMethod = pFilterMethod; }
88            std::string getDirEntryNameFromModName(unsigned int pMapId, const std::string& pModPosName);
89            unsigned int getUniqueNameId(const std::string pName);
90    };
91    //===============================================
92}                                                           // VMAP
93#endif                                                      /*_TILEASSEMBLER_H_*/
Note: See TracBrowser for help on using the browser.