当前位置: 首页>>代码示例>>C++>>正文


C++ TimeManager类代码示例

本文整理汇总了C++中TimeManager的典型用法代码示例。如果您正苦于以下问题:C++ TimeManager类的具体用法?C++ TimeManager怎么用?C++ TimeManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TimeManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST

TEST(TimeManagerTest, testTimeoutNoParam) {
	TimeManager time;
	timeManagerTestCallback.callbackNoParamCalled = false;
	time.setTimeout(1, &timeManagerTestCallback,
			&TimeManagerTestCallback::timeoutNoParamCallback);
	time.update(1);
	ASSERT_TRUE(timeManagerTestCallback.callbackNoParamCalled);
}
开发者ID:LibreGames,项目名称:caveexpress,代码行数:8,代码来源:TimeManagerTest.cpp

示例2: mouseMove

void mouseMove(int x, int y)
{
	Vector3r mousePos;
	MiniGL::unproject(x, y, mousePos);
	const Vector3r diff = mousePos - oldMousePos;

	TimeManager *tm = TimeManager::getCurrent();
	const Real h = tm->getTimeStepSize();

	ParticleData &pd = model.getParticles();
	for (unsigned int j = 0; j < selectedParticles.size(); j++)
	{
		pd.getVelocity(selectedParticles[j]) += 5.0*diff/h;
	}
	oldMousePos = mousePos;
}
开发者ID:PeterZs,项目名称:PositionBasedDynamics,代码行数:16,代码来源:GenericParticleConstraintsDemo.cpp

示例3: mouseMove

void mouseMove(int x, int y)
{
	Vector3r mousePos;
	MiniGL::unproject(x, y, mousePos);
	const Vector3r diff = mousePos - oldMousePos;

	TimeManager *tm = TimeManager::getCurrent();
	const float h = tm->getTimeStepSize();

	SimulationModel::RigidBodyVector &rb = model.getRigidBodies();
	for (size_t j = 0; j < selectedBodies.size(); j++)
	{
		rb[selectedBodies[j]]->getVelocity() += 1.0f / h * diff;
	}
	oldMousePos = mousePos;
}
开发者ID:termi3,项目名称:PositionBasedDynamics,代码行数:16,代码来源:ElasticRodDemo.cpp

示例4: clearAccelerations

void TimeStepFluidModel::step(FluidModel &model)
{
	TimeManager *tm = TimeManager::getCurrent ();
	const float h = tm->getTimeStepSize();
	ParticleData &pd = model.getParticles();

	clearAccelerations(model);

	// Compute viscosity forces
	if (TimeManager::getCurrent()->getTime() > 0.0)			// in the first step we do not know the neighbors
	{		
		computeDensities(model);
		computeViscosityAccels(model);
	}

	// Update time step size by CFL condition
	updateTimeStepSizeCFL(model, 0.0001f, 0.005f);

	// Time integration
	for (unsigned int i = 0; i < pd.size(); i++)
	{ 
		model.getDeltaX(i).setZero();
		pd.getLastPosition(i) = pd.getOldPosition(i);
		pd.getOldPosition(i) = pd.getPosition(i);
		TimeIntegration::semiImplicitEuler(h, pd.getMass(i), pd.getPosition(i), pd.getVelocity(i), pd.getAcceleration(i));
	}

	// Perform neighborhood search
	model.getNeighborhoodSearch()->neighborhoodSearch(&model.getParticles().getPosition(0), model.numBoundaryParticles(), &model.getBoundaryX(0));

	// Solve density constraint
	constraintProjection(model);

	// Update velocities	
	for (unsigned int i = 0; i < pd.size(); i++)
	{
		if (m_velocityUpdateMethod == 0)
			TimeIntegration::velocityUpdateFirstOrder(h, pd.getMass(i), pd.getPosition(i), pd.getOldPosition(i), pd.getVelocity(i));
		else
			TimeIntegration::velocityUpdateSecondOrder(h, pd.getMass(i), pd.getPosition(i), pd.getOldPosition(i), pd.getLastPosition(i), pd.getVelocity(i));
	}

	// Compute new time	
	tm->setTime (tm->getTime () + h);
	model.getNeighborhoodSearch()->update();
}
开发者ID:derkreature,项目名称:PositionBasedDynamics,代码行数:46,代码来源:TimeStepFluidModel.cpp

示例5: main

int main(int argc, const char *argv[])
{
    BarotropicModel_Semiimp model;
    RossbyHaurwitzTestCase testCase;

    TimeManager timeManager;
    Time startTime, endTime(68*DAYS);
    //Time startTime, endTime(1*DAYS);

    timeManager.init(startTime, endTime, 4*MINUTES);

    model.init(80, 41);
    testCase.calcInitCond(model);

    model.run(timeManager);

    return 0;
}
开发者ID:huyong1109,项目名称:semiimp-swe,代码行数:18,代码来源:run_semiimp.cpp

示例6: setup

gboolean setup (void* data)
{
	if (runtime_get_surface_list () == NULL)
		return TRUE;

	Surface *surface = (Surface *) runtime_get_surface_list ()->data; 

	if (surface == NULL)
		return TRUE;
 
	TimeManager *manager = surface_get_time_manager (surface);
	ManualTimeSource *source = (ManualTimeSource *) manager->GetSource ();
    
	printf ("Setting up...\n");
	surface->SetExposeHandoffFunc (expose_handoff, NULL);
	g_idle_add (increase_timer, NULL);

	return FALSE;    
}
开发者ID:499940913,项目名称:moon,代码行数:19,代码来源:animation-recorder.cpp

示例7: mouseMove

void mouseMove(int x, int y)
{
	Eigen::Vector3f mousePos;
	MiniGL::unproject(x, y, mousePos);
	const Eigen::Vector3f diff = mousePos - oldMousePos;

	TimeManager *tm = TimeManager::getCurrent();
	const float h = tm->getTimeStepSize();

	SimulationModel::RigidBodyVector &rb = model.getRigidBodies();
	for (size_t j = 0; j < selectedBodies.size(); j++)
	{
		rb[selectedBodies[j]]->getVelocity() += 1.0f / h * diff;
	}
	ParticleData &pd = model.getParticles();
	for (unsigned int j = 0; j < selectedParticles.size(); j++)
	{
		pd.getVelocity(selectedParticles[j]) += 5.0*diff / h;
	}
	oldMousePos = mousePos;
}
开发者ID:ImNaohaing,项目名称:PositionBasedDynamics,代码行数:21,代码来源:RigidBodyClothCouplingDemo.cpp

示例8: invalidate

	void CVariableStore::invalidate(TimeManager& timeManager)
	{
		lock_guard<std::mutex> lock(storeMutex);
		map<string, shared_ptr<ConsensusVariable>>::iterator it;
		for (it = store.begin(); it != store.end(); it++)
		{
			shared_ptr<ConsensusVariable> var = it->second;
			if (var->getValidityTime() < timeManager.getDistributedTime())
			{
				var->hasValue = false;
			}
		}
	}
开发者ID:carpe-noctem-cassel,项目名称:cace,代码行数:13,代码来源:CVariableStore.cpp

示例9: increase_timer

gboolean increase_timer (void *data)
{
	if (runtime_get_surface_list () == NULL)
		return TRUE;

	Surface *surface = (Surface *) runtime_get_surface_list ()->data; 

	if (surface == NULL)
		return TRUE;
    
	TimeManager *manager = surface_get_time_manager (surface);
	ManualTimeSource *source = (ManualTimeSource *) manager->GetSource ();

	source->SetCurrentTime (TimeSpan_FromSecondsFloat (current_time));
	current_time += 0.04; // 25 frames per second
	image_no++;

	if (current_time > 5.0) {
		printf ("ALL DONE! %d images captured\n", image_no - 1);
		exit (0);
	}

	return FALSE;
}
开发者ID:499940913,项目名称:moon,代码行数:24,代码来源:animation-recorder.cpp

示例10: testManagers

void testManagers()
{	
	/*
	struct MyObject;
	struct MyStorage: public IDPair<MyStorage,MyObject>::Store
	{
	}storage;
	struct MyObject: public IDPair<MyStorage,MyObject>::Stored
	{
		MyObject(MyStorage *manager,const char *n)
			:Stored(manager),hello(n)
		{}
		std::string hello;
	};
	new MyObject(&storage,"object1");
	new MyObject(&storage,"object2");
	new MyObject(&storage,"object3");
	new MyObject(&storage,"object4");*/
	TimeManager manager;
	struct TestEvent : public TimeManager::Action
	{
	public:
		std::string eventMsg;
		TestEvent(const std::string &str):eventMsg(str){}
		virtual void Execute()
		{
			printf("TestEvent::Execute(%s)\n",eventMsg.c_str());
		}
	};
	manager.add(new TestEvent("Event 1"), 40);
	manager.add(new TestEvent("Event 2"), 60);
	manager.add(new TestEvent("Event 3"), 20);
	manager.add(new TestEvent("Event 4"), 50);
	for(int i = 0; i < 8; i++)
		manager.update(5);

	manager.add(new TestEvent("Event 5"), 20);
	manager.add(new TestEvent("Event 6"), 30);	
	for(int i = 0; i < 30; i++)
		manager.update(5);
	int w = 0;
}
开发者ID:FrostHand,项目名称:frosttools,代码行数:42,代码来源:testIdManagers.cpp

示例11: run

        void LevelManager::run()
        {
            /* Behold, as I have been told
             * what follows below
             * is very important, you know! */
            InputManager *inputManager = InputManager::getInstance();
            TimeManager *timeManager = TimeManager::getInstance();
            VideoManager *videoManager = VideoManager::getInstance();
            EffectManager *effectManager = EffectManager::getInstance();
            SketchManager *sketchManager = SketchManager::getInstance();

            FPSLogger fps;
 
            float freq_to_update = 1000.0f / 60.0f;

            long lastUpdate = timeManager->getTicks();
            while(!inputManager->hasQuitEvent()) {

                /* Calculate the ticks that have passed. */
                long ticks = timeManager->getTicks();
                float ms = (float)(ticks - lastUpdate);
                lastUpdate = ticks;

                /* Cap FPS by sleeping a little. */
                if(ms <= freq_to_update) {
                    float wait = freq_to_update - ms;
                    timeManager->sleep(wait);
                }

                /* Update the input state. */
                inputManager->update(ms);

                /* Update the level. */
                if(level && ms > 0.0f) level->update(timeFactor * ms);

                /* Update other things. */
                effectManager->update(timeFactor * ms);
                fps.update(ms);

                /* Setup the videoManager for rendering. */
                videoManager->clear();
                videoManager->identity();

                /* Render the level first, this will also apply our camera
                 * transformation, which is good, since the effect manager
                 * wants the same transformation. */
                if(level) level->render();
                effectManager->render();
                fps.render();

                /* Flip the video buffer. */
                videoManager->flip();

                /* Update level queue. */
                if(queue) {
                    /* Remove old level. */
                    if(level)
                        delete level;

                    effectManager->clear();
                    sketchManager->clear();

                    /* Load new level. */
                    level = new Level(queueFileName);
                    queue = false;
                    timeFactor = 1.0f;

                    /* Loading the level might have taken some time, so we skip
                     * some ticks. */
                    lastUpdate = timeManager->getTicks();
                }
            }
        }
开发者ID:sjuxax,项目名称:JVGS,代码行数:73,代码来源:LevelManager.cpp

示例12: main

int main(int argc, const char *argv[])
{
    ConfigManager configManager;
    Domain domain(1);
    Mesh mesh(domain, 2);
    Field<double, 2> u, f;
    Field<double> fu;
    TimeManager timeManager;
    IOManager io;
    int outputFileIdx;
    TimeLevelIndex<2> oldIdx, newIdx, halfIdx;

    double dt, dx;
    string outputPattern = "beam_warming.%3s.nc";

    if (argc != 2) {
        REPORT_ERROR("Configure file is needed!");
    }

    // Read configuration from file.
    configManager.parse(argv[1]);
    dt = configManager.getValue("beam_warming", "dt", 1);
    dx = configManager.getValue("beam_warming", "dx", 0.01);
    outputPattern = configManager.getValue("beam_warming", "output_pattern", outputPattern);

    // Set the one dimensional space axis.
    domain.setAxis(0, "x", "x axis", "m",
                   0, geomtk::BndType::PERIODIC,
                   1, geomtk::BndType::PERIODIC);

    // Set the discrete mesh on the domain.
    mesh.init(domain.axisSpan(0)/dx);

    // Set the time manager.
    Time startTime(0*geomtk::TimeUnit::SECONDS);
    Time endTime(200*geomtk::TimeUnit::SECONDS);
    timeManager.init(startTime, endTime, dt);

    // Set up velocity and density fields.
    u.create("u", "m s-1", "velocity component along x axis", mesh, X_FACE, 1, true);
    f.create("f", "kg m-1", "tracer density", mesh, CENTER, 1);
    fu.create("fu", "kg s-1", "tracer mass flux", mesh, X_FACE, 1);

    // Set the initial conditions.
    newIdx = oldIdx+1;
    for (int i = mesh.is(HALF); i <= mesh.ie(HALF); ++i) {
        u(oldIdx, i) = 0.005;
        u(newIdx, i) = 0.005;
    }
    u.applyBndCond(oldIdx);
    u.applyBndCond(newIdx, true);
    for (int i = mesh.is(FULL); i <= mesh.ie(FULL); ++i) {
        const SpaceCoord &x = mesh.gridCoord(CENTER, i);
        if (x(0) >= 0.05 && x(0) <= 0.1) {
            f(oldIdx, i) = 1.0;
        } else {
            f(oldIdx, i) = 0.0;
        }
    }
    f.applyBndCond(oldIdx);

    // Set up IO manager.
    io.init(timeManager);
    outputFileIdx = io.registerOutputFile(mesh, outputPattern, geomtk::TimeStepUnit::STEP, 1);
    io.registerField(outputFileIdx, "double", FULL_DIMENSION, {&f});
    io.output<double, 2>(outputFileIdx, oldIdx, {&f});

    // Run the main loop.
    double C = dt/dx;
    while (!timeManager.isFinished()) {
        newIdx = oldIdx+1; halfIdx = oldIdx+0.5;
        for (int i = mesh.is(HALF); i <= mesh.ie(HALF); ++i) {
            fu(i) = 0.5*C*(      u(halfIdx, i)    *(3*f(oldIdx, i)-f(oldIdx, i-1))-
                           C*pow(u(halfIdx, i), 2)*(  f(oldIdx, i)-f(oldIdx, i-1)));
        }
        fu.applyBndCond();
        for (int i = mesh.is(FULL); i <= mesh.ie(FULL); ++i) {
            f(newIdx, i) = f(oldIdx, i)-(fu(i)-fu(i-1));
        }
        f.applyBndCond(newIdx);
        timeManager.advance(); oldIdx.shift();
        io.output<double, 2>(outputFileIdx, oldIdx, {&f});
    }

    return 0;
}
开发者ID:fanghuan,项目名称:IAP-CGFD,代码行数:86,代码来源:main.cpp

示例13: main

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Space Invaders");
    //STARTING SETTINGS

    AudioManager audioManager;
    BulletManager bulletManager;
    EnemyManager enemyManager;
    Randomizer random;
    TimeManager time;
    Menu mainMenu;
    Interface mainInterface;
    Player player(400, 500);
    Player *playerWsk = &player;

    //CONTROL VARIABLES
    bool menu = true;
    bool init = false;
    bool menuMusic = false;
    bool stageTwo = false;


    mainMenu.loadData();

    while (window.isOpen())
    {
        if(menu == false)
        {

            if(init == false)
            {
                audioManager.stopMenu();
                menuMusic = false;

                player.setHealth(3);


                //CREATING ENEMIES and INITILIAZING
                enemyManager.addEnemies(); //2 ROWS


                random.initialize();
                audioManager.playMusic();
                init = true;
            }
        if((stageTwo == false) && (mainInterface.getScore() >= 280))
        {
            enemyManager.addEnemiesMedium();
            stageTwo = true;

        }
        if((mainInterface.getScore() >= 560))
        {
            audioManager.stopMusic();
            init = false;
            menu = true;
        }

        time.updateShoot();
        time.updateRandomShoot();
        // REFRESHING WINDOW
        // ALL PHYSICS HERE

        while(time.getAccumulator() > time.getUps())
        {
            time.updateAccumulator();
            player.keyboardControl(time.getUps(), bulletManager, time.getShootTimer(), time, audioManager);
            enemyManager.controlEnemies(random, bulletManager, time);
            bulletManager.controlBullets(time.getUps());


            //COLLISIONS
            bulletManager.checkPlayerCollisions(playerWsk);
            enemyManager.updateDead(bulletManager);
            player.gameOver(audioManager, menu, init);

        }


        //SIMPLE EVENTS
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        mainInterface.checkRecords(mainMenu);

        //DRAWING
        window.clear();
        mainInterface.drawText(window, player.getHealth());
        enemyManager.drawEnemies(window);
        window.draw(player.getSprite());
        bulletManager.drawBullets(window);
        window.display();

         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
            {
                window.close();
            }
//.........这里部分代码省略.........
开发者ID:Th3NiKo,项目名称:Projects,代码行数:101,代码来源:main.cpp

示例14: simulate

void VisualizerFMU::simulate(TimeManager& omvm)
{
  while (omvm.getSimTime() < omvm.getRealTime() + omvm.getHVisual() && omvm.getSimTime() < omvm.getEndTime())
    omvm.setSimTime(simulateStep(omvm.getSimTime()));
}
开发者ID:hkiel,项目名称:OMEdit,代码行数:5,代码来源:VisualizerFMU.cpp

示例15:

bool TimeManager::operator==(TimeManager input) {
	return ((this->hour == input.hour) && (this->min == input.min) && ((int)this->sec == (int)input.sec) && \
		(this->solarDate.solarDay == input.getSolarDay()) && (this->solarDate.solarMonth == input.getSolarMonth()) && \
		(this->solarDate.solarYear == input.getSolarYear()));
}
开发者ID:RedChiken,项目名称:Calendar,代码行数:5,代码来源:TimeManager.cpp


注:本文中的TimeManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。