static void KeyboardCallback(unsigned char key, int x, int y) { static Random random; int sceneIndex = random.rand()&1; switch (key) { case 27: exit(0); break; case ' ': CreateCube(sceneIndex, NxVec3(0.0f, 20.0f, 0.0f), 1+(rand()&3)); break; case 's': CreateStack(sceneIndex, 10); break; case 'b': CreateStack(sceneIndex, 30); break; case 't': CreateTower(sceneIndex, 30); break; case 'x': gShadows = !gShadows; break; case 'p': gPause = !gPause; break; case 101: case '8': Eye += Dir * 2.0f; break; case 103: case '2': Eye -= Dir * 2.0f; break; case 100: case '4': Eye -= N * 2.0f; break; case 102: case '6': Eye += N * 2.0f; break; case 'w': { NxVec3 t = Eye; NxVec3 Vel = Dir; Vel.normalize(); Vel*=200.0f; CreateCube(sceneIndex, t, 8, &Vel); } break; } }
CBuilding::CBuilding (int type, int x, int y, int height, int width, int depth, int seed, GLrgba color) { _x = x; _y = y; _width = width; _depth = depth; _height = height; _center = glVector ((float)(_x + width / 2), 0.0f, (float)(_y + depth / 2)); _seed = seed; _texture_type = RandomVal (); _color = color; _color.alpha = 0.1f; _have_lights = false; _have_logo = false; _have_trim = false; _roof_tiers = 0; //Pick a color for logos & roof lights _trim_color = WorldLightColor (seed); _mesh = new CMesh; //The main textured mesh for the building _mesh_flat = new CMesh; //Flat-color mesh for untextured detail items. switch (type) { case BUILDING_SIMPLE: CreateSimple (); break; case BUILDING_MODERN: CreateModern (); break; case BUILDING_TOWER: CreateTower (); break; case BUILDING_BLOCKY: CreateBlocky (); break; } }