dungeon_crawler
changeset 3:31e53fd79c2d
lalala
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 10 Aug 2012 04:45:38 +0300 |
parents | 1f61f2a02832 |
children | 158de53b4e18 |
files | prototype/src/tile.cc prototype/src/tile.h |
diffstat | 2 files changed, 25 insertions(+), 12 deletions(-) [+] |
line diff
1.1 --- a/prototype/src/tile.cc Thu Aug 09 06:20:27 2012 +0300 1.2 +++ b/prototype/src/tile.cc Fri Aug 10 04:45:38 2012 +0300 1.3 @@ -4,20 +4,24 @@ 1.4 1.5 bool Tile::load(const char *fname) 1.6 { 1.7 + unsigned int proc_flags = aiProcess_JoinIdenticalVertices | 1.8 + aiProcess_PreTransformVertices | aiProcess_Triangulate | 1.9 + aiProcess_GenNormals | aiProcess_SortByPType | aiProcess_FlipUVs; 1.10 + const aiScene *scn = aiImportFile(fname, proc_flags); 1.11 + if(!scn) { 1.12 + fprintf(stderr, "failed to load tile: %s\n", fname); 1.13 + return -1; 1.14 + } 1.15 + 1.16 + load_lights(scn); 1.17 + 1.18 + load_meshes(scn); 1.19 + 1.20 + printf("loaded tile %s: %d meshes, %d lights\n", fname, scn->mNumMeshes, scn->mNumLights); 1.21 return true; 1.22 } 1.23 1.24 -void Tile::draw() const 1.25 +void Tile::draw(unsigned int drawmask) const 1.26 { 1.27 - float color[] = {1, 0, 0, 1}; 1.28 - float white[] = {1, 1, 1, 1}; 1.29 1.30 - glPushAttrib(GL_LIGHTING_BIT); 1.31 - 1.32 - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); 1.33 - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); 1.34 - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60.0); 1.35 - glutSolidSphere(0.5, 16, 8); 1.36 - 1.37 - glPopAttrib(); 1.38 }
2.1 --- a/prototype/src/tile.h Thu Aug 09 06:20:27 2012 +0300 2.2 +++ b/prototype/src/tile.h Fri Aug 10 04:45:38 2012 +0300 2.3 @@ -4,14 +4,23 @@ 2.4 #include <vector> 2.5 #include "mesh.h" 2.6 2.7 +enum { 2.8 + TILE_NORTH = 1, 2.9 + TILE_SOUTH = 2, 2.10 + TILE_EAST = 4, 2.11 + TILE_WEST = 8, 2.12 + TILE_ALL = 0xf 2.13 +}; 2.14 + 2.15 class Tile { 2.16 private: 2.17 std::vector<Mesh*> meshes; 2.18 + std::vector<Light*> lights; 2.19 2.20 public: 2.21 bool load(const char *fname); 2.22 2.23 - void draw() const; 2.24 + void draw(unsigned int drawmask) const; 2.25 }; 2.26 2.27 #endif // TILE_H_