void FloorScene::basicCircle(QPoint *mousePos, int numSample) { Profile* commonProfile = new Profile(false); ProfileDestructorManager::putProfile(commonProfile); QRectF thisSize = this->sceneRect(); int radius(thisSize.width()/4); float x(0.0f); float y(0.0f); float alpha(0.0f); FloorVertex* firstVertex; FloorVertex* previousVertex; FloorVertex* currentVertex; // define a floor plan by taking samples on a circle equation for(int i(0); i < numSample; i++) { alpha = 2.0f * M_PI * (float)(i) / (float)(numSample); x = mousePos->x() + radius * cos(alpha); y = mousePos->y() + radius * sin(alpha); QRectF thisSize = this->sceneRect(); Utils::adjustCoordinatesSceneTo3D(x, y, thisSize.width(), thisSize.height()); if (i == 0) { firstVertex = new FloorVertex(x, y, commonProfile); mesh->setFloorPlan(firstVertex); mesh->incrementFloorPlanSize(); previousVertex = firstVertex; } else { currentVertex = new FloorVertex(x, y, commonProfile); mesh->incrementFloorPlanSize(); previousVertex->setNeighbor2(currentVertex);//addNeighbor currentVertex->setNeighbor1(previousVertex);//addNeighbor previousVertex = currentVertex; } } currentVertex->setNeighbor2(firstVertex);//addNeighbor firstVertex->setNeighbor1(currentVertex);//addNeighbor newProfileSelected(commonProfile); loadFloorPlan(); // tell the mesh to generate new point/triangle mesh->setUpdateOnMesh(); }
void parseScene(char *line) { char command[MAX_LINE_SIZE]; char arg[MAX_LINE_SIZE]; char *start, *end; /* i need to get the first word */ end = findFirstSpace(line); /* observe what the command is */ copyString(command, line, end); if (!strcmp(command,"DIMENSIONS")) { /* parse the dimensions of the scene */ start = skipSpace(end); end = findFirstSpace(start); copyString(arg, start, end); end = skipSpace(end); cells_wide = atoi(arg); start = skipSpace(end); end = findFirstSpace(start); copyString(arg, start, end); end = skipSpace(end); cells_high = atoi(arg); assert(lineCanBeIgnored(end)); /* the rest of the line should be able to be ignored */ fprintf(stderr,"width: %d height: %d\n", cells_wide, cells_high); } else if (!strcmp(command,"HEIGHT")) { start = skipSpace(end); end = findFirstSpace(start); copyString(arg, start, end); end = skipSpace(end); wall_height = atoi(arg); fprintf(stderr,"wall height: %d\n", wall_height); } else if (!strcmp(command,"CELL")) { start = skipSpace(end); end = findFirstSpace(start); copyString(arg, start, end); end = skipSpace(end); cell_size = atoi(arg); fprintf(stderr,"cell size: %d\n", cell_size); } else if (!strcmp(command,"TEXTURES")) { start = skipSpace(end); end = findFirstSpace(start); copyString(arg, start, end); end = skipSpace(end); num_tex = atoi(arg); fprintf(stderr,"number of textures: %d\n", num_tex); loadTextures(); } else if (!strcmp(command,"FLOORPLAN")) { assert(lineCanBeIgnored(end)); /* the rest of the line should be able to be ignored */ loadFloorPlan(); } else { fprintf(stderr,"ERROR! Unrecognized command in scene file \n"); fprintf(stderr,"%s\n", line); exit(-1); } return; }