Beispiel #1
0
/**
 * Get a scene from a map file in XML format.
 */
Scene* MapLoader::getScene(const std::string &path) {
  scene = new Scene();
  // FIXME: shall we init player here? Probably not, and do it ONCE.
  scene->player.addComponent<Transform>();
  scene->player.addComponent<PlayerMotion>();
  scene->player.addComponent<Health>();
  scene->player.addComponent<SoundSource>();
  scene->player.addComponent<SoundListener>();

  XMLDocument doc;
  XMLError error = doc.LoadFile((Environment::getDataDir() + "/maps/" + path + ".xml").c_str());

  if (error == XML_NO_ERROR) {
    XMLHandle docHandle(&doc);
    XMLElement *element = docHandle.FirstChildElement().ToElement();
    rootHandle = XMLHandle(element);

    extractMaterials();
    extractSpawn();
    extractDoor();
    extractModels();
    extractLights();
    extractWalls();
    extractAcids();
    extractTriggers();
    System::Log(Info) << "Map " << path << " loaded";
  } else {
    System::Log(Error) << "Failed to load map " << Environment::getDataDir() << "/" << path << ".xml";
  }
  return scene;
}
S_MaterialPtr MeshResourceMarker::getMaterials()
{
  S_MaterialPtr materials;
  if( entity_ )
  {
    extractMaterials( entity_, materials );
  }
  return materials;
}
Beispiel #3
0
S_MaterialPtr ShapeMarker::getMaterials()
{
  S_MaterialPtr materials;
  extractMaterials(shape_->getEntity(), materials);
  return materials;
}