void ContractLineRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << ContractLine << Date << PostingCode << Contract; RecordFactory::DumpDouble(of, Amount); RecordFactory::DumpDouble(of, Discount); of << RefNum << SvcAddr << CoveragePeriod << RenewalPeriod << ConsecutiveMonthsLeft << ConsecutiveMonthsTotal; RecordFactory::DumpDouble(of, Deviation); of.width(3); of << Location << '\n'; of.fill(fc); }
//============================================================================ // This method writes the information related to the NAClusterInfo class to a // logfile called "NAClusterInfo.txt". //============================================================================ void NAClusterInfo::captureNAClusterInfo(ofstream & naclfile) { CollIndex i, ci; char filepath[OSIM_PATHMAX]; char filename[OSIM_FNAMEMAX]; // We don't capture data members that are computed during the compilation of // a query. These include: // // * smpCount_; // * tableToClusterMap_; // * activeClusters_; // naclfile << "localCluster_: " << localCluster_ << endl << "localSMP_: " << localSMP_ << endl; CollIndex *key_collindex; maps *val_maps; // Iterator for logging all the entries in clusterToCPUMap_ HashDictionary. NAHashDictionaryIterator<CollIndex, maps> C2CPUIter (*clusterToCPUMap_, NULL, NULL); naclfile << "clusterToCPUMap_: " << C2CPUIter.entries() << " :" << endl; if (C2CPUIter.entries() > 0) { // Write the header line for the table. naclfile << " "; naclfile.width(10); naclfile << "clusterNum" << " "; naclfile << "cpuList" << endl; for (i=0; i<C2CPUIter.entries(); i++) { C2CPUIter.getNext(key_collindex, val_maps); naclfile << " "; naclfile.width(10); naclfile << *key_collindex << " "; naclfile << val_maps->list->entries() << " : "; for (ci=0; ci<val_maps->list->entries(); ci++) { naclfile.width(3); naclfile << (*(val_maps->list))[ci] << " "; } naclfile << endl; } } Int32 * nodeID = NULL; NAString* nodeName = NULL; NAHashDictionaryIterator<Int32, NAString> nodeNameAndIDIter (*nodeIdToNodeNameMap_); naclfile << "nodeIdAndNodeNameMap: " << nodeNameAndIDIter.entries() << endl; for(nodeNameAndIDIter.getNext(nodeID, nodeName); nodeID && nodeName; nodeNameAndIDIter.getNext(nodeID, nodeName)) { naclfile << *nodeID << " " << nodeName->data() << endl; } // Now save the OS-specific information to the NAClusterInfo.txt file captureOSInfo(naclfile); }
void PostingCode::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << PostCode; of.width(3); of << Code; of << ShortDesc << Description << '\n'; of.fill(fc); }
void DivisionRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << Division; of.width(2); of << DivNum; of << DivisionName << DivisionAddr1 << DivisionAddr2 << DivisionAddr3 << '\n'; of.fill(fc); }
void InfoHeaderRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << InfoHeader << '\n'; of.fill(fc); }
void PromptPayMsgRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << PromptPayMsg; of << Message << '\n'; of.fill(fc); }
void InstImage(IMG img, void *v) { outfile << "-----------" << endl <<"Image name = " << IMG_Name(img) << endl << flush; ADDRINT mappedStart = IMG_StartAddress(img); ADDRINT mappedEnd = mappedStart + IMG_SizeMapped(img); outfile << hex << showbase; outfile << "mapped start " << mappedStart << " mapped end " << mappedEnd << endl; ADDRINT virtStart = IMG_LowAddress(img); ADDRINT virtEnd = IMG_HighAddress(img); outfile << "low addr " << virtStart << " high address " << virtEnd << endl; for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec)) { ADDRINT secData = reinterpret_cast <ADDRINT > (SEC_Data(sec)); if (secData) { if ((secData < mappedStart) || (secData >= mappedEnd)) { cout << "ERROR: Image " << IMG_Name(img) << " Section " << SEC_Name(sec) << " data wrong ptr: " << secData << endl; exit(-1); } } ADDRINT secAddr = SEC_Address(sec); if (secAddr) { if ((secAddr < virtStart) || (secAddr >= virtEnd)) { cout << "ERROR: Image " << IMG_Name(img) << "Section " << SEC_Name(sec) << " address wrong ptr: " << secAddr << endl; exit(-1); } } outfile << "Section \""; outfile.width(30); outfile << left << SEC_Name(sec) << "\""; outfile << " \t data ptr "; outfile.width(sizeof(ADDRINT)*2+4); outfile << left << secData << " addr ptr " << secAddr << endl; } }
void TrailerRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << Trailer; of << Date << Time; of.fill(' '); of.width(7); of << TotalItems; of.fill('0'); RecordFactory::DumpDouble(of, TotalBilled, 10); of << '\n'; of.fill(fc); }
void MeterInfoRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << MeterInfo; of << '\n'; of.fill(fc); }
void StatementAddrRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << StatementAddr; of.fill(' '); of << Address << '\n'; of.fill(fc); }
void LineItemAddrRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << LineItemAddr; of.fill(' '); of << Address << '\n'; of.fill(fc); }
void FinChgInfoRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << FinChgInfo; of << ChargeDate << RefNum << '\n'; of.fill(fc); }
void ContractFlagsRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << ContractFlags; of << TotalMessage << BudgetIncludeFlag << '\n'; of.fill(fc); }
void ContractInfoRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << ContractInfo; of << Contract; of << Text << '\n'; of.fill(fc); }
void ContractTaxLineRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << ContractTaxLine; RecordFactory::DumpDouble(of, SalesTax); RecordFactory::DumpDouble(of, TotalAmount); of << '\n'; of.fill(fc); }
void TrailerRec::dumpNew(ofstream &of, int dumpCount, double dump_stmt_bal) const { of.width(2); char fc = of.fill('0'); of << Trailer; time_t tt = time(0); struct tm *t = localtime(&tt); char timebuf[14+1]; strftime(timebuf, sizeof(timebuf), "%m%d%y%I:%M %p", t); of << timebuf; of.fill(' '); of.width(7); of << dumpCount; of.fill('0'); RecordFactory::DumpDouble(of, dump_stmt_bal, 10); of << '\n'; of.fill(fc); }
/// \brief Opens the statistics file and sets the properties for the ofstream /// /// \param file An uninitialized ofstream for the statistics files void CMinimizerThread::OpenStatisticsFile(ofstream & file) { stringstream filename; if(file.is_open()) file.close(); // Open the statistics file for writing: filename.str(""); filename << mSaveDirectory << "/best_fit.txt"; file.open(filename.str().c_str()); file.width(15); file.precision(8); }
void DiscntInfoRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << DiscntInfo; of << DiscDate; RecordFactory::DumpDouble(of, DiscAmt, 9, 2, true); of << '\n'; of.fill(fc); }
char Scanner::NextChar() { char c; sourceFile.get(c); if (c == '\n') { listFile.width(6); listFile << ++lineNumber << " " << lineBuffer << endl; lineBuffer = ""; } else lineBuffer += c; return c; }
/** writes the genotype of the individual to the stream (for multiple instances of the same trait)*/ void FileHandler::FHwriteIndividual2Stream(ofstream& FILE, Individual* ind, const int& ploidy, const int& position){ int nb_locus; unsigned char** seq; for(int t=0; t<_nb_trait; ++t){ nb_locus = _trait[t]->get_nb_locus(); seq = (unsigned char**)ind->getTrait(_TTidx[t])->get_sequence(); for(int k = 0; k < nb_locus; ++k) { for (int l = 0; l < ploidy; ++l) { FILE.fill('0'); FILE.width(position); FILE<<(unsigned int)(seq[k][l]+1); } FILE<<" "; } } }
static void image_pixel( void *userdata, ofstream& fp, unsigned char *rgb) { unsigned char transp[3] = {255,0,255}; int grey; if ( *rgb == transp[0] && *(rgb+1) == transp[1] && *(rgb+2) == transp[2]) grey = 255; else grey = (int) ((0.0 + *rgb + *(rgb+1) + *(rgb+2)) / 3 + 0.5); fp.width(2); fp << grey; if ( ++char_cnt >= 40) { char_cnt = 0; fp << endl; } }
void isis2ascii(Buffer &in) { for(int i = 0; i < in.size(); i++) { fout.width(13); // Width must be set everytime if(IsSpecial(in[i])) { if(IsNullPixel(in[i])) fout << "NULL"; if(IsHrsPixel(in[i])) fout << "HRS"; if(IsHisPixel(in[i])) fout << "HIS"; if(IsLrsPixel(in[i])) fout << "LRS"; if(IsLisPixel(in[i])) fout << "LIS"; } else { fout << in[i]; } } fout << endl; }
/** * Function to write Undergraduate student's data to an output file * stream that has been opened */ void Undergraduate::write_to_stream (ofstream & outputfile) { // Left align the data outputfile.setf(ios::left); outputfile.width(MAXIMUM_NUMBER_OF_CHARACTERS); outputfile << "Undergraduate"; outputfile.width(MAXIMUM_NUMBER_OF_CHARACTERS); outputfile << Student::get_lastname(); outputfile.width(MAXIMUM_NUMBER_OF_CHARACTERS); outputfile << get_firstname(); outputfile.width(MAXIMUM_NUMBER_OF_CHARACTERS); outputfile << get_ssn(); outputfile.width(MAXIMUM_NUMBER_OF_CHARACTERS); outputfile << get_phone(); outputfile.width(MAXIMUM_NUMBER_OF_CHARACTERS); outputfile << get_age(); outputfile.width(MAXIMUM_NUMBER_OF_CHARACTERS); outputfile << get_major(); outputfile.width(MAXIMUM_NUMBER_OF_CHARACTERS); outputfile << get_minor() << endl; //outputfile << endl; }
void DocumentHeaderRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << DocHeader; of << docType << docDate << db << budgetDue << budgetMonDue; for (int i = 0; i < 11; i++) { of << docMessage[i]; } of << logo << expDB << '\n'; of.fill(fc); }
void CreditInfoRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << CreditInfo; RecordFactory::DumpDouble(of, FinanceCharge); RecordFactory::DumpDouble(of, BudgetInterest); if (file_ver <= 1) { RecordFactory::DumpDouble(of, CurrentOld); RecordFactory::DumpDouble(of, OldPastDue1); RecordFactory::DumpDouble(of, OldPastDue2); RecordFactory::DumpDouble(of, OldPastDue3); RecordFactory::DumpDouble(of, OldPastDue4); } else { RecordFactory::DumpDouble(of, Current); RecordFactory::DumpDouble(of, PastDue1); RecordFactory::DumpDouble(of, PastDue2); RecordFactory::DumpDouble(of, PastDue3); RecordFactory::DumpDouble(of, PastDue4); } if (PriceProgGallonsRemain * 100 < 0.99) of << " "; else RecordFactory::DumpDouble(of, PriceProgGallonsRemain); of << Addr << DunningMsg[0] << DunningMsg[1]; for (int i = 0; i < 24; i++) of << SummaryMsg[i]; RecordFactory::DumpDouble(of, FinanceChargeAnnualRate, 4, 2, true); RecordFactory::DumpDouble(of, FinanceChargeMonthlyRate, 4, 2, true); RecordFactory::DumpDouble(of, AvgDailyBal, 9, 2, true); of << FinanceChargeDate; if (file_ver >= 1) { of << FinanceChargeDueDate; RecordFactory::DumpDouble(of, LateFee); } if (file_ver >= 2) { RecordFactory::DumpDouble(of, Current, 12); RecordFactory::DumpDouble(of, PastDue1, 12); RecordFactory::DumpDouble(of, PastDue2, 12); RecordFactory::DumpDouble(of, PastDue3, 12); RecordFactory::DumpDouble(of, PastDue4, 12); } of << "\n"; of.fill(fc); }
std::vector<token_lexeme_pair> lexically_analyze(ifstream &code_file, ofstream &lex_file, ofstream &symbol_file) { if ( ! code_file.is_open()) throw "File not found"; std::unordered_set<string> symbols; std::vector<token_lexeme_pair> token_lexemes; int line_number = 1; DFA dfaz[DFA_COUNT]; initialize(dfaz[0], dfaz[1], dfaz[2], dfaz[3], dfaz[4], dfaz[5], dfaz[6], dfaz[7], dfaz[8], dfaz[9]); int curr_dfa = 0; int consecutive_break_count = 0; // To check for symbols not in the language. std::string _subject((std::istreambuf_iterator<char>(code_file)), (std::istreambuf_iterator<char>())); for (unsigned int _index = 0; _index < _subject.size(); _index++) { if (_subject[_index] == '\n') line_number++; if (consecutive_break_count == DFA_COUNT || _subject[_index] == ' ' || _subject[_index] == '\n' || _subject[_index] == '\t' || _subject[_index] == '\0') { consecutive_break_count = 0; continue; } int i = _index; string str; int last_state = 0; for (unsigned int j = i; ; j++) { // DFA breaks. int result = dfaz[curr_dfa].simulate_symbol(_subject[j]); if (result == dfaz[curr_dfa].get_reserved_state()) { if (last_state) { // Keep the 'str' string because a token has been found. consecutive_break_count = 0; _index = j - 1; // Continue where this DFA broke. } else { // Return to original position. str.clear(); _index = i - 1; consecutive_break_count++; } break; } // DFA enters into a neutral state. if (result == 0) { if (_subject[j] == '\n') line_number++; str.push_back(_subject[j]); last_state = 0; } // DFA enters into an accept state. if (result == 1) { _index = j; str.push_back(_subject[j]); last_state = 1; } } // Token found. if (str.size() > 0) { if (dfaz[curr_dfa].getName() == "identifier" && check_keyword(str)) { token_lexemes.push_back(token_lexeme_pair("keyword", str, line_number)); } else { token_lexemes.push_back(token_lexeme_pair(dfaz[curr_dfa].getName(), str, line_number)); } if (dfaz[curr_dfa].getName() == "identifier" && !check_keyword(str)) { symbols.insert(str); } } // Change DFA. curr_dfa++; if (curr_dfa == DFA_COUNT) curr_dfa = 0; } for (const auto& elem : symbols) { symbol_file << elem <<endl; } lex_file << setw(15); for (std::vector<token_lexeme_pair>::iterator it = token_lexemes.begin(); it != token_lexemes.end(); it++) { lex_file.width(30); lex_file << "(" + it->name + ", '" + it->lexeme + "') "; lex_file.width(20); lex_file<< "Line: " + std::to_string(it->line_number) << endl; } return token_lexemes; }
void LineItemRec::dump(ofstream &of) const { of.width(2); char fc = of.fill('0'); of << LineItem; of << TransDate << TransCode; of.fill('0'); if (file_ver <= 1) { RecordFactory::DumpDouble(of, TransDollarsOld); RecordFactory::DumpDouble(of, TransGallonsOld, 9, 1); } else { RecordFactory::DumpDouble(of, TransDollars); RecordFactory::DumpDouble(of, TransGallons, 9, 1); } RecordFactory::DumpDouble(of, TransUnitPrice, 8, 4); of << RefNum << Addr << DetailMsg[0] << DetailMsg[1] << CylQuantDeliv << CylQuantReturn << PONum; if (TransWasMinCharge) of << 'Y'; else of << ' '; if (file_ver == 0) { RecordFactory::DumpDouble(of, OrigTransDollarsOld); } else { RecordFactory::DumpDouble(of, OrigTransDollars); } if (file_ver <= 1) { of << " "; } else if (file_ver >= 2) { of << DueDate << NetDays; if (KeyOffFlag || !Statement->isOpenItem()) of << ' '; else of << 'N'; if (EFTTrans) of << 'E'; else of << 'N'; RecordFactory::DumpDouble(of, TransGallons, 10); RecordFactory::DumpDouble(of, TransDollars, 10); RecordFactory::DumpDouble(of, OrigTransDollars, 10); } if (file_ver >= 3) { char fc = of.fill('0'); of.width(3); of << TankNum; of.fill(fc); } if (file_ver >= 4) { RecordFactory::DumpDouble(of, TransUnitPrice2, 8); } of << '\n'; of.fill(fc); }
/// output Blast-like alignments (code modified from SSW-library) void report_blast (ofstream &fileout, s_align* a, char* read_name, char* read_seq, char* read_qual, char* ref_name, char* ref_seq, double evalue, uint32_t readlen, uint32_t bitscore, bool strand, // 1: forward aligned ; 0: reverse complement aligned double id, double coverage, uint32_t mismatches, uint32_t gaps ) { char to_char[5] = {'A','C','G','T','N'}; // Blast-like pairwise alignment (only for aligned reads) if ( blast_outfmt == 0 ) { fileout << "Sequence ID: "; char* tmp = ref_name; while (*tmp != '\n') fileout << *tmp++; fileout << endl; fileout << "Query ID: "; tmp = read_name; while (*tmp != '\n') fileout << *tmp++; fileout << endl; fileout << "Score: " << a->score1 << " bits (" << bitscore << ")\t"; fileout.precision(3); fileout << "Expect: " << evalue << "\t"; if (strand) fileout << "strand: +\n\n"; else fileout << "strand: -\n\n"; if (a->cigar) { uint32_t i, c = 0, left = 0, e = 0, qb = a->ref_begin1, pb = a->read_begin1; //mine while (e < a->cigarLen || left > 0) { int32_t count = 0; int32_t q = qb; int32_t p = pb; fileout << "Target: "; fileout.width(8); fileout << q+1 << " "; for (c = e; c < a->cigarLen; ++c) { uint32_t letter = 0xf&*(a->cigar + c); uint32_t length = (0xfffffff0&*(a->cigar + c))>>4; uint32_t l = (count == 0 && left > 0) ? left: length; for (i = 0; i < l; ++i) { if (letter == 1) fileout << "-"; else { fileout << to_char[(int)*(ref_seq + q)]; ++q; } ++ count; if (count == 60) goto step2; } } step2: fileout << " " << q << "\n"; fileout.width(20); fileout << " "; q = qb; count = 0; for (c = e; c < a->cigarLen; ++c) { uint32_t letter = 0xf&*(a->cigar + c); uint32_t length = (0xfffffff0&*(a->cigar + c))>>4; uint32_t l = (count == 0 && left > 0) ? left: length; for (i = 0; i < l; ++i) { if (letter == 0) { if ((char)to_char[(int)*(ref_seq + q)] == (char)to_char[(int)*(read_seq + p)]) fileout << "|"; else fileout << "*"; ++q; ++p; } else { fileout << " "; if (letter == 1) ++p; else ++q; } ++ count; if (count == 60) { qb = q; goto step3; } } } step3: p = pb; fileout << "\nQuery: "; fileout.width(9); fileout << p+1 << " "; count = 0; for (c = e; c < a->cigarLen; ++c) { uint32_t letter = 0xf&*(a->cigar + c); uint32_t length = (0xfffffff0&*(a->cigar + c))>>4; uint32_t l = (count == 0 && left > 0) ? left: length; for (i = 0; i < l; ++i) { if (letter == 2) fileout << "-"; else { fileout << (char)to_char[(int)*(read_seq + p)]; ++p; } ++ count; if (count == 60) { pb = p; left = l - i - 1; e = (left == 0) ? (c + 1) : c; goto end; } } } e = c; left = 0; end: fileout << " " << p << "\n\n"; } }
void MapAndDump(char* pcRow) { std::map<int, string> msg; std::map<int, string>::iterator it; string sLocal(pcRow); string sDummy; size_t pos; if ((pos = sLocal.find(cSep)) == string::npos) { return; } sLocal = sLocal.substr(sLocal.substr(0, pos).find_last_of(' ') + 1); sLocal = sLocal.substr(strcspn(sLocal.c_str(), "0123456789")); string sFixString = sLocal; if ((pos = sFixString.find_last_of(cSep)) != string::npos) { sFixString = sFixString.substr(0, pos + 1); } string sTag; while((sLocal.length() > 0) && (isdigit(sLocal[0]) || isspace(sLocal[0]))) { pos = sLocal.find(cSep); if (pos == string::npos) { sTag = sLocal; sLocal = ""; } else { sTag = sLocal.substr(0, pos); sLocal = sLocal.substr(pos + 1); } // cerr << "New tag: " << sTag <<endl; pos = sTag.find("="); msg[atoi(sTag.substr(0, pos).c_str())] = sTag.substr(pos + 1); } if (lOptValue & PRGOPT_MSGLIST) { pos = sFixTypesList.find((char)(*msg[35].c_str())); if (pos == string::npos) { return; } } if (!(lOptValue & PRGOPT_SEPARATOR) && ((it = msg.find(35)) == msg.end())) { return; } if ((lOptValue & PRGOPT_FILTER) && !isFilterTrue(msg, iFilterOnTag, sFilterOnTagValue)) return; if (lOptValue & PRGOPT_BAREDUMP) { os << sFixString << endl; return; } if (lOptValue & PRGOPT_PRINTHDR) { os << "\n----------------*" << endl; os << "Message Type: " << mFixMsgType[(char)(*msg[35].c_str())] << endl; os << "Sent from : " << msg[49] << endl; os << "Sent to : " << msg[56] << endl; os << endl; } sDummy = " "; string sSep = ""; stringstream ssCsvSep; ssCsvSep << csvSep; for(it = msg.begin(); it != msg.end(); it++) { int iTag = (*it).first; if (!(lOptValue & PRGOPT_TAGLIST) || (lOptValue & PRGOPT_TAGLIST) && (isInList(iTag))) { if (!(lOptValue & PRGOPT_COMMASEP)) { os.width(iTagWidth); os << (*it).first; os << " => "; if (iDescWidth) { os << (*it).second.substr(0, iDescWidth); if ((*it).second.substr(0, iDescWidth).length() < iDescWidth) { os << sDummy.substr(0, iDescWidth - (*it).second.substr(0, iDescWidth).length()); } os << endl; } else { os << (*it).second.c_str() << endl; } } else { os << sSep << (*it).second.c_str(); ssCsvSep >> sSep; } } } os << endl; }
void GeometryExportFile::writeModel( Object *o, ofstream &out ) { out << "{ 'MODL'\n" " { 'SRC' \"Innovation 3D exported by WF geometry exporter V0.11\"" " }\n" " { 'TRGT' \"World Foundy Game Engine (www.worldfoundry.org)\"\n" " }\n" << endl; out << " { 'NAME' \"" << o->getName() << "\"\n" " }\n"; out.setf(std::ios::showpoint); //Vector4 pos; float texturex=0; float texturey=0; float color=0; //pos = o->getPosition(); int oldWidth = out.width(8); char oldFill = out.fill('0'); // kts i3d is a left handed coordinate system with positive y up, WF is left handed with positive z up // so I rotate -90 degrees around x putting y up (swap y&z, negate the new y) VertexList *vlist = o->getVerts(); int size = (int)vlist->size(); Vector4 vertpos; Vector4 uv; for(int i=0; i<size; i++) { vertpos = (*vlist)[i]->getPosition(); VertexAndUV vuv; vuv.position = vertpos; } CreateVertUVList(o); WriteVertexList(out); out << " { 'MATL' //flags: [FLAT_SHADED=0, GOURAUD_SHADED=1] [SOLID_COLOR=0, TEXTURE_MAPPED=2] [SINGLE_SIDED=0, TWO_SIDED=8]" << endl; //save materials here. ObjectDB *odb = I3D::getDB(); TextureMaterial *m; for(int materialIndex=0; materialIndex<odb->numMaterials(); materialIndex++) { m = odb->getMaterial(materialIndex); _MaterialOnDisk mod; mod._materialFlags = 0; if(m->enable_texture) mod._materialFlags |= TEXTURE_MAPPED; for(int temp=0;temp<MATERIAL_NAME_LEN;temp++) mod.textureName[temp] = 0; if(m->texture) strncpy(mod.textureName, m->texture->getFilename()->ascii(), MATERIAL_NAME_LEN); mod.textureName[MATERIAL_NAME_LEN-1] = 0; // make sure it is 0 terminated mod._color = ((((unsigned int)m->cDiffuse.r)<<16) | (((unsigned int)m->cDiffuse.g)<<8) | ((unsigned int)m->cDiffuse.b)); out << " //Material " << materialIndex << ": flags: " << mod._materialFlags << ", color: " << hex << mod._color << dec << ", texturename: \"" << mod.textureName << "\"" << endl; out << " "; for(int index=0;index<sizeof(_MaterialOnDisk);index++) { out << (unsigned int)(((unsigned char*)&mod)[index]) << "y "; } out << " // #" << materialIndex << endl; } out << " }" << endl; // faces size = (int)o->numFaces(); out << " { 'FACE' // count = " << size << endl; for(int faceIndex=0; faceIndex<size; faceIndex++) { Face* face = o->getFace(faceIndex); vector<int> *vlist = face->getVerts(); vector<int> *uvlist = face->getUVs(); assert(vlist->size() >= 3); // must be at least a triangle // output list of triangles for this face // make a fan of triangles, first vertex is the same for all polys int vert1 = LookupVertUVEntry(CreateVUV(*face,vlist, 0, o->getTextureMaterial())); // second point int vert2 = LookupVertUVEntry(CreateVUV(*face,vlist, 1, o->getTextureMaterial())); for(int vertexIndex=2;vertexIndex<vlist->size();vertexIndex++) { VertexAndUV vuv3 = CreateVUV(*face,vlist, vertexIndex, o->getTextureMaterial()); int vert3 = LookupVertUVEntry(vuv3); int materialIndex = -1; if(o->getTextureMaterial() != 0) { materialIndex = I3D::getDB()->getMaterialIndex(o->getTextureMaterial()); } else cerr << "material not set!" << endl; out << " " << vert1 << "w " << vert2 << "w " << vert3 << "w " << materialIndex << "w // face #" << faceIndex << ", poly #" << vertexIndex << endl; // vert2 on next fan is vert3 from this fan vert2 = vert3; } } out << " }" << endl; out << "}" << endl; }