dungeon_crawler

changeset 14:67ae9fcb802c

loading normal map
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 19 Aug 2012 06:30:18 +0300
parents 6a650b3b7084
children 3a3236a4833c
files prototype/Makefile prototype/src/material.cc prototype/src/tile.cc
diffstat 3 files changed, 18 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/prototype/Makefile	Sun Aug 19 05:50:58 2012 +0300
     1.2 +++ b/prototype/Makefile	Sun Aug 19 06:30:18 2012 +0300
     1.3 @@ -6,7 +6,7 @@
     1.4  
     1.5  CFLAGS = -pedantic -Wall -g -Ivmath
     1.6  CXXFLAGS = $(CFLAGS) -std=c++11
     1.7 -LDFLAGS = $(libgl) -lm -lassimp -limago
     1.8 +LDFLAGS = $(libgl) -lm -lassimpD -limago
     1.9  
    1.10  ifeq ($(shell uname -s), Darwin)
    1.11  	libgl = -framework OpenGL -framework GLUT -lglew
    1.12 @@ -14,7 +14,7 @@
    1.13  	libgl = -lGL -lGLU -lglut -lGLEW
    1.14  endif
    1.15  
    1.16 -$(bin): $(obj)
    1.17 +$(bin): $(obj) Makefile
    1.18  	$(CXX) -o $@ $(obj) $(LDFLAGS)
    1.19  
    1.20  -include $(dep)
     2.1 --- a/prototype/src/material.cc	Sun Aug 19 05:50:58 2012 +0300
     2.2 +++ b/prototype/src/material.cc	Sun Aug 19 06:30:18 2012 +0300
     2.3 @@ -36,18 +36,21 @@
     2.4  	ks *= val;
     2.5  
     2.6  	// must match TEXTYPE enum in material.h
     2.7 -	unsigned int asstypes[] = {
     2.8 -		aiTextureType_DIFFUSE,
     2.9 -		aiTextureType_NORMALS,
    2.10 -		aiTextureType_SPECULAR
    2.11 +	unsigned int asstypes[][2] = {
    2.12 +		{aiTextureType_DIFFUSE, 0},
    2.13 +		{aiTextureType_NORMALS, aiTextureType_HEIGHT},
    2.14 +		{aiTextureType_SPECULAR, 0}
    2.15  	};
    2.16  
    2.17  	for(int i=0; i<NUM_TEXTURE_TYPES; i++) {
    2.18 -		aiString tex_name;
    2.19 -		if(aiGetMaterialString(assmat, AI_MATKEY_TEXTURE(asstypes[i], 0), &tex_name) == 0) {
    2.20 -			tex[i] = texset->get_texture(tex_name.data);
    2.21 -		} else {
    2.22 -			tex[i] = 0;
    2.23 +		for(int j=0; j<2; j++) {
    2.24 +			aiString tex_name;
    2.25 +			if(asstypes[i][j] > 0 && aiGetMaterialString(assmat, AI_MATKEY_TEXTURE(asstypes[i][j], 0), &tex_name) == 0) {
    2.26 +				tex[i] = texset->get_texture(tex_name.data);
    2.27 +				break;
    2.28 +			} else {
    2.29 +				tex[i] = 0;
    2.30 +			}
    2.31  		}
    2.32  	}
    2.33  }
     3.1 --- a/prototype/src/tile.cc	Sun Aug 19 05:50:58 2012 +0300
     3.2 +++ b/prototype/src/tile.cc	Sun Aug 19 06:30:18 2012 +0300
     3.3 @@ -22,6 +22,9 @@
     3.4  		return false;
     3.5  	}
     3.6  
     3.7 +	char *saved_fname = (char*)alloca(strlen(fname) + 1);
     3.8 +	strcpy(saved_fname, fname);
     3.9 +
    3.10  	unsigned int proc_flags = aiProcess_JoinIdenticalVertices |
    3.11  		aiProcess_Triangulate |
    3.12  		aiProcess_SortByPType |
    3.13 @@ -39,7 +42,7 @@
    3.14  	load_lights(scn);
    3.15  	load_meshes(scn, nodemap);
    3.16  
    3.17 -	printf("loaded tile %s: %d meshes, %d lights\n", fname, scn->mNumMeshes, scn->mNumLights);
    3.18 +	printf("loaded tile %s: %d meshes, %d lights\n", saved_fname, scn->mNumMeshes, scn->mNumLights);
    3.19  	return true;
    3.20  }
    3.21