void debugLots() { lots.clear(); debugOffset = 0.005; vector<Polygon> debugBlocks; Polygon p; p.vertices.push_back(Vector3d(0.398803, 0.363752, 0)); p.vertices.push_back(Vector3d(0.407103, 0.352854, 0)); p.vertices.push_back(Vector3d(0.414602, 0.357363, 0)); p.vertices.push_back(Vector3d(0.408383, 0.371349, 0)); p.vertices.push_back(Vector3d(0.401586, 0.36584, 0)); debugBlocks.push_back(p); lg = LotGenerator(debugBlocks, parser.get(LOT_EDGE_MAX_WIDTH)*wMult, 0, //area parser.get(LOT_SPLIT_DEVIANCE), is); lg.getLots(lots); gotLots = true; debug = true; stage = CS_BUILDINGS; }
void keyboard(unsigned char key, int x, int y) { if(key == ' ') { roadsystem.generate(1); } if(key == 'x') { roadsystem.generate(100); } if(key == 'z') { roadsystem.generate(1000); } if(key == 'q') { roadsystem.printStats(); } if(key == 'i') { scale *= 1.1; } if(key == 'k') { scale /= 1.1; } /* if(key == 'u') { wMult += 0.05; debugLots(); } if(key == 'j') { wMult -= 0.05; debugLots(); } */ if(key == 'd') { if(stage >= CS_ROADS) { printf("dumping roads to roads.mel..."); roadsystem.dumpRoads(); printf("done!\n"); } } if(key == 'f') { if(stage >= CS_LOTS) { printf("dumping blocks to blocks.obj..."); roadsystem.dumpPolygons(); printf("done!\n"); } } if(key == 'g') { if(stage >= CS_BUILDINGS) { printf("dumping lots to lots.obj..."); dumpLots(); printf("done!\n"); } } /* if(key == 'f') { printf("debugging\n"); debugLots(); } */ if(key == 'p') { switch(stage) { case(CS_ROADS): printf("extracting blocks..."); roadsystem.getPolygons(); blocks.clear(); roadsystem.extractPolygons(blocks); gotBlocks = true; printf("done!\n"); stage = CS_LOTS; printf("-------------------------------------\n"); printf("Lot Subdivision\n"); printf("(p) to generate lots\n"); printf("(f) to dump blocks to blocks.obj\n"); printf("(d) to dump roads to roads.mel\n"); printf("The code likes to blow up at this stage :(\n"); printf("If it does, just restart the program\n"); break; case(CS_LOTS): lg = LotGenerator(blocks, parser.get(LOT_EDGE_MAX_WIDTH), parser.get(LOT_MIN_AREA), parser.get(LOT_SPLIT_DEVIANCE), is); lg.getLots(lots); gotLots = true; printf("Done subdividing blocks!\n"); stage = CS_BUILDINGS; printf("-------------------------------------\n"); printf("Building Generation\n"); printf("(p) to generate buildings\n"); printf("(g) to dump lots to lots.obj\n"); printf("(f) to dump blocks to blocks.obj\n"); printf("(d) to dump roads to roads.mel\n"); printf("output will be written to outputFile.obj\n"); break; case(CS_BUILDINGS): printf("generating buildings..."); bg = BuildingGenerator(lots); bg.getBuildings(parser.get(BUILDING_MAX_HEIGHT), is); bg.generateObjFile(); printf("done!\n"); printf("(p) to quit\n"); printf("(g) to dump lots to lots.obj\n"); printf("(f) to dump blocks to blocks.obj\n"); printf("(d) to dump roads to roads.mel\n"); stage = CS_DONE; break; case(CS_DONE): exit(0); break; } } glutPostRedisplay(); }