dungeon_crawler

diff prototype/src/tile.cc @ 35:d0e93b4d9ec9

normal mapping
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 28 Aug 2012 06:28:22 +0300
parents ddb68dc4ba07
children 84a56fb24850
line diff
     1.1 --- a/prototype/src/tile.cc	Tue Aug 28 03:34:56 2012 +0300
     1.2 +++ b/prototype/src/tile.cc	Tue Aug 28 06:28:22 2012 +0300
     1.3 @@ -6,6 +6,7 @@
     1.4  #include <assimp/postprocess.h>
     1.5  #include "tile.h"
     1.6  #include "tileset.h"
     1.7 +#include "renderer.h"
     1.8  
     1.9  using std::map;
    1.10  
    1.11 @@ -29,6 +30,7 @@
    1.12  	strcpy(saved_fname, fname);
    1.13  
    1.14  	unsigned int proc_flags = aiProcess_JoinIdenticalVertices |
    1.15 +		aiProcess_CalcTangentSpace |
    1.16  		aiProcess_Triangulate |
    1.17  		aiProcess_SortByPType |
    1.18  		aiProcess_FlipUVs;
    1.19 @@ -111,12 +113,20 @@
    1.20  {
    1.21  	int count = 0;
    1.22  
    1.23 +	int attr_loc = get_tangent_location();
    1.24 +	if(attr_loc == -1) {
    1.25 +		fprintf(stderr, "warning: failed to retrieve tangent attribute location while loading tile\n");
    1.26 +	}
    1.27 +
    1.28  	for(int i=0; i<(int)scn->mNumMeshes; i++) {
    1.29  		Mesh *mesh = new Mesh;
    1.30  		if(!mesh->create(scn, scn->mMeshes[i])) {
    1.31  			delete mesh;
    1.32  			continue;
    1.33  		}
    1.34 +		if(attr_loc != -1) {
    1.35 +			mesh->set_attrib_location(MESH_ATTR_TANGENT, attr_loc);
    1.36 +		}
    1.37  
    1.38  		Material mat;
    1.39  		mat.load(scn->mMaterials[scn->mMeshes[i]->mMaterialIndex], tset->get_textures());