74 for (MapData::iterator map_iter =
mapData.begin(); map_iter !=
mapData.end() && success; ++map_iter)
77 std::vector<ModelSpawn*> mapSpawns;
78 UniqueEntryMap::iterator entry;
79 printf(
"Calculating model bounds for map %u...\n", map_iter->first);
80 for (entry = map_iter->second->UniqueEntries.begin(); entry != map_iter->second->UniqueEntries.end(); ++entry)
83 if (entry->second.flags &
MOD_M2)
92 entry->second.iBound = entry->second.iBound +
Vector3(533.33333f*32, 533.33333f*32, 0.f);
94 mapSpawns.push_back(&(entry->second));
98 printf(
"Creating map tree for map %u...\n", map_iter->first);
105 catch (std::exception& e)
107 printf(
"Exception ""%s"" when calling pTree.build", e.what());
112 std::map<uint32, uint32> modelNodeIdx;
113 for (
uint32 i=0; i<mapSpawns.size(); ++i)
114 modelNodeIdx.insert(pair<uint32, uint32>(mapSpawns[i]->ID, i));
117 std::stringstream mapfilename;
118 mapfilename <<
iDestDir <<
'/' << std::setfill(
'0') << std::setw(4) << map_iter->first <<
".vmtree";
119 FILE* mapfile = fopen(mapfilename.str().c_str(),
"wb");
123 printf(
"Cannot open %s\n", mapfilename.str().c_str());
128 if (success && fwrite(
VMAP_MAGIC, 1, 8, mapfile) != 8) success =
false;
130 pair<TileMap::iterator, TileMap::iterator> globalRange = map_iter->second->TileEntries.equal_range(globalTileID);
131 char isTiled = globalRange.first == globalRange.second;
132 if (success && fwrite(&isTiled,
sizeof(
char), 1, mapfile) != 1) success =
false;
134 if (success && fwrite(
"NODE", 4, 1, mapfile) != 1) success =
false;
137 if (success && fwrite(
"GOBJ", 4, 1, mapfile) != 1) success =
false;
139 for (TileMap::iterator glob=globalRange.first; glob != globalRange.second && success; ++glob)
149 TileMap &tileEntries = map_iter->second->TileEntries;
150 TileMap::iterator tile;
151 for (tile = tileEntries.begin(); tile != tileEntries.end(); ++tile)
153 const ModelSpawn &spawn = map_iter->second->UniqueEntries[tile->second];
156 uint32 nSpawns = tileEntries.count(tile->first);
157 std::stringstream tilefilename;
158 tilefilename.fill(
'0');
159 tilefilename <<
iDestDir <<
'/' << std::setw(4) << map_iter->first <<
'_';
162 tilefilename << std::setw(2) << x <<
'_' << std::setw(2) << y <<
".vmtile";
163 if (FILE* tilefile = fopen(tilefilename.str().c_str(),
"wb"))
166 if (success && fwrite(
VMAP_MAGIC, 1, 8, tilefile) != 8) success =
false;
168 if (success && fwrite(&nSpawns,
sizeof(
uint32), 1, tilefile) != 1) success =
false;
170 for (
uint32 s=0; s<nSpawns; ++s)
174 const ModelSpawn &spawn2 = map_iter->second->UniqueEntries[tile->second];
177 std::map<uint32, uint32>::iterator nIdx = modelNodeIdx.find(spawn2.ID);
178 if (success && fwrite(&nIdx->second,
sizeof(
uint32), 1, tilefile) != 1) success =
false;
189 std::cout <<
"\nConverting Model Files" << std::endl;
192 std::cout <<
"Converting " << *mfile << std::endl;
195 std::cout <<
"error converting " << *mfile << std::endl;
202 for (MapData::iterator map_iter =
mapData.begin(); map_iter !=
mapData.end(); ++map_iter)
204 delete map_iter->second;
Definition: ModelInstance.h:38
static uint32 packTileID(uint32 tileX, uint32 tileY)
Definition: MapTree.h:64
bool convertRawFile(const std::string &pModelFilename)
Definition: TileAssembler.cpp:307
bool readMapSpawns()
Definition: TileAssembler.cpp:209
std::multimap< uint32, uint32 > TileMap
Definition: TileAssembler.h:56
std::set< std::string > spawnedModelFiles
Definition: TileAssembler.h:102
bool writeToFile(FILE *wf) const
Definition: BoundingIntervalHierarchy.cpp:247
static bool writeToFile(FILE *rw, const ModelSpawn &spawn)
Definition: ModelInstance.cpp:200
void exportGameobjectModels()
Definition: TileAssembler.cpp:343
Definition: ModelInstance.h:37
std::string iDestDir
Definition: TileAssembler.h:96
MapData mapData
Definition: TileAssembler.h:101
bool calculateTransformedBound(ModelSpawn &spawn)
Definition: TileAssembler.cpp:250
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: BoundsTrait.h:17
G3D::int16 x
Definition: Vector2int16.h:37
void build(const PrimArray &primitives, BoundsFunc &getBounds, uint32 leafSize=3, bool printStats=false)
Definition: BoundingIntervalHierarchy.h:84
Definition: BoundingIntervalHierarchy.h:70
const char VMAP_MAGIC[]
Definition: VMapDefinitions.h:28
static void unpackTileID(uint32 ID, uint32 &tileX, uint32 &tileY)
Definition: MapTree.h:65
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083