当前位置: 首页>>代码示例>>C++>>正文


C++ Chunk类代码示例

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


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

示例1: ProcessInternal

void WorldModelHandler::ProcessInternal( ChunkedData* subChunks )
{
    if (!IsSane())
        return;
    Chunk* wmoReferencesChunk = subChunks->GetChunkByName("MCRW");
    if (!wmoReferencesChunk)
        return;
    FILE* stream = wmoReferencesChunk->GetStream();
    uint32 refCount = wmoReferencesChunk->Length / 4;
    for (uint32 i = 0; i < refCount; i++)
    {
        int32 index;
        if (fread(&index, sizeof(int32), 1, stream) != 1)
            printf("WorldModelDefinition::Read: Error reading data, expected 1, read 0\n");

        if (index < 0 || uint32(index) >= _definitions->size())
            continue;

        WorldModelDefinition wmo = (*_definitions)[index];

        if (_drawn.find(wmo.UniqueId) != _drawn.end())
            continue;
        _drawn.insert(wmo.UniqueId);

        if (wmo.MwidIndex >= _paths->size())
            continue;

        std::string path = (*_paths)[wmo.MwidIndex];
        WorldModelRoot* model = Cache->WorldModelCache.Get(path);
        if (!model)
        {
            model = new WorldModelRoot(path);
            Cache->WorldModelCache.Insert(path, model);
        }

        Vertices.reserve(1000);
        Triangles.reserve(1000);

        InsertModelGeometry(Vertices, Triangles, wmo, model);
    }
}
开发者ID:AlucardVoss,项目名称:Patchs,代码行数:41,代码来源:WorldModelHandler.cpp

示例2: ASSERT

void _3dsLoader::readMaterialMapFile(Chunk &currentChunk, Material &material) const
{
	ASSERT(currentChunk.getID()==MATMAPFILE, "Expected chunk ID MATMAPFILE");

	const size_t size = currentChunk.getSize() - currentChunk.tell();
	char *relativeFileName = new char[size];
	currentChunk.read(relativeFileName, size);

	const string chunkFile = currentChunk.getFilename();
	const string path = File::getPath(chunkFile);
	const string absoluteFileName = pathAppend(path, relativeFileName);

	TRACE("3DS current file: " + chunkFile);
	TRACE("3DS current path: " + path);
	TRACE(string("3DS material: ") + relativeFileName);
	TRACE("Reading 3DS material from: " + absoluteFileName);

	material.loadTexture(absoluteFileName, 0);

	delete[] relativeFileName;
}
开发者ID:foxostro,项目名称:arbarlith2,代码行数:21,代码来源:3dsLoader.cpp

示例3: ReadModelPaths

void WorldModelHandler::ReadModelPaths()
{
    Chunk* mwid = Source->ObjectData->GetChunkByName("MWID");
    Chunk* mwmo = Source->ObjectData->GetChunkByName("MWMO");
    if (!mwid || !mwmo)
        return;

    uint32 paths = mwid->Length / 4;
    _paths = new std::vector<std::string>;
    _paths->reserve(paths);
    for (uint32 i = 0; i < paths; i++)
    {
        FILE* stream = mwid->GetStream();
        fseek(stream, i * 4, SEEK_CUR);
        uint32 offset;
        fread(&offset, sizeof(uint32), 1, stream);
        FILE* dataStream = mwmo->GetStream();
        fseek(dataStream, offset + mwmo->Offset, SEEK_SET);
        _paths->push_back(Utils::ReadString(dataStream));
    }
}
开发者ID:Lop3r,项目名称:vychytavky,代码行数:21,代码来源:WorldModelHandler.cpp

示例4: setBiomes

void ChunkGenerator::setBiomes(Map& m, Chunk chunk, int x, int z, int biomeNoise) {
  BiomeType type = chunk.getBiomeType();

  double frequency = getFrequency(type);
  int lowerBound = getLowerBound(type);
  int upperBound = getUpperBound(type);

  for(int xi = x * 16; xi < (x * 16) + 16; xi++) {
    // Blöcke von oben nach unten (in Blockkoordinaten)
    for(int zj = z * 16; zj < (z * 16) + 16; zj++) {




      // Simplex Noise:
      double simpNoise;
      int noise;
      // Wenn Biom Mountains oder Hillside
      if(70 <= biomeNoise && biomeNoise <= 126){
        // Umrechnen von Intervall [70,126] in [-1.25,1.25] für Gaußsche Glockenkurve
        double term = ((1.75 * biomeNoise - (-1.75) * biomeNoise + 126 * (-1.75) - 1.75 * 70) / (126.0 - 70.0));
        // Multiplikation von Simplex Noise mit Gaußscher Glockenkurve für einen weicheren Biomübergang an den Bergen
        simpNoise = exp(-1 * term * term) * SimplexNoise::noise(frequency * xi, frequency * zj, m_seed);
        // Umrechnen von Intervall [-1,1] in Intervall [c,d]
        noise = SimplexNoise::noiseInt(lowerBound, upperBound, simpNoise) - 9;
        if(type == BiomeType::WaterHillside) {
          noise -= 10;
        } 
        if(m_setWater == false) {
          noise += 3;
        }
      }
      else {
        // Berechne Werte im Intervall [-1,1] mit Simplex Noise
        simpNoise = SimplexNoise::noise(frequency * xi, frequency * zj, m_seed);
        // Umrechnen von Intervall [-1,1] in Intervall [c,d]
        noise = SimplexNoise::noiseInt(lowerBound, upperBound, simpNoise) + 1;
      }

      // xi und zj umrechnen
      int xii = xi%16;
	    int zjj = zj%16;
	    if(xii < 0) {
	      xii += 16;
	    }
	    if(zjj % 16 < 0) {
	      zjj += 16;
	    }

      setBlockHeight(m, type, x, z, xii, zjj, noise, biomeNoise);
    }
  }
}
开发者ID:NikoKrause,项目名称:cg-14,代码行数:53,代码来源:ChunkGenerator.cpp

示例5: loadChunk

void loadChunk(Chunk chunk, bool alive){
    for(int y=LEVEL_HEIGHT-1; y > 0 ; y--){
        for(int x=0; x < LEVEL_WIDTH; x++){
            if(chunk.get(y, x)){
                Entity myEntity = *new Entity(chunk.tileGlobalX(y, x),-(chunk.tileGlobalY(y,x)),TILE_X,TILE_Y);
                if (rand() % 100 < 20){
                    myEntity.type = BPLATFORM;
                    myEntity.sprite = SheetSprite(spriteSheetTexture, 0.0f/914.0f, 432.0f/936.0f, 70.0f/914.0f, 70.0f/936.0f, 0.2);
                }
                else{
                    myEntity.type = PLATFORM;
                    myEntity.sprite = SheetSprite(spriteSheetTexture, 504.0f/914.0f, 288.0f/936.0f, 70.0f/914.0f, 70.0f/936.0f, 0.2);
                }
                
                myEntity.isStatic = true;
                myEntity.isAlive = alive;
                entities.push_back(myEntity);
            }
        }
    }
}
开发者ID:maxlebedev,项目名称:CS3113,代码行数:21,代码来源:main.cpp

示例6: ReadModelPaths

void WorldModelHandler::ReadModelPaths()
{
    Chunk* mwid = Source->ObjectData->GetChunkByName("MWID");
    Chunk* mwmo = Source->ObjectData->GetChunkByName("MWMO");
    if (!mwid || !mwmo)
        return;

    uint32 paths = mwid->Length / 4;
    _paths = new std::vector<std::string>;
    _paths->reserve(paths);
    for (uint32 i = 0; i < paths; i++)
    {
        Stream* stream = mwid->GetStream();
        stream->Seek(i * 4, SEEK_CUR);
        uint32 offset = stream->Read<uint32>();

        Stream* dataStream = mwmo->GetStream();
        dataStream->Seek(offset + mwmo->Offset, SEEK_SET);
        _paths->push_back(dataStream->ReadString());
    }
}
开发者ID:happy-tree-friends,项目名称:Eluna-TC-Cata,代码行数:21,代码来源:WorldModelHandler.cpp

示例7: chunkDownloaded

	void ChunkManager::chunkDownloaded(unsigned int i)
	{
		if (i >= (Uint32)d->chunks.size())
			return;

		Chunk* c = d->chunks[i];
		if (!c->isExcluded())
		{
			// update the index file
			bitset.set(i,true);
			d->todo.set(i,false);
			d->recalc_chunks_left = true;
			d->writeIndexFileEntry(c);
			c->setStatus(Chunk::ON_DISK);
			tor.updateFilePercentage(i,*this);
		}
		else
		{
			Out(SYS_DIO|LOG_IMPORTANT) << "Warning: attempted to save a chunk which was excluded" << endl;
		}
	}
开发者ID:netrunner-debian-kde-extras,项目名称:libktorrent,代码行数:21,代码来源:chunkmanager.cpp

示例8: Encode

 void Encode(const Chunk& data)
 {
   const std::size_t samples = data.size();
   float** const buffer = VorbisApi->vorbis_analysis_buffer(&State, samples);
   for (std::size_t pos = 0; pos != samples; ++pos)
   {
     const Sample in = data[pos];
     buffer[0][pos] = ToFloat(in.Left());
     buffer[1][pos] = ToFloat(in.Right());
   }
   CheckVorbisCall(VorbisApi->vorbis_analysis_wrote(&State, samples), THIS_LINE);
 }
开发者ID:vitamin-caig,项目名称:zxtune,代码行数:12,代码来源:ogg_backend.cpp

示例9: checkChunk

void Player::checkChunk()
{
	glm::vec3 currentChunkPosition = ChunkManager::instance()->getCurrentChunk(m_currentPosition);

	if (currentChunkPosition != m_chunkPosition)
	{
		Chunk c;
		bool gotChunk = ChunkManager::instance()->getChunkHandle(currentChunkPosition, c);

		if (gotChunk)
		{
			m_chunkPosition = currentChunkPosition;
			m_chunkPositions = c.getBlockPositions();
			m_chunkPositionsFoliage = c.getFoliageBlockPositions();

			// If gravity was not enabled, well then enable it
			if(!m_ready)
				m_ready = true;
		}
	}
}
开发者ID:simon-bourque,项目名称:Computer-Graphics-Project,代码行数:21,代码来源:Player.cpp

示例10: buildData

    std::vector<char> buildData(Chunk& chunk) const
    {
        Cell::PooledStack cellStack(chunk.acquire());
        Data::PooledStack dataStack(chunk.pool().dataPool());
        for (Cell& cell : cellStack) dataStack.push(cell.acquire());
        cellStack.release();

        const std::size_t pointSize(chunk.schema().pointSize());

        std::vector<char> data;
        data.reserve(
                dataStack.size() * pointSize +
                buildTail(chunk, dataStack.size()).size());

        for (const char* d : dataStack)
        {
            data.insert(data.end(), d, d + pointSize);
        }

        return data;
    }
开发者ID:json87,项目名称:entwine,代码行数:21,代码来源:binary.hpp

示例11: allocChunk

MojErr MojBuffer::consolidate()
{
	if (m_chunks.size() > 1) {
		// calc total size
		MojSize size = 0;
		for (ChunkList::ConstIterator i = m_chunks.begin(); i != m_chunks.end(); ++i) {
			size += (*i)->dataSize();
		}
		// alloc chunk big enoug to hold it all
		Chunk* chunk = allocChunk(size);
		MojAllocCheck(chunk);
		// copy alldata to new chunk
		for (ChunkList::ConstIterator i = m_chunks.begin(); i != m_chunks.end(); ++i) {
			chunk->write((*i)->data(), (*i)->dataSize());
		}
		// replace existing chunks with new one
		clear();
		m_chunks.pushBack(chunk);
	}
	return MojErrNone;
}
开发者ID:feniksa,项目名称:indb8,代码行数:21,代码来源:MojBuffer.cpp

示例12: toObstacle

Vector3 toObstacle( const Vector3& v )
{
	// restrict to looking in the current chunk
	Chunk * chunk = ChunkManager::instance().cameraSpace()->findChunkFromPoint( v );
	if (chunk == NULL)
		return v;

	// look up for clusest thing above
	Vector3 pos(v);
	Vector3 end(v);
	end.y += 400.f;

	const BoundingBox& chunkBox = chunk->boundingBox();
	bool cliped = chunkBox.clip(pos, end);

	Vector3 groundPos = toObstacle(end, Vector3(0.f, -1.f, 0.f));
	if (groundPos != pos)
		return groundPos;

	return v;
}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:21,代码来源:snaps.cpp

示例13: in

    size_t BitmapEncoding::Bitmap::decompress(void const* src, size_t size, Chunk& chunk)
    {
        size_t chunkSize = chunk.getSize();
        TypeId type = chunk.getAttributeDesc().getType();        
        _elementSize = TypeLibrary::getType(type).byteSize();

        if(_elementSize == 0 || _elementSize > 8 || chunk.isSparse() || !chunk.getArrayDesc().isImmutable() || chunk.getAttributeDesc().isNullable())
        {
            _bitmapElements = chunkSize;
            _elementSize = 1;
        }
        else
        {
            _bitmapElements = chunkSize / _elementSize;
        }


        if(!_bitmapElements) { return chunkSize; }

        uint8_t* dst = (uint8_t*)chunk.getData();
        ByteInputItr in((uint8_t *)src, size);
        uint32_t bmLength = ceil(_bitmapElements / 8.0);
        uint32_t individualBMLength = bmLength + _elementSize; // value + bm
        assert(individualBMLength);
        uint32_t bitmaps = size / individualBMLength;

        boost::scoped_array<uint8_t> bitmapArr(new uint8_t[bmLength]);
        boost::scoped_array<uint8_t> baseValueArr(new uint8_t[_elementSize]);

        uint8_t *bitmap = bitmapArr.get();
        uint8_t *baseValue = baseValueArr.get();

        for(uint32_t i = 0; i < bitmaps; ++i)
        {
            if(in.getArray(baseValue, _elementSize) == -1) { return 0; }
            if(in.getArray(bitmap, bmLength)== -1) { return 0; } 
            decodeBitmap(baseValue, bitmap, dst);
        }
        return chunkSize;
    }
开发者ID:hansmire,项目名称:scidb-osx-12.10-mountain-lion,代码行数:40,代码来源:BitmapEncoding.cpp

示例14: verifyChunkMD5

void verifyChunkMD5(vector<File> &files) {
  try {
    while (true) {
      Chunk * c = chunksToComputeMD5.consume();
      if (files[c->parentFileIndex].matchStatus == File::Status::FAILED_TO_MATCH_REMOTE_FILE) {
        // We have already marked file as a non-match, don't waste time reading more chunks from it
        c->log("File status == FAILED_TO_MATCH_REMOTE_FILE, Skipping the MD5 compute...");
        chunksSkipped.produce(c);
      } else {
        c->log("Computing MD5...");
        string computedMD5 = c->computeMD5();
        if (c->expectedMD5 != computedMD5) {
          c->log("MISMATCH between expected MD5 '" + c->expectedMD5 + "', and computed MD5 '" + computedMD5 + "' ... marking the file as Mismatch");
          files[c->parentFileIndex].matchStatus = File::Status::FAILED_TO_MATCH_REMOTE_FILE;
          chunksFailed.produce(c);
        } else {
          c->log("Expected and computed MD5 match!");
          chunksFinished.produce(c);
        }
      }
    }
  } catch (boost::thread_interrupted &ti) {
    return;
  }
}
开发者ID:jameslz,项目名称:dx-toolkit,代码行数:25,代码来源:main.cpp

示例15: DestroyBlock

// World editing
void Player::DestroyBlock()
{
	if (m_blockSelection)
	{
		Chunk* pChunk = m_pChunkManager->GetChunkFromPosition(m_blockSelectionPos.x, m_blockSelectionPos.y, m_blockSelectionPos.z);

		if (pChunk != NULL)
		{
			int blockX, blockY, blockZ;
			vec3 blockPos;
			bool active = m_pChunkManager->GetBlockActiveFrom3DPosition(m_blockSelectionPos.x, m_blockSelectionPos.y, m_blockSelectionPos.z, &blockPos, &blockX, &blockY, &blockZ, &pChunk);
			if (active)
			{
				float r;
				float g;
				float b;
				float a;
				pChunk->GetColour(blockX, blockY, blockZ, &r, &g, &b, &a);

				pChunk->StartBatchUpdate();
				pChunk->SetColour(blockX, blockY, blockZ, 0);
				pChunk->StopBatchUpdate();

				m_pChunkManager->CreateBlockDestroyParticleEffect(r, g, b, a, m_blockSelectionPos);

				// Create the collectible block item
				BlockType blockType = pChunk->GetBlockType(blockX, blockY, blockZ);
				m_pChunkManager->CreateCollectibleBlock(blockType, m_blockSelectionPos);
			}
		}

		m_blockSelection = false;
	}
}
开发者ID:AlwaysGeeky,项目名称:Vox,代码行数:35,代码来源:PlayerCombat.cpp


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