本文整理汇总了C++中ReadChunk函数的典型用法代码示例。如果您正苦于以下问题:C++ ReadChunk函数的具体用法?C++ ReadChunk怎么用?C++ ReadChunk使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadChunk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DI_SERIAL_LOG
void DiMeshSerializerImpl::ReadSubMesh( DiDataStreamPtr& stream, DiMesh* pMesh )
{
DI_SERIAL_LOG("Reading submesh..");
DiSubMesh* sm = pMesh->CreateSubMesh();
unsigned short streamID = 0;
DiString material = ReadString(stream);
sm->SetMaterialName(material);
DI_SERIAL_LOG("Liking material: %s", material.c_str());
unsigned int indexCount = 0;
ReadInts(stream, &indexCount, 1);
DI_SERIAL_LOG("Indeices count: %d", indexCount);
bool idx32bit;
ReadBools(stream, &idx32bit, 1);
DI_SERIAL_LOG("Index size: %d", idx32bit?32:16);
uint16 primitive;
ReadShorts(stream,&primitive,1);
sm->SetPrimitiveType((DiPrimitiveType)primitive);
DI_SERIAL_LOG("Primitive type: %d", primitive);
if (indexCount > 0)
{
void* indexdata = sm->CreateIndexData(indexCount,idx32bit?TRUE:FALSE);
int size = indexCount * (sm->GetIndexSize() / 8);
stream->Read(indexdata, size);
DI_SERIAL_LOG("%d bytes readed", size);
}
streamID = ReadChunk(stream);
if (streamID != DI_GEOMETRY)
{
DI_ERROR("Bad stream ID");
return;
}
ReadGeometry(stream, sm);
if (!stream->Eof())
{
streamID = ReadChunk(stream);
if (streamID == DI_MESH_WEIGHTS)
{
ReadSubMeshBoneWeights(stream,sm);
}
else
{
if (!stream->Eof())
stream->Skip(-MSTREAM_OVERHEAD_SIZE);
}
}
}
示例2: ReadChunk
bool MeshLoaderB3D::Load(const char* file) {
_file = new lfFile;
if( !_file->Open(file) )
return false;
_mesh = new Mesh;
lfStr head = ReadChunk();
int nB3DVersion = _file->ReadInt();
Sys_Printf("load b3d file %s, version %s %d\n", file, head.c_str(), nB3DVersion);
while( CheckSize() ) {
lfStr t = ReadChunk();
if (t == "TEXS")
ReadTexs();
else if (t == "BRUS")
ReadBrus();
else if (t == "NODE")
_mesh->SetJoint(ReadNode());
ExitChunk();
}
delete _file;
_file = NULL;
// The MESH chunk describes a mesh.
// A mesh only has one VRTS chunk, but potentially many TRIS chunks.
srfTriangles_t* tri = _mesh->GetGeometries(0);
tri->numIndices = _indices.size();
_indices.set_free_when_destroyed(false);
tri->indices = _indices.pointer();
return true;
}
示例3: ReadFileHeader
void DiMotionSerializerImpl::ImportMotion( DiDataStreamPtr& stream, DiMotion* pDest )
{
ReadFileHeader(stream);
if (!stream->Eof())
{
uint16 streamID = ReadChunk(stream);
while(!stream->Eof() &&
(streamID == DI_SKELETON ||
streamID == DI_POSE ||
streamID == DI_ANIMATION))
{
switch(streamID)
{
case DI_SKELETON:
ReadSkeleton(stream,pDest);
break;
case DI_ANIMATION:
ReadAnimations(stream, pDest);
break;
case DI_POSE:
ReadPoses(stream,pDest);
break;
}
if (!stream->Eof())
streamID = ReadChunk(stream);
}
if (!stream->Eof())
stream->Skip(-MSTREAM_OVERHEAD_SIZE);
}
}
示例4: ReadChunk
bool L3DS::FindChunk(LChunk &target, const LChunk &parent)
{
if (Pos() >= parent.end)
return false;
LChunk chunk;
chunk = ReadChunk();
while (( chunk.id != target.id) && (chunk.end <= parent.end))
{
SkipChunk(chunk);
if (chunk.end >= parent.end)
break;
unsigned short id = chunk.id;
uint end = chunk.end;
chunk = ReadChunk();
// try to detect a endless loop amz
if(id == chunk.id && end == chunk.end)
break;
}
if (chunk.id == target.id)
{
target.start = chunk.start;
target.end = chunk.end;
return true;
}
return false;
}
示例5: ReadFileHeader
void DiMeshSerializerImpl::ImportMesh( DiDataStreamPtr& stream, DiMesh* pMesh )
{
ReadFileHeader(stream);
if (!stream->Eof())
{
uint16 streamID = ReadChunk(stream);
while(!stream->Eof() &&
(
streamID == DI_SUBMESH ||
streamID == DI_MESH_BOUNDS))
{
switch(streamID)
{
case DI_SUBMESH:
ReadSubMesh(stream, pMesh);
break;
case DI_MESH_BOUNDS:
ReadBoundsInfo(stream, pMesh);
break;
}
if (!stream->Eof())
{
streamID = ReadChunk(stream);
}
}
if (!stream->Eof())
{
stream->Skip(-MSTREAM_OVERHEAD_SIZE);
}
}
}
示例6: ReadFloat
void L3DS::ReadCamera(const LChunk &parent)
{
LVector3 v,t;
LCamera camera;
camera.SetName(m_objName);
v.x = ReadFloat();
v.y = ReadFloat();
v.z = ReadFloat();
t.x = ReadFloat();
t.y = ReadFloat();
t.z = ReadFloat();
camera.SetPosition(v);
camera.SetTarget(t);
camera.SetBank(ReadFloat());
camera.SetFOV(2400.0f/ReadFloat());
LChunk chunk = ReadChunk();
while (chunk.end <= parent.end)
{
switch (chunk.id)
{
case CAM_RANGES:
camera.SetNearplane(ReadFloat());
camera.SetFarplane(ReadFloat());
break;
default:
break;
}
SkipChunk(chunk);
if (chunk.end >= parent.end)
break;
chunk = ReadChunk();
}
m_cameras.push_back(camera);
}
示例7: ErrorMsg
void L3DS::ReadFaceList(const LChunk &chunk, LMesh &mesh)
{
// variables
unsigned short count, t;
uint i;
LTri tri;
LChunk ch;
char str[20];
//uint mat;
// consistency checks
if (chunk.id != TRI_FACELIST)
{
ErrorMsg("L3DS::ReadFaceList - internal error: wrong chunk passed as parameter");
return;
}
GotoChunk(chunk);
tri.smoothingGroups = 1;
// read the number of faces
count = ReadShort();
mesh.SetTriangleArraySize(count);
for (i=0; i<count; i++)
{
tri.a = ReadShort();
tri.b = ReadShort();
tri.c = ReadShort();
ReadShort();
mesh.SetTri(tri, i);
}
// now read the optional chunks
ch = ReadChunk();
int mat_id;
while (ch.end <= chunk.end)
{
switch (ch.id)
{
case TRI_MAT_GROUP:
ReadASCIIZ(str, 20);
mat_id=0;
if (FindMaterial(str)!=NULL)
mat_id = FindMaterial(str)->GetID();
mesh.AddMaterial(mat_id);
count = ReadShort();
for (i=0; i<count; i++)
{
t = ReadShort();
mesh.GetTri(t).materialId = mat_id;
}
break;
case TRI_SMOOTH_GROUP:
for (i=0; i<mesh.GetTriangleCount(); i++)
mesh.GetTri(i).smoothingGroups = (ulong) ReadInt();
break;
}
SkipChunk(ch);
ch = ReadChunk();
}
}
示例8: tData
bool CLeadingPropCoder::DeCode_EffectUnitProp( const CDataChunk& inData , OBJ_HANDLE handle )
{
CLeadingProp* pEffectUnitProp = (CLeadingProp*)(handle);
CBufFile tData( inData.GetBuffer(), inData.GetSize() );
tData.SafeRead( (char*)&pEffectUnitProp->m_eTextOp, sizeof(SPR_BLENDOP) );
tData.SafeRead( (char*)&pEffectUnitProp->m_JumpSpeed, sizeof(int32) );
tData.SafeRead( (char*)&pEffectUnitProp->m_JumpNum, sizeof(int32) );
tData.SafeRead( (char*)&pEffectUnitProp->m_eLType, sizeof(CLeadingProp::eLP_LKType) );
tData.SafeRead( (char*)&pEffectUnitProp->m_eSSType, sizeof(CLeadingProp::eLP_StartScr) );
tData.SafeRead( (char*)&pEffectUnitProp->m_fStartAngle, sizeof(float) );
tData.SafeRead( (char*)&pEffectUnitProp->m_fRotSpeed, sizeof(float) );
tData.SafeRead( (char*)&pEffectUnitProp->m_fUVSpeed, sizeof(float) );
tData.SafeRead( (char*)&pEffectUnitProp->m_nPieceCount, sizeof(uint32) );
tData.SafeRead( (char*)&pEffectUnitProp->m_nDouCount, sizeof(uint32) );
tData.SafeRead( (char*)&pEffectUnitProp->m_fDouPercent, sizeof(float) );
tData.SafeRead( (char*)&pEffectUnitProp->m_fDouInterval, sizeof(float) );
tData.SafeRead( (char*)&pEffectUnitProp->m_eBlendModel, sizeof(SPR_BLENDMODE) );
tData.SafeRead( (char*)&pEffectUnitProp->m_eZTest, sizeof(Z_TEST) );
tData.SafeRead( (char*)&pEffectUnitProp->m_bLightEnable, sizeof(BOOL) );
tData.SafeRead( (char*)&pEffectUnitProp->m_fZBias, sizeof(float) );
CDataChunk tChunk;
tData.SafeRead(&tChunk.GetHdr(),sizeof(CDataChunk::ChunkHdr));
ReadChunk(tData,tChunk);
_DoDecode(tChunk,pEffectUnitProp);
return true;
}
示例9: while
void C3DSLoader::ReadNextObjChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreChunk)
{
int buffer[50000] = {0};
m_CurrentChunk = new tChunk;
while (pPreChunk->bytesRead < pPreChunk->length)
{
ReadChunk(m_CurrentChunk);
switch (m_CurrentChunk->ID)
{
case OBJ_MESH:
ReadNextObjChunk(pModel, pObject, m_CurrentChunk);
break;
case OBJ_VERTICES:
ReadVertices(pObject, m_CurrentChunk);
break;
case OBJ_FACES:
ReadVertexIndices(pObject, m_CurrentChunk);
break;
case OBJ_MATERIAL:
ReadObjMat(pModel, pObject, m_CurrentChunk);
break;
case OBJ_UV:
ReadUVCoordinates(pObject, m_CurrentChunk);
break;
default:
m_CurrentChunk->bytesRead += fread(buffer, 1, m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_FilePointer);
break;
}
pPreChunk->bytesRead += m_CurrentChunk->bytesRead;
}
delete m_CurrentChunk;
m_CurrentChunk = pPreChunk;
}
示例10: ac_isWAVEadpcm
/* 0 if adpcm, -1 otherwise */
static int ac_isWAVEadpcm(void *data, UNUSED(ALuint size), int encoding) {
alWaveFMT_LOKI *format;
Chunk riffchunk = { 0, 0, 0 };
int offset = 12;
do {
ReadChunk(data, &offset, &riffchunk);
} while ((riffchunk.magic == WAVE) ||
(riffchunk.magic == RIFF));
if(riffchunk.magic != FMT) {
return -1;
}
format = (alWaveFMT_LOKI *) riffchunk.data;
if(swap16le(format->encoding) == encoding) {
return 0;
}
#ifdef DEBUG_CONVERT
fprintf(stderr, "encoding | format->enc %d|%d\n",
format->encoding, encoding);
#endif
return -1;
}
示例11: main
/*----------------------------------------------------------------------
| main
+---------------------------------------------------------------------*/
int
main(int /*argc*/, char** /*argv*/)
{
// setup debugging
#if defined(WIN32) && defined(_DEBUG)
int flags = _crtDbgFlag |
_CRTDBG_ALLOC_MEM_DF |
_CRTDBG_DELAY_FREE_MEM_DF |
_CRTDBG_CHECK_ALWAYS_DF;
_CrtSetDbgFlag(flags);
//AllocConsole();
//freopen("CONOUT$", "w", stdout);
#endif
NPT_RingBuffer buffer(BUFFER_SIZE);
for (int i=0; i<100000000; i++) {
if (NPT_FAILED(WriteChunk(buffer))) {
printf("WriteChunk failed\n");
return 1;
}
if (NPT_FAILED(ReadChunk(buffer))) {
printf("ReadChunk failed\n");
return 1;
}
}
printf("RingBufferTest1 passed\n");
return 0;
}
示例12: while
void C3DSLoader::ReadObjectChunk(tChunk& pObjectChunk,C3DMesh& pMesh)
{
//get a fresh working chunk
tChunk currentChunk={0};
//read the sub chunks until we find the end of the parent chunk
while(pObjectChunk.bytesRead < pObjectChunk.length)
{
//Read the next chunk
ReadChunk(currentChunk);
switch(currentChunk.ID)
{
case OBJECT_MESH:
// We found a new object, so let's read in it's info using recursion
ReadTrimeshChunk(currentChunk,pMesh);
break;
default:
currentChunk.bytesRead+=fread(m_iBuffer,1,currentChunk.length-currentChunk.bytesRead,m_FilePointer);
break;
}//end switch
//Just read and discard unknown or unwanted chunks
pObjectChunk.bytesRead+=currentChunk.bytesRead;
}//end while
}//end ReadObjectChunk
示例13: pb
void Programmer::VerifyMainBlock(const std::string& hexfilename, const bool ignoreCheck)
{
// is MainBlock readback disabled?
if (!ignoreCheck && !CanReadMainBlock())
throw std::string("MainBlock readback is disabled by the target configuration.");
ProgressBar pb("Verifying");
FlashMemory flash(flashSize);
flash.LoadHex(hexfilename); // read the HEX file
FlashMemory verifyFlash(flashSize);
int address = 0;
while (address < flashSize)
{
ReadChunk(false, verifyFlash, address);
address += PROG_CHUNK_SIZE;
// update the progress bar
pb.Refresh(address / double(flashSize));
}
// now compare
if (flash != verifyFlash)
{
//flash.SaveHex("orig.hex");
//verifyFlash.SaveHex("verif.hex");
throw std::string("MainBlock verification failed.");
}
}
示例14: fopen
//////////////////////////////////////////////////////////////////
//加载模型
bool CLoad3DS::Import3DS(t3DModel *pModel, char *strFileName)
{
char strMessage[255] = {0};
m_FilePointer = fopen(strFileName, "rb");
if(!m_FilePointer)
{
sprintf(strMessage, "Unable to find the file: %s!", strFileName);
MessageBox(NULL, strMessage, "Error", MB_OK);
return false;
}
ReadChunk(m_CurrentChunk);
if (m_CurrentChunk->ID != PRIMARY)
{
sprintf(strMessage, "Unable to load PRIMARY chuck from file: %s!", strFileName);
MessageBox(NULL, strMessage, "Error", MB_OK);
return false;
}
ReadNextChunk(pModel, m_CurrentChunk);
ComputeNormals(pModel);
return true;
}
示例15: DEBUG
void AGG::Cache::LoadOrgICN(Sprite & sp, const ICN::icn_t icn, const u16 index, bool reflect)
{
std::vector<u8> body;
if(ReadChunk(ICN::GetString(icn), body))
{
// loading original
DEBUG(DBG_ENGINE, DBG_TRACE, "AGG::Cache::LoadOrgICN: " << ICN::GetString(icn) << ", " << index);
const u16 count = ReadLE16(&body[0]);
ICN::Header header1, header2;
header1.Load(&body[6 + index * ICN::Header::SizeOf()]);
if(index + 1 != count) header2.Load(&body[6 + (index + 1) * ICN::Header::SizeOf()]);
const u32 size_data = (index + 1 != count ? header2.OffsetData() - header1.OffsetData() :
// total size
ReadLE32(&body[2]) - header1.OffsetData());
sp.Set(header1.Width(), header1.Height(), ICN::RequiresAlpha(icn));
sp.SetOffset(header1.OffsetX(), header1.OffsetY());
sp.SetColorKey();
Sprite::DrawICN(sp, &body[6 + header1.OffsetData()], size_data, reflect);
Sprite::AddonExtensionModify(sp, icn, index);
}
else
Error::Except("AGG::Cache::LoadOrgICN: ReadChunk: ", ICN::GetString(icn));
}