本文整理汇总了C++中CFileHandler::LinkFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileHandler::LinkFile方法的具体用法?C++ CFileHandler::LinkFile怎么用?C++ CFileHandler::LinkFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileHandler
的用法示例。
在下文中一共展示了CFileHandler::LinkFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void CMD5Model::LoadModel( const std::string& a_Path, const std::string& a_SubFolder )
{
if ( CFile::FileExists( a_Path.c_str() ) == false )
{
CLog::GetInstance()->OutMessage( "Model file does not exist (%s)", CLog::MESSAGETYPE_ERROR, a_Path.c_str() );
}
m_SubFolder = a_SubFolder;
CFlatFile modelFile;
modelFile.Open( a_Path.c_str(), CFile::FILEMODE_READ, CFile::FILETYPE_PLAIN );
CFileHandler fileHandler;
fileHandler.LinkFile( &modelFile );
std::string data;
std::string dataTwo;
Uint position = modelFile.GetPosition();
data = fileHandler.ReadString();
while ( ( position = modelFile.GetPosition() ) < modelFile.GetSize() )
{
if ( data == "MD5Version" )
{
dataTwo = fileHandler.ReadString();
Int versionNumber = atoi( dataTwo.c_str() );
assert( versionNumber == 10 && "Incorrect version number in MD5file" );
}
else if ( data == "commandline" )
{
//We don't need this so skip
dataTwo = fileHandler.ReadString();
}
else if ( data == "numJoints" )
{
dataTwo = fileHandler.ReadString();
m_JointCount = atoi( dataTwo.c_str() );
}
else if ( data == "numMeshes" )
{
dataTwo = fileHandler.ReadString();
m_MeshCount = atoi( dataTwo.c_str() );
}
else if ( data == "joints" )
{
//Read out all the joint
SJoint joint;
data = fileHandler.ReadString();
data = fileHandler.ReadString();
for ( Uint i = 0; i < m_JointCount; ++i )
{
joint.m_Name = fileHandler.ReadString();
joint.m_Name.pop_back();
joint.m_Name.erase( joint.m_Name.begin() );
data = fileHandler.ReadString();
joint.m_ParentID = atoi( data.c_str() );
data = fileHandler.ReadString();
for ( Uint j = 0; j < 3; ++j )
{
data = fileHandler.ReadString();
joint.m_Position.Cell[j] = (Float)atof( data.c_str() );
}
data = fileHandler.ReadString();
data = fileHandler.ReadString();
for ( Uint j = 0; j < 3; ++j )
{
data = fileHandler.ReadString();
joint.m_Orientation.Cell[j] = (Float)atof( data.c_str() );
}
joint.m_Orientation.ComputeW();
data = fileHandler.ReadString();
data = fileHandler.ReadString();
m_Joints.push_back( joint );
}
//}
data = fileHandler.ReadString();
}
else if ( data == "mesh" )
{
//Read the mesh
SMesh* mesh = LoadMesh( fileHandler );
//Prepare the mesh and generate normals
PrepareMesh( mesh );
PrepareNormals( mesh );
//Generate rendering buffers
CreateBuffers( mesh );
CreateVAO( mesh );
m_Meshes.push_back( mesh );
}
data = fileHandler.ReadString();
}
}
示例2: LoadFromFile
const Bool CWAVFile::LoadFromFile( const Char* a_FilePath )
{
m_FilePath += a_FilePath;
CFlatFile file; CFileHandler fileHandler;
//Open the file
file.Open( a_FilePath, CFile::FILEMODE_READ, CFile::FILETYPE_BINARY );
//Link the file to the filehandler
fileHandler.LinkFile( &file );
//Read out the header ( yay for templates )
fileHandler.Read<CWAVFile::SWaveHeader>( &m_Header );
CLog* log = CLog::GetInstance();
//Check chunkID
Char* chunkID = (Char*)&m_Header.m_ChunkID;
if ( strncmp( chunkID, "RIFF", 4 ) != 0 )
{
log->OutMessage( "ChunkID does not correspond to RIFF", CLog::MESSAGETYPE_WARNING );
return false;
}
//Check chunkSize
if ( m_Header.m_ChunkSize != file.GetSize() - 8 )
{
log->OutMessage( "Filesize does not match size defined in the header", CLog::MESSAGETYPE_WARNING );
return false;
}
Char* formatString = (Char*)&m_Header.m_Format;
//Check format
if ( strncmp( "WAVE", formatString, 4 ) != 0 )
{
log->OutMessage( "Format does not correspond to WAVE", CLog::MESSAGETYPE_WARNING );
return false;
}
const Char* subChunkOneID = (Char*)&m_Header.m_SubChunkOneID;
//Check subchunk ID
if ( strncmp( "fmt", subChunkOneID, 3 ) != 0 )
{
log->OutMessage( "ChunkOne ID does not match fmt", CLog::MESSAGETYPE_WARNING );
return false;
}
//Check subchunk size
if ( m_Header.m_SubChunkOneSize != 16 )
{
log->OutMessage( "ChunkOne size does not match the PCM value ( 16 ), others are not supported", CLog::MESSAGETYPE_WARNING );
return false;
}
//Check audio format
if ( m_Header.m_AudioFormat != 1 )
{
log->OutMessage( "Audio format not match the PCM value ( 1 ), others are not supported", CLog::MESSAGETYPE_WARNING );
return false;
}
//Check Channel count
if ( m_Header.m_ChannelCount == 0 )
{
log->OutMessage( "No audio channels found in the header", CLog::MESSAGETYPE_WARNING );
return false;
}
Int bytesPerSample = m_Header.m_BitsPerSample / 8;
//Check if byterate matches other values
if ( m_Header.m_ByteRate != ( m_Header.m_SampleRate * m_Header.m_ChannelCount * bytesPerSample ) )
{
log->OutMessage( "Byterate does not match other values in header", CLog::MESSAGETYPE_WARNING );
return false;
}
//Block allignment
if ( m_Header.m_BlockAllignment != ( m_Header.m_ChannelCount * bytesPerSample ) )
{
log->OutMessage( "Block allignment does not match other values in header", CLog::MESSAGETYPE_WARNING );
return false;
}
//Check for valid bbp
if ( bytesPerSample != 1 && bytesPerSample != 2 )
{
log->OutMessage( "BBp value is not support only 8;16 are supported", CLog::MESSAGETYPE_WARNING );
return false;
}
//Reading of chunks
const Char* subChunkID = (Char*)&m_Header.m_SubChunkTwoID;
while ( strncmp( subChunkID, "data", 4 ) != 0 )
{
int currentPosition = file.GetPosition();
file.Skip( m_Header.m_SubChunkTwoSize );
fileHandler.Read<Int>( m_Header.m_SubChunkTwoID, 1 );
fileHandler.Read<Int>( m_Header.m_SubChunkTwoSize, 1 );
}
////Check subchunk ID
//if ( m_Header.m_SubChunkTwoID != _byteswap_ulong( 0x64617461 ) )
//{
// //log->OutMessage( "ChunkTwo ID does not match data", CLog::MESSAGETYPE_WARNING );
// //return false;
//}
////Check subchunk size
//if ( m_Header.m_SubChunkTwoSize != ( file.GetSize() - sizeof( SWaveHeader ) ) )
//{
// log->OutMessage( "ChunkTwo size does not match the filesize", CLog::MESSAGETYPE_WARNING );
//}
//.........这里部分代码省略.........