示例#1
0
void MainWindow::updateObject(const QString &objectName, int object)
{
    QFile objectFile(m_objectsDir.absoluteFilePath(QString::number(object)));
    QFile file(m_appDir.absoluteFilePath(objectName));

    objectFile.remove();
    QFile::copy(file.fileName(), objectFile.fileName());
}
示例#2
0
void nodachi2D::loadLevel()
{
    std::string visualAppearancesFile ( "data/visualAppearances.data" );
    std::string materialFile ( "data/materials.data" );
    std::string objectFile ( "data/spacialObjects.data" );

    this->globalGameObjectManager_->loadVisualAppearances( visualAppearancesFile );
    this->globalGameObjectManager_->loadMaterials( materialFile );
    this->globalGameObjectManager_->loadObjects( objectFile );
}
示例#3
0
void kajiya2D::loadLevelData( std::string worldname, std::string levelname )
{
    std::string visualAppearancesFile ( "data/visualAppearances.data" );
    std::string materialFile ( "data/materials.data" );
    std::string objectFile ( "data/spacialObjects.data" );

    this->globalGameObjectManager_ = new objects::GameObjectManager();

    this->globalGameObjectManager_->loadVisualAppearances( visualAppearancesFile );
    this->globalGameObjectManager_->loadMaterials( materialFile );
    this->globalGameObjectManager_->loadObjects( objectFile );
}
示例#4
0
bool Gcc::compile(QString filename)
{
	QFileInfo sourceInfo(filename);
	QStringList args;

	refreshSettings();

#ifdef Q_OS_WIN32
	m_outputFileName = sourceInfo.dir().absoluteFilePath(sourceInfo.baseName() + ".exe");
#else
	m_outputFileName = sourceInfo.dir().absoluteFilePath(sourceInfo.baseName());
#endif
	QString objectName = sourceInfo.dir().absoluteFilePath(sourceInfo.baseName() + ".o");

	QFileInfo outputInfo(m_outputFileName);
	if(sourceInfo.lastModified() < outputInfo.lastModified())
		return true;

	args = m_cflags;
	m_defaultPort.replace("\\", "\\\\");
	args << "-DDEFAULT_SERIAL_PORT=\"" + m_defaultPort + "\"";
	args << "-c" << filename << "-o" << objectName;
	m_gcc.start(m_gccPath, args);
	m_gcc.waitForFinished();
	processCompilerOutput();
	m_linkerMessages.clear();

	if(m_gcc.exitCode() != 0)
		return false;

	args.clear();
	args << "-o" << m_outputFileName << objectName;
	args << m_lflags;
	m_gcc.start(m_gccPath, args);
	m_gcc.waitForFinished();
	processLinkerOutput();

	QFile objectFile(objectName);
	objectFile.remove();

	if(m_gcc.exitCode() == 0)
		return true;
	return false;
}
示例#5
0
void OneSixUpdate::assetIndexFinished()
{
	AssetsIndex index;

	OneSixInstance *inst = (OneSixInstance *)m_inst;
	std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
	QString assetName = version->assets;

	QString asset_fname = "assets/indexes/" + assetName + ".json";
	if (!AssetsUtils::loadAssetsIndexJson(asset_fname, &index))
	{
		emitFailed("Failed to read the assets index!");
	}

	QList<Md5EtagDownloadPtr> dls;
	for (auto object : index.objects.values())
	{
		QString objectName = object.hash.left(2) + "/" + object.hash;
		QFileInfo objectFile("assets/objects/" + objectName);
		if ((!objectFile.isFile()) || (objectFile.size() != object.size))
		{
			auto objectDL = MD5EtagDownload::make(
				QUrl("http://" + URLConstants::RESOURCE_BASE + objectName),
				objectFile.filePath());
			objectDL->m_total_progress = object.size;
			dls.append(objectDL);
		}
	}
	if (dls.size())
	{
		setStatus(tr("Getting the assets files from Mojang..."));
		auto job = new NetJob("Assets for " + inst->name());
		for (auto dl : dls)
			job->addNetAction(dl);
		jarlibDownloadJob.reset(job);
		connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetsFinished()));
		connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(assetsFailed()));
		connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
				SIGNAL(progress(qint64, qint64)));
		jarlibDownloadJob->start();
		return;
	}
	assetsFinished();
}
示例#6
0
void MainWindow::displayObject(int object, int row)
{
    QFile objectFile(m_objectsDir.absoluteFilePath(QString::number(object)));
    QStringList objectText;

    objectFile.open(QFile::ReadOnly);
    QTextStream ts( &objectFile );
    while( !ts.atEnd() )
        objectText << ts.readLine()
            .remove(QLatin1Char('\r'))
            .remove(QLatin1Char('\n'));

    // Make it crash on purpose if the object has too many lines
    // simulates incompatibilities
    Q_ASSERT(objectText.size()<=m_table->columnCount()-1);

    m_table->setItem(row, 0, new QTableWidgetItem(QString::number(object)));

    for (int i = 0; i<objectText.size(); ++i) {
        m_table->setItem(row, i+1, new QTableWidgetItem(objectText[i]));
    }
}
示例#7
0
// obviously this will change depending on what we what we need
bool Catcher::initFromFile()
{
  string filepath = "data/objects/" + type + ".ct";

	cout << "Loading catcher " << filepath << ", ";

	ifstream objectFile(filepath.c_str(), std::ifstream::in);

	if(objectFile != NULL)
	{
		cout << "ifstream successfull... ";

    string tag = "";

    while(getline(objectFile, tag))
    {
        if(tag == "SIZE")
        {
          objectFile >> bounds.w;
          bounds.h = bounds.w;
          cout << "size = [" << bounds.w << " x " << bounds.h << "] ";
        }
        else if(tag == "USES")
void
DefaultCatalog::SetSignature(const entry_ref &catalogOwner)
{
	// figure out mimetype from image
	BFile objectFile(&catalogOwner, B_READ_ONLY);
	BAppFileInfo objectInfo(&objectFile);
	char objectSignature[B_MIME_TYPE_LENGTH];
	if (objectInfo.GetSignature(objectSignature) != B_OK) {
		fSignature = "";
		return;
	}

	// drop supertype from mimetype (should be "application/"):
	char* stripSignature = objectSignature;
	while (*stripSignature != '/' && *stripSignature != '\0')
		stripSignature ++;

	if (*stripSignature == '\0')
		stripSignature = objectSignature;
	else
		stripSignature ++;

	fSignature = stripSignature;
}
// ######################################################################
int submain(const int argc, const char** argv)
{
  // catch signals and redirect them for a clean exit (in particular, this gives us a chance to do useful things like
  // flush and close output files that would otherwise be left in a bogus state, like mpeg output files):
  catchsignals(&signum);

  LINFO("#############################################STARTING##############################################");

  ModelManager mgr("App Scorbot MultiGrab");

  scorbot.reset(new ScorbotSimple(mgr));
  mgr.addSubComponent(scorbot);

  setupGrabbers(mgr);

  ofs.reset(new OutputFrameSeries(mgr));
  mgr.addSubComponent(ofs);

  if(mgr.parseCommandLine(argc, argv, "FilePrefix SceneID", 2, 2) == false) return -1;
  mgr.start();

  if (grabbers.size() < NUMCAMS) LFATAL("Only found %" ZU " cameras instead of %d. Reboot your machine and try again.", grabbers.size(), NUMCAMS);

  // get our grabbers to start grabbing:  
  for (size_t cameraID = 0; cameraID < grabbers.size(); ++cameraID)
    grabberThreadServer.enqueueJob(rutz::make_shared(new GrabJob(cameraID)));

  sceneDir = mgr.getExtraArg(0);
  sceneID = boost::lexical_cast<int>(mgr.getExtraArg(1));

  pthread_t displayThread;
  pthread_create(&displayThread, NULL, &displayThreadMethod, NULL);

  // Create the interactive window
  userInteractiveWindow = new XWinManaged(Dims(640,480), -1, -1, "User Interactive");
  userInteractiveWindow->setVisible(false);
  userInteractiveWindow->setPosition(0, 0);

  // Main loop:
  int runnumber = 0;
  while(true) {
    if(signum != 0) break;

    // home the robot once in a while:
    if ((runnumber % 5) == 0) {
      int gogo = 0; getInt("Perform robot homing sequence and press ENTER", gogo);
    }

    // select the scene:
    getInt("Enter scene ID (-1 to exit):", sceneID);

    if (sceneID == -1) break; // abort on scene -1

    // STEP 1. Load the scene file
    SceneSetup setup = loadSceneSetup(sceneID);

    // STEP 2. Show the interactive window:
    userInteractiveWindow->setVisible(true);

    // STEP 3. Display background image and ask the user to place it on the scene
    Image< PixRGB<byte> > backgroundImage = Raster::ReadRGB(setup.setupPath + "/" + setup.backgroundFileName);
    backgroundImage = rescale(backgroundImage, Dims(640, 480));
    writeText(backgroundImage, Point2D<int>(0, 0), "Please place this background on the scene and press ENTER.");
    userInteractiveWindow->drawImage(backgroundImage, 0, 0, true);
    LINFO("Place background map on scene and add houses, trees, and other background objects. See User Interactive window for instructions...");
    // eat all previous mouse clicks and key presses, just in case:
    while (userInteractiveWindow->getLastMouseClick() != Point2D<int>(-1, -1)) { }
    while (userInteractiveWindow->getLastKeyPress() != -1) { }
    // wait for ENTER:
    while(userInteractiveWindow->getLastKeyPress() != 36) usleep(100000);
    LINFO("Background map done. Make sure you have built a nice scene.");

    // STEP 4. Display each object and ask user to put on the scene and specify its bounding box
    for (size_t i = 0; i < setup.objects.size(); ++i)
      setup.objects[i].outline = promptPlaceObjectOnScene(setup, i);

    // STEP 5. Hide the interactive window
    userInteractiveWindow->setVisible(false);

    // STEP 6. Write out outlines to a file
    {
      std::string objectFileName = sformat("%s/RobotScene-s%04d-polygons.txt", dataDir, sceneID);
      std::ofstream objectFile(objectFileName.c_str());

      LINFO("Saving the object bounding boxes into: %s", objectFileName.c_str());
 
      for(size_t i=0; i<setup.objects.size(); ++i)
	{
	  for(size_t j=0; j<setup.objects[i].outline.size(); ++j)
	    {
	      Point2D<int> &pnt = setup.objects[i].outline[j];
	      if(j != 0) objectFile << ',';
	      objectFile << pnt.i << ',' << pnt.j;
	    }
	  objectFile << std::endl;
	}
    }

    // STEP 7. Execute the path and record the videos
    for (pathID = 0; pathID < int(setup.pathIndex.size()); ++pathID) {
      if(signum != 0) break;
      // create a directory for this scene / light:
      const std::string dir = sformat("%s/RobotScene-s%04d-p%02d", dataDir, sceneID, pathID);
      const std::string cmd = sformat("/bin/mkdir -p %s", dir.c_str());
      if (system(cmd.c_str()) == -1) PLFATAL("Could not create directory %s", dir.c_str());

      int gogo = pathID; getInt("Set light and press ENTER to start video recording", gogo);

      // make sure we don't have too many pending disk writes:
      while(writer.size() > 1000) {
	LINFO("Waiting for image writer thread, queue size = %" ZU "...", writer.size());
	usleep(1000000);
      }

      LINFO("Running Scene %04d Path %02d ...", sceneID, setup.pathIndex[pathID]);

      executePath(setup.pathIndex[pathID]);
    }
    if(signum != 0) break;

    // STEP 8. Instruct users to place the objects back into the bins
    userInteractiveWindow->setVisible(true);
    userInteractiveWindow->setPosition(0, 0);
    for(size_t i=0; i<setup.objects.size(); ++i) promptReturnObjectToTray(setup, i);
    userInteractiveWindow->setVisible(false);

    // STEP 9. Ready for next scene
    ++sceneID;
    ++runnumber;
  }

  // stop grabbing:
  keepgoing = false;

  // wait for all pics to be written (note: this just waits until the queue of pending jobs is empty, the writer's
  // destructor will wait until all jobs are complete):
  while(writer.size()) {
    LINFO("Waiting for image writer thread, queue size = %" ZU "...", writer.size());
    usleep(500000);
  }
  writer.flushQueue(250000, true);

  // make sure all is done
  LINFO("Cleaning up... Stand by...");
  usleep(2000000);

  // stop all our ModelComponents
  mgr.stop();

  LINFO("Finished.");

  return 0;
}