dungeon_crawler

changeset 31:ddb68dc4ba07

OBJ hack
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 27 Aug 2012 04:14:04 +0300
parents 938a6a155c94
children 0cd55268eaf4
files prototype/src/material.cc prototype/src/tile.cc
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/prototype/src/material.cc	Mon Aug 27 04:03:22 2012 +0300
     1.2 +++ b/prototype/src/material.cc	Mon Aug 27 04:14:04 2012 +0300
     1.3 @@ -4,6 +4,8 @@
     1.4  #include "opengl.h"
     1.5  #include "material.h"
     1.6  
     1.7 +extern bool ass_obj_hack;
     1.8 +
     1.9  Material::Material()
    1.10  	: kd(1.0, 1.0, 1.0), ks(0.0, 0.0, 0.0)
    1.11  {
    1.12 @@ -24,11 +26,10 @@
    1.13  	unsigned int sz = 1;
    1.14  	val = 60.0;
    1.15  	aiGetMaterialFloatArray(assmat, AI_MATKEY_SHININESS, &val, &sz);
    1.16 -	if(val > 127) {
    1.17 -		fprintf(stderr, "Warning: shininess %f... setting to 127\n", val);
    1.18 -		val = 127;
    1.19 +	if(ass_obj_hack) {
    1.20 +		val /= 4.0;
    1.21  	}
    1.22 -	shin = val;
    1.23 +	shin = val > 127 ? 127 : val;
    1.24  
    1.25  	sz = 1;
    1.26  	val = 1.0;
     2.1 --- a/prototype/src/tile.cc	Mon Aug 27 04:03:22 2012 +0300
     2.2 +++ b/prototype/src/tile.cc	Mon Aug 27 04:14:04 2012 +0300
     2.3 @@ -12,6 +12,8 @@
     2.4  static void build_nodemap(map<aiMesh*, aiNode*> *nmap, const aiScene *scn, aiNode *node);
     2.5  static PointLight *mesh_to_light(Mesh *m);
     2.6  
     2.7 +bool ass_obj_hack;
     2.8 +
     2.9  Tile::Tile(TileSet *tileset)
    2.10  {
    2.11  	tset = tileset;
    2.12 @@ -40,6 +42,12 @@
    2.13  	map<aiMesh*, aiNode*> nodemap;
    2.14  	build_nodemap(&nodemap, scn, scn->mRootNode);
    2.15  
    2.16 +	if(strstr(fname, ".obj") == fname + strlen(fname) - 4) {
    2.17 +		ass_obj_hack = true;
    2.18 +	} else {
    2.19 +		ass_obj_hack = false;
    2.20 +	}
    2.21 +
    2.22  	//load_lights(scn);
    2.23  	load_meshes(scn, nodemap);
    2.24