예제 #1
0
static void *cb_func(const char* value, void *user_data)
{
  SVector* result = reinterpret_cast<SVector*>(user_data);
  result->push_back(value);
  return NULL;
}
예제 #2
0
bool sqr::CSceneAmpCoder::DeCode_Ver_H( const CDataChunk& inData,OBJ_HANDLE handle )
{
	CSceneManagerClient* pScene = (CSceneManagerClient*)handle;
	CPkgFile& File = *((CPkgFile*)inData.GetBuffer());

	DeCoder_Com_B_D(File,handle);

	//////////////////////////////////////////////////////////////////////////
	//read specular parameter 无效数据
	uint32 uColor = 0; 
	float  fPower = 0.0f;

	File.Read(&uColor, sizeof(uColor));
	File.Read(&uColor, sizeof(uColor));
	File.Read(&fPower, sizeof(fPower));
	File.Read(&fPower, sizeof(fPower));
	//////////////////////////////////////////////////////////////////////////

	locale loc = locale::global(locale(""));
	uint32 dwNameLen = 0;
	char szBuf[256];
	//////////////////////////////////////////////////////////////////////////
	//region ambient fx name
	SVector<SString>  ambientFxNameList;
	size_t size = 0;
	File.read(&size, sizeof(size_t));
	for ( size_t i = 0; i < size; ++i )
	{
		SString strEffectName = "";

		// 		File.Read(&dwNameLen,sizeof(dwNameLen));
		// 		File.Read(szBuf, sizeof(char)*dwNameLen);
		// 		szBuf[dwNameLen] = 0;
		// 		strEffectFileName = szBuf;

		File.Read(&dwNameLen,sizeof(dwNameLen));
		File.Read(szBuf, sizeof(char)*dwNameLen);
		szBuf[dwNameLen] = 0;
		strEffectName = szBuf;

		//		strEffectFileName = "fx\\setting\\mapfx_ambient_yb\\" + strEffectName + ".efx";

		ambientFxNameList.push_back(strEffectName);
	}
	//////////////////////////////////////////////////////////////////////////

	size = 0;
	File.read(&size, sizeof(size_t));
	if( size == 0 )
		return true;
	else
	{
		for( size_t i = 0; i < size; ++i )
		{
			RegionsInfo *pRgnInfo = new RegionsInfo;

			if( !pRgnInfo )
				return false;
			///scene
			File.read(&pRgnInfo->lightParam.globalAmbient.R,  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.globalAmbient.G,  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.globalAmbient.B,  sizeof(uint8));

			File.read(&pRgnInfo->lightParam.globalDiffuse.R,  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.globalDiffuse.G,  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.globalDiffuse.B,  sizeof(uint8));

			File.read(&pRgnInfo->lightParam.globalSpecular.R, sizeof(uint8));
			File.read(&pRgnInfo->lightParam.globalSpecular.G, sizeof(uint8));
			File.read(&pRgnInfo->lightParam.globalSpecular.B, sizeof(uint8));

#ifndef AMBIENT_SHADOW_COLOR
			File.read(&pRgnInfo->lightParam.globalShadow.R,   sizeof(uint8));
			File.read(&pRgnInfo->lightParam.globalShadow.G,   sizeof(uint8));
			File.read(&pRgnInfo->lightParam.globalShadow.B,   sizeof(uint8));
#else
			uint8 dummy;
			File.read(&dummy,   sizeof(uint8));
			File.read(&dummy,   sizeof(uint8));
			File.read(&dummy,   sizeof(uint8));
#endif

			File.read(&pRgnInfo->lightParam.fogColor.R,		  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.fogColor.G,		  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.fogColor.B,		  sizeof(uint8));

			///player
			File.read(&pRgnInfo->lightParam.playerAmbient.R,  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.playerAmbient.G,  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.playerAmbient.B,  sizeof(uint8));

			File.read(&pRgnInfo->lightParam.playerDiffuse.R,  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.playerDiffuse.G,  sizeof(uint8));
			File.read(&pRgnInfo->lightParam.playerDiffuse.B,  sizeof(uint8));

			File.read(&pRgnInfo->lightParam.playerSpecular.R, sizeof(uint8));
			File.read(&pRgnInfo->lightParam.playerSpecular.G, sizeof(uint8));
			File.read(&pRgnInfo->lightParam.playerSpecular.B, sizeof(uint8));

			File.read(&pRgnInfo->uFogMode,					  sizeof(pRgnInfo->uFogMode));
			File.read(&pRgnInfo->lightParam.fogStart,		  sizeof(float));
			File.read(&pRgnInfo->lightParam.fogEnd,			  sizeof(float));
			File.read(&pRgnInfo->lightParam.fogDensity,       sizeof(float));

			///music name
			File.Read(&dwNameLen,sizeof(dwNameLen));
			File.Read(szBuf, sizeof(char)*dwNameLen);
			pRgnInfo->strMusicName = szBuf;

			///ambient effect
			size_t ambientFxSize = 0;
			File.read(&ambientFxSize, sizeof(ambientFxSize));
			for ( size_t m = 0; m < ambientFxSize; ++m )
			{
				int nIndex = 0;
				File.read(&nIndex, sizeof(nIndex));

				DWORD dwPlayMin = 0;
				File.read(&dwPlayMin, sizeof(dwPlayMin));

				DWORD dwPlayMax = 0;
				File.read(&dwPlayMax, sizeof(dwPlayMax));

				DWORD dwIntervalMin = 0;
				File.read(&dwIntervalMin, sizeof(dwIntervalMin));

				DWORD dwIntervalMax = 0;
				File.read(&dwIntervalMax, sizeof(dwIntervalMax));

				SString strEffectName	 = ambientFxNameList[nIndex];

				//SVector<CRgnAmbientFxInfo*> rgnAmbientFxList;
				CRgnAmbientFxInfo *pTemp = new CRgnAmbientFxInfo;
				pTemp->szFxName		= strEffectName;
				pTemp->nPlayMax		= dwPlayMax;
				pTemp->nPlayMin		= dwPlayMin;
				pTemp->nIntervalMax = dwIntervalMax;
				pTemp->nIntervalMin = dwIntervalMin;

				pRgnInfo->rgnAmbientFxList.push_back(pTemp);
			}

			pScene->m_RgnsList.push_back(pRgnInfo);
		}

		// ----------------------------------------------------------------------------
		// 读取摄像机轨迹动画信息

		uint32 uAnimCount = 0;
		File.read( &uAnimCount, sizeof(uint32) );	
		pScene->m_vecCamPath.resize(uAnimCount, NULL);

		for ( uint i=0; i<uAnimCount; ++i )
		{
			int		pc		= 0;
			File.read( &pc, sizeof(int) );
			if ( pc != NULL )
			{
				CCameraPath	*pNewPath	= new CCameraPath;
				pScene->m_vecCamPath[i] = pNewPath; 

				uint32 uKeyCount = 0;
				File.read( &uKeyCount, sizeof(uint32) );	

				CVector3f	data;
				float		time;
				for ( uint32 i=0; i<uKeyCount; ++i )
				{
					// 读取 摄像机位置帧
					File.read( &data, sizeof(CVector3f) );
					File.read( &time, sizeof(float) );
					pNewPath->AddPositionKey( data, time );

					// 读取 摄像机观察点帧
					File.read( &data, sizeof(CVector3f) );
					File.read( &time, sizeof(float) );
					pNewPath->AddTargetkey( data, time );

					// 读取 摄像机视角帧
					File.read( &data, sizeof(CVector3f) );
					File.read( &time, sizeof(float) );
					pNewPath->AddFovKey( data, time );
				}
			}
		}

		//////////////////////////////////////////////////////////////////////////
		// IsTileVisiable
		CMetaGridMgr& GridMgr = *pScene->m_pGridMgr;
		UINT Size = pScene->m_uWidth*pScene->m_uHeight;
		bool tileVisible = true;
		URegionID ID;
		for(size_t i = 0; i<Size; ++i)
		{
			ID.X = i % pScene->m_uWidth;
			ID.Z = i / pScene->m_uWidth;
			File.read( &tileVisible, sizeof(tileVisible) );

			GridMgr.SetRenderTileVisibleMark(ID, tileVisible);
		}

		//////////////////////////////////////////////////////////////////////////
	}

	locale::global(loc);//恢复全局locale	

	return true;
}