void BmpImageExporter::saveToStream(const ImageRawData& image, std::ostream& os) { if (image.isNull()) throw Exception("[BmpImageExporter::save] null image given"); BitmapFileHeader bf; // bmp fileheader BitmapInfoHeader * bfinfo = (BitmapInfoHeader *) image.data(); // uliss: TODO! check for endianness bf.bfType = 0x4d42; // 'BM' bf.bfSize = BMP_FILE_HEADER_SIZE + image.dataSize(); // fileheader + infoheader + palette bf.bfOffBits = BMP_FILE_HEADER_SIZE + sizeof(BitmapInfoHeader) + bfinfo->biClrUsed * sizeof(RGBQuad); os.write((char*) &bf, sizeof(bf)); if (os.fail()) throw Exception("[BmpImageExporter::save] failed"); os << image; if (os.fail()) throw Exception("[BmpImageExporter::save] failed"); }
void FeatureFileIO::SaveFile (FeatureVectorList& _data, const KKStr& _fileName, FeatureNumListConst& _selFeatures, std::ostream& _out, kkuint32& _numExamplesWritten, VolConstBool& _cancelFlag, bool& _successful, KKStr& _errorMessage, RunLog& _log ) { _errorMessage = "Driver: '" + this->DriverName () + "' does not implement 'SaveFile' method."; _log.Level (-1) << endl << "FeatureFileIO::SaveFile ***ERROR*** " << _errorMessage << endl << " _data.size : " << _data.size () << endl << " _fileName : " << _fileName << endl << " _selFeatures : " << _selFeatures.ToCommaDelStr () << endl << " _out.fail : " << _out.fail () << endl << " _cancelFlag : " << _cancelFlag << endl << endl; _successful = false; _numExamplesWritten = 0; return; }
bool VehicleStateBasicLux::serialize(std::ostream& os) const { const std::istream::pos_type startPos = os.tellp(); lock(); ibeo::writeLE(os, m_timestamp); ibeo::writeLE(os, m_scanNumber); ibeo::writeLE(os, m_errorFlags); ibeo::writeLE(os, m_longitudinalVelocity); ibeo::writeLE(os, m_steeringWheeAngle); ibeo::writeLE(os, m_wheelAngle); ibeo::writeLE(os, m_reserved0); ibeo::writeLE(os, m_xPos); ibeo::writeLE(os, m_yPos); ibeo::writeLE(os, m_courseAngle); ibeo::writeLE(os, m_timeDiff); ibeo::writeLE(os, m_xDiff); ibeo::writeLE(os, m_yDiff); ibeo::writeLE(os, m_yaw); ibeo::writeLE(os, m_reserved1); ibeo::writeLE(os, m_currentYawRate); ibeo::writeLE(os, m_reserved2); unlock(); return !os.fail() && ((os.tellp() - startPos) == this->getSerializedSize()); }
bool WriteBinaryMaterial(const Material& material, std::ostream& stream) { IOUtils::WriteBinaryFloat(material.diffuse.r, stream); IOUtils::WriteBinaryFloat(material.diffuse.g, stream); IOUtils::WriteBinaryFloat(material.diffuse.b, stream); IOUtils::WriteBinaryFloat(material.diffuse.a, stream); IOUtils::WriteBinaryFloat(material.ambient.r, stream); IOUtils::WriteBinaryFloat(material.ambient.g, stream); IOUtils::WriteBinaryFloat(material.ambient.b, stream); IOUtils::WriteBinaryFloat(material.ambient.a, stream); IOUtils::WriteBinaryFloat(material.specular.r, stream); IOUtils::WriteBinaryFloat(material.specular.g, stream); IOUtils::WriteBinaryFloat(material.specular.b, stream); IOUtils::WriteBinaryFloat(material.specular.a, stream); /* emissive.r */ IOUtils::WriteBinaryFloat(0.0f, stream); /* emissive.g */ IOUtils::WriteBinaryFloat(0.0f, stream); /* emissive.b */ IOUtils::WriteBinaryFloat(0.0f, stream); /* emissive.a */ IOUtils::WriteBinaryFloat(0.0f, stream); /* power */ IOUtils::WriteBinaryFloat(0.0f, stream); return !stream.fail(); }
// ヘッダを書き込む bool WriteHeader(std::ostream& stream, std::uint32_t hash_value, const std::string& architecture) { stream.write(reinterpret_cast<const char*>(&kVersion), sizeof(kVersion)); stream.write(reinterpret_cast<const char*>(&hash_value), sizeof(hash_value)); const std::uint32_t size = static_cast<std::uint32_t>(architecture.size()); stream.write(reinterpret_cast<const char*>(&size), sizeof(size)); stream.write(architecture.data(), size); return !stream.fail(); }
/** * Dump the current status to a stream * * @param[out] os The output stream where the data is saved * * @exception std::runtime_error When failed to dump. */ void dump(std::ostream& os) const { os.write((char*)&b_, sizeof(b_)); os.write((char*)&M_[0], sizeof(M_[0]) * M_.size()); os.write((char*)&c_, sizeof(c_)); os.write((char*)&p_, sizeof(p_)); if(os.fail()){ throw std::runtime_error("Failed to dump"); } }
bool ReaderWriterGZ::write(std::ostream& fout, const std::string& source) const { int ret, flush = Z_FINISH; unsigned have; z_stream strm; unsigned char out[CHUNK]; int level = 6; int stategy = Z_DEFAULT_STRATEGY; // looks to be the best for .osg/.ive files //int stategy = Z_FILTERED; //int stategy = Z_HUFFMAN_ONLY; //int stategy = Z_RLE; /* allocate deflate state */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; ret = deflateInit2(&strm, level, Z_DEFLATED, 15+16, // +16 to use gzip encoding 8, // default stategy); if (ret != Z_OK) return false; strm.avail_in = source.size(); strm.next_in = (Bytef*)(&(*source.begin())); /* run deflate() on input until output buffer not full, finish compression if all of source has been read in */ do { strm.avail_out = CHUNK; strm.next_out = out; ret = deflate(&strm, flush); /* no bad return value */ if (ret == Z_STREAM_ERROR) { OSG_NOTICE<<"Z_STREAM_ERROR"<<std::endl; return false; } have = CHUNK - strm.avail_out; if (have>0) fout.write((const char*)out, have); if (fout.fail()) { (void)deflateEnd(&strm); return false; } } while (strm.avail_out == 0); /* clean up and return */ (void)deflateEnd(&strm); return true; }
bool CModelFile::WriteBinaryModel(std::ostream& stream) { if (m_triangles.size() == 0) { GetLogger()->Error("Empty model\n"); return false; } NewModelHeader header; header.version = 1; header.totalTriangles = m_triangles.size(); IOUtils::WriteBinary<4, int>(header.version, stream); IOUtils::WriteBinary<4, int>(header.totalTriangles, stream); for (int i = 0; i < static_cast<int>( m_triangles.size() ); ++i) { NewModelTriangle1 t; t.p1 = m_triangles[i].p1; t.p2 = m_triangles[i].p2; t.p3 = m_triangles[i].p3; t.material = m_triangles[i].material; t.tex1Name = m_triangles[i].tex1Name; t.tex2Name = m_triangles[i].tex2Name; t.variableTex2 = m_triangles[i].variableTex2; t.state = m_triangles[i].state; switch (m_triangles[i].lodLevel) { case LOD_Constant: t.lodLevel = 0; break; case LOD_Low: t.lodLevel = 1; break; case LOD_Medium: t.lodLevel = 2; break; case LOD_High: t.lodLevel = 3; break; } WriteBinaryVertexTex2(t.p1, stream); WriteBinaryVertexTex2(t.p2, stream); WriteBinaryVertexTex2(t.p3, stream); WriteBinaryMaterial(t.material, stream); IOUtils::WriteBinaryString<1>(t.tex1Name, stream); IOUtils::WriteBinaryString<1>(t.tex2Name, stream); IOUtils::WriteBinaryBool(t.variableTex2, stream); IOUtils::WriteBinary<4, int>(t.lodLevel, stream); IOUtils::WriteBinary<4, int>(t.state, stream); if (stream.fail()) { GetLogger()->Error("Error writing model file\n"); return false; } } return true; }
bool Event::Write(std::ostream & o) const { if(o.fail()) return false; o.write(reinterpret_cast<const char*>(pack), sp); o.write(&status, 1); if(size) o.write(reinterpret_cast<const char*>(data), size); return true; }
void cmnDataSerializeBinary_size_t(const size_t & data, std::ostream & outputStream) throw (std::runtime_error) { outputStream.write(reinterpret_cast<const char *>(&data), sizeof(size_t)); if (outputStream.fail()) { cmnThrow("cmnDataSerializeBinary(type): error occured with std::ostream::write"); } }
void cmnDataSerializeText_size_t(const size_t & data, std::ostream & outputStream, const char CMN_UNUSED(delimiter)) throw (std::runtime_error) { outputStream << data; if (outputStream.fail()) { cmnThrow("cmnDataSerializeText_size_t: error occured with std::ostream::write"); } }
bool WriteTextVertexTex2(const VertexTex2& vertex, std::ostream& stream) { stream << "c " << vertex.coord.x << " " << vertex.coord.y << " " << vertex.coord.z; stream << " n " << vertex.normal.x << " " << vertex.normal.y << " " << vertex.normal.z; stream << " t1 " << vertex.texCoord.x << " " << vertex.texCoord.y; stream << " t2 " << vertex.texCoord2.x << " " << vertex.texCoord2.y; stream << std::endl; return !stream.fail(); }
void cmnDataSerializeBinary(const std::string & data, std::ostream & outputStream) throw (std::runtime_error) { cmnData<size_t>::SerializeBinary(data.size(), outputStream); outputStream.write(data.data(), data.size()); if (outputStream.fail()) { cmnThrow("cmnDataSerializeBinary(std::string): error occured with std::ostream::write"); } }
bool S3D::WritePoint( std::ostream& aFile, const SGPOINT& aPoint ) { aFile.write( (char*)&aPoint.x, sizeof(aPoint.x) ); aFile.write( (char*)&aPoint.y, sizeof(aPoint.y) ); aFile.write( (char*)&aPoint.z, sizeof(aPoint.z) ); if( aFile.fail() ) return false; return true; }
virtual WriteResult writeImage(const Image& image,std::ostream& fout, const osgDB::ReaderWriter::Options* options) const { ive::DataOutputStream out(&fout, options); out.writeImage(ive::IMAGE_INCLUDE_DATA, const_cast<osg::Image*>(&image)); if (fout.fail()) return WriteResult::ERROR_IN_WRITING_FILE; if (out.getException()) { OSG_WARN<<"Error writing IVE image: "<< out.getException()->getError() << std::endl; return WriteResult::FILE_NOT_HANDLED; } return WriteResult::FILE_SAVED; }
/* Compress from file source to file dest until EOF on source. def() returns Z_OK on success, Z_MEM_ERROR if memory could not be allocated for processing, Z_STREAM_ERROR if an invalid compression level is supplied, Z_VERSION_ERROR if the version of zlib.h and the version of the library linked do not match, or Z_ERRNO if there is an error reading or writing the files. */ bool Misc::deflate(const uint8_t* in, size_t inlen, std::ostream& dest, string& err, int CHUNK, int level) { int ret, flush; unsigned have; z_stream strm; if ( level == -1 ) level = Z_BEST_COMPRESSION; if ( CHUNK == -1 ) CHUNK = CL_Z_DEFAULT_CHUNK; uint8_t* out = (uint8_t*)malloc(CHUNK); /* allocate deflate state */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; ret = deflateInit(&strm, level); if (ret != Z_OK){ free(out); zerr(ret, err); return false; } /* compress until end of file */ do { strm.avail_in = inlen; strm.next_in = (uint8_t*)in; flush = Z_FINISH; /* run deflate() on input until output buffer not full, finish compression if all of source has been read in */ do { strm.avail_out = CHUNK; strm.next_out = out; ret = ::deflate(&strm, flush); /* no bad return value */ assert(ret != Z_STREAM_ERROR); /* state not clobbered */ have = CHUNK - strm.avail_out; dest.write( (char*)out,have); if ( dest.fail() ) { (void)deflateEnd(&strm); free(out); zerr(Z_ERRNO, err); return false; } } while (strm.avail_out == 0); assert(strm.avail_in == 0); /* all input will be used */ /* done when last data in file processed */ } while (flush != Z_FINISH); assert(ret == Z_STREAM_END); /* stream will be complete */ /* clean up and return */ (void)deflateEnd(&strm); free(out); return true; }
bool S3D::WriteColor( std::ostream& aFile, const SGCOLOR& aColor ) { float r, g, b; aColor.GetColor( r, g, b ); aFile.write( (char*)&r, sizeof(float) ); aFile.write( (char*)&g, sizeof(float) ); aFile.write( (char*)&b, sizeof(float) ); if( aFile.fail() ) return false; return true; }
bool S3D::WriteVector( std::ostream& aFile, const SGVECTOR& aVector ) { double x, y, z; aVector.GetVector( x, y, z ); aFile.write( (char*)&x, sizeof(double) ); aFile.write( (char*)&y, sizeof(double) ); aFile.write( (char*)&z, sizeof(double) ); if( aFile.fail() ) return false; return true; }
bool WriteBinaryVertex(Vertex vertex, std::ostream& stream) { IOUtils::WriteBinaryFloat(vertex.coord.x, stream); IOUtils::WriteBinaryFloat(vertex.coord.y, stream); IOUtils::WriteBinaryFloat(vertex.coord.z, stream); IOUtils::WriteBinaryFloat(vertex.normal.x, stream); IOUtils::WriteBinaryFloat(vertex.normal.y, stream); IOUtils::WriteBinaryFloat(vertex.normal.z, stream); IOUtils::WriteBinaryFloat(vertex.texCoord.x, stream); IOUtils::WriteBinaryFloat(vertex.texCoord.y, stream); return !stream.fail(); }
bool server_response::write(std::ostream &os) { // Set "content-length" header auto i=headers.find("content-length"); if (i==headers.end()) { headers.insert(std::make_pair("Content-Length", boost::lexical_cast<std::string>(get_content_length()))); } else { i->second.assign(boost::lexical_cast<std::string>(get_content_length())); } // Write headers if (!write_header(os)) return false; // Write body os.write(&(raw_body_stream_.vector()[0]), raw_body_stream_.vector().size()); return !os.eof() && !os.fail() && !os.bad(); }
bool server_response::write_header(std::ostream &os) { std::string ka; if (keep_alive) { ka="keep-alive"; } else { ka="close"; } auto i=headers.find("connection"); if (i==headers.end()) { headers.insert(std::make_pair("Connection", ka)); } else { i->second.assign(ka); } if (!common::response::write_header(os)) return false; return !os.eof() && !os.fail() && !os.bad(); }
bool ObjectLux::serialize(std::ostream& os) const { const std::istream::pos_type startPos = os.tellp(); ibeo::writeLE(os, m_id); ibeo::writeLE(os, m_age); ibeo::writeLE(os, m_predictionAge); ibeo::writeLE(os, m_relativeTimestamp); m_refPoint.serialize(os); m_refPointSigma.serialize(os); m_closestPoint.serialize(os); m_boundingBoxCenter.serialize(os); ibeo::writeLE(os, m_boundingBoxWidth); ibeo::writeLE(os, m_boundingBoxLength); m_objectBoxCenter.serialize(os); ibeo::writeLE(os, m_objectBoxSizeX); ibeo::writeLE(os, m_objectBoxSizeY); ibeo::writeLE(os, m_objectBoxOrientation); m_absVelocity.serialize(os); ibeo::writeLE(os, m_absVelSigmaX); ibeo::writeLE(os, m_absVelSigmaY); m_relVelocity.serialize(os); const UINT16 c=m_class; ibeo::writeLE(os, c); ibeo::writeLE(os, m_classAge); ibeo::writeLE(os, m_classCertainty); if (m_numContourPointsIsValid) ibeo::writeLE(os, m_numContourPoints); else ibeo::writeLE(os, ObjectLux::contourIsInvalid); std::vector<Point2d>::const_iterator cpIter = m_contourPoints.begin(); for (; cpIter != m_contourPoints.end(); ++cpIter) { cpIter->serialize(os); } return !os.fail() && ((os.tellp() - startPos) == this->getSerializedSize()); }
bool ObjectListEcu::serialize(std::ostream& os) const { const std::istream::pos_type startPos = os.tellp(); lock(); ibeo::writeBE(os, m_scanStartTimestamp); const UINT16 nbOfObjects = this->m_objects.size(); ibeo::writeBE(os, nbOfObjects); std::vector<ObjectEcu>::const_iterator objIter = m_objects.begin(); for (; objIter != m_objects.end(); ++objIter) { objIter->serialize(os); } unlock(); return !os.fail() && ((os.tellp() - startPos) == this->getSerializedSize()); }
bool WriteTextMaterial(const Material& material, std::ostream& stream) { stream << "dif " << material.diffuse.r << " " << material.diffuse.g << " " << material.diffuse.b << " " << material.diffuse.a; stream << " amb " << material.ambient.r << " " << material.ambient.g << " " << material.ambient.b << " " << material.ambient.a; stream << " spc " << material.specular.r << " " << material.specular.g << " " << material.specular.b << " " << material.specular.a; stream << std::endl; return !stream.fail(); }
void MagickImageExporter::saveToStream(const ImageRawData& image, std::ostream& os) { if (image.isNull()) throw Exception("[MagickImageExporter::save] null image given"); if (os.fail()) throw Exception("[MagickImageExporter::save] invalid stream"); Magick::Blob blob(image.data(), image.dataSize()); try { Magick::Image image; image.verbose(true); image.magick("DIB"); image.read(blob); image.magick(formatToString(format())); image.write(&blob); os.write((char*) blob.data(), blob.length()); } catch (Magick::Exception &e) { std::cerr << e.what() << "\n"; throw Exception("MagickImageExporter::load failed"); } }
bool ScanPointEcu::serialize(std::ostream& os) const { const std::istream::pos_type startPos = os.tellp(); ibeo::writeBE(os, m_posX); ibeo::writeBE(os, m_posY); ibeo::writeBE(os, m_posZ); ibeo::writeBE(os, m_epw); ibeo::writeBE(os, m_deviceId); ibeo::writeBE(os, m_layer); ibeo::writeBE(os, m_echo); ibeo::writeBE(os, m_reserved); ibeo::writeBE(os, m_timeOffset); ibeo::writeBE(os, m_flags); ibeo::writeBE(os, m_segmentId); return !os.fail() && ((os.tellp() - startPos) == this->getSerializedSize()); }
bool MTrk::Write(std::ostream & o) const { if(o.fail()) return false; o.write(ID_MTRK, 4); u32 size = 0; std::list<Event *>::const_iterator it1 = events.begin(); std::list<Event *>::const_iterator it2 = events.end(); for(; it1 != it2; ++it1) if(*it1) size += (*it1)->Size(); u32 x = size; SwapBE32(x); o.write(reinterpret_cast<char *>(&x), 4); if(events.size()) { it1 = events.begin(); it2 = events.end(); for(; it1 != it2; ++it1) if(*it1) (*it1)->Write(o); } return true; }
void LLFilterSD2XMLRPC::streamOut(std::ostream& ostr, const LLSD& sd) { ostr << "<value>"; switch(sd.type()) { case LLSD::TypeMap: { #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(map) BEGIN" << llendl; #endif ostr << "<struct>"; if(ostr.fail()) { llinfos << "STREAM FAILURE writing struct" << llendl; } LLSD::map_const_iterator it = sd.beginMap(); LLSD::map_const_iterator end = sd.endMap(); for(; it != end; ++it) { ostr << "<member><name>" << xml_escape_string((*it).first) << "</name>"; streamOut(ostr, (*it).second); if(ostr.fail()) { llinfos << "STREAM FAILURE writing '" << (*it).first << "' with sd type " << (*it).second.type() << llendl; } ostr << "</member>"; } ostr << "</struct>"; #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(map) END" << llendl; #endif break; } case LLSD::TypeArray: { #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(array) BEGIN" << llendl; #endif ostr << "<array><data>"; LLSD::array_const_iterator it = sd.beginArray(); LLSD::array_const_iterator end = sd.endArray(); for(; it != end; ++it) { streamOut(ostr, *it); if(ostr.fail()) { llinfos << "STREAM FAILURE writing array element sd type " << (*it).type() << llendl; } } #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(array) END" << llendl; #endif ostr << "</data></array>"; break; } case LLSD::TypeUndefined: // treat undefined as a bool with a false value. case LLSD::TypeBoolean: #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(bool)" << llendl; #endif ostr << "<boolean>" << (sd.asBoolean() ? "1" : "0") << "</boolean>"; break; case LLSD::TypeInteger: #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(int)" << llendl; #endif ostr << "<i4>" << sd.asInteger() << "</i4>"; break; case LLSD::TypeReal: #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(real)" << llendl; #endif ostr << "<double>" << sd.asReal() << "</double>"; break; case LLSD::TypeString: #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(string)" << llendl; #endif ostr << "<string>" << xml_escape_string(sd.asString()) << "</string>"; break; case LLSD::TypeUUID: #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(uuid)" << llendl; #endif // serialize it as a string ostr << "<string>" << sd.asString() << "</string>"; break; case LLSD::TypeURI: { #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(uri)" << llendl; #endif // serialize it as a string ostr << "<string>" << xml_escape_string(sd.asString()) << "</string>"; break; } case LLSD::TypeBinary: { #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(binary)" << llendl; #endif // this is pretty inefficient, but we'll deal with that // problem when it becomes one. ostr << "<base64>"; LLSD::Binary buffer = sd.asBinary(); if(!buffer.empty()) { // *TODO: convert to LLBase64 int b64_buffer_length = apr_base64_encode_len(buffer.size()); char* b64_buffer = new char[b64_buffer_length]; b64_buffer_length = apr_base64_encode_binary( b64_buffer, &buffer[0], buffer.size()); ostr.write(b64_buffer, b64_buffer_length - 1); delete[] b64_buffer; } ostr << "</base64>"; break; } case LLSD::TypeDate: #if LL_SPEW_STREAM_OUT_DEBUGGING llinfos << "streamOut(date)" << llendl; #endif // no need to escape this since it will be alpha-numeric. ostr << "<dateTime.iso8601>" << sd.asString() << "</dateTime.iso8601>"; break; default: // unhandled type llwarns << "Unhandled structured data type: " << sd.type() << llendl; break; } ostr << "</value>"; }
// Write a C/C++ numerical type template <class T> bool WriteAttrNum(std::ostream& os, T n) { os << attB << n << attE; return (!os.fail()); }
bool CModelFile::WriteTextModel(std::ostream& stream) { if (m_triangles.size() == 0) { GetLogger()->Error("Empty model\n"); return false; } NewModelHeader header; header.version = 1; header.totalTriangles = m_triangles.size(); stream << "# Colobot text model" << std::endl; stream << std::endl; stream << "### HEAD" << std::endl; stream << "version " << header.version << std::endl; stream << "total_triangles " << header.totalTriangles << std::endl; stream << std::endl; stream << "### TRIANGLES" << std::endl; for (int i = 0; i < static_cast<int>( m_triangles.size() ); ++i) { NewModelTriangle1 t; t.p1 = m_triangles[i].p1; t.p2 = m_triangles[i].p2; t.p3 = m_triangles[i].p3; t.material = m_triangles[i].material; t.tex1Name = m_triangles[i].tex1Name; t.tex2Name = m_triangles[i].tex2Name; t.variableTex2 = m_triangles[i].variableTex2; t.state = m_triangles[i].state; switch (m_triangles[i].lodLevel) { case LOD_Constant: t.lodLevel = 0; break; case LOD_Low: t.lodLevel = 1; break; case LOD_Medium: t.lodLevel = 2; break; case LOD_High: t.lodLevel = 3; break; } stream << "p1 "; WriteTextVertexTex2(t.p1, stream); stream << "p2 "; WriteTextVertexTex2(t.p2, stream); stream << "p3 "; WriteTextVertexTex2(t.p3, stream); stream << "mat "; WriteTextMaterial(t.material, stream); stream << "tex1 " << t.tex1Name << std::endl; stream << "tex2 " << t.tex2Name << std::endl; stream << "var_tex2 " << (t.variableTex2 ? 'Y' : 'N') << std::endl; stream << "lod_level " << t.lodLevel << std::endl; stream << "state " << t.state << std::endl; stream << std::endl; if (stream.fail()) { GetLogger()->Error("Error writing model file\n"); return false; } } return true; }