这篇教程C++ GetChunk函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetChunk函数的典型用法代码示例。如果您正苦于以下问题:C++ GetChunk函数的具体用法?C++ GetChunk怎么用?C++ GetChunk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetChunk函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: m_SoundCallbacksSound::Sound(const std::wstring& waveResourceName, bool loopForever, bool hasReverb) : m_SoundCallbacks(this), m_SubmixVoice(nullptr){ auto waveFile = RiffFile::Create(waveResourceName); Assert(waveFile.GetFormat() == RiffFourCC::WAVE); ZeroMemory(&m_WaveFormat, sizeof(m_WaveFormat)); ZeroMemory(&m_AudioBuffer, sizeof(m_AudioBuffer)); const auto& formatChunk = waveFile.GetChunk(RiffFourCC::FMT); Assert(sizeof(m_WaveFormat) >= formatChunk.GetSize()); memcpy(&m_WaveFormat, formatChunk.GetData(), formatChunk.GetSize()); auto& dataChunk = waveFile.GetChunk(RiffFourCC::DATA); m_SoundDataBuffer = std::move(dataChunk.GetDataBuffer()); m_AudioBuffer.AudioBytes = dataChunk.GetSize(); m_AudioBuffer.pAudioData = m_SoundDataBuffer.get(); m_AudioBuffer.Flags = XAUDIO2_END_OF_STREAM; m_AudioBuffer.LoopCount = loopForever ? XAUDIO2_LOOP_INFINITE : 0; if (hasReverb) { m_SubmixVoice = AudioManager::GetInstance().CreateSubmixVoice(m_WaveFormat); }}
开发者ID:William500,项目名称:Speecher,代码行数:27,
示例2: GetChunk void GLMapRenderer::DrawColumnDLight(int cx, int cy, int cz, spades::Vector3 eye, const std::vector<GLDynamicLight>& lights){ cx &= numChunkWidth -1; cy &= numChunkHeight - 1; for(int z = std::max(cz, 0); z < numChunkDepth; z++) GetChunk(cx, cy, z)->RenderDLightPass(lights); for(int z = std::min(cz - 1, 63); z >= 0; z--) GetChunk(cx, cy, z)->RenderDLightPass(lights); }
开发者ID:2mac,项目名称:openspades,代码行数:8,
示例3: strstr// return false if _takeIdx not found (e.g. empty *item*)bool SNM_TakeParserPatcher::GetTakeChunkPos(int _takeIdx, int* _pos, int* _len){ int tkCount = 0; const char* p = strstr(GetChunk()->Get(), "/nTAKE"); // force GetChunk() (+ add fake 1st take if needed) while (p) { if (IsValidTakeChunkLine(p)) { if (tkCount == _takeIdx) { // is there a next take ? const char* p2 = strstr(p+1, "/nTAKE"); while (p2) { if (IsValidTakeChunkLine(p2)) break; p2 = strstr(p2+1, "/nTAKE"); } *_pos = (int)(p+1 - m_chunk->Get()); if (_len) { if (p2 && !strncmp(p2, "/nTAKE", 5)) *_len = (int)(p2-p); // it's the last take else *_len = strlen(p+1)-2; // -2 for final ">/n" } return true; } tkCount++; } p = strstr(p+1, "/nTAKE"); } return false;}
开发者ID:Jeff0S,项目名称:sws,代码行数:34,
示例4: OnSetChunkNeighborhoodvoid OnSetChunkNeighborhood(Packet& packet) { u16 chunkID, neighborhoodID; packet.Read(chunkID); packet.Read(neighborhoodID); auto chmgr = ChunkManager::Get(); auto ch = chmgr->GetChunk(chunkID); if(!ch) { logger << "Server tried to set neighborhood of unknown chunk!"; return; } auto neigh = chmgr->GetNeighborhood(neighborhoodID); if(!neigh) { neigh = chmgr->CreateNeighborhood(); neigh->neighborhoodID = neighborhoodID; neigh->chunkSize = ivec3{ch->width, ch->height, ch->depth}; } ch->SetNeighborhood(neigh); packet.Read<ivec3>(ch->positionInNeighborhood); logger << ch->positionInNeighborhood; neigh->UpdateChunkTransform(ch);}
开发者ID:manpat,项目名称:vox,代码行数:25,
示例5: OnSetBlockvoid OnSetBlock(Packet& packet) { auto chmgr = ChunkManager::Get(); u8 orientation; u16 chunkID, blockType; ivec3 vxPos; // Assume vxPos is in bounds packet.Read(chunkID); packet.Read<ivec3>(vxPos); packet.Read(blockType); orientation = blockType & 3; blockType >>= 2; auto ch = chmgr->GetChunk(chunkID); if(!ch) { logger << "Missing chunkID " << chunkID; return; } if(blockType) { auto blk = ch->CreateBlock(vxPos, blockType); if(blk) blk->orientation = orientation; else logger << "Block create failed at " << vxPos; }else{ ch->DestroyBlock(vxPos); }}
开发者ID:manpat,项目名称:vox,代码行数:28,
示例6: DoNextChunkstatic int DoNextChunk( T3dsLoaderPers *pers, int endofs ){ T3dsChunk *chunk;#ifdef DEBUG_PM_3DS printf( "DoNextChunk: endofs %d/n",endofs );#endif while ( pers->cofs < endofs ) { long nextofs = pers->cofs; if ( ( chunk = GetChunk( pers ) ) == NULL ) { return 0; } if ( !chunk->len ) { return 0; } nextofs += chunk->len;#ifdef DEBUG_PM_3DS_EX printf( "Chunk %04x (%s), len %d pers->cofs %x/n",chunk->id,DebugGetChunkName( chunk->id ),chunk->len,pers->cofs );#endif /*** version ***/ if ( chunk->id == CHUNK_VERSION ) { /* at this point i get the 3ds file version. since there */ /* might be new additions to the 3ds file format in 4.0 */ /* it might be a good idea to store the version somewhere */ /* for later handling or message displaying */ /* get the version */ int version; version = GetWord( pers ); GetWord( pers );#ifdef DEBUG_PM_3DS printf( "FileVersion: %d/n",version );#endif /* throw out a warning for version 4 models */ if ( version == 4 ) { _pico_printf( PICO_WARNING, "3DS version is 4. Model might load incorrectly." ); } /* store the 3ds file version in pico special field 0 */ /* PicoSetSurfaceSpecial(pers->surface,0,version); */ /* ydnar: this was causing a crash accessing uninitialized surface */ /* rest of chunk is skipped here */ } /*** editor data ***/ if ( chunk->id == CHUNK_EDITOR_DATA ) { if ( !DoNextEditorDataChunk( pers,nextofs ) ) { return 0; } continue; } /* skip unknown chunk */ pers->cofs = nextofs; if ( pers->cofs >= pers->maxofs ) { break; } } return 1;}
开发者ID:xonotic,项目名称:netradient,代码行数:60,
示例7: GetChunk void GLRadiosityRenderer::UpdateChunk(int cx, int cy, int cz) { Chunk &c = GetChunk(cx, cy, cz); if (!c.dirty) return; int originX = cx * ChunkSize; int originY = cy * ChunkSize; int originZ = cz * ChunkSize; for (int z = c.dirtyMinZ; z <= c.dirtyMaxZ; z++) for (int y = c.dirtyMinY; y <= c.dirtyMaxY; y++) for (int x = c.dirtyMinX; x <= c.dirtyMaxX; x++) { IntVector3 pos; pos.x = (x + originX); pos.y = (y + originY); pos.z = (z + originZ); Result res = Evaluate(pos); c.dataFlat[z][y][x] = EncodeValue(res.base); c.dataX[z][y][x] = EncodeValue(res.x); c.dataY[z][y][x] = EncodeValue(res.y); c.dataZ[z][y][x] = EncodeValue(res.z); } c.dirty = false; c.transferDone = false; }
开发者ID:yvt,项目名称:openspades,代码行数:27,
示例8: InsertTake// assumes _chunk always begins with "TAKE"// _pos: start pos of the take if known, for optimization (-1 if unknown)// returns the end position after insertion (or -1 if failed)int SNM_TakeParserPatcher::InsertTake(int _takeIdx, WDL_FastString* _chunk, int _pos){ int afterPos = -1; int length = _chunk ? _chunk->GetLength() : 0; if (length && GetChunk()) // force GetChunk() (force cache + add fake 1st take if needed) { // last pos? if (_takeIdx >= CountTakesInChunk()) { afterPos = AddLastTake(_chunk); } // other pos else { int pos = _pos; if (pos < 0) GetTakeChunkPos(_takeIdx, &pos); if (pos >= 0) { m_chunk->Insert(_chunk->Get(), pos); afterPos = pos + length; m_currentTakeCount++; // *always* reflect the nb of takes in the *chunk* m_updates++; // as we're directly working on the cached chunk.. } } } return afterPos;}
开发者ID:Jeff0S,项目名称:sws,代码行数:32,
示例9: GetChunkconst unsigned char C_Game::GetCubeType(const int h, const int i, const int j){ int diffX = 0; int diffY = 0; if(h < 0) diffX = 1; if(i < 0) diffY = 1; int a = (h+diffX)/CHUNK_SIZE; if(h < 0) a--; int b = (i+diffY)/CHUNK_SIZE; if(i < 0) b--; MinecraftChunk *ch = GetChunk(a, b); int xx = h + diffX - (int)((h+diffX)/CHUNK_SIZE) * CHUNK_SIZE; if(h < 0) { if(xx <= 0) xx = CHUNK_SIZE - 1 + xx; } int yy = i + diffY - (int)((i+diffY)/CHUNK_SIZE) * CHUNK_SIZE; if(i < 0) { if(yy <= 0) yy = CHUNK_SIZE - 1 + yy; } return ch->_chunkMap[xx][yy][j];}
开发者ID:Okara,项目名称:Minecraft,代码行数:32,
示例10: CreateRandomChunkvoid C_Game::CreateRandomChunk(const int a, const int b){ if(GetChunk(a, b) != NULL) return; MinecraftChunk *temp = new MinecraftChunk; temp->x = a; temp->y = b; temp->_hidden = true; _chunks.push_back(temp); for(int h=0;h<CHUNK_SIZE;h++) { for(int i=0;i<CHUNK_SIZE;i++) { for(int j=0;j<CHUNK_ZVALUE;j++) { _chunks.back()->_chunkMap[h][i][j] = (rand() % (NB_TYPE_CUBE-1)) +1; } } } for(int h=0;h<CHUNK_SIZE;h++) for(int i=0;i<CHUNK_SIZE;i++) for(int j=CHUNK_ZVALUE/2;j<CHUNK_ZVALUE;j++) _chunks.back()->_chunkMap[h][i][j] = CUBE_AIR;}
开发者ID:Okara,项目名称:Minecraft,代码行数:26,
示例11: ofvoid HierarchicalPathfinder::FindNearestNavcellInRegions(const std::set<RegionID>& regions, u16& iGoal, u16& jGoal, pass_class_t passClass){ // Find the navcell in the given regions that's nearest to the goal navcell: // * For each region, record the (squared) minimal distance to the goal point // * Sort regions by that underestimated distance // * For each region, find the actual nearest navcell // * Stop when the underestimated distances are worse than the best real distance std::vector<std::pair<u32, RegionID> > regionDistEsts; // pair of (distance^2, region) for (const RegionID& region : regions) { int i0 = region.ci * CHUNK_SIZE; int j0 = region.cj * CHUNK_SIZE; int i1 = i0 + CHUNK_SIZE - 1; int j1 = j0 + CHUNK_SIZE - 1; // Pick the point in the chunk nearest the goal int iNear = Clamp((int)iGoal, i0, i1); int jNear = Clamp((int)jGoal, j0, j1); int dist2 = (iNear - iGoal)*(iNear - iGoal) + (jNear - jGoal)*(jNear - jGoal); regionDistEsts.emplace_back(dist2, region); } // Sort by increasing distance (tie-break on RegionID) std::sort(regionDistEsts.begin(), regionDistEsts.end()); int iBest = iGoal; int jBest = jGoal; u32 dist2Best = std::numeric_limits<u32>::max(); for (auto& pair : regionDistEsts) { if (pair.first >= dist2Best) break; RegionID region = pair.second; int i, j; u32 dist2; GetChunk(region.ci, region.cj, passClass).RegionNavcellNearest(region.r, iGoal, jGoal, i, j, dist2); if (dist2 < dist2Best) { iBest = i; jBest = j; dist2Best = dist2; } } iGoal = iBest; jGoal = jBest;}
开发者ID:krichter722,项目名称:0ad,代码行数:56,
示例12: GetChunk// assumes _newTakeChunk always begins with "TAKE"bool SNM_TakeParserPatcher::ReplaceTake(int _startTakePos, int _takeLength, WDL_FastString* _newTakeChunk){ bool updated = false; if (GetChunk() && _newTakeChunk && _startTakePos >= 0) // force GetChunk() (force cache + add fake 1st take if needed) { int prevLgth = GetChunk()->GetLength(); GetChunk()->DeleteSub(_startTakePos, _takeLength); m_updates++; // as we're directly working on the cached chunk.. updated = true; m_currentTakeCount--; if (prevLgth > GetChunk()->GetLength()) // see WDL_FastString.DeleteSub() { GetChunk()->Insert(_newTakeChunk->Get(), _startTakePos, _newTakeChunk->GetLength()); m_updates++; m_currentTakeCount++; } } return updated;}
开发者ID:Jeff0S,项目名称:sws,代码行数:20,
示例13: SPADES_MARK_FUNCTION WavAudioStream::WavAudioStream(IStream *s, bool ac) { SPADES_MARK_FUNCTION(); stream = s; autoClose = ac; // skip header s->SetPosition(12 + s->GetPosition()); while(s->GetPosition() < s->GetLength()) { RiffChunkInfo info = ReadChunkInfo(); chunks[info.name] = info; s->SetPosition(info.dataPosition + info.length); } const RiffChunkInfo& fmt = GetChunk("fmt "); stream->SetPosition(fmt.dataPosition); stream->ReadLittleShort();// ?? channels = stream->ReadLittleShort(); rate = stream->ReadLittleInt(); stream->ReadLittleInt(); stream->ReadLittleShort(); int bits = stream->ReadLittleShort(); switch(bits){ case 8: sampleFormat = UnsignedByte; break; case 16: sampleFormat = SignedShort; break; case 32: sampleFormat = SingleFloat; break; default: SPRaise("Unsupported bit count: %d", bits); } dataChunk = &GetChunk("data"); stream->SetPosition(dataChunk->dataPosition); startPos = dataChunk->dataPosition; endPos = dataChunk->dataPosition + dataChunk->length; }
开发者ID:insanity54,项目名称:openspades,代码行数:43,
示例14: GetPosbool BabelGlue::GetPos(GPXCoord *pos){ const char *file; unsigned long fs; int num; long crc; kGUIString created; kGUIString coords; kGUIStringSplit ss; bool gotnew=false; crc=kGUI::FileCRC("gpsbabel.kml"); file=(const char *)kGUI::LoadFile("gpsbabel.kml",&fs); if(file) { /* get created string */ if(GetChunk("<Snippet>",file,&created)) { /* get coords */ if(GetChunk("<coordinates>",file,&coords)) { /* created only has 1 second resolution so we use crc too */ if(strcmp(created.GetString(),m_created.GetString()) || m_crc!=crc) { num=ss.Split(&coords,","); if((num==2) || (num==3)) { /* lon/lat/alt */ m_created.SetString(&created); m_crc=crc; m_lat=ss.GetWord(1)->GetDouble(); m_lon=ss.GetWord(0)->GetDouble(); pos->Set(m_lat,m_lon); gotnew=true; } } } } delete []file; } return(gotnew);}
开发者ID:neolu,项目名称:gpsturbo,代码行数:42,
示例15: GetChunkbool World::UnloadChunk(Chunk::ChunkPosition chunkPosition) { Chunk* pChunk = GetChunk(chunkPosition.x, chunkPosition.y, chunkPosition.z); if(pChunk == nullptr) return false; m_vpChunks.erase(std::remove(m_vpChunks.begin(), m_vpChunks.end(), pChunk), m_vpChunks.end()); m_vpChunksToGenerate.erase(std::remove(m_vpChunksToGenerate.begin(), m_vpChunksToGenerate.end(), pChunk), m_vpChunksToGenerate.end()); m_vpChunksToMesh.erase(std::remove(m_vpChunksToMesh.begin(), m_vpChunksToMesh.end(), pChunk), m_vpChunksToMesh.end()); m_vpChunksToRender.erase(std::remove(m_vpChunksToRender.begin(), m_vpChunksToRender.end(), pChunk), m_vpChunksToRender.end()); delete pChunk; pChunk = nullptr; return true;}
开发者ID:SamuelBoerlin,项目名称:Marching-Cubes,代码行数:11,
示例16: GetChunkBOOL CADORecordset::GetChunk(int nIndex, CString& strValue){ _variant_t vtIndex; vtIndex.vt = VT_I2; vtIndex.iVal = nIndex; FieldPtr pField = m_pRecordset->Fields->GetItem(vtIndex); return GetChunk(pField, strValue);}
开发者ID:zxlooong,项目名称:minica,代码行数:11,
示例17: GetChunkvoid nuiAiffReader::SetPosition(uint32 position){ if (!mInitialized) return; Chunk* pDataChunk = GetChunk("SSND"); NGL_ASSERT(pDataChunk); nglFileOffset StreamPosition = pDataChunk->mDataPosition + mInfo.GetChannels() * (mInfo.GetBitsPerSample() / 8) * position; mrStream.SetPos(StreamPosition); mPosition = position;}
开发者ID:YetToCome,项目名称:nui3,代码行数:11,
示例18: AddLastTake// assumes that _tkChunk begins with "TAKE" // returns the end position after insertion (or -1 if failed)int SNM_TakeParserPatcher::AddLastTake(WDL_FastString* _tkChunk){ int afterPos = -1; if (_tkChunk && _tkChunk->GetLength() && GetChunk()) // force GetChunk() (cache + add fake 1st take if needed) { m_chunk->Insert(_tkChunk->Get(), m_chunk->GetLength()-2, _tkChunk->GetLength()); //-2: before ">/n" afterPos = m_chunk->GetLength()-2; m_currentTakeCount++; // *always* reflect the nb of takes in the *chunk* m_updates++; // as we're directly working on the cached chunk.. } return afterPos;}
开发者ID:Jeff0S,项目名称:sws,代码行数:14,
示例19: GetChunkvoid nuiWaveReader::SetPosition(int64 position){ if (!mInitialized) return; Chunk* pDataChunk = GetChunk("data"); nglFileOffset newStreamPosition = pDataChunk->mDataPosition + mInfo.GetChannels() * (mInfo.GetBitsPerSample() / 8) * position; nglFileOffset newPos = mrStream.SetPos(newStreamPosition); NGL_ASSERT(newPos == newStreamPosition); mPosition = position;}
开发者ID:JamesLinus,项目名称:nui3,代码行数:12,
示例20: GetChunkbool ChunkedFile::prepareLoadedData(){ FileChunk* chunk = GetChunk("MVER"); if (!chunk) return false; // Check version file_MVER* version = chunk->As<file_MVER>(); if (version->fcc != MverMagic.fcc) return false; if (version->ver != FILE_FORMAT_VERSION) return false; return true;}
开发者ID:GlassFace,项目名称:LegacyCore_6.x.x,代码行数:14,
示例21: GetChunkint SoundManager::PlayLoopingSample(std::string _filename){ //Look the sound up, it's probably already loaded. If not then load it. if(status_ != SoundStatus::OK) return -1; Mix_Chunk* sample = GetChunk(_filename); if(sample) { //Play the sound return Mix_PlayChannel(-1, sample, -1); } return -1;}
开发者ID:RahulSDeshpande,项目名称:ReverseArkanoid,代码行数:14,
示例22: GetChunkChunk* ChunkManager::GetChunkFromPosition(float posX, float posY, float posZ){ int gridX = (int)((posX + Chunk::BLOCK_RENDER_SIZE) / Chunk::CHUNK_SIZE); int gridY = (int)((posY + Chunk::BLOCK_RENDER_SIZE) / Chunk::CHUNK_SIZE); int gridZ = (int)((posZ + Chunk::BLOCK_RENDER_SIZE) / Chunk::CHUNK_SIZE); if (posX <= -0.5f) gridX -= 1; if (posY <= -0.5f) gridY -= 1; if (posZ <= -0.5f) gridZ -= 1; return GetChunk(gridX, gridY, gridZ);}
开发者ID:CodeMason,项目名称:Vox,代码行数:15,
注:本文中的GetChunk函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetClassLong函数代码示例 C++ GetChildren函数代码示例 |