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


C++ IArchive::Init方法代码示例

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


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

示例1: OnLoadWorldFile


//.........这里部分代码省略.........
		EngineGetToolBox()->Log(LOGWARNING, _T("Invalid world file %s\n"), pFileName);
		Archive->Close();
		static DWORD msgHash_SetFileVersion = CHashString(_T("SetFileVersion")).GetUniqueID();
		m_ToolBox->SendMessage(msgHash_SetFileVersion, sizeof(IHashString), &oldVersion);
		return MSG_ERROR;
	}

	// failure checks
	bool componentFailed = false;
	int failedDepth = 0;

	float secondsPerFrame = 1 / m_fLoadingUpdateFPS;
	ITimer *timer = EngineGetToolBox()->GetTimer();
	float lastLoadTime = timer->GetRealTime();
	float elapsedTime = 0.0f;

	while (Archive->GetNode(szNodeName))
	{
		int currDepth = Archive->GetDepth();
		if (componentFailed == true)
		{
			// current node is child of failed
			if (currDepth > failedDepth)
			{
				continue;
			}
			// if sibling or uncle, reset comp failed flag
			else
			{
				componentFailed = false;
			}
		}

		hszTypeName.Init( szNodeName.c_str() );

		StdString parentName;
		StdString parentType;
		StdString childType;
		Archive->GotoParentNode( parentType );
		Archive->Read( parentName, _T("Name") );
		if ( parentName != _T("") )
		{
			hszParentName = parentName;
		}
		Archive->ReturnToChildNode( childType );
		if( hszTypeName.GetString() != childType )
		{
			assert( hszTypeName.GetString() == childType );
			static DWORD msgHash_SetFileVersion = CHashString(_T("SetFileVersion")).GetUniqueID();
			m_ToolBox->SendMessage(msgHash_SetFileVersion, sizeof(IHashString), &oldVersion);
			return MSG_ERROR;
		}
		//parentName = Archive->GetParentName();

		StdString szName;
		Archive->Read( szName, _T("Name") );
		hszName.Init( szName.c_str() );

		cop.parentName = &hszParentName;
		cop.typeName = &hszTypeName;
		cop.name = &hszName;
		static DWORD msgHash_CreateObject = CHashString(_T("CreateObject")).GetUniqueID();
		DWORD retval = m_ToolBox->SendMessage(msgHash_CreateObject, sizeof(CREATEOBJECTPARAMS), &cop, NULL, NULL);

		if (retval != MSG_HANDLED)
		{
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:67,代码来源:XMLWorldLoader.cpp

示例2: Visit

bool CWorldVisitor::Visit( IComponent * component, bool bVisitEnter )
{
	IObject *theObject;
	IHashString *name;
	IHashString *parentName;
	IHashString *type;

	StdString parentType;
	StdString childType;

	std::string str;

	theObject = dynamic_cast<IObject *>(component);
	// This shouldn't happen but it does for some odd reason....
	assert(theObject);
	if( theObject == NULL )
	{
		return false;
	}
	name = theObject->GetName();
	parentName = theObject->GetParentName();
	type = theObject->GetComponentType();

	//Check to see if it is a valid object (for object exclusion)
	if( !CheckObject( type->GetString() ) )
	{
		return true;
	}

	else
	{
		if ( name == NULL )
		{
			name = &CHashString(_T("NULL"));
		}	

		if( bVisitEnter == true )
		{
			//if( (m_pArchiver != NULL) && ( _tcscmp( type->GetString(), _T("CPhysicsObject") ) != 0 ) )
			if( (m_pArchiver != NULL) )
			{
				// Start the Node
				m_pArchiver->StartClass( type->GetString() );
				
				// Write out the Unique ID aka Name
				m_pArchiver->Write( name->GetString(), _T("Name") );
				theObject->Serialize( *m_pArchiver );
			}

			// Removal of CPhysShape and changes to CPhysicsObject
			if( _tcscmp( type->GetString(), _T("CPhysicsObject") ) == 0 )
			{
				
				CPhysObjectStruct tmpCPhysObject;
				StdString CPhyShapeFile;
				StdString CPhyShapeFileOld;
				// if it's parent is not a CTerrainSector Object
				if( _tcsstr( name->GetString(), _T("Terrain") ) == NULL )
				{
					static DWORD msgHash_GetModelFileName = CHashString(_T("GetModelFileName")).GetUniqueID();
					m_ToolBox->SendMessage(msgHash_GetModelFileName, sizeof(StdString*), &CPhyShapeFile, parentName, NULL );
					CPhyShapeFile += _T(".psl");
				}
				// CTerrainSector Object
				else
				{
					CPhyShapeFile = _T("maps\\terrain.psl");
				}

				IArchive *PhysObjectIn;
				IArchive *PhysObjectRead;
				CHashString memTypePhysObjectIn(_T("Memory"));
				
				int PhysObjectInMemSize = 1024 * 1024 * sizeof(char);
				char* PhysObjectInMemChunk = new char[PhysObjectInMemSize];
				memset( PhysObjectInMemChunk, 0, PhysObjectInMemSize );

				CREATEARCHIVE caPhysObjectIn;
				caPhysObjectIn.mode = STREAM_MODE_READ;
				caPhysObjectIn.streamData = PhysObjectInMemChunk;
				caPhysObjectIn.streamSize = PhysObjectInMemSize;
				caPhysObjectIn.streamType = &memTypePhysObjectIn;
				static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caPhysObjectIn) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectIn = caPhysObjectIn.archive;

				CREATESTREAM csPhysObjectIn;
				csPhysObjectIn.streamData = caPhysObjectIn.streamData;
				csPhysObjectIn.streamSize = caPhysObjectIn.streamSize;
				csPhysObjectIn.mode = STREAM_MODE_WRITE;
				static DWORD msgHash_CreateStream_Memory = CHashString(_T("CreateStream_Memory")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csPhysObjectIn) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectIn->Init(csPhysObjectIn.openStream);		    

//.........这里部分代码省略.........
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:101,代码来源:WorldVisitor.cpp

示例3: CreateParticleSystem

void CParticleToolPal::CreateParticleSystem()
{
	CREATEOBJECTPARAMS cop;
	INITOBJECTPARAMS iop;
	SERIALIZEOBJECTPARAMS sop;
	
	CHashString hszParentName(_T("World"));
	CHashString hszTypeName(_T("CParticleRenderObject"));
	
	cop.parentName = &hszParentName;
	cop.typeName = &hszTypeName;
	cop.name = &m_ParticleName;
	DWORD retval = m_ToolBox->SendMessage(_T("CreateObject"), sizeof(CREATEOBJECTPARAMS), &cop, NULL, NULL);

	IArchive *MemArchive;
	CHashString memType(_T("Memory"));
	int size =	sizeof(char) * 256 + sizeof(Vec3) * 3 + 256;
	char* memchunk = new char[size];
	memset( memchunk, 0, size );
				
	CREATEARCHIVE caOut;
	caOut.mode = STREAM_MODE_WRITE;
	caOut.streamData = memchunk;
	caOut.streamSize = size;
	caOut.streamType = &memType;
	if (m_ToolBox->SendMessage(_T("CreateArchive"), sizeof(CREATEARCHIVE), &caOut) != MSG_HANDLED)
	{
		return;
	}
	MemArchive = caOut.archive;
	Vec3 vec(0,0,0);
	int clip = 30000;
	float life = 300000;
	bool enabled = true;
	bool screenaligned = true;
	MemArchive->Write( _T("Particles/Fire.xml"), _T("FileName") );
	MemArchive->Write( vec, _T("Position"));
	MemArchive->Write( vec, _T("Rotation") );
	MemArchive->Write( vec, _T("Scaling") );		
	MemArchive->Write( enabled , _T("Enabled"));
	MemArchive->Write( clip, _T("ClipDistance"));
	MemArchive->Write( life, _T("RemaingLife") );
	MemArchive->Write( screenaligned, _T("ScreenAligned") );

	CREATESTREAM cs;
	cs.streamData = caOut.streamData;
	cs.streamSize = caOut.streamSize;
	cs.mode = STREAM_MODE_READ;
	if (m_ToolBox->SendMessage(_T("CreateStream_Memory"), sizeof(CREATESTREAM), &cs) != MSG_HANDLED)
	{
		return;
	}
	MemArchive->Init(cs.openStream);

	sop.name = &m_ParticleName;
	sop.archive = MemArchive;
	m_ToolBox->SendMessage(_T("SerializeObject"), sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);
	

	iop.name = &m_ParticleName;
	if( retval == MSG_HANDLED )
	{
		retval = m_ToolBox->SendMessage(_T("InitObject"), sizeof(INITOBJECTPARAMS), &iop, NULL, NULL);
	}
	if( retval == MSG_HANDLED )
	{
		retval = m_ToolBox->SendMessage(_T("Enable"), 0, 0, &m_ParticleName, NULL);
	}

	if( retval == MSG_HANDLED )
	{
		m_ParticleVisible = true;
	}
	return;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:75,代码来源:ParticleToolPal.cpp


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