本文整理汇总了C++中IReader::r方法的典型用法代码示例。如果您正苦于以下问题:C++ IReader::r方法的具体用法?C++ IReader::r怎么用?C++ IReader::r使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReader
的用法示例。
在下文中一共展示了IReader::r方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadData
void CBone::LoadData(IReader& F)
{
R_ASSERT(F.find_chunk(BONE_CHUNK_DEF));
F.r_stringZ (name); xr_strlwr(name);
R_ASSERT(F.find_chunk(BONE_CHUNK_MATERIAL));
F.r_stringZ (game_mtl);
R_ASSERT(F.find_chunk(BONE_CHUNK_SHAPE));
F.r (&shape,sizeof(SBoneShape));
if (F.find_chunk(BONE_CHUNK_FLAGS))
IK_data.ik_flags.assign(F.r_u32());
R_ASSERT(F.find_chunk(BONE_CHUNK_IK_JOINT));
IK_data.type = (EJointType)F.r_u32();
F.r (IK_data.limits,sizeof(SJointLimit)*3);
IK_data.spring_factor = F.r_float();
IK_data.damping_factor = F.r_float();
if (F.find_chunk(BONE_CHUNK_IK_JOINT_BREAK)){
IK_data.break_force = F.r_float();
IK_data.break_torque= F.r_float();
}
if (F.find_chunk(BONE_CHUNK_IK_JOINT_FRICTION)){
IK_data.friction = F.r_float();
}
if (F.find_chunk(BONE_CHUNK_MASS)){
mass = F.r_float();
F.r_fvector3(center_of_mass);
}
}
示例2:
void CALifeSpawnHeader::load (IReader &file_stream)
{
m_version = file_stream.r_u32();
R_ASSERT2 (XRAI_CURRENT_VERSION == m_version,"'game.spawn' version mismatch!");
file_stream.r (&m_guid,sizeof(m_guid));
file_stream.r (&m_graph_guid,sizeof(m_graph_guid));
m_count = file_stream.r_u32();
m_level_count = file_stream.r_u32();
}
示例3: Load
//------------------------------------------------------------------------------
// I/O part
//------------------------------------------------------------------------------
BOOL CPGDef::Load(IReader& F)
{
R_ASSERT (F.find_chunk(PGD_CHUNK_VERSION));
u16 version = F.r_u16();
if (version!=PGD_VERSION){
Log ("!Unsupported PG version. Load failed.");
return FALSE;
}
R_ASSERT (F.find_chunk(PGD_CHUNK_NAME));
F.r_stringZ (m_Name);
F.r_chunk (PGD_CHUNK_FLAGS,&m_Flags);
if (F.find_chunk(PGD_CHUNK_EFFECTS)){
m_Effects.resize(F.r_u32());
for (EffectIt it=m_Effects.begin(); it!=m_Effects.end(); it++){
*it = xr_new<SEffect>();
F.r_stringZ ((*it)->m_EffectName);
F.r_stringZ ((*it)->m_OnPlayChildName);
F.r_stringZ ((*it)->m_OnBirthChildName);
F.r_stringZ ((*it)->m_OnDeadChildName);
(*it)->m_Time0 = F.r_float();
(*it)->m_Time1 = F.r_float();
(*it)->m_Flags.assign (F.r_u32());
}
}else{ //.??? убрать через некоторое время
R_ASSERT (F.find_chunk(PGD_CHUNK_EFFECTS2));
m_Effects.resize(F.r_u32());
for (EffectIt it=m_Effects.begin(); it!=m_Effects.end(); it++){
*it = xr_new<SEffect>();
F.r_stringZ ((*it)->m_EffectName);
F.r_stringZ ((*it)->m_OnPlayChildName);
(*it)->m_Time0 = F.r_float();
(*it)->m_Time1 = F.r_float();
(*it)->m_Flags.assign (F.r_u32());
}
}
if (F.find_chunk(PGD_CHUNK_TIME_LIMIT)){
m_fTimeLimit= F.r_float();
}
#ifdef _EDITOR
if (F.find_chunk(PGD_CHUNK_OWNER)){
F.r_stringZ (m_OwnerName);
F.r_stringZ (m_ModifName);
F.r (&m_CreateTime,sizeof(m_CreateTime));
F.r (&m_ModifTime,sizeof(m_ModifTime));
}
#endif
return TRUE;
}
示例4: LoadStream
bool ESceneAIMapTool::LoadStream(IReader& F)
{
inherited::LoadStream (F);
u16 version = 0;
R_ASSERT(F.r_chunk(AIMAP_CHUNK_VERSION,&version));
if( version!=AIMAP_VERSION ){
ELog.DlgMsg( mtError, "AIMap: Unsupported version.");
return false;
}
R_ASSERT(F.find_chunk(AIMAP_CHUNK_FLAGS));
F.r (&m_Flags,sizeof(m_Flags));
R_ASSERT(F.find_chunk(AIMAP_CHUNK_BOX));
F.r (&m_AIBBox,sizeof(m_AIBBox));
R_ASSERT(F.find_chunk(AIMAP_CHUNK_PARAMS));
F.r (&m_Params,sizeof(m_Params));
R_ASSERT(F.find_chunk(AIMAP_CHUNK_NODES));
m_Nodes.resize (F.r_u32());
for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){
*it = xr_new<SAINode>();
(*it)->LoadStream (F,this);
}
DenumerateNodes ();
if (F.find_chunk(AIMAP_CHUNK_INTERNAL_DATA)){
m_VisRadius = F.r_float();
m_BrushSize = F.r_u32();
}
if (F.find_chunk(AIMAP_CHUNK_INTERNAL_DATA2)){
m_SmoothHeight = F.r_float();
}
// snap objects
if (F.find_chunk(AIMAP_CHUNK_SNAP_OBJECTS)){
shared_str buf;
int cnt = F.r_u32();
if (cnt){
for (int i=0; i<cnt; i++){
F.r_stringZ (buf);
CCustomObject* O = Scene->FindObjectByName(buf.c_str(),OBJCLASS_SCENEOBJECT);
if (!O) ELog.Msg(mtError,"AIMap: Can't find snap object '%s'.",buf.c_str());
else m_SnapObjects.push_back(O);
}
}
}
hash_FillFromNodes ();
return true;
}
示例5: stream
void ppmd_initialize ()
{
if (trained_model)
trained_model->rewind ();
static bool initialized = false;
if (initialized)
return;
string_path file_name;
FS.update_path (file_name,"$game_config$","mp\\!PPMd.mdl");
if (FS.exist(file_name)) {
IReader *reader = FS.r_open(file_name);
R_ASSERT (reader);
u32 buffer_size = reader->length();
u8 *buffer = (u8*)xr_malloc(buffer_size);
reader->r (buffer,buffer_size);
FS.r_close (reader);
trained_model = new stream(buffer,buffer_size);
}
initialized = true;
if (StartSubAllocator(suballocator_size))
return;
exit (-1);
}
示例6:
void CGameGraphBuilder::load_graph_points (const float &start, const float &amount)
{
Progress (start);
Msg ("Loading graph points");
string_path spawn_file_name;
strconcat (sizeof(spawn_file_name),spawn_file_name,*m_level_name,"level.spawn");
IReader *reader = FS.r_open(spawn_file_name);
u32 id;
NET_Packet net_packet;
for (
IReader *chunk = reader->open_chunk_iterator(id);
chunk;
chunk = reader->open_chunk_iterator(id,chunk)
)
{
net_packet.B.count = chunk->length();
chunk->r (net_packet.B.data,net_packet.B.count);
load_graph_point (net_packet);
}
FS.r_close (reader);
Msg ("%d graph points loaded",graph().vertices().size());
Progress (start + amount);
}
示例7: ov_read_func
size_t ov_read_func(void *ptr, size_t size, size_t nmemb, void *datasource)
{
IReader* F = (IReader*)datasource;
size_t exist_block = _max(0ul,iFloor(F->elapsed()/(float)size));
size_t read_block = _min(exist_block,nmemb);
F->r (ptr,(int)(read_block*size));
return read_block;
}
示例8: triangle
void CHOM::Load ()
{
// Find and open file
string_path fName;
FS.update_path (fName,"$level$","level.hom");
if (!FS.exist(fName))
{
Msg (" WARNING: Occlusion map '%s' not found.",fName);
return;
}
Msg ("* Loading HOM: %s",fName);
IReader* fs = FS.r_open(fName);
IReader* S = fs->open_chunk(1);
// Load tris and merge them
CDB::Collector CL;
while (!S->eof())
{
HOM_poly P;
S->r (&P,sizeof(P));
CL.add_face_packed_D (P.v1,P.v2,P.v3,P.flags,0.01f);
}
// Determine adjacency
xr_vector<u32> adjacency;
CL.calc_adjacency (adjacency);
// Create RASTER-triangles
m_pTris = xr_alloc<occTri> (u32(CL.getTS()));
for (u32 it=0; it<CL.getTS(); it++)
{
CDB::TRI& clT = CL.getT()[it];
occTri& rT = m_pTris[it];
Fvector& v0 = CL.getV()[clT.verts[0]];
Fvector& v1 = CL.getV()[clT.verts[1]];
Fvector& v2 = CL.getV()[clT.verts[2]];
rT.adjacent[0] = (0xffffffff==adjacency[3*it+0])?((occTri*) (-1)):(m_pTris+adjacency[3*it+0]);
rT.adjacent[1] = (0xffffffff==adjacency[3*it+1])?((occTri*) (-1)):(m_pTris+adjacency[3*it+1]);
rT.adjacent[2] = (0xffffffff==adjacency[3*it+2])?((occTri*) (-1)):(m_pTris+adjacency[3*it+2]);
rT.flags = clT.dummy;
rT.area = Area (v0,v1,v2);
if (rT.area<EPS_L) {
Msg ("! Invalid HOM triangle (%f,%f,%f)-(%f,%f,%f)-(%f,%f,%f)",VPUSH(v0),VPUSH(v1),VPUSH(v2));
}
rT.plane.build (v0,v1,v2);
rT.skip = 0;
rT.center.add(v0,v1).add(v2).div(3.f);
}
// Create AABB-tree
m_pModel = xr_new<CDB::MODEL> ();
m_pModel->build (CL.getV(),int(CL.getVS()),CL.getT(),int(CL.getTS()));
bEnabled = TRUE;
S->close ();
FS.r_close (fs);
}
示例9:
bool CALifeSimulatorHeader::valid (IReader &file_stream) const
{
if (!file_stream.find_chunk(ALIFE_CHUNK_DATA))
return (false);
u32 version;
file_stream.r (&version, sizeof(version));
return (version>=2);
}
示例10: Load
bool ESceneCustomMTools::Load(IReader& F)
{
if (F.find_chunk(CHUNK_TOOLS_TAG)){
F.r_stringZ (m_ModifName);
F.r (&m_ModifTime,sizeof(m_ModifTime));
}else{
m_ModifName = "";
m_ModifTime = 0;
}
return true;
}
示例11: Read
void st_LevelOptions::Read(IReader& F)
{
R_ASSERT(F.find_chunk(CHUNK_LO_VERSION));
DWORD vers = F.r_u32( );
if( vers < 0x00000008 )
{
ELog.DlgMsg( mtError, "Skipping bad version of level options." );
return;
}
R_ASSERT(F.find_chunk(CHUNK_LO_NAMES));
F.r_stringZ (m_FNLevelPath);
if (F.find_chunk(CHUNK_LO_PREFIX)) F.r_stringZ (m_LevelPrefix);
R_ASSERT(F.find_chunk(CHUNK_LO_BOP));
F.r_stringZ (m_BOPText);
if (F.find_chunk(CHUNK_LO_MAP_VER))
F.r_stringZ (m_map_version);
vers = 0;
if (F.find_chunk(CHUNK_LO_BP_VERSION))
vers = F.r_u32( );
if (CURRENT_LEVELOP_BP_VERSION==vers){
if (F.find_chunk(CHUNK_BUILD_PARAMS))
F.r(&m_BuildParams, sizeof(m_BuildParams));
}else{
ELog.DlgMsg (mtError, "Skipping bad version of build params.");
m_BuildParams.Init();
}
if (F.find_chunk(CHUNK_LIGHT_QUALITY))
{
m_LightHemiQuality = F.r_u8();
m_LightSunQuality = F.r_u8();
}
if (F.find_chunk(CHUNK_MAP_USAGE))
{
if(vers > 0x00000008)
{
m_mapUsage.m_GameType.assign (F.r_u16());
}else
{
m_mapUsage.m_GameType.zero ();
m_mapUsage.m_GameType.set (eGameIDDeathmatch , F.r_s32());
m_mapUsage.m_GameType.set (eGameIDTeamDeathmatch, F.r_s32());
m_mapUsage.m_GameType.set (eGameIDArtefactHunt, F.r_s32());
}
}
}
示例12: Load
bool CEditShape::Load(IReader& F)
{
R_ASSERT(F.find_chunk(SHAPE_CHUNK_VERSION));
u16 vers = F.r_u16();
if (SHAPE_CURRENT_VERSION!=vers){
ELog.DlgMsg( mtError, "CEditShape: unsupported version. Object can't load.");
return false;
}
inherited::Load (F);
R_ASSERT(F.find_chunk(SHAPE_CHUNK_SHAPES));
shapes.resize (F.r_u32());
F.r (shapes.begin(),shapes.size()*sizeof(shape_def));
ComputeBounds();
return true;
}
示例13: LoadStream
bool CEditShape::LoadStream(IReader& F)
{
R_ASSERT(F.find_chunk(SHAPE_CHUNK_VERSION));
u16 vers = F.r_u16();
inherited::LoadStream (F);
R_ASSERT(F.find_chunk(SHAPE_CHUNK_SHAPES));
shapes.resize (F.r_u32());
F.r (shapes.begin(),shapes.size()*sizeof(shape_def));
if(F.find_chunk(SHAPE_CHUNK_DATA))
m_shape_type = F.r_u8();
ComputeBounds();
return true;
}
示例14:
void CResourceManager::OnDeviceCreate (LPCSTR shName)
{
#ifdef _EDITOR
if (!FS.exist(shName)) return;
#endif
// Check if file is compressed already
string32 ID = "shENGINE";
string32 id;
IReader* F = FS.r_open(shName);
R_ASSERT2 (F,shName);
F->r (&id,8);
if (0==strncmp(id,ID,8))
{
FATAL ("Unsupported blender library. Compressed?");
}
OnDeviceCreate (F);
FS.r_close (F);
}
示例15: LoadLevelPartLTX
//------------------------------------------------------------------------------------------------
// Scene
//------------------------------------------------------------------------------------------------
BOOL EScene::LoadLevelPartLTX(ESceneToolBase* M, LPCSTR mn)
{
string_path map_name;
strcpy(map_name, mn);
if(!M->can_use_inifile())
return LoadLevelPart(M, map_name);
int fnidx=0;
while(FS.exist(map_name))
{
IReader* R = FS.r_open (map_name);
VERIFY (R);
char ch;
R->r (&ch,sizeof(ch));
bool b_is_inifile = (ch=='[');
FS.r_close (R);
if(!b_is_inifile)
return LoadLevelPart(M, map_name);
M->m_EditFlags.set(ESceneToolBase::flReadonly,FALSE);
CInifile ini(map_name);
// check level part GUID
xrGUID guid;
guid.LoadLTX (ini, "guid", "guid");
if (guid!=m_GUID)
{
ELog.DlgMsg (mtError,"Skipping invalid version of level part: '%s\\%s.part'",EFS.ExtractFileName(map_name).c_str(),M->ClassName());
return FALSE;
}
// read data
M->LoadLTX (ini);
++fnidx;
sprintf(map_name, "%s%d", mn, fnidx);
}
return TRUE;
}