本文整理汇总了C++中IFileSystem::Seek方法的典型用法代码示例。如果您正苦于以下问题:C++ IFileSystem::Seek方法的具体用法?C++ IFileSystem::Seek怎么用?C++ IFileSystem::Seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem::Seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool CMeshLoader::Load(const wchar* path, bool ignore_animation_data/*=false*/)
{
if (m_bLoaded)
{
Unload();
m_bLoaded = false;
}
IFileSystem* pFS = CEngine::instance()->mFilesystem();
unsigned int ltim = GetTickCount();
// open file
wchar fspath[P3DMAX_PATH];
wsprintf(fspath, P3DMAX_PATH-1, _W("models/%s.rmesh"), path);
FSFILE* fp = pFS->Open(fspath, _W("rb"));
if (!fp)
{
CON(MSG_ERR, _W("MeshLoader: Can't find mesh file '%s'!"), fspath);
return false;
}
if (fp->nLen<sizeof(sRMHeader))
{
CON(MSG_ERR, _W("MeshLoader: Mesh file '%s' is corrupted!"), fspath);
pFS->Close(fp);
return false;
}
// load and check header
m_rhead = new sRMHeader();
pFS->Read(m_rhead, sizeof(sRMHeader), 1, fp);
if (m_rhead->magic[0]!='R' || m_rhead->magic[1]!='M')
{
CON(MSG_ERR, _W("MeshLoader: File '%s' is not valid RMesh!"), fspath);
pFS->Close(fp);
return false;
}
if (m_rhead->major!=RM_MAJOR)
{
CON(MSG_ERR, _W("MeshLoader: Mesh '%s' is version %d, but engine can load only %d!"), fspath, m_rhead->major, RM_MAJOR);
pFS->Close(fp);
return false;
}
if (m_rhead->minor!=RM_MINOR)
{
CON(MSG_DBG, _W("MeshLoader: Minor version warning. Mesh '%s' is minor version %d, engine can load %d."), fspath, m_rhead->minor, RM_MINOR);
}
m_bLoaded=true;
// LOAD INFO ---------------------------------------------------
m_rinfo = new sRMInfo();
pFS->Seek(fp, m_rhead->contents[RM_FILE_INFO].offset, SEEK_SET);
pFS->Read(m_rinfo, sizeof(sRMInfo), 1, fp);
// LOAD SUBSETS ---------------------------------------------------
m_nSubsets = m_rhead->contents[RM_SUBSETS].length/sizeof(sRMSubset);
m_rsubsets = new sRMSubset[m_nSubsets];
pFS->Seek(fp, m_rhead->contents[RM_SUBSETS].offset, SEEK_SET);
pFS->Read(m_rsubsets, sizeof(sRMSubset), m_nSubsets, fp);
// LOAD VERTICES ---------------------------------------------------
m_nVerts = m_rhead->contents[RM_VERTICES].length/sizeof(sRMVertex);
m_rverts = new sRMVertex[m_nVerts];
pFS->Seek(fp, m_rhead->contents[RM_VERTICES].offset, SEEK_SET);
pFS->Read(m_rverts, sizeof(sRMVertex), m_nVerts, fp);
// LOAD INDICES ---------------------------------------------------
m_nInds = m_rhead->contents[RM_INDICES].length/sizeof(sRMIndex);
m_rinds = new sRMIndex[m_nInds];
pFS->Seek(fp, m_rhead->contents[RM_INDICES].offset, SEEK_SET);
pFS->Read(m_rinds, sizeof(sRMIndex), m_nInds, fp);
// MAKE FACE GROUPS -----------------------------------------------
m_faceGroups = new unsigned int[m_nInds/3];
memset(m_faceGroups, 0, sizeof(unsigned int)*m_nInds/3);
for (unsigned int s=0; s<m_nSubsets; s++)
{
// find faces which belongs to this subset
unsigned int beginFace = m_rsubsets[s].firstindex/3;
unsigned int endFace = (m_rsubsets[s].firstindex+m_rsubsets[s].numindices)/3;
// assign face groups to this subset
for (unsigned int f=beginFace; f<endFace; f++) m_faceGroups[f]=s;
}
// IF THIS FILE HAS ANIMATION AND IT IS LAODED MAKE SURE TO SET m_bAnimated TO TRUE
m_bAnimated = false;
if (!m_rinfo->idontimportanim)
{
// check if file contain animated content
// TODO:
}
// close file
pFS->Close(fp);
ltim = GetTickCount() - ltim;
if (ltim<1000)
CON(MSG_INFO, _W("MeshLoader: Mesh '%s' loaded. Loading took %d miliseconds."), path, ltim);
else
//.........这里部分代码省略.........
示例2: Load
// ------------------------------------------------
bool CTextureLoader::Load(const wchar* path)
{
IFileSystem *fs = CRenderer::mEngine()->mFilesystem();
Unload();
//memset(&m_info, 0, sizeof(sRTInfo));
// make physical FS path
wchar physPath[512];
wsprintf(physPath, 511, _W("textures/%s.rtex"), path);
for (unsigned int i=0; i<wstrlen(physPath); i++)
if (physPath[i]==',') physPath[i]='/';
FSFILE* fp;
fp = fs->Open(physPath, _W("rb"));
if (!fp)
{
return false;
}
m_dataLen = fp->nLen;
if (m_dataLen < sizeof(sRTHeader))
{
fs->Close(fp);
return false;
}
// read header
sRTHeader head;
fs->Read(&head, 1, sizeof(sRTHeader), fp);
// check header
if (head.magic[0]!='R' || head.magic[1]!='T')
{
CON(MSG_ERR, _W("Texture %s is not valid rtex!"), path);
fs->Close(fp);
return false;
}
// load texture info
fs->Seek(fp, head.contents[RT_FILE_INFO].offset, SEEK_SET);
fs->Read(&m_info, 1, sizeof(sRTInfo), fp);
// load texture data
unsigned long rawDataLen = fp->nLen-head.contents[RT_IMAGE_SUBSET].offset-head.contents[RT_IMAGE_SUBSET].length;
m_data = new BYTE[rawDataLen];
fs->Seek(fp, head.contents[RT_IMAGE_SUBSET].offset+head.contents[RT_IMAGE_SUBSET].length, SEEK_SET);
fs->Read(m_data, 1, rawDataLen, fp);
m_bLoaded=true;
// load all subsets
fs->Seek(fp, head.contents[RT_IMAGE_SUBSET].offset, SEEK_SET);
unsigned int numSubs = head.contents[RT_IMAGE_SUBSET].length / sizeof(sRTImageSubset);
for (unsigned int s = 0; s < numSubs; s++)
{
sImageData* ida = new sImageData();
fs->Read(&ida->subset, 1, sizeof(sRTImageSubset), fp);
ida->size = ida->subset.len;
ida->pData = &m_data[ida->subset.offset];
m_subs.push_back(ida);
}
fs->Close(fp);
int i = 0; // debug
return true;
}