1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/*
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
*
* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _COORDMODELMAPPING_H_
#define _COORDMODELMAPPING_H_
#include <G3D/Table.h>
#include <G3D/Array.h>
/**
This Class is a helper Class to convert the raw vector data into BSP-Trees.
We read the directory file of the raw data output and build logical groups.
Models with a lot of vectors are not merged into a resulting model, but separated into an additional file.
*/
namespace VMAP
{
#define MIN_VERTICES_FOR_OWN_CONTAINER_FILE 65000
// if we are in an instance
#define MIN_INST_VERTICES_FOR_OWN_CONTAINER_FILE 40000
//=====================================================
class NameCollection
{
public:
G3D::Array<std::string> iMainFiles;
G3D::Array<std::string> iSingeFiles;
void appendToMain(const std::string& pStr) { iMainFiles.append(pStr); }
void appendToSingle(const std::string& pStr) { iSingeFiles.append(pStr); }
size_t size() { return (iMainFiles.size() + iSingeFiles.size()); }
};
//=====================================================
class CMappingEntry
{
private:
int xPos;
int yPos;
unsigned int iMapId;
G3D::Array<std::string> iFilenames;
public:
CMappingEntry() { };
CMappingEntry(unsigned int pMapId, const int pXPos, const int pYPos)
{
iMapId = pMapId;
xPos = pXPos; yPos = pYPos;
};
~CMappingEntry() {};
void addFilename(char *pName);
const std::string getKeyString() const;
inline const G3D::Array<std::string>& getFilenames() const { return(iFilenames); }
static const std::string getKeyString(unsigned int pMapId, int pXPos, int pYPos)
{
char b[100];
sprintf(b,"%03u_%d_%d", pMapId, pXPos, pYPos);
return(std::string(b));
}
};
//=====================================================
class CoordModelMapping
{
private:
G3D::Table<std::string, CMappingEntry *> iMapObjectFiles;
G3D::Table<std::string, std::string> iProcesseSingleFiles;
G3D::Array<unsigned int> iMapIds;
G3D::Array<unsigned int> iWorldAreaGroups;
bool (*iFilterMethod)(char *pName);
inline void addCMappingEntry(CMappingEntry* pCMappingEntry)
{
iMapObjectFiles.set(pCMappingEntry->getKeyString(), pCMappingEntry);
}
inline CMappingEntry* getCMappingEntry(const std::string& pKey)
{
if(iMapObjectFiles.containsKey(pKey))
return(iMapObjectFiles.get(pKey));
else
return 0;
}
public:
CoordModelMapping() { iFilterMethod = NULL; }
virtual ~CoordModelMapping();
bool readCoordinateMapping(const std::string& pDirectoryFileName);
const NameCollection getFilenamesForCoordinate(unsigned int pMapId, int xPos, int yPos);
static unsigned int getMapIdFromFilename(const std::string& pName)
{
size_t spos;
spos = pName.find_last_of('/');
std::string basename = pName.substr(0, spos);
spos = basename.find_last_of('/');
std::string groupname = basename.substr(spos+1, basename.length());
unsigned int mapId = atoi(groupname.c_str());
return(mapId);
}
const G3D::Array<unsigned int>& getMaps() const { return iMapIds; }
bool isAlreadyProcessedSingleFile(const std::string& pName) const { return iProcesseSingleFiles.containsKey(pName); }
void addAlreadyProcessedSingleFile(const std::string& pName) { iProcesseSingleFiles.set(pName,pName); }
inline void addWorldAreaMap(unsigned int pMapId)
{
if(!iWorldAreaGroups.contains(pMapId))
{
iWorldAreaGroups.append(pMapId);
}
}
inline bool isWorldAreaMap(unsigned int pMapId) { return(iWorldAreaGroups.contains(pMapId)); }
void setModelNameFilterMethod(bool (*pFilterMethod)(char *pName)) { iFilterMethod = pFilterMethod; }
};
}
#endif /*_COORDMODELMAPPING_H_*/
|