port from perforce
This commit is contained in:
957
evoke-64k/trunk/ev10/ConfigFiles.cpp
Normal file
957
evoke-64k/trunk/ev10/ConfigFiles.cpp
Normal file
@@ -0,0 +1,957 @@
|
||||
#include "defines.h"
|
||||
#include "ConfigFiles.h"
|
||||
#include "globals.h"
|
||||
|
||||
#include "ShaderFactory.h"
|
||||
|
||||
#include "textinfo.h"
|
||||
#include "entityinfo.h"
|
||||
#include "intrin.h"
|
||||
|
||||
#include "greebledata.h"
|
||||
#include "cave.h"
|
||||
|
||||
HANDLE g_FileChangeNotification= NULL;
|
||||
static std::string g_strShaderData;
|
||||
|
||||
extern int g_iActLoadStep;
|
||||
|
||||
void StopFileWatch()
|
||||
{
|
||||
if (g_FileChangeNotification != INVALID_HANDLE_VALUE && g_FileChangeNotification != NULL)
|
||||
{
|
||||
FindCloseChangeNotification(g_FileChangeNotification);
|
||||
}
|
||||
g_FileChangeNotification= NULL;
|
||||
}
|
||||
|
||||
void StartFileWatch()
|
||||
{
|
||||
StopFileWatch();
|
||||
std::string strPath= ".\\cfg\\";
|
||||
|
||||
g_FileChangeNotification= FindFirstChangeNotification(
|
||||
strPath.c_str(),
|
||||
FALSE,
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE );
|
||||
}
|
||||
|
||||
bool CheckFileWatch()
|
||||
{
|
||||
if (g_FileChangeNotification == INVALID_HANDLE_VALUE || g_FileChangeNotification == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD dwRet= WaitForSingleObject( g_FileChangeNotification, 1 );
|
||||
|
||||
if( WAIT_OBJECT_0 == dwRet )
|
||||
{
|
||||
FindNextChangeNotification( g_FileChangeNotification );
|
||||
g_iActLoadStep= 0;
|
||||
|
||||
ReadDataFromDisc();
|
||||
|
||||
// Shader neu compilieren
|
||||
PrepareShaders();
|
||||
|
||||
//Texte neu setzen
|
||||
CreateTextRenderJobs();
|
||||
SetCrystalPos();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ReadSceneTxt()
|
||||
{
|
||||
FrameWork::TextFileReader tfr;
|
||||
tfr.read( "cfg/scene.txt" );
|
||||
|
||||
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfr.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
if( strCommandFull.size() < 4 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int iFunc= strCommandFull[ strCommandFull.size() - 1 ] - '0';
|
||||
iFunc+= 10 * ( strCommandFull[ strCommandFull.size() - 2 ] - '0' );
|
||||
iFunc+= 100 * ( strCommandFull[ strCommandFull.size() - 3 ] - '0' );
|
||||
|
||||
std::string strCommand;
|
||||
strCommand= strCommandFull.substr( 0, strCommandFull.size() - 3 );
|
||||
if( strCommand == "SCENE" )
|
||||
{
|
||||
DWORD dwMask= 0;
|
||||
for( int j= 0; j < 32; ++j )
|
||||
{
|
||||
char c= '.';
|
||||
ss >> c;
|
||||
if( c != '.' )
|
||||
{
|
||||
dwMask|= 1 << j;
|
||||
}
|
||||
}
|
||||
g_SceneMask[ iFunc ]= dwMask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int g_iCurSpriptLength;
|
||||
int g_iCurSpriptParams;
|
||||
|
||||
void ReadScriptTxt()
|
||||
{
|
||||
/*
|
||||
g_iCurSpriptLength= 0;
|
||||
g_iCurSpriptParams= 0;
|
||||
|
||||
FrameWork::TextFileReader tfrScript;
|
||||
tfrScript.read( "cfg/script.txt" );
|
||||
|
||||
//#ifdef SCRIPTEDITOR
|
||||
for( int i= 0; i < (int)tfrScript.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfrScript.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
if( strCommandFull == "SKIP" )
|
||||
{
|
||||
#ifdef SCRIPTEDITOR
|
||||
ss >> g_iSkipTicks;
|
||||
#endif
|
||||
}
|
||||
if( strCommandFull == "CLEAN" )
|
||||
{
|
||||
g_iCurSpriptLength= 0;
|
||||
g_iCurSpriptParams= 0;
|
||||
}
|
||||
else if( strCommandFull == "CSPEED" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= CSPEED;
|
||||
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
|
||||
}
|
||||
else if( strCommandFull == "OSPEED" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= OSPEED;
|
||||
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
|
||||
}
|
||||
else if( strCommandFull == "CTIME" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= CTIME;
|
||||
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
|
||||
}
|
||||
else if( strCommandFull == "OTIME" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= OTIME;
|
||||
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
|
||||
}
|
||||
else if( strCommandFull == "CAM" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= CAM;
|
||||
int iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
}
|
||||
else if( strCommandFull == "CAM" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= CAM;
|
||||
int iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
}
|
||||
else if( strCommandFull == "OBJ" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= OBJ;
|
||||
int iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
}
|
||||
else if( strCommandFull == "TICK" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= TICK;
|
||||
int iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
}
|
||||
else if( strCommandFull == "QUIT" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= QUIT;
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
*/
|
||||
}
|
||||
|
||||
void SetParamValue( int Bank, int i, float fVal )
|
||||
{
|
||||
g_GreebleParam[ Bank * 4 + i ]= fVal;
|
||||
}
|
||||
|
||||
void ReadParamTxt()
|
||||
{
|
||||
FrameWork::TextFileReader tfrSong;
|
||||
tfrSong.read( "cfg/param.txt" );
|
||||
|
||||
for( int i= 0; i < (int)tfrSong.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfrSong.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
#ifdef SINGLEEDITMODE
|
||||
if( strCommandFull == "PCUR" )
|
||||
{
|
||||
ss >> g_iCurrentPortrait;
|
||||
}
|
||||
else if( strCommandFull == "OCUR" )
|
||||
{
|
||||
ss >> g_iCurrentObject;
|
||||
}
|
||||
else if( strCommandFull == "OCOUNT" )
|
||||
{
|
||||
ss >> g_iCurrentObjectCount;
|
||||
}
|
||||
else if( strCommandFull == "CCUR" )
|
||||
{
|
||||
ss >> g_iCurrentCamera;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( strCommandFull.size() < 4 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int iFunc= strCommandFull[ strCommandFull.size() - 1 ] - '0';
|
||||
iFunc+= 10 * ( strCommandFull[ strCommandFull.size() - 2 ] - '0' );
|
||||
iFunc+= 100 * ( strCommandFull[ strCommandFull.size() - 3 ] - '0' );
|
||||
|
||||
std::string strCommand;
|
||||
strCommand= strCommandFull.substr( 0, strCommandFull.size() - 3 );
|
||||
if( strCommand == "BANK" )
|
||||
{
|
||||
for( int j= 0; j < 4; ++j )
|
||||
{
|
||||
float fVal= 0.0f;
|
||||
ss >> fVal;
|
||||
int iVal= (int)( fVal * 64.0f + 0.5f );
|
||||
fVal= (float)( iVal ) / 64.0f;
|
||||
SetParamValue( iFunc, j, fVal );
|
||||
}
|
||||
}
|
||||
else if( strCommand == "SIZE" )
|
||||
{
|
||||
ss >> g_GreebleObj[ iFunc ].m_iSizeX;
|
||||
ss >> g_GreebleObj[ iFunc ].m_iSizeY;
|
||||
}
|
||||
else if( strCommand == "BASE" )
|
||||
{
|
||||
ss >> g_GreebleObj[ iFunc ].m_iBaseMeshType;
|
||||
ss >> g_GreebleObj[ iFunc ].m_iBaseBank;
|
||||
}
|
||||
else if( strCommand == "OFFSET" )
|
||||
{
|
||||
ss >> g_GreebleObj[ iFunc ].m_iOffsetFunc;
|
||||
ss >> g_GreebleObj[ iFunc ].m_iOffsetBank;
|
||||
}
|
||||
else if( strCommand == "HEIGHT" )
|
||||
{
|
||||
ss >> g_GreebleObj[ iFunc ].m_iHeightFunc;
|
||||
ss >> g_GreebleObj[ iFunc ]. m_iHeightBank;
|
||||
}
|
||||
else if( strCommand == "MIX" )
|
||||
{
|
||||
ss >> g_GreebleObj[ iFunc ].m_iMixFunc;
|
||||
ss >> g_GreebleObj[ iFunc ].m_iMixBank;
|
||||
}
|
||||
else if( strCommand == "COLOR" )
|
||||
{
|
||||
float fR;
|
||||
float fG;
|
||||
float fB;
|
||||
float fA;
|
||||
ss >> fR;
|
||||
ss >> fG;
|
||||
ss >> fB;
|
||||
ss >> fA;
|
||||
fR= min( 255.0f, fR );
|
||||
fG= min( 255.0f, fG );
|
||||
fB= min( 255.0f, fB );
|
||||
fA= min( 255.0f, fA );
|
||||
|
||||
DWORD dwColor= ( (int)fA << 24 ) |
|
||||
( (int)fR << 16 ) |
|
||||
( (int)fG << 8 ) |
|
||||
( (int)fB );
|
||||
|
||||
g_GreebleObj[ iFunc ].m_dwColor= dwColor;
|
||||
}
|
||||
|
||||
#ifdef SINGLEFUNCEDITOR
|
||||
/*if( strCommand == "DRAW" )
|
||||
{
|
||||
ss >> g_iCamFunc;
|
||||
ss >> g_iPaintFunc[ 0 ];
|
||||
ss >> g_iPaintFunc[ 1 ];
|
||||
}
|
||||
if( strCommand == "CAMREPEAT" )
|
||||
{
|
||||
ss >> g_iCamRepeat;
|
||||
}*/
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void ReadShader( char* pcTarget, const char* pcVarName, const char* pcFileName )
|
||||
{
|
||||
FrameWork::TextFileReader tfrShaderTxt;
|
||||
tfrShaderTxt.read( pcFileName );
|
||||
|
||||
//shorten the data?
|
||||
int iPos= 0;
|
||||
|
||||
for( int i= 0; i < (int)tfrShaderTxt.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfrShaderTxt.getFileLines()[ i ];
|
||||
bool bNonWhiteFound= false;
|
||||
for( size_t j= 0; j < strAct.size(); ++j )
|
||||
{
|
||||
char c= strAct[ j ];
|
||||
if( c == ' ' && !bNonWhiteFound )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( c == '\t' && !bNonWhiteFound )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bNonWhiteFound= true;
|
||||
if( c == '/' && strAct[ j + 1 ] == '/' )
|
||||
{
|
||||
break;
|
||||
}
|
||||
pcTarget[ iPos ]= c;
|
||||
iPos++;
|
||||
}
|
||||
|
||||
// better readability?
|
||||
pcTarget[ iPos ]= 13;
|
||||
iPos++;
|
||||
}
|
||||
pcTarget[ iPos ]= 0;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "const char " << pcVarName << "[]=\n";
|
||||
ss << "\"";
|
||||
int iCount= 0;
|
||||
char cPrevious= 0;
|
||||
while( pcTarget[ iCount ] != 0 )
|
||||
{
|
||||
char c= pcTarget[ iCount ];
|
||||
if( c == 13 )
|
||||
{
|
||||
if( 13 != cPrevious && 10 != cPrevious )
|
||||
{
|
||||
ss << "\\n\"\n\"";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << c;
|
||||
}
|
||||
cPrevious= c;
|
||||
iCount++;
|
||||
}
|
||||
ss << "\";\n\n";
|
||||
g_strShaderData+= ss.str();
|
||||
}
|
||||
|
||||
void ReadShaders()
|
||||
{
|
||||
g_strShaderData= "";
|
||||
ReadShader( g_ShaderVSGeneral, "g_ShaderVSGeneral", "cfg/vsgeneral.txt" );
|
||||
ReadShader( g_ShaderPSPhong, "g_ShaderPSPhong", "cfg/psphong.txt" );
|
||||
ReadShader( g_ShaderPSCrystal, "g_ShaderPSCrystal", "cfg/pscrystal.txt" );
|
||||
ReadShader( g_ShaderPSDepth, "g_ShaderPSDepth", "cfg/psdepth.txt" );
|
||||
ReadShader( g_ShaderPSText, "g_ShaderPSText", "cfg/pstext.txt" );
|
||||
ReadShader( g_ShaderPSEnvLit, "g_ShaderPSEnvLit", "cfg/psenvlit.txt" );
|
||||
|
||||
ReadShader( g_ShaderVSSky, "g_ShaderVSSky", "cfg/vssky.txt" );
|
||||
ReadShader( g_ShaderPSSky, "g_ShaderPSSky", "cfg/pssky.txt" );
|
||||
|
||||
ReadShader( g_ShaderVSOcean, "g_ShaderVSOcean", "cfg/vsocean.txt" );
|
||||
ReadShader( g_ShaderPSOcean, "g_ShaderPSOcean", "cfg/psocean.txt" );
|
||||
|
||||
ReadShader( g_ShaderVSFSQuad, "g_ShaderVSFSQuad", "cfg/vsfsquad.txt" );
|
||||
ReadShader( g_ShaderPSTexGen, "g_ShaderPSTexGen", "cfg/pstexgen.txt" );
|
||||
ReadShader( g_ShaderPSPSSM, "g_ShaderPSPSSM", "cfg/pspssm.txt" );
|
||||
ReadShader( g_ShaderPSAmbOcc, "g_ShaderPSAmbOcc", "cfg/psao.txt" );
|
||||
ReadShader( g_ShaderPSDOF, "g_ShaderPSDOF", "cfg/psdof.txt" );
|
||||
ReadShader( g_ShaderPSRay, "g_ShaderPSRay", "cfg/psray.txt" );
|
||||
ReadShader( g_ShaderPSBlur, "g_ShaderPSBlur", "cfg/psblur.txt" );
|
||||
|
||||
ReadShader( g_ShaderPSTerrain, "g_ShaderPSTerrain", "cfg/psterrain.txt" );
|
||||
|
||||
ReadShader( g_ShaderVSFluid, "g_ShaderVSFluid", "cfg/vsfluid.txt" );
|
||||
ReadShader( g_ShaderPSFluid, "g_ShaderPSFluid", "cfg/psfluid.txt" );
|
||||
}
|
||||
|
||||
void ReadTextInfos()
|
||||
{
|
||||
m_iTextCount= -1;
|
||||
int iCharPos= 0;
|
||||
STextInfo* pInfo= m_TextInfos;
|
||||
|
||||
FrameWork::TextFileReader tfr;
|
||||
tfr.read( "cfg/text.txt" );
|
||||
|
||||
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfr.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
if( strCommandFull == "Text" )
|
||||
{
|
||||
if( m_iTextCount < m_iMaxTextCount )
|
||||
{
|
||||
m_iTextCount++;
|
||||
pInfo= m_TextInfos + m_iTextCount;
|
||||
}
|
||||
strcpy_s( m_pcTextData + iCharPos, sizeof( m_pcTextData ) - iCharPos, strAct.c_str() );
|
||||
iCharPos+= strAct.size() + 1;
|
||||
|
||||
if( m_iTextCount == 0 )
|
||||
{
|
||||
pInfo->m_v3Pos.x= 0.0f;
|
||||
pInfo->m_v3Pos.y= 0.0f;
|
||||
pInfo->m_v3Pos.z= 0.0f;
|
||||
pInfo->m_v3Rot.x= 0.0f;
|
||||
pInfo->m_v3Rot.y= 0.0f;
|
||||
pInfo->m_v3Rot.z= 0.0f;
|
||||
pInfo->m_v3Scale.x= 1.0f;
|
||||
pInfo->m_v3Scale.y= 1.0f;
|
||||
pInfo->m_v3Scale.z= 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pInfo= m_TextInfos[ m_iTextCount - 1 ];
|
||||
}
|
||||
pInfo->m_v3Move.x= 0.0f;
|
||||
pInfo->m_v3Move.y= 0.0f;
|
||||
pInfo->m_v3Move.z= 0.0f;
|
||||
pInfo->m_iTimeStart= 0;
|
||||
pInfo->m_iTimeLength= 0;
|
||||
}
|
||||
else if( strCommandFull == "Pos" )
|
||||
{
|
||||
ss >> pInfo->m_v3Pos.x;
|
||||
ss >> pInfo->m_v3Pos.y;
|
||||
ss >> pInfo->m_v3Pos.z;
|
||||
}
|
||||
else if( strCommandFull == "Rot" )
|
||||
{
|
||||
ss >> pInfo->m_v3Rot.x;
|
||||
ss >> pInfo->m_v3Rot.y;
|
||||
ss >> pInfo->m_v3Rot.z;
|
||||
pInfo->m_v3Rot.x*= c_PI / 180.0f;
|
||||
pInfo->m_v3Rot.y*= c_PI / 180.0f;
|
||||
pInfo->m_v3Rot.z*= c_PI / 180.0f;
|
||||
}
|
||||
else if( strCommandFull == "Scale" )
|
||||
{
|
||||
ss >> pInfo->m_v3Scale.x;
|
||||
ss >> pInfo->m_v3Scale.y;
|
||||
ss >> pInfo->m_v3Scale.z;
|
||||
}
|
||||
else if( strCommandFull == "Move" )
|
||||
{
|
||||
ss >> pInfo->m_v3Move.x;
|
||||
ss >> pInfo->m_v3Move.y;
|
||||
ss >> pInfo->m_v3Move.z;
|
||||
}
|
||||
else if( strCommandFull == "Time" )
|
||||
{
|
||||
ss >> pInfo->m_iTimeStart;
|
||||
ss >> pInfo->m_iTimeLength;
|
||||
}
|
||||
}
|
||||
m_iTextCount++;
|
||||
}
|
||||
|
||||
void ReadEntityInfos()
|
||||
{
|
||||
m_iEntityCount= -1;
|
||||
int iCharPos= 0;
|
||||
SEntityInfo* pInfo= m_EntityInfos;
|
||||
|
||||
FrameWork::TextFileReader tfr;
|
||||
tfr.read( "cfg/entity.txt" );
|
||||
|
||||
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfr.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
if( strCommandFull == "Entity" )
|
||||
{
|
||||
if( m_iEntityCount < m_iMaxEntityCount )
|
||||
{
|
||||
m_iEntityCount++;
|
||||
pInfo= m_EntityInfos + m_iEntityCount;
|
||||
}
|
||||
strcpy_s( m_pcEntityData + iCharPos, sizeof( m_pcEntityData ) - iCharPos, strAct.c_str() );
|
||||
iCharPos+= strAct.size() + 1;
|
||||
|
||||
if( m_iEntityCount == 0 )
|
||||
{
|
||||
pInfo->m_v3Pos.x= 0.0f;
|
||||
pInfo->m_v3Pos.y= 0.0f;
|
||||
pInfo->m_v3Pos.z= 0.0f;
|
||||
pInfo->m_v3Rot.x= 0.0f;
|
||||
pInfo->m_v3Rot.y= 0.0f;
|
||||
pInfo->m_v3Rot.z= 0.0f;
|
||||
pInfo->m_v3Scale.x= 1.0f;
|
||||
pInfo->m_v3Scale.y= 1.0f;
|
||||
pInfo->m_v3Scale.z= 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pInfo= m_EntityInfos[ m_iEntityCount - 1 ];
|
||||
}
|
||||
pInfo->m_v3Move.x= 0.0f;
|
||||
pInfo->m_v3Move.y= 0.0f;
|
||||
pInfo->m_v3Move.z= 0.0f;
|
||||
pInfo->m_iTimeStart= 0;
|
||||
pInfo->m_iTimeLength= 0;
|
||||
}
|
||||
else if( strCommandFull == "Pos" )
|
||||
{
|
||||
ss >> pInfo->m_v3Pos.x;
|
||||
ss >> pInfo->m_v3Pos.y;
|
||||
ss >> pInfo->m_v3Pos.z;
|
||||
}
|
||||
else if( strCommandFull == "Rot" )
|
||||
{
|
||||
ss >> pInfo->m_v3Rot.x;
|
||||
ss >> pInfo->m_v3Rot.y;
|
||||
ss >> pInfo->m_v3Rot.z;
|
||||
pInfo->m_v3Rot.x*= c_PI / 180.0f;
|
||||
pInfo->m_v3Rot.y*= c_PI / 180.0f;
|
||||
pInfo->m_v3Rot.z*= c_PI / 180.0f;
|
||||
}
|
||||
else if( strCommandFull == "Scale" )
|
||||
{
|
||||
ss >> pInfo->m_v3Scale.x;
|
||||
ss >> pInfo->m_v3Scale.y;
|
||||
ss >> pInfo->m_v3Scale.z;
|
||||
}
|
||||
else if( strCommandFull == "Move" )
|
||||
{
|
||||
ss >> pInfo->m_v3Move.x;
|
||||
ss >> pInfo->m_v3Move.y;
|
||||
ss >> pInfo->m_v3Move.z;
|
||||
}
|
||||
else if( strCommandFull == "Time" )
|
||||
{
|
||||
ss >> pInfo->m_iTimeStart;
|
||||
ss >> pInfo->m_iTimeLength;
|
||||
}
|
||||
}
|
||||
m_iEntityCount++;
|
||||
}
|
||||
|
||||
void ReadCrystalInfos()
|
||||
{
|
||||
m_iCrystalCount= -1;
|
||||
SCrystalInfo* pInfo= m_CrystalInfos;
|
||||
|
||||
FrameWork::TextFileReader tfr;
|
||||
tfr.read( "cfg/cryspos.txt" );
|
||||
|
||||
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfr.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
if( strCommandFull == "Crystal" )
|
||||
{
|
||||
if( m_iCrystalCount < m_iMaxCrystalCount )
|
||||
{
|
||||
m_iCrystalCount++;
|
||||
pInfo= m_CrystalInfos + m_iCrystalCount;
|
||||
}
|
||||
|
||||
if( m_iCrystalCount == 0 )
|
||||
{
|
||||
pInfo->m_v3Pos.x= 0.0f;
|
||||
pInfo->m_v3Pos.y= 0.0f;
|
||||
pInfo->m_v3Pos.z= 0.0f;
|
||||
pInfo->m_v3Rot.x= 0.0f;
|
||||
pInfo->m_v3Rot.y= 0.0f;
|
||||
pInfo->m_v3Rot.z= 0.0f;
|
||||
pInfo->m_fScale= 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pInfo= m_CrystalInfos[ m_iCrystalCount - 1 ];
|
||||
}
|
||||
}
|
||||
else if( strCommandFull == "Pos" )
|
||||
{
|
||||
ss >> pInfo->m_v3Pos.x;
|
||||
ss >> pInfo->m_v3Pos.y;
|
||||
ss >> pInfo->m_v3Pos.z;
|
||||
}
|
||||
else if( strCommandFull == "Rot" )
|
||||
{
|
||||
ss >> pInfo->m_v3Rot.x;
|
||||
ss >> pInfo->m_v3Rot.y;
|
||||
ss >> pInfo->m_v3Rot.z;
|
||||
pInfo->m_v3Rot.x*= c_PI / 180.0f;
|
||||
pInfo->m_v3Rot.y*= c_PI / 180.0f;
|
||||
pInfo->m_v3Rot.z*= c_PI / 180.0f;
|
||||
}
|
||||
else if( strCommandFull == "Scale" )
|
||||
{
|
||||
ss >> pInfo->m_fScale;
|
||||
}
|
||||
}
|
||||
m_iCrystalCount++;
|
||||
}
|
||||
|
||||
|
||||
void ReadDataFromDisc()
|
||||
{
|
||||
ReadParamTxt();
|
||||
ReadScriptTxt();
|
||||
ReadShaders();
|
||||
ReadTextInfos();
|
||||
ReadEntityInfos();
|
||||
ReadCrystalInfos();
|
||||
ReadSceneTxt();
|
||||
|
||||
/*static bool bWritten= false;
|
||||
if( bWritten )
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
#ifdef CREATE_HEADER
|
||||
WriteHeader();
|
||||
#endif
|
||||
}
|
||||
|
||||
void WriteHeaderFunc()
|
||||
{
|
||||
std::ofstream ofs( "greeblearrays.h" );
|
||||
|
||||
ofs << "const float g_GreebleParam[ 4 * 48 ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < 4 * 48; ++i )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s(
|
||||
pcSpecial,
|
||||
1024,
|
||||
"%1.9ff,\n",
|
||||
g_GreebleParam[ i ] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
|
||||
{
|
||||
int iBytes= sizeof( g_GreebleObj );
|
||||
ofs << "const unsigned char byteObjectData[ " << iBytes <<" ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
|
||||
int iLine= 0;
|
||||
for( int i= 0; i < iBytes; ++i )
|
||||
{
|
||||
ofs << (int)(((unsigned char*)g_GreebleObj)[ i ]) << ",";
|
||||
|
||||
iLine++;
|
||||
if( iLine == 8 )
|
||||
{
|
||||
ofs << "\n";
|
||||
iLine= 0;
|
||||
}
|
||||
}
|
||||
ofs << "\n" << "};" << "\n";
|
||||
ofs << "Greeble::SObjectDescription* g_GreebleObj= (Greeble::SObjectDescription*)byteObjectData;\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
void WriteHeaderScript()
|
||||
{
|
||||
/*
|
||||
std::ofstream ofs( "scriptdata.h" );
|
||||
ofs << "const int g_iScriptLength= " << g_iCurSpriptLength << ";\n";
|
||||
ofs << "const unsigned char g_Script[ g_iScriptLength ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < g_iCurSpriptLength; ++i )
|
||||
{
|
||||
ofs << (int)g_Script[ i ] << ",\n";
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
|
||||
ofs << "const float g_ScriptParamFloat[ " << g_iCurSpriptParams << " ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < g_iCurSpriptParams; ++i )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s(
|
||||
pcSpecial,
|
||||
1024,
|
||||
"%1.9ff,\n",
|
||||
g_ScriptParamFloat[ i ] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
ofs << "\n";
|
||||
*/
|
||||
}
|
||||
|
||||
void WriteSceneHeader()
|
||||
{
|
||||
std::ofstream ofs( "scenedata.h" );
|
||||
int iLast= g_SceneMaskCount - 1;
|
||||
while( g_SceneMask[ iLast ] == 0 )
|
||||
{
|
||||
iLast--;
|
||||
}
|
||||
|
||||
ofs << "DWORD g_SceneMask[]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i <= iLast; ++i )
|
||||
{
|
||||
ofs << g_SceneMask[ i ] << ",\n";
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
|
||||
ofs << "\n";
|
||||
}
|
||||
|
||||
void WriterShaderInclude()
|
||||
{
|
||||
std::ofstream ofs( "shaderdata.h" );
|
||||
ofs << g_strShaderData;
|
||||
}
|
||||
|
||||
void WriterTextInclude()
|
||||
{
|
||||
std::ofstream ofs( "textdata.h" );
|
||||
ofs << "int m_iTextCount= " << m_iTextCount <<";\n";
|
||||
ofs << "\n";
|
||||
ofs << "const char m_pcTextData[]=\n";
|
||||
ofs << "{\n";
|
||||
int iZeroCount= 0;
|
||||
for( int i= 0; i < 65536; ++i )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s(
|
||||
pcSpecial,
|
||||
1024,
|
||||
"\t%d,\n",
|
||||
(int)m_pcTextData[ i ] );
|
||||
ofs << pcSpecial;
|
||||
if( m_pcTextData[ i ] == 0 )
|
||||
{
|
||||
iZeroCount++;
|
||||
if( iZeroCount == m_iTextCount )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ofs << "};\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "const DWORD c_BinaryText[]= " << "\n";
|
||||
ofs << "{\n";
|
||||
|
||||
for( int i= 0; i < (int)m_iTextCount; ++i )
|
||||
{
|
||||
int dwords= m_iTextCount * sizeof( STextInfo ) / 4;
|
||||
if( dwords > 0 )
|
||||
{
|
||||
DWORD* pdwData= (DWORD*)&(m_TextInfos);
|
||||
for( int j= 0; j < dwords; ++j )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s( pcSpecial,
|
||||
1024,
|
||||
"\t%d,\n",
|
||||
pdwData[ j ] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( m_iTextCount == 0 )
|
||||
{
|
||||
ofs << "0";
|
||||
}
|
||||
ofs << "};\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "STextInfo* m_TextInfos= (STextInfo*)c_BinaryText;\n";
|
||||
ofs << "\n";
|
||||
}
|
||||
|
||||
void WriterEntityInclude()
|
||||
{
|
||||
std::ofstream ofs( "entitydata.h" );
|
||||
ofs << "int m_iEntityCount= " << m_iEntityCount <<";\n";
|
||||
ofs << "\n";
|
||||
ofs << "const char m_pcEntityData[]=\n";
|
||||
ofs << "{\n";
|
||||
int iZeroCount= 0;
|
||||
for( int i= 0; i < 65536; ++i )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s(
|
||||
pcSpecial,
|
||||
1024,
|
||||
"\t%d,\n",
|
||||
(int)m_pcEntityData[ i ] );
|
||||
ofs << pcSpecial;
|
||||
if( m_pcEntityData[ i ] == 0 )
|
||||
{
|
||||
iZeroCount++;
|
||||
if( iZeroCount == m_iEntityCount )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ofs << "};\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "const DWORD c_BinaryEntity[]= " << "\n";
|
||||
ofs << "{\n";
|
||||
|
||||
for( int i= 0; i < (int)m_iEntityCount; ++i )
|
||||
{
|
||||
int dwords= m_iEntityCount * sizeof( SEntityInfo ) / 4;
|
||||
if( dwords > 0 )
|
||||
{
|
||||
DWORD* pdwData= (DWORD*)&(m_EntityInfos);
|
||||
for( int j= 0; j < dwords; ++j )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s( pcSpecial,
|
||||
1024,
|
||||
"\t%d,\n",
|
||||
pdwData[ j ] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( m_iEntityCount == 0 )
|
||||
{
|
||||
ofs << "0";
|
||||
}
|
||||
ofs << "};\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "SEntityInfo* m_EntityInfos= (SEntityInfo*)c_BinaryEntity;\n";
|
||||
ofs << "\n";
|
||||
}
|
||||
|
||||
void WriterCrystalInclude()
|
||||
{
|
||||
std::ofstream ofs( "crystaldata.h" );
|
||||
ofs << "int m_iCrystalCount= " << m_iCrystalCount <<";\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "const DWORD c_BinaryCrystal[]= " << "\n";
|
||||
ofs << "{\n";
|
||||
|
||||
for( int i= 0; i < (int)m_iCrystalCount; ++i )
|
||||
{
|
||||
int dwords= m_iCrystalCount * sizeof( SCrystalInfo ) / 4;
|
||||
if( dwords > 0 )
|
||||
{
|
||||
DWORD* pdwData= (DWORD*)&(m_CrystalInfos);
|
||||
for( int j= 0; j < dwords; ++j )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s( pcSpecial,
|
||||
1024,
|
||||
"\t%d,\n",
|
||||
pdwData[ j ] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( m_iCrystalCount == 0 )
|
||||
{
|
||||
ofs << "0";
|
||||
}
|
||||
ofs << "};\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "SCrystalInfo* m_CrystalInfos= (SCrystalInfo*)c_BinaryCrystal;\n";
|
||||
ofs << "\n";
|
||||
}
|
||||
|
||||
void WriteHeader()
|
||||
{
|
||||
WriteHeaderFunc();
|
||||
//#ifdef SCRIPTEDITOR
|
||||
WriteHeaderScript();
|
||||
//#endif
|
||||
WriterShaderInclude();
|
||||
WriterTextInclude();
|
||||
WriterEntityInclude();
|
||||
WriterCrystalInclude();
|
||||
|
||||
WriteSceneHeader();
|
||||
}
|
||||
Reference in New Issue
Block a user