aboutsummaryrefslogtreecommitdiff
path: root/src/shared/vmap
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/vmap')
-rw-r--r--src/shared/vmap/BaseModel.cpp4
-rw-r--r--src/shared/vmap/BaseModel.h4
-rw-r--r--src/shared/vmap/CoordModelMapping.cpp103
-rw-r--r--src/shared/vmap/CoordModelMapping.h5
-rw-r--r--src/shared/vmap/DebugCmdLogger.cpp6
-rw-r--r--src/shared/vmap/DebugCmdLogger.h4
-rw-r--r--src/shared/vmap/IVMapManager.h4
-rw-r--r--src/shared/vmap/Makefile.am58
-rw-r--r--src/shared/vmap/ManagedModelContainer.cpp4
-rw-r--r--src/shared/vmap/ManagedModelContainer.h4
-rw-r--r--src/shared/vmap/ModelContainer.cpp4
-rw-r--r--src/shared/vmap/ModelContainer.h4
-rw-r--r--src/shared/vmap/NodeValueAccess.h4
-rw-r--r--src/shared/vmap/ShortBox.h4
-rw-r--r--src/shared/vmap/ShortVector.h4
-rw-r--r--src/shared/vmap/SubModel.cpp4
-rw-r--r--src/shared/vmap/SubModel.h4
-rw-r--r--src/shared/vmap/TileAssembler.cpp769
-rw-r--r--src/shared/vmap/TileAssembler.h4
-rw-r--r--src/shared/vmap/TreeNode.cpp4
-rw-r--r--src/shared/vmap/TreeNode.h4
-rw-r--r--src/shared/vmap/VMapDefinitions.h4
-rw-r--r--src/shared/vmap/VMapFactory.cpp4
-rw-r--r--src/shared/vmap/VMapFactory.h4
-rw-r--r--src/shared/vmap/VMapManager.cpp4
-rw-r--r--src/shared/vmap/VMapManager.h4
-rw-r--r--src/shared/vmap/VMapTools.h4
27 files changed, 561 insertions, 468 deletions
diff --git a/src/shared/vmap/BaseModel.cpp b/src/shared/vmap/BaseModel.cpp
index f4bf13bc558..2ffd5672218 100644
--- a/src/shared/vmap/BaseModel.cpp
+++ b/src/shared/vmap/BaseModel.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/BaseModel.h b/src/shared/vmap/BaseModel.h
index 6c17f704692..098e1d9381b 100644
--- a/src/shared/vmap/BaseModel.h
+++ b/src/shared/vmap/BaseModel.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/CoordModelMapping.cpp b/src/shared/vmap/CoordModelMapping.cpp
index 319e7bb8c31..86e3347a614 100644
--- a/src/shared/vmap/CoordModelMapping.cpp
+++ b/src/shared/vmap/CoordModelMapping.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
@@ -21,6 +21,7 @@
#include "CoordModelMapping.h"
#include <string.h>
+#include <cstdio>
using namespace G3D;
@@ -87,63 +88,65 @@ namespace VMAP
bool CoordModelMapping::readCoordinateMapping(const std::string& pDirectoryFileName)
{
FILE *f = fopen(pDirectoryFileName.c_str(), "rb");
- bool result = false;
+ if(!f)
+ {
+ printf("ERROR: Can't open file: %s\n",pDirectoryFileName.c_str());
+ return false;
+ }
+
char buffer[500+1];
- if(f)
+ CMappingEntry* cMappingEntry;
+ while(fgets(buffer, 500, f))
{
- result = true;
- CMappingEntry* cMappingEntry;
- while(fgets(buffer, 500, f))
- {
- //char namebuffer[500];
- char positionbuffer[500];
- int xpos, ypos, noVec;
- float scale;
- xpos = ypos = noVec = 0;
+ //char namebuffer[500];
+ char positionbuffer[500];
+ int xpos, ypos, noVec;
+ float scale;
+ xpos = ypos = noVec = 0;
- //sscanf(buffer, "%d %d %s %s %f %d", &xpos, &ypos, namebuffer,positionbuffer, &scale, &noVec);
+ //sscanf(buffer, "%d %d %s %s %f %d", &xpos, &ypos, namebuffer,positionbuffer, &scale, &noVec);
- // this is ugly, but the format has no read delimiter and a space could be in the first part of the name
- int nameStart = findPosChar(buffer, ' ', 2);// find the 2. space
- if(nameStart > -1 && (iFilterMethod == NULL || (*iFilterMethod)(buffer)))
+ // this is ugly, but the format has no read delimiter and a space could be in the first part of the name
+ int nameStart = findPosChar(buffer, ' ', 2);// find the 2. space
+ if(nameStart > -1 && (iFilterMethod == NULL || (*iFilterMethod)(buffer)))
+ {
+ ++nameStart;
+ // find the 1. / (now a space only can be found at the end of the name)
+ int nameEnd = nameStart + findPosChar(&buffer[nameStart], '/', 1);
+ // find the 1. space (after the name)
+ nameEnd += findPosChar(&buffer[nameEnd], ' ', 1);
+ buffer[nameEnd] = 0; // terminate the name
+
+ sscanf(buffer, "%d %d", &xpos, &ypos);
+ sscanf(&buffer[nameEnd+1], "%s %f %d", positionbuffer, &scale, &noVec);
+ unsigned int mapId = getMapIdFromFilename(std::string(&buffer[nameStart]));
+ if(!iMapIds.contains(mapId))
{
- ++nameStart;
- // find the 1. / (now a space only can be found at the end of the name)
- int nameEnd = nameStart + findPosChar(&buffer[nameStart], '/', 1);
- // find the 1. space (after the name)
- nameEnd += findPosChar(&buffer[nameEnd], ' ', 1);
- buffer[nameEnd] = 0; // terminate the name
-
- sscanf(buffer, "%d %d", &xpos, &ypos);
- sscanf(&buffer[nameEnd+1], "%s %f %d", positionbuffer, &scale, &noVec);
- unsigned int mapId = getMapIdFromFilename(std::string(&buffer[nameStart]));
- if(!iMapIds.contains(mapId))
- {
- iMapIds.append(mapId);
- }
- if(!isWorldAreaMap(mapId))
- {
- xpos = 0; // store all files under the groupKey
- ypos = 0;
- }
-
- std::string key = CMappingEntry::getKeyString(mapId, xpos, ypos);
- cMappingEntry = getCMappingEntry(key);
- if(cMappingEntry == 0)
- {
- cMappingEntry = new CMappingEntry(mapId, xpos, ypos);
- addCMappingEntry(cMappingEntry);
- }
- char namebuffer2[500];
- sprintf(namebuffer2, "%d %s#%s_%f", noVec, &buffer[nameStart], positionbuffer, scale);
- cMappingEntry->addFilename(namebuffer2);
- //break;
+ iMapIds.append(mapId);
+ printf("Coords for map %u...\n",mapId);
}
+ if(!isWorldAreaMap(mapId))
+ {
+ xpos = 0; // store all files under the groupKey
+ ypos = 0;
+ }
+
+ std::string key = CMappingEntry::getKeyString(mapId, xpos, ypos);
+ cMappingEntry = getCMappingEntry(key);
+ if(cMappingEntry == 0)
+ {
+ cMappingEntry = new CMappingEntry(mapId, xpos, ypos);
+ addCMappingEntry(cMappingEntry);
+ }
+ char namebuffer2[500];
+ sprintf(namebuffer2, "%d %s#%s_%f", noVec, &buffer[nameStart], positionbuffer, scale);
+ cMappingEntry->addFilename(namebuffer2);
+ //break;
}
- fclose(f);
}
- return result;
+ fclose(f);
+ return true;
}
//============================================================
diff --git a/src/shared/vmap/CoordModelMapping.h b/src/shared/vmap/CoordModelMapping.h
index cfaa600ee81..c1f49462962 100644
--- a/src/shared/vmap/CoordModelMapping.h
+++ b/src/shared/vmap/CoordModelMapping.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
@@ -21,6 +21,7 @@
#ifndef _COORDMODELMAPPING_H_
#define _COORDMODELMAPPING_H_
+#include <cstdio>
#include <G3D/Table.h>
#include <G3D/Array.h>
diff --git a/src/shared/vmap/DebugCmdLogger.cpp b/src/shared/vmap/DebugCmdLogger.cpp
index 2552a16acc2..e6b36572c45 100644
--- a/src/shared/vmap/DebugCmdLogger.cpp
+++ b/src/shared/vmap/DebugCmdLogger.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
@@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <cstdio>
+
#include "DebugCmdLogger.h"
using namespace G3D;
diff --git a/src/shared/vmap/DebugCmdLogger.h b/src/shared/vmap/DebugCmdLogger.h
index a194d335381..5493ab6f332 100644
--- a/src/shared/vmap/DebugCmdLogger.h
+++ b/src/shared/vmap/DebugCmdLogger.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/IVMapManager.h b/src/shared/vmap/IVMapManager.h
index 01aef4b9d4c..243a15aef73 100644
--- a/src/shared/vmap/IVMapManager.h
+++ b/src/shared/vmap/IVMapManager.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/Makefile.am b/src/shared/vmap/Makefile.am
new file mode 100644
index 00000000000..483a926c907
--- /dev/null
+++ b/src/shared/vmap/Makefile.am
@@ -0,0 +1,58 @@
+# Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+#
+# Copyright (C) 2008-2009 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
+
+## Process this file with automake to produce Makefile.in
+
+## Sub-directories to parse
+
+## CPP flags for includes, defines, etc.
+AM_CPPFLAGS = $(TRINI_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir) -I$(srcdir)/../../../dep/include -I$(srcdir)/../../framework -I$(srcdir)/../../shared -I$(srcdir)/../../../dep/include/g3dlite
+
+## Build MaNGOS shared library and its parts as convenience library.
+# All libraries will be convenience libraries. Might be changed to shared
+# later.
+noinst_LIBRARIES = libmangosvmaps.a
+
+libmangosvmaps_a_SOURCES = \
+ AABSPTree.h \
+ BaseModel.cpp \
+ BaseModel.h \
+ CoordModelMapping.cpp \
+ CoordModelMapping.h \
+ DebugCmdLogger.cpp \
+ DebugCmdLogger.h \
+ IVMapManager.h \
+ ManagedModelContainer.cpp \
+ ManagedModelContainer.h \
+ ModelContainer.cpp \
+ ModelContainer.h \
+ NodeValueAccess.h \
+ ShortBox.h \
+ ShortVector.h \
+ SubModel.cpp \
+ SubModel.h \
+ TileAssembler.cpp \
+ TileAssembler.h \
+ TreeNode.cpp \
+ TreeNode.h \
+ VMapDefinitions.h \
+ VMapFactory.cpp \
+ VMapFactory.h \
+ VMapManager.cpp \
+ VMapManager.h \
+ VMapTools.h
diff --git a/src/shared/vmap/ManagedModelContainer.cpp b/src/shared/vmap/ManagedModelContainer.cpp
index 1362002bafd..c7bfefe7179 100644
--- a/src/shared/vmap/ManagedModelContainer.cpp
+++ b/src/shared/vmap/ManagedModelContainer.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/ManagedModelContainer.h b/src/shared/vmap/ManagedModelContainer.h
index 33c675d0806..e6862f915c7 100644
--- a/src/shared/vmap/ManagedModelContainer.h
+++ b/src/shared/vmap/ManagedModelContainer.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/ModelContainer.cpp b/src/shared/vmap/ModelContainer.cpp
index 9eb100161d8..4a722d2585b 100644
--- a/src/shared/vmap/ModelContainer.cpp
+++ b/src/shared/vmap/ModelContainer.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/ModelContainer.h b/src/shared/vmap/ModelContainer.h
index 9613bf53d96..abc96261050 100644
--- a/src/shared/vmap/ModelContainer.h
+++ b/src/shared/vmap/ModelContainer.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/NodeValueAccess.h b/src/shared/vmap/NodeValueAccess.h
index e14a6dba676..54fc5ee99b6 100644
--- a/src/shared/vmap/NodeValueAccess.h
+++ b/src/shared/vmap/NodeValueAccess.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/ShortBox.h b/src/shared/vmap/ShortBox.h
index bffca0d806d..0e98677aa9e 100644
--- a/src/shared/vmap/ShortBox.h
+++ b/src/shared/vmap/ShortBox.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/ShortVector.h b/src/shared/vmap/ShortVector.h
index f7dd0f74859..5f0fb7d9fd8 100644
--- a/src/shared/vmap/ShortVector.h
+++ b/src/shared/vmap/ShortVector.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/SubModel.cpp b/src/shared/vmap/SubModel.cpp
index c6022d2ed69..370c80062d6 100644
--- a/src/shared/vmap/SubModel.cpp
+++ b/src/shared/vmap/SubModel.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/SubModel.h b/src/shared/vmap/SubModel.h
index c52dc7f5c51..89ea9b91d7b 100644
--- a/src/shared/vmap/SubModel.h
+++ b/src/shared/vmap/SubModel.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/TileAssembler.cpp b/src/shared/vmap/TileAssembler.cpp
index bb73a2ba241..cbaa4e58108 100644
--- a/src/shared/vmap/TileAssembler.cpp
+++ b/src/shared/vmap/TileAssembler.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
@@ -75,12 +75,12 @@ namespace VMAP
addWorldAreaMapId(0); //Azeroth
addWorldAreaMapId(1); //Kalimdor
addWorldAreaMapId(530); //Expansion01
+ addWorldAreaMapId(571); //Expansion02
}
//=================================================================
std::string getModNameFromModPosName(const std::string& pModPosName)
{
-
size_t spos = pModPosName.find_first_of('#');
std::string modelFileName = pModPosName.substr(0,spos);
return(modelFileName);
@@ -142,7 +142,6 @@ namespace VMAP
//=================================================================
bool TileAssembler::convertWorld()
{
-
#ifdef _ASSEMBLER_DEBUG
# ifdef _DEBUG
::g_df = fopen("../TileAssembler_debug.txt", "wb");
@@ -151,424 +150,454 @@ namespace VMAP
# endif
#endif
- bool result = true;
std::string fname = iSrcDir;
fname.append("/");
fname.append("dir");
iCoordModelMapping->setModelNameFilterMethod(iFilterMethod);
- iCoordModelMapping->readCoordinateMapping(fname);
+
+ printf("Read coordinate mapping...\n");
+ if(!iCoordModelMapping->readCoordinateMapping(fname))
+ return false;
Array<unsigned int> mapIds = iCoordModelMapping->getMaps();
if(mapIds.size() == 0)
{
- result = false;
+ printf("Fatal error: empty map list!\n");
+ return false;
}
- for(int i=0; i<mapIds.size() && result; ++i)
+
+ for(int i=0; i<mapIds.size(); ++i)
{
unsigned int mapId = mapIds[i];
#ifdef _ASSEMBLER_DEBUG
if(mapId == 0) // "Azeroth" just for debug
{
- for(int x=28; x<29 && result; ++x) //debug
+ for(int x=28; x<29; ++x) //debug
{
- for(int y=28; y<29 && result; ++y)
+ for(int y=28; y<29; ++y)
{
- #else
- // ignore DeeprunTram (369) it is too large for short vector and not important
- // ignore test (13), Test (29) , development (451)
- if(mapId != 369 && mapId != 13 && mapId != 29 && mapId != 451)
+ #else
+ // ignore DeeprunTram (369) it is too large for short vector and not important
+ // ignore test (13), Test (29) , development (451)
+ if(mapId != 369 && mapId != 13 && mapId != 29 && mapId != 451)
+ {
+ for(int x=0; x<66; ++x)
+ {
+ for(int y=0; y<66; ++y)
+ {
+ #endif
+ Array<ModelContainer*> mc;
+ std::string dirname;
+ char buffer[100];
+ if(iCoordModelMapping->isWorldAreaMap(mapId) && x<65 && y<65)
{
- for(int x=0; x<66 && result; ++x)
- {
- for(int y=0; y<66 && result; ++y)
- {
- #endif
- Array<ModelContainer*> mc;
- std::string dirname;
- char buffer[100];
- if(iCoordModelMapping->isWorldAreaMap(mapId) && x<65 && y<65)
- {
- sprintf(buffer, "%03u_%d_%d",mapId,y,x); // Let's flip x and y here
- dirname = std::string(buffer);
- }
- else
- {
- sprintf(buffer, "%03u",mapId);
- dirname = std::string(buffer);
- }
- result = fillModelContainerArray(dirname, mapId, x, y, mc);
- emptyArray(mc);
- }
- }
+ sprintf(buffer, "%03u_%d_%d",mapId,y,x); // Let's flip x and y here
+ dirname = std::string(buffer);
+ printf("%s...\n",dirname.c_str());
}
- }
- #ifdef _ASSEMBLER_DEBUG
- if(::g_df) fclose(::g_df);
- #endif
-
- return result;
- }
+ else
+ {
+ sprintf(buffer, "%03u",mapId);
+ dirname = std::string(buffer);
- //=================================================================
+ // prevent spam for small maps
+ if(x==0 && y==0)
+ printf("%s...\n",dirname.c_str());
+ }
- bool TileAssembler::fillModelContainerArray(const std::string& pDirFileName, unsigned int pMapId, int pXPos, int pYPos, Array<ModelContainer*>& pMC)
- {
- bool result = true;
- ModelContainer* modelContainer;
+ bool result = fillModelContainerArray(dirname, mapId, x, y, mc);
+ emptyArray(mc);
- NameCollection nameCollection = iCoordModelMapping->getFilenamesForCoordinate(pMapId, pXPos, pYPos);
- if(nameCollection.size() > 0)
- {
- result = false;
- char dirfilename[500];
- sprintf(dirfilename,"%s/%s.vmdir",iDestDir.c_str(),pDirFileName.c_str());
- FILE *dirfile = fopen(dirfilename, "ab");
- if(dirfile)
- {
- result = true;
- char destnamebuffer[500];
- char fullnamedestnamebuffer[500];
- if(nameCollection.iMainFiles.size() >0)
- {
- sprintf(destnamebuffer,"%03u_%i_%i.vmap",pMapId, pYPos, pXPos); // flip it here too
- std::string checkDoubleStr = std::string(dirfilename);
- checkDoubleStr.append("##");
- checkDoubleStr.append(std::string(destnamebuffer));
- // Check, if same file already is in the same dir file
- if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr))
- {
- iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr);
- fprintf(dirfile, "%s\n",destnamebuffer);
- sprintf(fullnamedestnamebuffer,"%s/%s",iDestDir.c_str(),destnamebuffer);
- modelContainer = processNames(nameCollection.iMainFiles, fullnamedestnamebuffer);
- if(modelContainer)
- {
- pMC.append(modelContainer);
- }
- else
- {
- result = false;
- }
- }
- }
- // process the large singe files
- int pos = 0;
- while(result && (pos < nameCollection.iSingeFiles.size()))
- {
- std::string destFileName = iDestDir;
- destFileName.append("/");
- std::string dirEntryName = getDirEntryNameFromModName(pMapId,nameCollection.iSingeFiles[pos]);
- std::string checkDoubleStr = std::string(dirfilename);
- checkDoubleStr.append("##");
- checkDoubleStr.append(nameCollection.iSingeFiles[pos]);
- // Check, if same file already is in the same dir file
- if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr))
- {
- iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr);
- fprintf(dirfile, "%s\n",dirEntryName.c_str());
- destFileName.append(dirEntryName);
-
- Array<std::string> positionarray;
- positionarray.append(nameCollection.iSingeFiles[pos]);
-
- if(!iCoordModelMapping->isAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]))
- {
- modelContainer = processNames(positionarray, destFileName.c_str());
- iCoordModelMapping->addAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]);
- if(modelContainer)
- {
- pMC.append(modelContainer);
- }
- else
- {
- result = false;
- }
- }
- }
- ++pos;
- }
- fclose(dirfile);
- }
+ if(!result)
+ return false;
}
- return(result);
}
+ }
+ }
+ #ifdef _ASSEMBLER_DEBUG
+ if(::g_df) fclose(::g_df);
+ #endif
- //=================================================================
+ return true;
+ }
+
+ //=================================================================
+
+ bool TileAssembler::fillModelContainerArray(const std::string& pDirFileName, unsigned int pMapId, int pXPos, int pYPos, Array<ModelContainer*>& pMC)
+ {
+ ModelContainer* modelContainer;
- void removeEntriesFromTree(AABSPTree<SubModel *>* pTree)
+ NameCollection nameCollection = iCoordModelMapping->getFilenamesForCoordinate(pMapId, pXPos, pYPos);
+ if(nameCollection.size() == 0)
+ return true; // no data...
+
+ char dirfilename[500];
+ sprintf(dirfilename,"%s/%s.vmdir",iDestDir.c_str(),pDirFileName.c_str());
+ FILE *dirfile = fopen(dirfilename, "ab");
+ if(!dirfile)
+ {
+ printf("ERROR: Can't create file %s",dirfilename);
+ return false;
+ }
+
+ char destnamebuffer[500];
+ char fullnamedestnamebuffer[500];
+
+ if(nameCollection.iMainFiles.size() >0)
+ {
+ sprintf(destnamebuffer,"%03u_%i_%i.vmap",pMapId, pYPos, pXPos); // flip it here too
+ std::string checkDoubleStr = std::string(dirfilename);
+ checkDoubleStr.append("##");
+ checkDoubleStr.append(std::string(destnamebuffer));
+ // Check, if same file already is in the same dir file
+ if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr))
+ {
+ iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr);
+ fprintf(dirfile, "%s\n",destnamebuffer);
+ sprintf(fullnamedestnamebuffer,"%s/%s",iDestDir.c_str(),destnamebuffer);
+ modelContainer = processNames(nameCollection.iMainFiles, fullnamedestnamebuffer);
+ if(modelContainer)
+ pMC.append(modelContainer);
+ else
+ printf("warning: (if) problems in processing data for %s\n",destnamebuffer);
+ }
+ }
+ // process the large singe files
+ int pos = 0;
+ while(pos < nameCollection.iSingeFiles.size())
+ {
+ std::string destFileName = iDestDir;
+ destFileName.append("/");
+ std::string dirEntryName = getDirEntryNameFromModName(pMapId,nameCollection.iSingeFiles[pos]);
+ std::string checkDoubleStr = std::string(dirfilename);
+ checkDoubleStr.append("##");
+ checkDoubleStr.append(nameCollection.iSingeFiles[pos]);
+ // Check, if same file already is in the same dir file
+ if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr))
+ {
+ iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr);
+ fprintf(dirfile, "%s\n",dirEntryName.c_str());
+ destFileName.append(dirEntryName);
+
+ Array<std::string> positionarray;
+ positionarray.append(nameCollection.iSingeFiles[pos]);
+
+ if(!iCoordModelMapping->isAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]))
{
- Array<SubModel *> submodelArray;
- pTree->getMembers(submodelArray);
- int no = submodelArray.size();
- while(no > 0)
- {
- --no;
- delete submodelArray[no];
- }
+ modelContainer = processNames(positionarray, destFileName.c_str());
+ iCoordModelMapping->addAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]);
+ if(modelContainer)
+ pMC.append(modelContainer);
+ else
+ printf("warning: (while) problems in processing data for %s\n",destFileName.c_str());
}
+ }
+ ++pos;
+ }
- //=================================================================
+ fclose(dirfile);
+ return true;
+ }
- ModelContainer* TileAssembler::processNames(const Array<std::string>& pPositions, const char* pDestFileName)
- {
- ModelContainer *modelContainer = 0;
+ //=================================================================
- Vector3 basepos = Vector3(0,0,0);
- AABSPTree<SubModel *>* mainTree = new AABSPTree<SubModel *>();
+ void removeEntriesFromTree(AABSPTree<SubModel *>* pTree)
+ {
+ Array<SubModel *> submodelArray;
+ pTree->getMembers(submodelArray);
+ int no = submodelArray.size();
+ while(no > 0)
+ {
+ --no;
+ delete submodelArray[no];
+ }
+ }
- int pos = 0;
+ //=================================================================
- bool result = true;
- while(result && (pos < pPositions.size()))
- {
- std::string modelPosString = pPositions[pos];
- std::string modelFileName = getModNameFromModPosName(modelPosString);
+ ModelContainer* TileAssembler::processNames(const Array<std::string>& pPositions, const char* pDestFileName)
+ {
+ ModelContainer *modelContainer = 0;
- if(!fillModelIntoTree(mainTree, basepos, modelPosString, modelFileName))
- {
- result = false;
- break;
- }
- ++pos;
- }
- if(result && mainTree->size() > 0)
- {
- mainTree->balance();
- modelContainer = new ModelContainer(mainTree);
- modelContainer->writeFile(pDestFileName);
- }
- removeEntriesFromTree(mainTree);
+ Vector3 basepos = Vector3(0,0,0);
+ AABSPTree<SubModel *>* mainTree = new AABSPTree<SubModel *>();
- delete mainTree;
+ int pos = 0;
- return(modelContainer);
- }
+ bool result = true;
+ while(result && (pos < pPositions.size()))
+ {
+ std::string modelPosString = pPositions[pos];
+ std::string modelFileName = getModNameFromModPosName(modelPosString);
- //=================================================================
- bool TileAssembler::readRawFile(std::string& pModelFilename, ModelPosition& pModelPosition, AABSPTree<SubModel *> *pMainTree)
- {
- bool result = false;
-
- std::string filename = iSrcDir;
- if(filename.length() >0)
- filename.append("/");
- filename.append(pModelFilename);
- FILE *rf = fopen(filename.c_str(), "rb");
- if(!rf)
- {
- // depending on the extractor version, the data could be located in the root dir
- std::string baseModelFilename = pModelFilename.substr((pModelFilename.find_first_of("/")+1),pModelFilename.length());
- filename = iSrcDir;
- if(filename.length() >0)
- filename.append("/");
- filename.append(baseModelFilename);
- rf = fopen(filename.c_str(), "rb");
- }
- char ident[8];
-
- int trianglecount =0;
-
- #ifdef _ASSEMBLER_DEBUG
- int startgroup = 0; //2;
- int endgroup = INT_MAX; //2;
- fprintf(::g_df,"-------------------------------------------------\n");
- fprintf(::g_df,"%s\n", pModelFilename.c_str());
- fprintf(::g_df,"-------------------------------------------------\n");
- #else
- int startgroup = 0;
- int endgroup = INT_MAX;
- #endif
-
- if(rf)
- {
- if(fread(&ident, 8, 1, rf) != 1) { fclose(rf); return(false); }
- if(strcmp(ident, "VMAP001") == 0)
- {
- // OK, do nothing
- }
- else if(strcmp(ident, "VMAP002") == 0)
- {
- // we have to read one int. This is needed during the export and we have to skip it here
- int tempNVectors;
- if(fread(&tempNVectors, sizeof(int), 1, rf) != 1) { fclose(rf); return(false); }
+ if(!fillModelIntoTree(mainTree, basepos, modelPosString, modelFileName))
+ {
+ result = false;
+ break;
+ }
+ ++pos;
+ }
+ if(result && mainTree->size() > 0)
+ {
+ mainTree->balance();
+ modelContainer = new ModelContainer(mainTree);
+ modelContainer->writeFile(pDestFileName);
+ }
+ removeEntriesFromTree(mainTree);
- }
- else
- {
- // wrong version
- fclose(rf);
- return(false);
- }
- G3D::uint32 groups;
- char blockId[5];
- blockId[4] = 0;
- int blocksize;
+ delete mainTree;
- if(fread(&groups, sizeof(G3D::uint32), 1, rf) != 1) { fclose(rf); return(false); }
+ return(modelContainer);
+ }
- for(int g=0;g<(int)groups;g++)
- {
- // group MUST NOT have more then 65536 indexes !! Array will have a problem with that !! (strange ...)
- Array<int> tempIndexArray;
- Array<Vector3> tempVertexArray;
-
- AABSPTree<Triangle> *gtree = new AABSPTree<Triangle>();
-
- G3D::uint32 flags;
- if(fread(&flags, sizeof(G3D::uint32), 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
-
- G3D::uint32 branches;
- if(fread(&blockId, 4, 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
- if(strcmp(blockId, "GRP ") != 0) { fclose(rf); delete gtree; return(false); }
- if(fread(&blocksize, sizeof(int), 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
- if(fread(&branches, sizeof(G3D::uint32), 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
- for(int b=0;b<(int)branches; b++)
- {
- G3D::uint32 indexes;
- // indexes for each branch (not used jet)
- if(fread(&indexes, sizeof(G3D::uint32), 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
- }
-
- // ---- indexes
- if(fread(&blockId, 4, 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
- if(strcmp(blockId, "INDX") != 0) { fclose(rf); delete gtree; return(false); }
- if(fread(&blocksize, sizeof(int), 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
- unsigned int nindexes;
- if(fread(&nindexes, sizeof(G3D::uint32), 1, rf) != 1) { fclose(rf); return(false); }
- if(nindexes >0)
- {
- unsigned short *indexarray = new unsigned short[nindexes*sizeof(unsigned short)];
- if(fread(indexarray, sizeof(unsigned short), nindexes, rf) != nindexes) { fclose(rf); delete gtree; delete[] indexarray; return(false); }
- for(int i=0;i<(int)nindexes; i++)
- {
- unsigned short val = indexarray[i];
- tempIndexArray.append(val);
- }
- delete[] indexarray;
- }
-
- // ---- vectors
- if(fread(&blockId, 4, 1, rf) != 1) {fclose(rf); delete gtree; return(false); }
- if(strcmp(blockId, "VERT") != 0) { fclose(rf); delete gtree; return(false); }
- if(fread(&blocksize, sizeof(int), 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
- unsigned int nvectors;
- if(fread(&nvectors, sizeof(int), 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
- float *vectorarray = 0;
- if(nvectors >0)
- {
- vectorarray = new float[nvectors*sizeof(float)*3];
- if(fread(vectorarray, sizeof(float)*3, nvectors, rf) != nvectors) { fclose(rf); delete gtree; delete[] vectorarray; return(false); }
- }
- // ----- liquit
- if(flags & 1)
- {
- // we have liquit -> not handled yet ... skip
- if(fread(&blockId, 4, 1, rf) != 1) { fclose(rf); delete gtree; delete[] vectorarray; return(false); }
- if(strcmp(blockId, "LIQU") != 0) { fclose(rf); delete gtree; delete[] vectorarray; return(false); }
- if(fread(&blocksize, sizeof(int), 1, rf) != 1) { fclose(rf); delete gtree; delete[] vectorarray; return(false); }
- fseek(rf, blocksize, SEEK_CUR);
- }
-
- for(unsigned int i=0, indexNo=0; indexNo<nvectors; indexNo++)
- {
- Vector3 v = Vector3(vectorarray[i+2], vectorarray[i+1], vectorarray[i+0]);
- i+=3;
- v = pModelPosition.transform(v);
-
- float swapy = v.y;
- v.y = v.x;
- v.x = swapy;
-
- tempVertexArray.append(v);
- }
-
- // ---- calculate triangles
- int rest = nindexes%3;
- if(rest != 0)
- {
- nindexes -= rest;
- }
-
- for(unsigned int i=0;i<(nindexes);)
- {
- Triangle t = Triangle(tempVertexArray[tempIndexArray[i+2]], tempVertexArray[tempIndexArray[i+1]], tempVertexArray[tempIndexArray[i+0]] );
- i+=3;
- ++trianglecount;
- if(g>= startgroup && g <= endgroup)
- {
- gtree->insert(t);
- }
- }
-
- if(vectorarray != 0)
- {
- delete vectorarray;
- }
-
- if(gtree->size() >0)
- {
- gtree->balance();
- SubModel *sm = new SubModel(gtree);
- #ifdef _ASSEMBLER_DEBUG
- if(::g_df) fprintf(::g_df,"group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size());
- if(sm->getNTriangles() != gtree->memberTable.size())
- {
- if(::g_df) fprintf(::g_df,"ERROR !!!! group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size());
- }
- #endif
- sm->setBasePosition(pModelPosition.iPos);
- pMainTree->insert(sm);
- }
- delete gtree;
- }
- fclose(rf);
- result = true;
- }
- return(result);
- }
+ //=================================================================
+ bool TileAssembler::readRawFile(std::string& pModelFilename, ModelPosition& pModelPosition, AABSPTree<SubModel *> *pMainTree)
+ {
+ std::string filename = iSrcDir;
+ if(filename.length() >0)
+ filename.append("/");
+ filename.append(pModelFilename);
+ FILE *rf = fopen(filename.c_str(), "rb");
+ if(!rf)
+ {
+ // depending on the extractor version, the data could be located in the root dir
+ std::string baseModelFilename = pModelFilename.substr((pModelFilename.find_first_of("/")+1),pModelFilename.length());
+ filename = iSrcDir;
+ if(filename.length() >0)
+ filename.append("/");
+ filename.append(baseModelFilename);
+ rf = fopen(filename.c_str(), "rb");
+ }
+
+ if(!rf)
+ {
+ printf("ERROR: Can't open model file in form: %s",pModelFilename.c_str());
+ printf("... or form: %s",filename.c_str() );
+ return false;
+ }
+
+ char ident[8];
+
+ int trianglecount =0;
+
+ #ifdef _ASSEMBLER_DEBUG
+ int startgroup = 0; //2;
+ int endgroup = INT_MAX; //2;
+ fprintf(::g_df,"-------------------------------------------------\n");
+ fprintf(::g_df,"%s\n", pModelFilename.c_str());
+ fprintf(::g_df,"-------------------------------------------------\n");
+ #else
+ int startgroup = 0;
+ int endgroup = INT_MAX;
+ #endif
+
+ // temporary use defines to simplify read/check code (close file and return at fail)
+ #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \
+ fclose(rf); return(false); }
+ #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \
+ fclose(rf); return(false); }
+
+ READ_OR_RETURN(&ident, 8);
+ if(strcmp(ident, "VMAP001") == 0)
+ {
+ // OK, do nothing
+ }
+ else if(strcmp(ident, "VMAP002") == 0)
+ {
+ // we have to read one int. This is needed during the export and we have to skip it here
+ int tempNVectors;
+ READ_OR_RETURN(&tempNVectors, sizeof(int));
+
+ }
+ else
+ {
+ // wrong version
+ fclose(rf);
+ return(false);
+ }
+ G3D::uint32 groups;
+ char blockId[5];
+ blockId[4] = 0;
+ int blocksize;
- //=================================================================
+ READ_OR_RETURN(&groups, sizeof(G3D::uint32));
- bool TileAssembler::fillModelIntoTree(AABSPTree<SubModel *> *pMainTree, const Vector3& pBasePos, std::string& pPos, std::string& pModelFilename)
+ for(int g=0;g<(int)groups;g++)
+ {
+ // group MUST NOT have more then 65536 indexes !! Array will have a problem with that !! (strange ...)
+ Array<int> tempIndexArray;
+ Array<Vector3> tempVertexArray;
+
+ AABSPTree<Triangle> *gtree = new AABSPTree<Triangle>();
+
+ // add free gtree at fail
+ #undef READ_OR_RETURN
+ #undef CMP_OR_RETURN
+ #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \
+ fclose(rf); delete gtree; return(false); }
+ #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \
+ fclose(rf); delete gtree; return(false); }
+
+ G3D::uint32 flags;
+ READ_OR_RETURN(&flags, sizeof(G3D::uint32));
+
+ G3D::uint32 branches;
+ READ_OR_RETURN(&blockId, 4);
+ CMP_OR_RETURN(blockId, "GRP ");
+ READ_OR_RETURN(&blocksize, sizeof(int));
+ READ_OR_RETURN(&branches, sizeof(G3D::uint32));
+ for(int b=0;b<(int)branches; b++)
+ {
+ G3D::uint32 indexes;
+ // indexes for each branch (not used jet)
+ READ_OR_RETURN(&indexes, sizeof(G3D::uint32));
+ }
+
+ // ---- indexes
+ READ_OR_RETURN(&blockId, 4);
+ CMP_OR_RETURN(blockId, "INDX");
+ READ_OR_RETURN(&blocksize, sizeof(int));
+ unsigned int nindexes;
+ READ_OR_RETURN(&nindexes, sizeof(G3D::uint32));
+ if(nindexes >0)
+ {
+ unsigned short *indexarray = new unsigned short[nindexes*sizeof(unsigned short)];
+ READ_OR_RETURN(indexarray, nindexes*sizeof(unsigned short));
+ for(int i=0;i<(int)nindexes; i++)
{
- bool result = false;
- ModelPosition modelPosition;
- getModelPosition(pPos, modelPosition);
- // all should be relative to object base position
- modelPosition.moveToBasePos(pBasePos);
+ unsigned short val = indexarray[i];
+ tempIndexArray.append(val);
+ }
+ delete[] indexarray;
+ }
+
+ // ---- vectors
+ READ_OR_RETURN(&blockId, 4);
+ CMP_OR_RETURN(blockId, "VERT");
+ READ_OR_RETURN(&blocksize, sizeof(int));
+ unsigned int nvectors;
+ READ_OR_RETURN(&nvectors, sizeof(int));
+
+ float *vectorarray = 0;
+
+ // add vectorarray free
+ #undef READ_OR_RETURN
+ #undef CMP_OR_RETURN
+ #define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \
+ fclose(rf); delete gtree; delete[] vectorarray; return(false); }
+ #define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \
+ fclose(rf); delete gtree; delete[] vectorarray; return(false); }
+
+ if(nvectors >0)
+ {
+ vectorarray = new float[nvectors*sizeof(float)*3];
+ READ_OR_RETURN(vectorarray, nvectors*sizeof(float)*3);
+ }
+ // ----- liquit
+ if(flags & 1)
+ {
+ // we have liquit -> not handled yet ... skip
+ READ_OR_RETURN(&blockId, 4);
+ CMP_OR_RETURN(blockId, "LIQU");
+ READ_OR_RETURN(&blocksize, sizeof(int));
+ fseek(rf, blocksize, SEEK_CUR);
+ }
- modelPosition.init();
- if(readRawFile(pModelFilename, modelPosition, pMainTree))
- {
- result = true;
- }
+ for(unsigned int i=0, indexNo=0; indexNo<nvectors; indexNo++)
+ {
+ Vector3 v = Vector3(vectorarray[i+2], vectorarray[i+1], vectorarray[i+0]);
+ i+=3;
+ v = pModelPosition.transform(v);
+
+ float swapy = v.y;
+ v.y = v.x;
+ v.x = swapy;
+
+ tempVertexArray.append(v);
+ }
+
+ // ---- calculate triangles
+ int rest = nindexes%3;
+ if(rest != 0)
+ {
+ nindexes -= rest;
+ }
- return result;
+ for(unsigned int i=0;i<(nindexes);)
+ {
+ Triangle t = Triangle(tempVertexArray[tempIndexArray[i+2]], tempVertexArray[tempIndexArray[i+1]], tempVertexArray[tempIndexArray[i+0]] );
+ i+=3;
+ ++trianglecount;
+ if(g>= startgroup && g <= endgroup)
+ {
+ gtree->insert(t);
}
+ }
+
+ // drop of temporary use defines
+ #undef READ_OR_RETURN
+ #undef CMP_OR_RETURN
- //=================================================================
- void TileAssembler::getModelPosition(std::string& pPosString, ModelPosition& pModelPosition)
+ if(vectorarray != 0)
+ {
+ delete vectorarray;
+ }
+
+ if(gtree->size() >0)
+ {
+ gtree->balance();
+ SubModel *sm = new SubModel(gtree);
+ #ifdef _ASSEMBLER_DEBUG
+ if(::g_df) fprintf(::g_df,"group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size());
+ if(sm->getNTriangles() != gtree->memberTable.size())
{
- float vposarray[3];
- float vdirarray[3];
- float scale;
+ if(::g_df) fprintf(::g_df,"ERROR !!!! group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size());
+ }
+ #endif
+ sm->setBasePosition(pModelPosition.iPos);
+ pMainTree->insert(sm);
+ }
+ delete gtree;
+ }
+ fclose(rf);
+ return true;
+ }
+
+ //=================================================================
- size_t spos = pPosString.find_first_of('#');
- std::string stripedPosString = pPosString.substr(spos+1,pPosString.length());
+ bool TileAssembler::fillModelIntoTree(AABSPTree<SubModel *> *pMainTree, const Vector3& pBasePos, std::string& pPos, std::string& pModelFilename)
+ {
+ ModelPosition modelPosition;
+ getModelPosition(pPos, modelPosition);
+ // all should be relative to object base position
+ modelPosition.moveToBasePos(pBasePos);
- sscanf(stripedPosString.c_str(), "%f,%f,%f_%f,%f,%f_%f",
- &vposarray[0],&vposarray[1],&vposarray[2],
- &vdirarray[0],&vdirarray[1],&vdirarray[2],
- &scale);
+ modelPosition.init();
- pModelPosition.iPos = Vector3(vposarray[0], vposarray[1], vposarray[2]);
- pModelPosition.iDir = Vector3(vdirarray[0], vdirarray[1], vdirarray[2]);
- pModelPosition.iScale = scale;
+ return readRawFile(pModelFilename, modelPosition, pMainTree);
+ }
- }
- //==========================================
+ //=================================================================
+ void TileAssembler::getModelPosition(std::string& pPosString, ModelPosition& pModelPosition)
+ {
+ float vposarray[3];
+ float vdirarray[3];
+ float scale;
+
+ size_t spos = pPosString.find_first_of('#');
+ std::string stripedPosString = pPosString.substr(spos+1,pPosString.length());
- } // VMAP
+ sscanf(stripedPosString.c_str(), "%f,%f,%f_%f,%f,%f_%f",
+ &vposarray[0],&vposarray[1],&vposarray[2],
+ &vdirarray[0],&vdirarray[1],&vdirarray[2],
+ &scale);
+ pModelPosition.iPos = Vector3(vposarray[0], vposarray[1], vposarray[2]);
+ pModelPosition.iDir = Vector3(vdirarray[0], vdirarray[1], vdirarray[2]);
+ pModelPosition.iScale = scale;
+
+ }
+ //==========================================
+} // VMAP
diff --git a/src/shared/vmap/TileAssembler.h b/src/shared/vmap/TileAssembler.h
index a2fe8055fcf..d2183794a9e 100644
--- a/src/shared/vmap/TileAssembler.h
+++ b/src/shared/vmap/TileAssembler.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/TreeNode.cpp b/src/shared/vmap/TreeNode.cpp
index 113199235bf..c884f9b3b1d 100644
--- a/src/shared/vmap/TreeNode.cpp
+++ b/src/shared/vmap/TreeNode.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/TreeNode.h b/src/shared/vmap/TreeNode.h
index d71396487b9..1b9532001e5 100644
--- a/src/shared/vmap/TreeNode.h
+++ b/src/shared/vmap/TreeNode.h
@@ -1,7 +1,7 @@
/*
-* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
-* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+* Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/VMapDefinitions.h b/src/shared/vmap/VMapDefinitions.h
index 0800bfbda88..fd28a91d515 100644
--- a/src/shared/vmap/VMapDefinitions.h
+++ b/src/shared/vmap/VMapDefinitions.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/VMapFactory.cpp b/src/shared/vmap/VMapFactory.cpp
index 2dad2047189..5189f79daba 100644
--- a/src/shared/vmap/VMapFactory.cpp
+++ b/src/shared/vmap/VMapFactory.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/VMapFactory.h b/src/shared/vmap/VMapFactory.h
index 9a4493d8817..f3375d723c1 100644
--- a/src/shared/vmap/VMapFactory.h
+++ b/src/shared/vmap/VMapFactory.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/VMapManager.cpp b/src/shared/vmap/VMapManager.cpp
index 3b93b63086b..f5c2640be70 100644
--- a/src/shared/vmap/VMapManager.cpp
+++ b/src/shared/vmap/VMapManager.cpp
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/VMapManager.h b/src/shared/vmap/VMapManager.h
index 8ece6de4652..bfeba3cfe67 100644
--- a/src/shared/vmap/VMapManager.h
+++ b/src/shared/vmap/VMapManager.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2009 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
diff --git a/src/shared/vmap/VMapTools.h b/src/shared/vmap/VMapTools.h
index 4961064d188..3af3a29310d 100644
--- a/src/shared/vmap/VMapTools.h
+++ b/src/shared/vmap/VMapTools.h
@@ -1,7 +1,7 @@
/*
-* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
-* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+* Copyright (C) 2008-2009 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