diff --git a/src/viewer/ModelContainerView.cpp b/src/viewer/ModelContainerView.cpp index 26c4039..c924174 100644 --- a/src/viewer/ModelContainerView.cpp +++ b/src/viewer/ModelContainerView.cpp @@ -9,7 +9,8 @@ #include "ModelContainerView.h" #include "Config/Config.h" - +#include +using namespace std; // only for "load *" console command : #ifdef WIN32 @@ -59,7 +60,7 @@ namespace VMAP iShowPortals = false; iShowPath = false; - iVARAreaRef = VARArea::create (settings.window.width * settings.window.height * 60 * 40); // thats huge ! + iVARAreaRef = VARArea::create (settings.window.width * settings.window.height * 60); // thats huge ! iMap = mapId; ix = x; @@ -194,6 +195,38 @@ namespace VMAP offset += vArray.size (); //break; } + // ok so what we have is + // 1. an array iGlobArray that contains all points in this model. + // we need to save it as: v iGlobArray[index].x iGlobArray[index].y iGlobArray[index].z + // 2. an array containing all lines, and thus verticles. + /* vArray.append (t.vertex (0)); + vArray.append (t.vertex (1)); <- this is a triangle out of 3 vertexes + vArray.append (t.vertex (2)); + + iArray.append (count + 0); + iArray.append (count + 1); + iArray.append (count + 1); + iArray.append (count + 2); + iArray.append (count + 2); + iArray.append (count + 0); + */ + // How does it work. the face of a triangle consists of + // f 1 2 3 + // f 4 5 6 + // f 6 7 8 + // i think :/ + int numberofpoints = iGlobArray.size(); + // lets create file in two steps + ofstream SaveFile("map.obj"); + // 1. write down all points + for (int count = 0; count < numberofpoints ; count++) { + SaveFile << "v " << iGlobArray[count].x << " " << iGlobArray[count].y << " " << iGlobArray[count].z << "\n"; + } + // 2 write down all surfaces wich is just all combinantion of points. + for (int count = 1; count < numberofpoints; ) { + SaveFile << "f " << count++ << " " << count++ << " " << count++ << "\n"; + } + SaveFile.close(); iTriVarTable.set (pName, new VAR (iGlobArray, iVARAreaRef)); iTriIndexTable.set (pName, iIndexArray); }