Beispiel #1
0
bool ZFileSectorLoader::LoadSector(Long x, Long y, Long z)
{
  ZVoxelSector * NewSector;
  bool Redo, TryLoad;

  if ( !RequestTag.find(x,y,z) )
  {
    NewSector = SectorRecycling->PullFromList(); // Try recycling some old used sector.
    if (!NewSector) {
		NewSector = new ZVoxelSector( GameEnv->Basic_Renderer->GetCuller() ); 
	}

    TryLoad = true;
    do
    {
      Redo = false;

      NewSector->Pos_x = x; NewSector->Pos_y = y; NewSector->Pos_z = z;
      NewSector->SetVoxelTypeManager(VoxelTypeManager);

      if (TryLoad && NewSector->Load(UniverseNum))
      {
        // Does this sector must be regenerated ?
        if ( 0==(NewSector->Flag_IsModified & ZVoxelSector::CHANGE_SAVEMASK) )
        {
          if (COMPILEOPTION_ALLOWSAVE) NewSector->DeleteSave(UniverseNum);
          NewSector->ReinitSector();
		  Redo = true;
          TryLoad = false;
          continue;
        }
      }
      else
      {
        SectorCreator->GenerateSector(NewSector);
      }
    } while (Redo);

    // Set the options for further edge faceculling.

    NewSector->Flag_NeedFullCulling = false;
    NewSector->PartialCulling = DRAWFACE_ALL;

    // Add it in the tag

    RequestTag.Add(x,y,z);

    // Partial face culling on the sector. Edges must be completed later when other sectors will be availlable.

    LimitedUpdateFaceCulling(NewSector );
    //NoDrawFaceCulling(NewSector);

    // Push it to the list for integration in the world on the main thread.

    ReadySectorList->PushToList(NewSector);
    return(true);
  }
  return(false);
}
Beispiel #2
0
bool ZWorldConverter::WorldConvert(char const * Path)
{

  struct dirent * Entry;

  ZVoxelSector Sector;

  DIR * Directory;
  ZString FileSpec, FileName;

  if (!(Directory = opendir(Path))) { return(false); }
  while (( Entry = readdir(Directory) ))
  {
    FileName = Entry->d_name;
    FileSpec = Path; FileSpec << "/" << FileName;
    // printf("%s %x\n",Entry->d_name, Entry->d_type);
    if (Entry->d_type == DT_DIR)
    {


    }
    else if (Entry->d_type == DT_REG)
    {
      if (FileName.Lefts(6)=="Sector")
      {
        printf("Loading Sector %s\n", FileSpec.String);
        Sector.Load(0,FileSpec.String);
        SectorConvert(&Sector);
        Sector.Save(0,FileSpec.String);
      }
    }
  }

  closedir(Directory);
  return(true);
}