• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GetChunk函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetChunk函数的典型用法代码示例。如果您正苦于以下问题:C++ GetChunk函数的具体用法?C++ GetChunk怎么用?C++ GetChunk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetChunk函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: m_SoundCallbacks

Sound::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,代码来源:Sound.cpp


示例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,代码来源:GLMapRenderer.cpp


示例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,代码来源:SnM_Chunk.cpp


示例4: OnSetChunkNeighborhood

void 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,代码来源:clientnetinterface.cpp


示例5: OnSetBlock

void 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,代码来源:clientnetinterface.cpp


示例6: DoNextChunk

static 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,代码来源:pm_3ds.c


示例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,代码来源:GLRadiosityRenderer.cpp


示例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,代码来源:SnM_Chunk.cpp


示例9: GetChunk

const 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,代码来源:chunk.cpp


示例10: CreateRandomChunk

void 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,代码来源:chunk.cpp


示例11: of

void 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,代码来源:HierarchicalPathfinder.cpp


示例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,代码来源:SnM_Chunk.cpp


示例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,代码来源:WavAudioStream.cpp


示例14: GetPos

bool 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,代码来源:babelglue.cpp


示例15: GetChunk

bool 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,代码来源:world.cpp


示例16: GetChunk

BOOL 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,代码来源:ado2.cpp


示例17: GetChunk

void 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,代码来源:nuiAiffReader.cpp


示例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,代码来源:SnM_Chunk.cpp


示例19: GetChunk

void 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,代码来源:nuiWaveReader.cpp


示例20: GetChunk

bool 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,代码来源:loadlib.cpp



注:本文中的GetChunk函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetClassLong函数代码示例发布时间:2022-05-30
下一篇:
C++ GetChildren函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap