2013-03-02 00:11:18 +01:00
|
|
|
/*---------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
KubKraft
|
2013-05-22 23:43:05 +02:00
|
|
|
Copyright (C) 2013 Quentin Bazin <quent42340@gmail.com>
|
2013-03-02 00:11:18 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------------*/
|
|
|
|
#ifndef CHUNK_H
|
|
|
|
#define CHUNK_H
|
|
|
|
|
|
|
|
class Chunk {
|
|
|
|
public:
|
2013-04-29 15:29:22 +02:00
|
|
|
Chunk(int x, int y, int z);
|
2013-03-02 00:11:18 +01:00
|
|
|
~Chunk();
|
|
|
|
|
2013-03-09 03:23:13 +01:00
|
|
|
void setSurroundingChunk(unsigned char face, Chunk* chunk);
|
|
|
|
|
2013-03-07 07:58:55 +01:00
|
|
|
void render();
|
2013-03-02 00:11:18 +01:00
|
|
|
|
|
|
|
void deleteCube(Cube *cube);
|
2013-03-11 21:09:55 +01:00
|
|
|
void addCube(Cube *selectedCube, int type = 2);
|
2013-03-02 00:11:18 +01:00
|
|
|
|
2013-03-09 03:23:13 +01:00
|
|
|
void refreshVBO();
|
|
|
|
|
2013-03-02 00:11:18 +01:00
|
|
|
int x() const { return m_x; }
|
|
|
|
int y() const { return m_y; }
|
|
|
|
int z() const { return m_z; }
|
|
|
|
|
2013-04-30 19:36:41 +02:00
|
|
|
void putCube(int x, int y, int z, int type) { m_cubes[CUBE_POS(x, y, z)] = new Cube(x, y, z, type); }
|
2013-05-01 14:43:20 +02:00
|
|
|
std::unordered_map<int, Cube*> *cubes() { return &m_cubes; }
|
2013-03-02 00:11:18 +01:00
|
|
|
|
2013-03-09 15:20:18 +01:00
|
|
|
Chunk **surroundingChunks() const { return m_surroundingChunks; }
|
|
|
|
|
2013-03-02 00:11:18 +01:00
|
|
|
private:
|
|
|
|
int m_x;
|
|
|
|
int m_y;
|
|
|
|
int m_z;
|
|
|
|
|
2013-03-11 21:09:55 +01:00
|
|
|
std::unordered_map<int, Cube*> m_cubes;
|
2013-03-07 07:58:55 +01:00
|
|
|
Cube *getCube(int x, int y, int z);
|
|
|
|
|
|
|
|
Chunk **m_surroundingChunks;
|
|
|
|
|
|
|
|
GLuint m_vboVertices;
|
|
|
|
GLuint m_vboTexCoords;
|
|
|
|
GLuint m_vboColors;
|
|
|
|
int m_vboVertexCount;
|
2013-04-29 23:53:31 +02:00
|
|
|
|
|
|
|
float getTexOffsetU(int type, int i = -1, Cube *cube = NULL);
|
|
|
|
float getTexOffsetV(int type);
|
2013-03-02 00:11:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CHUNK_H
|