dungeon_crawler

diff prototype/src/material.cc @ 14:67ae9fcb802c

loading normal map
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 19 Aug 2012 06:30:18 +0300
parents e95462632f9a
children ddb68dc4ba07
line diff
     1.1 --- a/prototype/src/material.cc	Sun Aug 19 05:50:58 2012 +0300
     1.2 +++ b/prototype/src/material.cc	Sun Aug 19 06:30:18 2012 +0300
     1.3 @@ -36,18 +36,21 @@
     1.4  	ks *= val;
     1.5  
     1.6  	// must match TEXTYPE enum in material.h
     1.7 -	unsigned int asstypes[] = {
     1.8 -		aiTextureType_DIFFUSE,
     1.9 -		aiTextureType_NORMALS,
    1.10 -		aiTextureType_SPECULAR
    1.11 +	unsigned int asstypes[][2] = {
    1.12 +		{aiTextureType_DIFFUSE, 0},
    1.13 +		{aiTextureType_NORMALS, aiTextureType_HEIGHT},
    1.14 +		{aiTextureType_SPECULAR, 0}
    1.15  	};
    1.16  
    1.17  	for(int i=0; i<NUM_TEXTURE_TYPES; i++) {
    1.18 -		aiString tex_name;
    1.19 -		if(aiGetMaterialString(assmat, AI_MATKEY_TEXTURE(asstypes[i], 0), &tex_name) == 0) {
    1.20 -			tex[i] = texset->get_texture(tex_name.data);
    1.21 -		} else {
    1.22 -			tex[i] = 0;
    1.23 +		for(int j=0; j<2; j++) {
    1.24 +			aiString tex_name;
    1.25 +			if(asstypes[i][j] > 0 && aiGetMaterialString(assmat, AI_MATKEY_TEXTURE(asstypes[i][j], 0), &tex_name) == 0) {
    1.26 +				tex[i] = texset->get_texture(tex_name.data);
    1.27 +				break;
    1.28 +			} else {
    1.29 +				tex[i] = 0;
    1.30 +			}
    1.31  		}
    1.32  	}
    1.33  }