motor::block_t& motor::World::getBlock(unsigned int x, unsigned int y, unsigned int z) { static block_t outOfBorderBlock = block_t(BLOCK_OOB, 0xFF); if((x >= worldDimX * chunkSizeX || y >= worldDimY * chunkSizeY || z >= worldDimZ * chunkSizeZ)) { //cout << "returning early!" << endl; outOfBorderBlock = block_t(BLOCK_OOB, 0xFF); return outOfBorderBlock; } //cout << "normal!" << endl; //cout << "x / 16:" << " y / 16:" << " z / 16:" << " x - ((x/16)*16):" << " y - ((y/16)*16):" << " z - ((z/16)*16):" << endl; //cout <<x / 16 << " " << y / 16 << " " << z / 16 << " " << x - ((x/16)*16) << " " << y - ((y/16)*16) << " " << z - ((z/16)*16) << endl; //return block_t(BLOCK_DIRT, 0); return chunks[x / chunkSizeX][y / chunkSizeY][z / chunkSizeZ].get(x - ((x/chunkSizeX)*chunkSizeX), y - ((y/chunkSizeY)*chunkSizeY), z - ((z/chunkSizeZ)*chunkSizeZ)); }
block_t &model_reader::findOrCreateBlock(const std::string &n) { block_t *b = findBlock(n); if (b == NULL) { blocks.push_back(block_t(n)); b = &blocks.back(); } return *b; }
bool model_writer::newBlock(const std::string &name) { blocks.push_back(std::make_pair(name, block_t(""))); return true; }