示例#1
0
void MainWindow::updateOGRE()
{
	QMutexLocker locker(&mutex);
	static bool updateGUI=true;


	Ogre::Root* mRoot = Ogre::Root::getSingletonPtr();
	mRoot->_fireFrameStarted();

	// loop through ogre widgets and update animation
	QList<OgreWidget*> rendlist = this->findChildren<OgreWidget*>();
	foreach (OgreWidget* w, rendlist)
	{

		// update animation for OgreWidget's sceneManager
		if (w->mRenderWindow && w->updatesEnabled())
		{
			// update OgreWidget
			w->update();
			//emit w->paintEvent(new QPaintEvent(w->rect()));
			for (Ogre::SceneManager::MovableObjectIterator mit = w->getSceneManager()->getMovableObjectIterator("Entity");
				mit.hasMoreElements(); mit.moveNext() )
			{
				Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
				if (updateGUI) {
					updateGUI = false;

				}
				// check has skeleton to avoid crash for non animable entities
				if (entity->hasSkeleton())
				{
					for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator();
						animIt.hasMoreElements(); animIt.moveNext() )
					{
						Ogre::AnimationState *animState = animIt.peekNextValue();
						if ( animState->getEnabled() )
						{
							//std::cout << entity->getName() << " ZZZZZZZZZZZ " << animState->getAnimationName();
							animState->addTime(w->getRenderWindow()->getBestFPS()/10000);
						}
					}
				}
			}
		}
	}
	mRoot->_fireFrameRenderingQueued();
	mRoot->_fireFrameEnded();
}
示例#2
0
/**
 * @brief render a frame
 * @author Kito Berg-Taylor
 */
void THIS::paintGL()
{
    if (!initialised)
        initializeOgre();

    for (Ogre::SceneManager::MovableObjectIterator mit = mSceneMgr->getMovableObjectIterator("Entity");mit.hasMoreElements(); mit.moveNext() )
    {
        Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
        if (entity->hasSkeleton() )
        {
            for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator(); animIt.hasMoreElements(); animIt.moveNext() )
            {
                Ogre::AnimationState *animState = animIt.peekNextValue();
                if ( animState->getEnabled() )
                {
                    animState->addTime(mWindow->getBestFPS()/10000);
                }
            }
        }
    }

    //Ogre::WindowEventUtilities::messagePump();
    mRoot->renderOneFrame();


}