本文整理汇总了C++中COFile::serial方法的典型用法代码示例。如果您正苦于以下问题:C++ COFile::serial方法的具体用法?C++ COFile::serial怎么用?C++ COFile::serial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COFile
的用法示例。
在下文中一共展示了COFile::serial方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void NLPACS::CZoneTessellation::saveTessellation(COFile &output)
{
output.serialCont(_Vertices);
uint i;
for (i=0; i<_Tessellation.size(); ++i)
_Tessellation[i].ElemId = i;
uint32 numTessel = (uint32)_Tessellation.size();
output.serial(numTessel);
for (i=0; i<_Tessellation.size(); ++i)
{
_Tessellation[i].serial(output, _Tessellation);
}
}
示例2: main
//.........这里部分代码省略.........
CConfigFile::CVar &cell_raytrace_delta_z = parameter.getVar ("cell_raytrace_delta_z");
float cellRaytraceDeltaZ= cell_raytrace_delta_z.asFloat ();
// colIdentifierPrefix
CConfigFile::CVar &col_identifier_prefix = parameter.getVar ("col_identifier_prefix");
string colIdentifierPrefix= col_identifier_prefix.asString ();
// colIdentifierSuffix
CConfigFile::CVar &col_identifier_suffix = parameter.getVar ("col_identifier_suffix");
string colIdentifierSuffix= col_identifier_suffix.asString ();
// colIdentifierSuffix
CConfigFile::CVar &build_debug_surface_shape = parameter.getVar ("build_debug_surface_shape");
bool buildDebugSurfaceShape= build_debug_surface_shape.asInt()!=0;
// try to open gr and rbank
CRetrieverBank *retrieverBank= NULL;
CGlobalRetriever *globalRetriever= NULL;
uint32 grFileDate= 0;
uint32 rbankFileDate= 0;
if( grFile!="" && rbankFile!="" )
{
CIFile fin;
// serial the retrieverBank. Exception if not found.
fin.open(CPath::lookup(rbankFile));
retrieverBank= new CRetrieverBank;
retrieverBank->setNamePrefix(CFile::getFilenameWithoutExtension(rbankFile).c_str ());
// Add the search path for LR files
CPath::addSearchPath (CFile::getPath(rbankFile));
fin.serial(*retrieverBank);
fin.close();
// serial the globalRetriever. Exception if not found.
fin.open(CPath::lookup(grFile));
globalRetriever= new CGlobalRetriever;
// set the RetrieverBank before loading
globalRetriever->setRetrieverBank(retrieverBank);
fin.serial(*globalRetriever);
fin.close();
// Get File Dates
rbankFileDate= CFile::getFileModificationDate(CPath::lookup(rbankFile));
grFileDate= CFile::getFileModificationDate(CPath::lookup(grFile));
// And init them.
globalRetriever->initAll();
}
// Scan and load all files .ig in directories
//=================
vector<string> listFile;
vector<CInstanceGroup*> listIg;
vector<string> listIgFileName;
vector<string> listIgPathName;
CPath::getPathContent(directoryIn, false, false, true, listFile);
for(uint iFile=0; iFile<listFile.size(); iFile++)
{
string &igFile= listFile[iFile];
// verify it is a .ig.
if( CFile::getExtension(igFile) == "ig" )
示例3: dump
//-----------------------------------------------
// dump :
// Create a file with information to debug.
//-----------------------------------------------
void dump(const std::string &name)
{
// Write information to start as the version
COFile fStart;
if(fStart.open(name + "_start.rec", false, false))
{
CVectorD currentPos = UserEntity->pos();
fStart.serialVersion(RecordVersion);
fStart.serial(currentPos);
// Close the File.
fStart.close();
}
else
nlwarning("dump: cannot open/create the file '%s_start.rec'.", name.c_str());
// Write the DB
IngameDbMngr.write(name + "_db.rec");
// Open the file.
COFile f;
if(f.open(name + ".rec", false, false))
{
// Dump entities.
EntitiesMngr.dump(f);
// Dump Client CFG.
ClientCfg.serial(f);
// Close the File.
f.close();
}
else
nlwarning("dump: cannot open/create the file '%s.rec'.", name.c_str());
// Open the file.
if(f.open(name + ".xml", false, true))
{
// Create the XML stream
COXml output;
// Init
if(output.init (&f, "1.0"))
{
// Open the XML Dump.
output.xmlPush("XML");
// Dump Client CFG.
ClientCfg.serial(output);
// Dump entities.
EntitiesMngr.dumpXML(output);
// Close the XML Dump.
output.xmlPop();
// Flush the stream, write all the output file
output.flush();
}
else
nlwarning("dump: cannot initialize '%s.xml'.", name.c_str());
// Close the File.
f.close();
}
else
nlwarning("dump: cannot open/create the file '%s.xml'.", name.c_str());
}// dump //
示例4: int
// ***************************************************************************
int main(int argc, char *argv[])
{
// Filter addSearchPath
NLMISC::createDebug();
NLMISC::InfoLog->addNegativeFilter ("adding the path");
if (argc != 3)
{
nlwarning("usage : %s hlsinfo_dir output_name ", argv[0]);
exit(-1);
}
// get all .hlsinfo file in directory.
vector<string> files;
vector<string> hlsInfofiles;
NLMISC::CPath::getPathContent(argv[1], false, false, true, files);
hlsInfofiles.reserve(files.size());
uint k;
for (k = 0; k < files.size(); ++k)
{
std::string fileExt = NLMISC::strupr(NLMISC::CFile::getExtension(files[k]));
if(fileExt=="HLSINFO")
hlsInfofiles.push_back(files[k]);
}
// If none, quit.
if(hlsInfofiles.empty())
exit(-1);
// Concat all hlsinfo in a Bank
CHLSTextureBank textBank;
for (k = 0; k < hlsInfofiles.size(); ++k)
{
printf("HLSBank Process [%2d]\r", (uint)(100*k/hlsInfofiles.size()));
try
{
CIFile f(hlsInfofiles[k]);
CHLSBankTextureInfo textInfo;
f.serial(textInfo);
addTextToBank(textInfo, textBank);
}
catch(Exception &e)
{
nlwarning("ERROR: Unable to process %s. Reason: %s. Processing next", hlsInfofiles[k].c_str(), e.what());
}
}
// compile it
textBank.compile();
// save the bank.
COFile fOut;
try
{
if(!fOut.open(argv[2]))
throw int(0);
fOut.serial(textBank);
fOut.close();
}
catch(Exception &e)
{
nlwarning("ERROR: Unable to write HLS Bank %s: %s", argv[2], e.what());
exit(-1);
}
catch(...)
{
nlwarning("ERROR: Unable to write HLS Bank %s.", argv[2]);
exit(-1);
}
return 0;
}
示例5: main
//.........这里部分代码省略.........
if(lighterDesc.OverSampling<2)
lighterDesc.OverSampling= 0;
// For ig of Zones, never disable Sun contrib !!!
lighterDesc.DisableSunContribution= false;
// Get the search pathes
CConfigFile::CVar &search_pathes = parameter.getVar ("search_pathes");
uint path;
for (path = 0; path < (uint)search_pathes.size(); path++)
{
// Add to search path
CPath::addSearchPath (search_pathes.asString(path));
}
// A landscape allocated with new: it is not delete because destruction take 3 secondes more!
CLandscape *landscape=new CLandscape;
landscape->init();
// A zone lighter
CMyIgZoneLighter lighter;
lighter.init ();
// A vector of zone id
vector<uint> listZoneId;
// The zone
CZone zone;
// List of ig
std::list<CInstanceGroup*> instanceGroup;
// Load
zone.serial (inputFile);
inputFile.close();
// Load ig of the zone
string igName = getName (argv[1])+".ig";
string igNameLookup = CPath::lookup (igName, false, false);
if (!igNameLookup.empty())
igName = igNameLookup;
bool zoneIgLoaded;
// Try to open the file
CInstanceGroup *centerInstanceGroup= NULL;
if (inputFile.open (igName))
{
// load the center ig
centerInstanceGroup=new CInstanceGroup;
// Serial it
centerInstanceGroup->serial (inputFile);
inputFile.close();
// Add to the list
instanceGroup.push_back (centerInstanceGroup);
zoneIgLoaded = true;
}
else
{
// Warning
fprintf (stderr, "Warning: can't load instance group %s\n", igName.c_str());
zoneIgLoaded = false;
}
示例6: main
//.........这里部分代码省略.........
}
// Sample Rate.
try
{
CConfigFile::CVar &anim_sample_rate = parameter.getVar ("anim_sample_rate");
float sr= anim_sample_rate.asFloat(0);
// Consider values > 1000 as error values.
if(sr<=0 || sr>1000)
{
nlwarning("Bad \"anim_sample_rate\" value. Use Default of 30 fps.");
animationOptimizer.setSampleFrameRate(30);
}
else
{
animationOptimizer.setSampleFrameRate(sr);
}
}
catch(EUnknownVar &)
{
nlwarning("\"anim_sample_rate\" not found in the parameter file. Use Default of 30 fps.");
animationOptimizer.setSampleFrameRate(30);
}
// Scan and load all files .ig in directories
//=================
uint numSkipped= 0;
uint numBuilded= 0;
vector<string> listFile;
CPath::getPathContent(directoryIn, false, false, true, listFile);
for(uint iFile=0; iFile<listFile.size(); iFile++)
{
string &igFile= listFile[iFile];
// verify it is a .anim.
if( CFile::getExtension(igFile) == "anim" )
{
string fileNameIn= CFile::getFilename(igFile);
string fileNameOut= pathOut + fileNameIn;
// skip the file?
bool mustSkip= false;
// If File Out exist
if(CFile::fileExists(fileNameOut))
{
// If newer than file In, skip
uint32 fileOutDate= CFile::getFileModificationDate(fileNameOut);
if( fileOutDate > CFile::getFileModificationDate(igFile) )
{
mustSkip= true;
}
}
// If must process the file.
if(!mustSkip)
{
// Read the animation.
CAnimation animIn;
CIFile fin;
fin.open(CPath::lookup(igFile));
fin.serial(animIn);
// process.
CAnimation animOut;
animationOptimizer.optimize(animIn, animOut);
// Save this animation.
COFile fout;
fout.open(fileNameOut);
fout.serial(animOut);
fout.close();
numBuilded++;
}
else
{
numSkipped++;
}
// progress
printf("Anim builded: %4d. Anim Skipped: %4d\r", numBuilded, numSkipped);
}
}
// Add some info in the log.
nlinfo("Anim builded: %4d", numBuilded);
nlinfo("Anim skipped: %4d", numSkipped);
}
catch (Exception& except)
{
// Error message
nlwarning ("ERROR %s\n", except.what());
}
}
// exit.
return 0;
}
示例7: if
/*
* init()
*/
bool CPrimChecker::build(const string &primitivesPath, const string &igLandPath, const string &igVillagePath, const string &outputDirectory, bool forceRebuild)
{
if (Verbose)
nlinfo("Checking pacs.packed_prims consistency");
NLLIGO::Register();
// Init ligo
if (!LigoConfig.readPrimitiveClass ("world_editor_classes.xml", false))
{
// Should be in l:\leveldesign\world_edit_files
nlwarning ("Can't load ligo primitive config file world_editor_classes.xml");
return false;
}
uint i, j;
string outputfname = CPath::standardizePath(outputDirectory)+"pacs.packed_prims";
_Grid.clear();
vector<string> files;
CPath::getPathContent(primitivesPath, true, false, true, files);
for (i=0; i<files.size(); ++i)
{
if (CFile::getExtension(files[i]) == "primitive")
{
readFile(files[i]);
}
}
files.clear();
CPath::getPathContent(igLandPath, true, false, true, files);
CPath::getPathContent(igVillagePath, true, false, true, files);
set<string> noWaterShapes;
for (i=0; i<files.size(); ++i)
{
try
{
// load ig associated to the zone
string igname = files[i];
string ignamelookup = CPath::lookup(igname);
//nlinfo("Reading ig '%s'", ignamelookup.c_str());
CIFile igStream(ignamelookup);
CInstanceGroup ig;
igStream.serial(ig);
// search in group for water instance
for (j=0; j<ig._InstancesInfos.size(); ++j)
{
string shapeName = ig._InstancesInfos[j].Name;
if (CFile::getExtension (shapeName) == "")
shapeName += ".shape";
if (noWaterShapes.find(shapeName) != noWaterShapes.end())
continue;
string shapeNameLookup = CPath::lookup (shapeName, false, false);
if (!shapeNameLookup.empty())
{
CIFile f;
if (f.open (shapeNameLookup))
{
CShapeStream shape;
shape.serial(f);
CWaterShape *wshape = dynamic_cast<CWaterShape*>(shape.getShapePointer());
if (wshape == NULL)
{
noWaterShapes.insert(shapeName);
continue;
}
//nlinfo("Render water shape '%s'", shapeNameLookup.c_str());
CMatrix matrix;
ig.getInstanceMatrix(j, matrix);
CPolygon wpoly;
//wshape->getShapeInWorldSpace(wpoly);
CPolygon2D wpoly2d = wshape->getShape();
uint k;
for (k=0; k<wpoly2d.Vertices.size(); ++k)
{
wpoly.Vertices.push_back(matrix * wpoly2d.Vertices[k]);
}
float zwater = wpoly.Vertices[0].z - WaterThreshold;
uint16 idx = (uint16)_WaterHeight.size();
_WaterHeight.push_back(zwater);
render(wpoly, idx);
if (Verbose)
//.........这里部分代码省略.........