# HG changeset patch # User John Tsiombikas # Date 1344563138 -10800 # Node ID 31e53fd79c2da3e6f9a81a1f25e22ab15bd65a8f # Parent 1f61f2a02832cd55eea107d62dd1769903b49864 lalala diff -r 1f61f2a02832 -r 31e53fd79c2d prototype/src/tile.cc --- a/prototype/src/tile.cc Thu Aug 09 06:20:27 2012 +0300 +++ b/prototype/src/tile.cc Fri Aug 10 04:45:38 2012 +0300 @@ -4,20 +4,24 @@ bool Tile::load(const char *fname) { + unsigned int proc_flags = aiProcess_JoinIdenticalVertices | + aiProcess_PreTransformVertices | aiProcess_Triangulate | + aiProcess_GenNormals | aiProcess_SortByPType | aiProcess_FlipUVs; + const aiScene *scn = aiImportFile(fname, proc_flags); + if(!scn) { + fprintf(stderr, "failed to load tile: %s\n", fname); + return -1; + } + + load_lights(scn); + + load_meshes(scn); + + printf("loaded tile %s: %d meshes, %d lights\n", fname, scn->mNumMeshes, scn->mNumLights); return true; } -void Tile::draw() const +void Tile::draw(unsigned int drawmask) const { - float color[] = {1, 0, 0, 1}; - float white[] = {1, 1, 1, 1}; - glPushAttrib(GL_LIGHTING_BIT); - - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60.0); - glutSolidSphere(0.5, 16, 8); - - glPopAttrib(); } diff -r 1f61f2a02832 -r 31e53fd79c2d prototype/src/tile.h --- a/prototype/src/tile.h Thu Aug 09 06:20:27 2012 +0300 +++ b/prototype/src/tile.h Fri Aug 10 04:45:38 2012 +0300 @@ -4,14 +4,23 @@ #include #include "mesh.h" +enum { + TILE_NORTH = 1, + TILE_SOUTH = 2, + TILE_EAST = 4, + TILE_WEST = 8, + TILE_ALL = 0xf +}; + class Tile { private: std::vector meshes; + std::vector lights; public: bool load(const char *fname); - void draw() const; + void draw(unsigned int drawmask) const; }; #endif // TILE_H_