コード例 #1
0
ファイル: PartyCLApp.cpp プロジェクト: Entropy/Entropy
//--------------------------------------------------------------
void PartyCLApp::keyPressed(int key)
{
    switch (key)
    {
    case ' ':
        bPaused ^= 1;
        break;

    case '`':
        bGuiVisible ^= 1;
        break;

    case 'p':
    case 'P':
        displayMode = (ParticleRenderer::DisplayMode)((displayMode + 1) % ParticleRenderer::PARTICLE_NUM_MODES);
        break;

    case 'r':
    case 'R':
        bReset = true;
        break;

    case '[':
        presetIndex = (presetIndex == 0) ? presets.size() - 1 : (presetIndex - 1) % presets.size();
        loadPreset();
        resetSimulation();
        break;

    case ']':
        presetIndex = (presetIndex + 1) % presets.size();
        loadPreset();
        resetSimulation();
        break;

    case 'f':
    case 'F':
        ofToggleFullscreen();
        break;

    case '1':
        activeConfig = NBODY_CONFIG_SHELL;
        resetSimulation();
        break;

    case '2':
        activeConfig = NBODY_CONFIG_RANDOM;
        resetSimulation();
        break;

    case '3':
        activeConfig = NBODY_CONFIG_EXPAND;
        resetSimulation();
        break;
    }
}
コード例 #2
0
int main (int argc, char **argv)
{
	doFast = true;
	
	// setup pointers to drawstuff callback functions
	dsFunctions fn;
	fn.version = DS_VERSION;
	fn.start = &start;
	fn.step = &simLoop;
	fn.command = &command;
	fn.stop = 0;
	fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH;
	
	dInitODE2(0);

	bodies = 0;
	joints = 0;
	boxes = 0;
	spheres = 0;
	
	resetSimulation();
	
	// run simulation
	dsSimulationLoop (argc,argv,352,288,&fn);
	
	dJointGroupDestroy (contactgroup);
	dSpaceDestroy (space);
	dWorldDestroy (world);
	dCloseODE();
	return 0;
}
コード例 #3
0
ファイル: MainWindow.cpp プロジェクト: abiyo/2D-Fluid-Solver
MainWindow::MainWindow()
  : _mainLayout(NULL),
    _controlLayout(NULL),
    _rendWidget(NULL),
    _resetButton(NULL)
    
{
  // Establish a default renderer to use.
  _rendWidget = QRendererWidget::rendererWidget
    (this, QRendererWidget::COMPATIBILITY_RENDERER);

  // Create the overall window layout - an HBoxLayout.
  _mainLayout = new QHBoxLayout;
  
  // Two children of the HBoxLayout: renderer and VBoxLayout (controls).
  _mainLayout->addWidget(_rendWidget);  
  _controlLayout = new QVBoxLayout;
  _mainLayout->addLayout(_controlLayout);

  // Children of the VBoxLayout.
  _resetButton = new QPushButton("Reset");
  _controlLayout->addWidget(_resetButton);
  QObject::connect(_resetButton, SIGNAL(clicked()),
		   SignalRelay::getInstance(), SIGNAL(resetSimulation()));

  // Realize all widgets.
  setLayout(_mainLayout);

  // Set window title.
  setWindowTitle(tr("2D Fluid Solver"));
}
void	WorkerServer::processMessage(char* pData, int dataLength)
{
	auto*	pMessage = reinterpret_cast<workerClientMessages::t_Message*>(pData);

	switch (pMessage->type)
	{
		case workerClientMessages::eInitialiseSimulation:
		{
			workerServerMessages::t_SimulationInitialisedMessage	message;

			sendMessage(reinterpret_cast<char*>(&message), sizeof(message));
		}
		break;

		case workerClientMessages::eResetAndProcessSimulation:
		{
			resetSimulation(pMessage);
			processSimulation();
		}
		break;

		case workerClientMessages::eProcessSimulation:
		{
			processSimulation();
		}
		break;

		default:
		{
			D_MYLOG("WORKER message => Unknown");
		}
	}
}
コード例 #5
0
void IslandControl::simulate()
{
    randSeed = time(NULL);
    srand(randSeed);
    while(numberOfSims > 0)
    {
        resetSimulation();
        runSimulation();
        numberOfSims--;
    }
}
コード例 #6
0
/** Stop the simulation */
void ParticleSystem::stopSimulation(float t)
{
    
	// TODO
	bake_end_time = t;
    resetSimulation(t);
	// These values are used by the UI
	simulate = false;
	dirty = true;

}
コード例 #7
0
ファイル: PhysicsManager.cpp プロジェクト: nerd-toolkit/nerd
void PhysicsManager::eventOccured(Event *e) {
	if(e == 0) {
		return;
	}
	else if(Core::getInstance()->isShuttingDown()) {
		return;
	}
	else if(e == mNextStepEvent) {
		
		if(mInitialResetDone == false) {
			//this should ensure that reset was executed at least once before a
			//step is executed.
			//TODO: This might not be sufficient or save. Check!
			resetSimulation();
		}

		executeSimulationStep();
	}
	else if(e == mResetEvent) {
		resetSimulation();
	}
}
コード例 #8
0
ファイル: PartyCLApp.cpp プロジェクト: Entropy/Entropy
//--------------------------------------------------------------
void PartyCLApp::update()
{
    ofSetWindowTitle(ofToString(ofGetFrameRate(), 2) + " FPS");

    if (bReset) {
        resetSimulation();
        bReset = false;
    }

    if (!bPaused) {
        // Set simulation parameters.
        system->setSoftening(softening);
        system->setDamping(damping);

        // Run the simulation computations.
        system->update(timestep);

        // Set renderer parameters.
        renderer->setPointSize(pointSize);
    }
}
コード例 #9
0
ファイル: main.cpp プロジェクト: mostua/TZSP
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Model model;
    model.population = 0;
    MainWindow view(&model);
    Controller controller(&model);
    qRegisterMetaType<vectorSquares>("vectorSquares");
    qRegisterMetaType<vectorPairs>("vectorPairs");
    QObject::connect(&controller, SIGNAL(stepSimulationStarted()), &view, SIGNAL(activateStepButtons()));
    QObject::connect(&controller, SIGNAL(continousSimulationStarted()), &view, SIGNAL(activateContinousButtons()));
    QObject::connect(&controller, SIGNAL(simulationReseted()), &view, SIGNAL(simulationReseted()));
    QObject::connect(&controller, SIGNAL(drawFitnessGraph(double,double,double,int)), &view, SLOT(drawFitnessGraph(double,double,double,int)));
    QObject::connect(&controller, SIGNAL(drawNumberOfIndivuals(vectorPairs,int)), &view, SLOT(drawNumberOfIndivuals(vectorPairs,int)));
    QObject::connect(&controller, SIGNAL(updateBest(vectorSquares)), &view, SIGNAL(updateBest(vectorSquares)));
    QObject::connect(&view, SIGNAL(startStepSimulation(Settings)), &controller, SLOT(beginStepSimulation(Settings)));
    QObject::connect(&view, SIGNAL(startContinousSimulation(Settings)), &controller, SLOT(beginContinousSimulation(Settings)));
    QObject::connect(&view, SIGNAL(resetSimulation()), &controller, SLOT(simulationReset()));

    view.show();
    return a.exec();
}
コード例 #10
0
static void command (int cmd)
{
	switch (cmd) {
	case 'a': case 'A':
		speed += 0.3;
		break;
	case 'z': case 'Z':
		speed -= 0.3;
		break;
	case ',':
		turn += 0.1;
		if (turn > 0.3)
			turn = 0.3;
		break;
	case '.':
		turn -= 0.1;
		if (turn < -0.3)
			turn = -0.3;
		break;
	case ' ':
		speed = 0;
		turn = 0;
		break;
	case 'f': case 'F':
		doFast = !doFast;
		break;
	case '+':
		dWorldSetAutoEnableDepthSF1 (world, dWorldGetAutoEnableDepthSF1 (world) + 1);
		break;
	case '-':
		dWorldSetAutoEnableDepthSF1 (world, dWorldGetAutoEnableDepthSF1 (world) - 1);
		break;
	case 'r': case 'R':
		resetSimulation();
		break;
	case '[':
		cannon_angle += 0.1;
		break;
	case ']':
		cannon_angle -= 0.1;
		break;
	case '1':
		cannon_elevation += 0.1;
		break;
	case '2':
		cannon_elevation -= 0.1;
		break;
	case 'x': case 'X': {
		dMatrix3 R2,R3,R4;
		dRFromAxisAndAngle (R2,0,0,1,cannon_angle);
		dRFromAxisAndAngle (R3,0,1,0,cannon_elevation);
		dMultiply0 (R4,R2,R3,3,3,3);
		dReal cpos[3] = {CANNON_X,CANNON_Y,1};
		for (int i=0; i<3; i++) cpos[i] += 3*R4[i*4+2];
		dBodySetPosition (cannon_ball_body,cpos[0],cpos[1],cpos[2]);
		dReal force = 10;
		dBodySetLinearVel (cannon_ball_body,force*R4[2],force*R4[6],force*R4[10]);
		dBodySetAngularVel (cannon_ball_body,0,0,0);
		break;
	}
	}
}
コード例 #11
0
DMMainWindow::DMMainWindow(QWidget * parent) : QMainWindow(parent), ui(new Ui::DMMainWindow)
{
	// qt init
	Q_INIT_RESOURCE(icons);
	ui->setupUi(this);
	this->setParent(parent);

	// logger init
	log_updater = new GuiLogSink();
	connect(log_updater, SIGNAL(newLogLine(QString)), SLOT(newLogLine(QString)), Qt::QueuedConnection);
#if defined DEBUG || _DEBUG
	DM::Log::init(log_updater,DM::Debug);
#else
	DM::Log::init(log_updater,DM::Standard);
#endif
	// add log export to file
	QString logfilepath = QDir::tempPath() + "/dynamind" 
		+ QDateTime::currentDateTime().toString("_yyMMdd_hhmmss_zzz")+".log";
	if(QFile::exists(logfilepath))
		QFile::remove(logfilepath);

	outputFile = new ofstream(logfilepath.toStdString().c_str());
	DM::Log::addLogSink(new DM::OStreamLogSink(*outputFile));
	DM::Logger() << "logfile: " << logfilepath;

	// init python env
	DM::PythonEnv *env = DM::PythonEnv::getInstance();
	env->addPythonPath(QApplication::applicationDirPath().toStdString());
	env->addOverWriteStdCout();

	// init simulation, we only use one instance
	this->simulation = new GUISimulation(parent, ui->tabWidget_4);
	simulationThread = NULL;
	simulationThreadWrapper = NULL;

	this->simulation->registerModulesFromDefaultLocation();
	this->simulation->registerModulesFromSettings();
	createModuleListView();

	connect( ui->actionRun, SIGNAL( triggered() ), this, SLOT( runSimulation() ), Qt::DirectConnection );
	connect( ui->actionPreferences, SIGNAL ( triggered() ), this, SLOT(preferences() ), Qt::DirectConnection );
	connect(ui->actionSave, SIGNAL(triggered()), this , SLOT(saveSimulation()), Qt::DirectConnection);
	connect(ui->actionSaveAs, SIGNAL(triggered()), this , SLOT(saveAsSimulation()), Qt::DirectConnection);
	connect(ui->actionOpen, SIGNAL(triggered()), this , SLOT(loadSimulation()), Qt::DirectConnection);
	connect(ui->actionNew, SIGNAL(triggered()), this , SLOT(clearSimulation()), Qt::DirectConnection);
	connect(ui->actionReload_Modules, SIGNAL(triggered()), this , SLOT(ReloadModules()), Qt::DirectConnection);
	connect(ui->actionUpdate, SIGNAL(triggered()), this , SLOT(updateSimulation()), Qt::DirectConnection);
	connect(ui->actionReset, SIGNAL(triggered()), this , SLOT(resetSimulation()), Qt::DirectConnection);
	connect(ui->actionCancel, SIGNAL(triggered()), this, SLOT(cancelSimulation()), Qt::DirectConnection);
	connect(ui->actionCancel, SIGNAL(triggered()), this, SLOT(cancelSimulation()), Qt::DirectConnection);
	connect(ui->actionShow_Help, SIGNAL(triggered()), this, SLOT(showHelp()), Qt::DirectConnection);

	QStringList args = QCoreApplication::arguments();
	if (args.size() == 2) {
		this->clearSimulation();
		this->getSimulation()->currentDocument = args[1];
		simulation->loadSimulation(args[1].toStdString());
	}

	ui->actionCancel->setEnabled(false);

	// load from qsettings
	QSettings settings;
	DM::DBConnectorConfig cfg = DM::DBConnector::getInstance()->getConfig();
	qulonglong v = settings.value("cacheBlockwritingSize", -1).toULongLong();
	if (v != (qulonglong)-1)
		cfg.cacheBlockwritingSize = v;

	v = settings.value("queryStackSize", -1).toULongLong();
	if (v != (qulonglong)-1)
		cfg.queryStackSize = v;

	int i = settings.value("peterDatastream", -1).toInt();
	if (i != -1)
		cfg.peterDatastream = (bool)i;
}