#ifndef BLOCK_H #define BLOCK_H #define AM_TEXTURES 11 //Enumeration of all the block textures in the same order as they appear in //"textures/blockTextures.png" typedef enum{GRASS_TOP=0, GRASS_SIDE=1, DIRT=2, COBBLESTONE=3, OAK_PLANKS=4, OAK_LOG_TOP=5, OAK_LOG=6, STONE=7, OAK_LEAVES=8, GLASS=9, WATER=10} TextureId; typedef enum{GRASS_BLOCK=0, DIRT_BLOCK=1, COBBLESTONE_BLOCK=2, OAK_PLANKS_BLOCK=3, OAK_LOG_BLOCK=4, STONE_BLOCK=5, OAK_LEAVES_BLOCK=6, GLASS_BLOCK=7, WATER_BLOCK=8, AIR=-1}BlockID; struct Color{ float r; float g; float b; Color(float _r,float _g,float _b){ r=_r; g=_g; b=_b; } Color(unsigned char _r,unsigned char _g,unsigned char _b){ this->r=(float)_r/255.0f; this->g=(float)_g/255.0f; this->b=(float)_b/255.0f; } Color(unsigned int c){ r=(float)((c >> 16) & 0xff)/255.0f, g=(float)((c >> 8) & 0xff)/255.0f, b=(float)(c & 0xff)/255.0f; } Color(){} }; #define WHITE Color(1.0f,1.0f,1.0f) struct BlockType{ TextureId t[6]; Color c[6]; BlockType(TextureId topT,TextureId bottomT,TextureId northT,TextureId southT, TextureId westT,TextureId eastT, Color topC,Color bottomC,Color northC,Color southC,Color westC,Color eastC){ t[0]=topT; t[1]=bottomT; t[2]=northT; t[3]=southT; t[4]=westT; t[5]=eastT; c[0]=topC; c[1]=bottomC; c[2]=northC; c[3]=southC; c[4]=westC; c[5]=eastC; } BlockType(TextureId faceT){ for(int i=0;i<6;i++){ t[i]=faceT; c[i]=WHITE; } } BlockType(TextureId faceT,Color faceC){ for(int i=0;i<6;i++){ t[i]=faceT; c[i]=faceC; } } BlockType(TextureId topT, TextureId bottomT, TextureId sideT){ t[0] = topT; c[0] = WHITE; t[1] = bottomT; c[1] = WHITE; for(int i=2;i<6;i++){ t[i]=sideT; c[i]=WHITE; } } BlockType(TextureId topT, TextureId bottomT, TextureId sideT, Color topC, Color bottomC, Color sideC){ t[0] = topT; c[0] = topC; t[1] = bottomT; c[1] = bottomC; for(int i=2;i<6;i++){ t[i]=sideT; c[i]=sideC; } } }; const float blockCoords[6][24] ={ //TOP FACE { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f,0.0f, 1.0f, 1.0f,0.0f}, //BOTTOM FACE {1.0f,0.0f,1.0f, 0.0f,0.0f,1.0f, 0.0f,0.0f,0.0f, 1.0f,0.0f,0.0f}, //NORTH FACE {0.0f,0.0f,1.0f, 1.0f,0.0f,1.0f, 1.0f,1.0f,1.0f, 0.0f,1.0f,1.0f}, //SOUTH FACE {0.0f,0.0f,0.0f, 1.0f,0.0f,0.0f, 1.0f,1.0f,0.0f, 0.0f,1.0f,0.0f}, //WEST FACE {0.0f,0.0f,1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f, 0.0f,1.0f,1.0f}, //EAST FACE {1.0f,0.0f,1.0f, 1.0f,0.0f,0.0f, 1.0f,1.0f,0.0f, 1.0f,1.0f,1.0f} }; #endif