当前位置: 首页>>代码示例>>C++>>正文


C++ CIFile::serial方法代码示例

本文整理汇总了C++中CIFile::serial方法的典型用法代码示例。如果您正苦于以下问题:C++ CIFile::serial方法的具体用法?C++ CIFile::serial怎么用?C++ CIFile::serial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CIFile的用法示例。


在下文中一共展示了CIFile::serial方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/*
 *		load()
 */
bool	CPrimChecker::load(const string &outputDirectory)
{
	string	outputfname = CPath::standardizePath(outputDirectory)+"pacs.packed_prims";

	CIFile	f;
	if (f.open(outputfname))
	{
		f.serial(_Grid);
		f.serialCont(_WaterHeight);
	}
	else
	{
		nlwarning("Couldn't load pacs.packed_prims file '%s'", outputfname.c_str());
		return false;
	}

	return true;
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:21,代码来源:prim_checker.cpp

示例2: loadDump

//-----------------------------------------------
// loadDump :
// Create a file with the current state of the client (good to report a bug).
//-----------------------------------------------
void loadDump(const std::string &name)
{
	CVectorD currentPos;

	// Load information to start as the version
	CIFile fStart;
	if(fStart.open(name + "_start.rec", false))
	{
		fStart.serialVersion(RecordVersion);
		fStart.serial(currentPos);
		// Close the File.
		fStart.close();
	}
	else
		nlwarning("loadDump: cannot open the file '%s_start.rec'.", name.c_str());

	// Update the position for the vision.
	NetMngr.setReferencePosition(currentPos);

	// Select the closest continent from the new position.
	class CDummyProgress : public IProgressCallback
	{
		void progress (float /* value */) {}
	};
	CDummyProgress dummy;
	ContinentMngr.select(currentPos, dummy);

	// Load the DB
	IngameDbMngr.read(name + "_db.rec");

	// Open the file.
	CIFile f;
	if(f.open(name + ".rec", false))
	{
		// Dump entities.
		EntitiesMngr.dump(f);

		// Close the File.
		f.close();
	}
	else
		nlwarning("loadDump: cannot open '%s.rec'.", name.c_str());
}// loadDump //
开发者ID:AzyxWare,项目名称:ryzom,代码行数:47,代码来源:misc.cpp

示例3:

void	NLPACS::CZoneTessellation::loadTessellation(CIFile &input)
{
	input.serialCont(_Vertices);

	uint	i;

	uint32	numTessel;
	input.serial(numTessel);
	_Tessellation.resize(numTessel);

	for (i=0; i<_Tessellation.size(); ++i)
	{
		_Tessellation[i].serial(input, _Tessellation);
	}

	Elements.resize(_Tessellation.size());
	for (i=0; i<_Tessellation.size(); ++i)
	{
		Elements[i] = &_Tessellation[i];
	}
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:21,代码来源:build_surf.cpp

示例4: Exception

int	main(int argc, char *argv[])
{
	uint	i;

	// Avoid warnings.
	NLMISC::createDebug();
	DebugLog->addNegativeFilter("Exception will be launched");
	WarningLog->addNegativeFilter("Exception will be launched");
	InfoLog->addNegativeFilter("FEHTIMER>");
	InfoLog->addNegativeFilter("adding the path");

	// Init serial
	registerSerial3d();

	if(argc<4)
	{
		puts("Usage:    build_clod_bank  path_file.cfg  config_file.cfg  destfile.clodbank  [bakeFrameRate=20] ");
		return 0;
	}


	try
	{
		// The bank to fill
		CLodCharacterShapeBank	lodShapeBank;


		// Read the frameRate to process bake of anims
		float	bakeFrameRate= 20;
		if(argc>=5)
		{
			bakeFrameRate= (float)atof(argv[4]);
			if(bakeFrameRate<=1)
			{
				nlwarning("bad bakeFrameRate value, use a default of 20");
				bakeFrameRate= 20;
			}
		}


		// parse the path file.
		//==================

		// try to load the config file.
		CConfigFile pathConfig;
		pathConfig.load (argv[1]);

		// Get the search pathes
		CConfigFile::CVar &search_pathes = pathConfig.getVar ("search_pathes");
		for (i = 0; i < (uint)search_pathes.size(); i++)
		{
			// Add to search path
			CPath::addSearchPath (search_pathes.asString(i));
		}

		// parse the config file.
		//==================

		// try to load the config file.
		CConfigFile config;
		config.load (argv[2]);

		// For all .clod to process
		//==================
		CConfigFile::CVar &clod_list = config.getVar ("clod_list");
		uint	lodId;
		for (lodId = 0; lodId < (uint)clod_list.size(); lodId++)
		{
			string	lodName= clod_list.asString(lodId);

			printf("Process LOD: %s\n", lodName.c_str());

			// Search the variable with this name.
			try
			{
				CIFile		iFile;

				// get the anim list.
				CConfigFile::CVar &clod_anim_list = config.getVar (lodName);

				// Correct format?
				if(clod_anim_list.size()<3)
				{
					nlwarning("%s skipped. Must have at least the skeleton file name, the lod file name, and one animation", lodName.c_str());
					// go to next.
					continue;
				}

				// Init lod shape process
				//===========================

				// The first variable is the name of the skeleton.
				string	skeletonName= clod_anim_list.asString(0);
				CSmartPtr<CSkeletonShape>	skeletonShape;

				// Load it.
				iFile.open(CPath::lookup(skeletonName));
				CShapeStream		strShape;
				strShape.serial(iFile);
				iFile.close();
//.........这里部分代码省略.........
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:101,代码来源:build_clod_bank.cpp

示例5: 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" )
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:67,代码来源:ig_lighter.cpp

示例6: main


//.........这里部分代码省略.........
					// The dependencies list
					vector< CZoneDependencies > dependencies;
					dependencies.resize ((lastX-firstX+1)*(lastY-firstY+1));

					// Ryzom specific: build bbox for villages
					TString2LightingBBox villagesBBox;					
					computeIGBBoxFromContinent(properties, shapeMap, villagesBBox);		


					// Insert each zone in the quad tree
					sint y, x;
					for (y=firstY; y<=lastY; y++)
					for (x=firstX; x<=lastX; x++)
					{
						

						// Progress
						progress ("Build bounding boxes", (float)(x+y*lastX)/(float)(lastX*lastY));

						// Make a zone file name
						string zoneName;
						getZoneNameByCoord (x, y, zoneName);

						// Open the file
						CIFile file;
						if (file.open (dir+zoneName+ext))
						{							
							// The zone
							CZone zone;

							try
							{
								// Serial the zone
								file.serial (zone);

								/// get bbox from the ig of this zone
								CLightingBBox igBBox;								
								if (computeDependenciesWithIgs)
								{
									computeZoneIGBBox(zoneName.c_str(), igBBox, shapeMap, villagesBBox);
								}								
								// Create a zone descriptor
								

								
								NLMISC::CAABBox zoneBox;
								zoneBox.setCenter(zone.getZoneBB().getCenter());
								zoneBox.setHalfSize(zone.getZoneBB().getHalfSize());

								CLightingBBox zoneLBox;
								zoneLBox.OccludingBox = zoneLBox.ReceivingBox = zoneBox; // can't be void
								zoneLBox.makeUnion(igBBox);								
								nlassert(!zoneLBox.ReceivingBox.IsVoid);
								//
								CZoneDescriptorBB zoneDesc;
								zoneDesc.X=x;
								zoneDesc.Y=y;
								zoneDesc.BBox=zoneLBox.ReceivingBox.Box;
								//
								if (!zoneLBox.OccludingBox.IsVoid)
								{
									quadGrid.insert (zoneLBox.ReceivingBox.Box.getMin(), zoneLBox.ReceivingBox.Box.getMax(), zoneDesc);
								}
																								
								// Insert in the dependencies
								// Index 
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:67,代码来源:zone_dependencies.cpp

示例7: OnOpenDocument

BOOL CTexGenThumbnailDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	CIFile file;
	if (file.open (lpszPathName))
	{
		try
		{
			NLTEXGEN::CTexGenDocument	doc;
			file.serial(doc);

			CFloatBitmap bitmap;
			CRenderParameter renderParameters (false, false, false);
			doc.Operators[0]->eval (bitmap, renderParameters);
			if ((bitmap.getWidth() != 0) && (bitmap.getHeight() != 0))
			{
				bitmap.resample (m_sizeDoc.cx, m_sizeDoc.cy);

				_DibBitmapInfo.bmiHeader.biSize	= sizeof(BITMAPINFO);
				_DibBitmapInfo.bmiHeader.biWidth	= m_sizeDoc.cx;
				_DibBitmapInfo.bmiHeader.biHeight	= m_sizeDoc.cy;
				_DibBitmapInfo.bmiHeader.biPlanes	= 1;
				_DibBitmapInfo.bmiHeader.biBitCount = 32;
				_DibBitmapInfo.bmiHeader.biCompression  = BI_RGB;
				_DibBitmapInfo.bmiHeader.biSizeImage	= 0;
				_DibBitmapInfo.bmiHeader.biXPelsPerMeter	= 0;
				_DibBitmapInfo.bmiHeader.biYPelsPerMeter	= 0;
				_DibBitmapInfo.bmiHeader.biClrUsed	= 0;
				_DibBitmapInfo.bmiHeader.biClrImportant	= 0;
				HWND desktop = ::GetDesktopWindow();
				HDC dc = ::GetDC (desktop);
				nlverify(_Dib = CreateDIBSection(dc, &_DibBitmapInfo, DIB_RGB_COLORS, (void**)&_DibBits, NULL, 0));

				const float *pixels = bitmap.getPixels();
				if (pixels)
				{
					uint8 *dst = _DibBits;
					const uint height = m_sizeDoc.cy;
					uint y;
					for (y=0; y<height; y++)
					{
						const uint width = m_sizeDoc.cx*4 + y*m_sizeDoc.cx*4;
						uint i = y*m_sizeDoc.cx*4;
						uint j = (height-y-1)*m_sizeDoc.cx*4;
						for (;i<width; i+=4, j+=4)
						{
							/*if (alpha)
							{
								int r = (int)(pixels[i+0] * 255.f);
								clamp (r, 0, 255);
								dst[j+0] = r;
								dst[j+1] = r;
								dst[j+2] = r;
							}
							else*/
							{
								int r = (int)(pixels[i+0] * 255.f);
								int g = (int)(pixels[i+1] * 255.f);
								int b = (int)(pixels[i+2] * 255.f);
								clamp (r, 0, 255);
								clamp (g, 0, 255);
								clamp (b, 0, 255);
								dst[j+0] = b;
								dst[j+1] = g;
								dst[j+2] = r;
							}
						}
					}
				}

				::ReleaseDC (desktop, dc);
				
				return TRUE;
			}
		}
		catch (Exception &)
		{
		}
	}
	
	return FALSE;
}
开发者ID:ryzom,项目名称:nel_tex_gen,代码行数:81,代码来源:TexGenThumbnailDoc.cpp

示例8: 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;
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:101,代码来源:anim_builder.cpp


注:本文中的CIFile::serial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。