/* * Copyright (C) 2005-2012 MaNGOS * * 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 */ #define _CRT_SECURE_NO_WARNINGS #include "vmapexport.h" #include "model.h" #include "wmo.h" #include "mpqfile.h" #include #include #include extern HANDLE WorldMpq; Model::Model(std::string &filename) : filename(filename), vertices(0), indices(0) { } bool Model::open() { MPQFile f(WorldMpq, filename.c_str()); ok = !f.isEof(); if (!ok) { f.close(); // Do not show this error on console to avoid confusion, the extractor can continue working even if some models fail to load //printf("Error loading model %s\n", filename.c_str()); return false; } _unload(); memcpy(&header, f.getBuffer(), sizeof(ModelHeader)); if(header.nBoundingTriangles > 0) { f.seek(0); f.seekRelative(header.ofsBoundingVertices); vertices = new Vec3D[header.nBoundingVertices]; f.read(vertices,header.nBoundingVertices*12); for (uint32 i=0; i0) { fwrite(indices, sizeof(unsigned short), nIndexes, output); } fwrite("VERT",4, 1, output); wsize = sizeof(int) + sizeof(float) * 3 * nVertices; fwrite(&wsize, sizeof(int), 1, output); fwrite(&nVertices, sizeof(int), 1, output); if(nVertices >0) { for(uint32 vpos=0; vpos