1 /* 2 * Copyright (C) 2005 Andreas Volz 3 * Copyright (C) 2006-2007 MakeHuman Project 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation; either version 3 of 8 * the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software Foun- 17 * dation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 * USA 19 * 20 * File: RIBExporter.h 21 * Project: MakeHuman <info@makehuman.org>, http://www.makehuman.org/ 22 * Library: ANIMORPH 23 * 24 * For individual developers look into the AUTHORS file. 25 * 26 */ 27 28 #ifndef RIBEXPORTER_H 29 #define RIBEXPORTER_H 1 30 31 #ifdef HAVE_CONFIG_H 32 #include <config.h> 33 #endif 34 #include <iostream> 35 #include <fstream> 36 #include <iostream> 37 #include <list> 38 #include "Mesh.h" 39 #include "Matrix.h" 40 #include "util.h" 41 #include "FaceGroup.h" 42 43 using std::string; 44 using std::list; 45 using std::ostringstream; 46 using std::ifstream; 47 48 namespace Animorph { 49 50 typedef std::pair <string, string> StringPair; 51 52 /*! \brief Export Mesh objects as RenderMan Interface Bytestream 53 * 54 * See eg. http://www.3dartist.com/WP/formats/index.html#rib 55 * 56 */ 57 class RIBExporter 58 { 59 protected: 60 Mesh &mesh; 61 Matrix tm; 62 63 /* 64 void createObjectStream (ostringstream &outStream, 65 const string& basename); 66 */ 67 void createObjectStream (ostringstream &out_stream, 68 const FGroupData &facegroupdata, 69 const VertexData &vertexgroupdata); 70 71 void replaceRIBTags (ifstream &in_stream, 72 ostringstream &outStream, 73 const list <StringPair> &replaceList); 74 75 public: 76 /*! 77 * \param _mesh construct RIBExporter from a Mesh object 78 */ RIBExporter(Animorph::Mesh & _mesh)79 RIBExporter (Animorph::Mesh &_mesh) : mesh (_mesh) 80 { 81 tm.identity (); 82 } 83 84 /*! 85 * \param tm the Matrix which transforms the Mesh before exporting 86 */ setTransformationMatrix(const Matrix & tm)87 void setTransformationMatrix (const Matrix &tm) {this->tm = tm;} 88 89 /// 90 /*! 91 92 */ 93 bool exportFile (const string &outFile); 94 95 bool exportFile (const string &templateDirectory, 96 const string &templateFile, 97 const string &outFile, 98 const list <StringPair> &replaceList); 99 100 }; 101 102 } 103 104 #endif // OBJEXPORTER_H 105