X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fapp.cc;h=60209477591434fc6d9d8c0bb9e952936bcb57bc;hb=dbcb9345c23c5c027d808915962843e7db2d14aa;hp=6cb808c9fd050f6e28a68f6322f2eac8a6d4df1b;hpb=572bf1ef8d54ef5a7cba7cdf38515cb16c4c312c;p=laserbrain_demo diff --git a/src/app.cc b/src/app.cc index 6cb808c..6020947 100644 --- a/src/app.cc +++ b/src/app.cc @@ -7,6 +7,7 @@ #include "mesh.h" #include "meshgen.h" #include "scene.h" +#include "metascene.h" #include "datamap.h" static void draw_scene(); @@ -14,6 +15,7 @@ static void draw_scene(); long time_msec; int win_width, win_height; bool opt_gear_wireframe; +bool show_walk_mesh; static float cam_dist = 0.0; static float cam_theta, cam_phi = 20; @@ -44,43 +46,11 @@ bool app_init() float ambient[] = {0.0, 0.0, 0.0, 0.0}; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); - datamap_set_path("data"); - if(!datamap_load_map("data.map")) { - fprintf(stderr, "failed to load datafile mappings\n"); - } - - unsigned int sflags = SCNLOAD_FLIPTEX; scn = new Scene(&texman); - if(!(scn->load("data/testscene/patoma.fbx", sflags)) || - !(scn->load("data/testscene/kolones.fbx", sflags))) { - fprintf(stderr, "failed to load test scene\n"); + if(!load_scene(scn, "data/museum.scene")) { return false; } - // hardcoded texture assignment hack - Texture *tex_kolones_lightmap = texman.get_texture("data/testscene/kolones_lighmap.jpg", TEX_2D); - Texture *tex_patoma_lightmap = texman.get_texture("data/testscene/patomacorona_lightmap.jpg", TEX_2D); - - /* - for(int i=0; i<(int)scn->objects.size(); i++) { - Object *obj = scn->objects[i]; - if(obj->mtl.name == "WiteMarble") { - obj->mtl.add_texture(tex_patoma_lightmap, MTL_TEX_LIGHTMAP); - } else if(obj->mtl.name == "BrownMarble") { - obj->mtl.add_texture(tex_patoma_lightmap, MTL_TEX_LIGHTMAP); - } else if(obj->mtl.name == "GiroGiroMarmaro") { - obj->mtl.add_texture(tex_patoma_lightmap, MTL_TEX_LIGHTMAP); - } else if(obj->mtl.name == "KentrikoKafeMarmaro") { - obj->mtl.add_texture(tex_patoma_lightmap, MTL_TEX_LIGHTMAP); - - } else if(obj->mtl.name == "SkouroGrizoMarmaro") { - obj->mtl.add_texture(tex_kolones_lightmap, MTL_TEX_LIGHTMAP); - } else if(obj->mtl.name == "PalioMarmaro") { - obj->mtl.add_texture(tex_kolones_lightmap, MTL_TEX_LIGHTMAP); - } - } - */ - if(!(sdr = create_program_load("sdr/test.v.glsl", "sdr/test.p.glsl"))) { fprintf(stderr, "failed to load test shaders\n"); return false; @@ -187,6 +157,18 @@ static void draw_scene() glUseProgram(sdr); scn->draw(); glUseProgram(0); + + if(show_walk_mesh && scn->walk_mesh) { + glPushAttrib(GL_ENABLE_BIT); + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + glDisable(GL_LIGHTING); + + glColor3f(0.5, 0.4, 0.05); + scn->walk_mesh->draw(); + + glPopAttrib(); + } } @@ -202,10 +184,17 @@ void app_reshape(int x, int y) void app_keyboard(int key, bool pressed) { if(pressed) { + printf("key: %d (mod: %x)\n", key, app_get_modifiers()); switch(key) { case 27: app_quit(); break; + + case 'w': + if(app_get_modifiers() & MOD_CTRL) { + show_walk_mesh = !show_walk_mesh; + } + break; } }