Tools/MeshExtractor: Removed shared and MySQL dependencies.

This commit is contained in:
Shauren
2013-01-22 15:40:12 +01:00
parent a65caa6da2
commit fcd258a8a9
16 changed files with 74 additions and 100 deletions

View File

@@ -11,69 +11,42 @@
file(GLOB_RECURSE sources *.cpp *.h)
if( UNIX )
include_directories (
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src/server/shared
${CMAKE_SOURCE_DIR}/src/server/shared/Database
${CMAKE_SOURCE_DIR}/src/server/shared/Database/Implementation
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
${CMAKE_SOURCE_DIR}/src/server/shared/Utilities
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour
${CMAKE_SOURCE_DIR}/dep/libmpq
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
${ACE_INCLUDE_DIR}
${MYSQL_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
elseif( WIN32 )
include_directories (
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src/server/shared
${CMAKE_SOURCE_DIR}/src/server/shared/Database
${CMAKE_SOURCE_DIR}/src/server/shared/Database/Implementation
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
${CMAKE_SOURCE_DIR}/src/server/shared/Utilities
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour
${CMAKE_SOURCE_DIR}/dep/libmpq
add_definitions(-DNO_CORE_FUNCS)
set(include_Base
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src/server/shared
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour
${CMAKE_SOURCE_DIR}/dep/libmpq
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
${ACE_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
if( WIN32 )
set(include_Base
${include_Base}
${CMAKE_SOURCE_DIR}/dep/libmpq/win
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
${ACE_INCLUDE_DIR}
${MYSQL_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
)
endif()
include_directories(${include_Base})
add_executable(MeshExtractor
${sources}
)
target_link_libraries(MeshExtractor
shared
g3dlib
mpq
Recast
Detour
${MYSQL_LIBRARY}
${OPENSSL_LIBRARIES}
${OPENSSL_EXTRA_LIBRARIES}
${BZIP2_LIBRARIES}
${ZLIB_LIBRARIES}
${ACE_LIBRARY}
)
add_dependencies(MeshExtractor mpq Recast Detour)
if( UNIX )
install(TARGETS MeshExtractor DESTINATION bin)
elseif( WIN32 )

View File

@@ -2,8 +2,9 @@
#define CACHE_H
#include <string>
#include <map>
#include "Common.h"
#include "ace/Synch.h"
#include "Define.h"
#include <ace/Guard_T.h>
#include <ace/Synch.h>
class WorldModelRoot;
class Model;

View File

@@ -1,6 +1,6 @@
#ifndef CHUNK_H
#define CHUNK_H
#include "Common.h"
#include "Define.h"
#include <string>
class ChunkedData;

View File

@@ -1,8 +1,6 @@
#ifndef CONSTANTS_H
#define CONSTANTS_H
#include "Common.h"
class Constants
{
public:

View File

@@ -2,7 +2,7 @@
#define CONT_BUILDER_H
#include <string>
#include "WDT.h"
#include "Common.h"
#include "Define.h"
class ContinentBuilder
{
@@ -22,7 +22,7 @@ private:
WDT* TileMap;
uint32 MapId;
uint32 NumberOfThreads;
int tileXMin;
int tileXMin;
int tileYMin;
int tileXMax;
int tileYMax;

View File

@@ -1,6 +1,6 @@
#include <cstdio>
#include "DBC.h"
#include "Common.h"
#include "Define.h"
DBC::DBC( FILE* stream ) : StringBlock(NULL), StringBlockSize(0), IsFaulty(true)
{

View File

@@ -1,7 +1,8 @@
#ifndef DBC_H
#define DBC_H
#include <vector>
#include "Common.h"
#include <string>
#include "Define.h"
class Record;

View File

@@ -2,7 +2,7 @@
#define LIQUID_H
#include "ADT.h"
#include "Utils.h"
#include "Common.h"
#include "Define.h"
#include <vector>

View File

@@ -2,27 +2,25 @@
#define MPQ_H
#include "libmpq/mpq.h"
#include "Common.h"
#include <string.h>
#include "Define.h"
#include <string>
#include <ctype.h>
#include <vector>
#include <iostream>
#include <deque>
using namespace std;
class MPQArchive
{
public:
mpq_archive_s *mpq_a;
vector<string> Files;
std::vector<std::string> Files;
MPQArchive(const char* filename);
void close();
void GetFileListTo(vector<string>& filelist) {
void GetFileListTo(std::vector<std::string>& filelist) {
uint32_t filenum;
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
libmpq__off_t size, transferred;
@@ -40,7 +38,7 @@ public:
while ((token != NULL) && (counter < size)) {
//cout << token << endl;
token[strlen(token) - 1] = 0;
string s = token;
std::string s = token;
filelist.push_back(s);
counter += strlen(token) + 2;
token = strtok(NULL, seps);

View File

@@ -2,8 +2,7 @@
#include "MPQ.h"
#include "DBC.h"
#include "Utils.h"
#include "ace/Synch.h"
#include <ace/Guard_T.h>
char* MPQManager::Files[] = {
"common.MPQ",

View File

@@ -2,7 +2,9 @@
#define MPQ_MANAGER_H
#include "MPQ.h"
#include "ace/Synch.h"
#include <ace/Synch.h>
#include <set>
#include <map>
class DBC;
class MPQManager

View File

@@ -12,11 +12,6 @@
#include <set>
#include "Common.h"
#include "LoginDatabase.h"
#include "Util.h"
LoginDatabaseWorkerPool LoginDatabase;
MPQManager* MPQHandler;
CacheClass* Cache;
@@ -64,7 +59,7 @@ void ExtractDBCs()
path += std::string(MPQManager::Languages[*itr]) + "/";
Utils::CreateDir(path);
}
std::string component = "component.wow-" + std::string(MPQManager::Languages[*itr]) + ".txt";
// Extract the component file
Utils::SaveToDisk(MPQHandler->GetFile(component), path + component);
@@ -104,7 +99,7 @@ void ExtractGameobjectModels()
{
fileName = Utils::FixModelPath(fileName);
Model model(path);
if (model.IsBad)
continue;
@@ -151,7 +146,7 @@ void ExtractGameobjectModels()
fwrite(indices, sizeof(uint16), numTris, output);
}
fwrite("VERT", 4, 1, output);
wsize = sizeof(int) + sizeof(float) * 3 * numVerts;
fwrite(&wsize, sizeof(int), 1, output);
@@ -170,7 +165,7 @@ void ExtractGameobjectModels()
fwrite(vertices, sizeof(float), numVerts * 3, output);
}
fclose(output);
delete[] indices;
delete[] vertices;
@@ -254,11 +249,14 @@ bool HandleArgs(int argc, char** argv, uint32& threads, std::set<uint32>& mapLis
param = argv[++i];
if (!param)
return false;
std::string maps = std::string(param);
Tokenizer tokens(maps, ',');
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
mapList.insert(atoi(*itr));
char* copy = strdup(param);
char* token = strtok(copy, ",");
while (token)
{
mapList.insert(atoi(token));
token = strtok(NULL, ",");
}
printf("Extracting only provided list of maps (%u).\n", uint32(mapList.size()));
}
@@ -337,7 +335,7 @@ int main(int argc, char* argv[])
uint32 threads = 4, extractFlags = 0;
std::set<uint32> mapIds;
bool debug = false;
if (!HandleArgs(argc, argv, threads, mapIds, debug, extractFlags))
{
PrintUsage();
@@ -425,6 +423,6 @@ int main(int argc, char* argv[])
printf("Found!");
}
return 0;
}

View File

@@ -10,7 +10,7 @@
#include "RecastAlloc.h"
#include "DetourNavMeshBuilder.h"
#include "ace/Synch.h"
#include <ace/Synch.h>
TileBuilder::TileBuilder(ContinentBuilder* _cBuilder, std::string world, int x, int y, uint32 mapId) :
World(world), X(x), Y(y), MapId(mapId), _Geometry(NULL), DataSize(0), cBuilder(_cBuilder)
@@ -118,7 +118,7 @@ uint8* TileBuilder::Build(bool dbg, dtNavMeshParams& navMeshParams)
fprintf(debug, "f %i %i %i\n", _Geometry->Triangles[i].V0 + 1, _Geometry->Triangles[i].V1 + 1, _Geometry->Triangles[i].V2 + 1);
fclose(debug);
}
uint32 numVerts = _Geometry->Vertices.size();
uint32 numTris = _Geometry->Triangles.size();
float* vertices;
@@ -128,13 +128,13 @@ uint8* TileBuilder::Build(bool dbg, dtNavMeshParams& navMeshParams)
_Geometry->Vertices.clear();
_Geometry->Triangles.clear();
rcVcopy(Config.bmin, cBuilder->bmin);
rcVcopy(Config.bmax, cBuilder->bmax);
// this sets the dimensions of the heightfield - should maybe happen before border padding
rcCalcGridSize(Config.bmin, Config.bmax, Config.cs, &Config.width, &Config.height);
// Initialize per tile config.
rcConfig tileCfg = Config;
tileCfg.width = Config.tileSize + Config.borderSize * 2;
@@ -154,8 +154,8 @@ uint8* TileBuilder::Build(bool dbg, dtNavMeshParams& navMeshParams)
tileCfg.bmin[2] = Config.bmin[2] + float(y * Config.tileSize - Config.borderSize) * Config.cs;
tileCfg.bmax[0] = Config.bmin[0] + float((x + 1) * Config.tileSize + Config.borderSize) * Config.cs;
tileCfg.bmax[2] = Config.bmin[2] + float((y + 1) * Config.tileSize + Config.borderSize) * Config.cs;
rcHeightfield* hf = rcAllocHeightfield();
rcCreateHeightfield(Context, *hf, tileCfg.width, tileCfg.height, tileCfg.bmin, tileCfg.bmax, tileCfg.cs, tileCfg.ch);
rcClearUnwalkableTriangles(Context, tileCfg.walkableSlopeAngle, vertices, numVerts, triangles, numTris, areas);
@@ -198,7 +198,7 @@ uint8* TileBuilder::Build(bool dbg, dtNavMeshParams& navMeshParams)
// Free memory
rcFreeCompactHeightfield(chf);
rcFreeContourSet(cset);
pmmerge[nmerge] = pmesh;
dmmerge[nmerge] = dmesh;
++nmerge;
@@ -207,15 +207,15 @@ uint8* TileBuilder::Build(bool dbg, dtNavMeshParams& navMeshParams)
rcPolyMesh* pmesh = rcAllocPolyMesh();
rcMergePolyMeshes(Context, pmmerge, nmerge, *pmesh);
rcPolyMeshDetail* dmesh = rcAllocPolyMeshDetail();
rcMergePolyMeshDetails(Context, dmmerge, nmerge, *dmesh);
delete[] pmmerge;
delete[] dmmerge;
printf("[%02i,%02i] Meshes merged!\n", X, Y);
// Remove padding from the polymesh data. (Remove this odditity)
for (int i = 0; i < pmesh->nverts; ++i)
{
@@ -262,10 +262,10 @@ uint8* TileBuilder::Build(bool dbg, dtNavMeshParams& navMeshParams)
rcVcopy(params.bmin, cBuilder->bmin);
rcVcopy(params.bmax, cBuilder->bmax);
// Offmesh-connection settings
params.offMeshConCount = 0; // none for now
params.tileSize = Constants::VertexPerMap;
if (!params.polyCount || !params.polys || Constants::TilesPerMap * Constants::TilesPerMap == params.polyCount)
@@ -281,7 +281,7 @@ uint8* TileBuilder::Build(bool dbg, dtNavMeshParams& navMeshParams)
delete vertices;
return NULL;
}
int navDataSize;
uint8* navData;
printf("[%02i,%02i] Creating the navmesh with %i vertices, %i polys, %i triangles!\n", X, Y, pmesh->nverts, pmesh->npolys, dmesh->ntris);

View File

@@ -7,12 +7,16 @@
#include "G3D/Matrix4.h"
#include "DetourNavMesh.h"
#include "Common.h"
#include "Define.h"
#include "Constants.h"
#include <ace/Stack_Trace.h>
struct WorldModelDefinition;
class DoodadInstance;
#define ASSERT(assertion) { if (!(assertion)) { ACE_Stack_Trace st; fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n", __FILE__, __LINE__, __FUNCTION__, #assertion, st.c_str()); *((volatile int*)NULL) = 0; } }
struct Vector3
{
Vector3() {}

View File

@@ -3,7 +3,7 @@
#include "Chunk.h"
#include "Cache.h"
#include "Model.h"
#include "Common.h"
#include "Define.h"
#include "G3D/Matrix4.h"
#include <cstdio>

View File

@@ -1,6 +1,6 @@
#ifndef WMODEL_HNDL_H
#define WMODEL_HNDL_H
#include "Common.h"
#include "Define.h"
#include "Utils.h"
#include "WorldModelRoot.h"
#include "ObjectDataHandler.h"