Esempio n. 1
0
void readFlight (FILE* fp_in, Flight* flight)
{
  fscanf(fp_in, "%d\n", &(flight->flightNum));
  fgets(flight->origin , MAX_ORIGIN_LENGTH, fp_in);
  fgets(flight->destination, MAX_DESTINATION_LENGTH, fp_in);
  
  strtok(flight->origin, "\r\n");
  strtok(flight->destination, "\r\n");
  
  flight->plane = (Plane*) malloc(sizeof(Plane));
  readPlane(fp_in, &(flight->plane));
} //read each flight from file
ShapePointer SceneLoader::readShape(const QDomElement &element) const {
  QString shapeType;
  if (!readAttributeAsString(element, "type", shapeType)) {
    return ShapePointer(NULL);
  }

  MaterialPointer shapeMaterial = readMaterial(element);
  if (shapeMaterial == NULL) {
    return ShapePointer(NULL);
  }

  if (shapeType == "plane") {
    return readPlane(element, shapeMaterial);
  }
  if (shapeType == "sphere") {
    return readSphere(element, shapeMaterial);
  }
  if (shapeType == "cylinder") {
    return readCylinder(element, shapeMaterial);
  }
  if (shapeType == "cone") {
    return readCone(element, shapeMaterial);
  }
  if (shapeType == "triangle") {
    return readTriangle(element, shapeMaterial);
  }
  if (shapeType == "box") {
    return readBox(element, shapeMaterial);
  }
  if (shapeType == "torus") {
    return readTorus(element, shapeMaterial);
  }
  if (shapeType == "model") {
    return readMeshModel(element, shapeMaterial);
  }

  std::cerr << "Scene parsing error: unknown shape type '" << shapeType.toUtf8().constData() << "'" << std::endl;
  return ShapePointer(NULL);
}