#include "scene.h"
#include "objmesh.h"
#include "datamap.h"
+#include "logger.h"
static bool load_material(Scene *scn, Material *mat, const aiMaterial *aimat);
static SceneNode *load_node(Scene *scn, const aiScene *aiscn, unsigned int flags, const aiNode *ainode);
ppflags |= aiProcess_FlipUVs;
}
- printf("Loading scene file: %s\n", fname);
+ info_log("Loading scene file: %s\n", fname);
const aiScene *aiscn = aiImportFile(fname, ppflags);
if(!aiscn) {
- fprintf(stderr, "failed to load scene file: %s\n", fname);
+ error_log("failed to load scene file: %s\n", fname);
return false;
}
break;
default:
- fprintf(stderr, "unsupported primitive type: %u\n", aimesh->mPrimitiveTypes);
+ error_log("unsupported primitive type: %u\n", aimesh->mPrimitiveTypes);
break;
}
}
mesh_by_aimesh.clear();
aiReleaseImport(aiscn);
- printf("loaded scene file: %s, %d meshes\n", fname, (int)meshes.size());
+ info_log("loaded scene file: %s, %d meshes\n", fname, (int)meshes.size());
nodes->update(0);
return true;
}
} else {
mat->name = "unknown";
}
- //printf("load_material: %s\n", mat->name.c_str());
+ //info_log("load_material: %s\n", mat->name.c_str());
if(aiGetMaterialColor(aimat, AI_MATKEY_COLOR_DIFFUSE, &aicol) == 0) {
mat->diffuse = Vec3(aicol[0], aicol[1], aicol[2]);
continue;
}
- char *fname;
- int nsize = datamap_path_size(aipath.data);
- if(nsize) {
- fname = new char[nsize];
- datamap_lookup(aipath.data, fname, nsize);
- } else {
- fname = new char[strlen(aipath.data) + 1];
- char *dptr = fname;
- char *sptr = aipath.data;
- do {
- *dptr++ = *sptr == '\\' ? '/' : *sptr;
- } while(*sptr++);
- }
+ char *fname = (char*)alloca(strlen(aipath.data) + 1);
+ char *dptr = fname;
+ char *sptr = aipath.data;
+ do {
+ *dptr++ = *sptr == '\\' ? '/' : *sptr;
+ } while(*sptr++);
int textype = assimp_textype(aitype);
- printf("loading %s texture: %s\n", assimp_textypestr(aitype), fname);
+ info_log("loading %s texture: %s\n", assimp_textypestr(aitype), fname);
Texture *tex = scn->texset->get_texture(fname, TEX_2D);
assert(tex);