示例#1
0
void ParticleSystem::_update(Real timeElapsed)
{
    Real nonvisibleTimeout = mNonvisibleTimeoutSet ? mNonvisibleTimeout : msDefaultNonvisibleTimeout;

    // Scale incoming speed for the rest of the calculation
    timeElapsed *= mSpeedFactor;

    // Init renderer if not done already
    configureRenderer();

    // Initialise emitted emitters list if not done already
    initialiseEmittedEmitters();

    Real iterationInterval = mIterationIntervalSet ? mIterationInterval : msDefaultIterationInterval;
    if (iterationInterval > 0)
    {
        mUpdateRemainTime += timeElapsed;

        while (mUpdateRemainTime >= iterationInterval)
        {
            // Update existing particles
            _expire(iterationInterval);
            _triggerAffectors(iterationInterval);
            _applyMotion(iterationInterval);

	    if (mIsEmitting)
	    {
		// Emit new particles
		_triggerEmitters(iterationInterval);
	    }

            mUpdateRemainTime -= iterationInterval;
        }
    }
    else
    {
        // Update existing particles
        _expire(timeElapsed);
        _triggerAffectors(timeElapsed);
        _applyMotion(timeElapsed);

	if (mIsEmitting)
	{
	    // Emit new particles
	    _triggerEmitters(timeElapsed);
	}
    }

    if (!mBoundsAutoUpdate && mBoundsUpdateTime > 0.0f)
    {
        mBoundsUpdateTime -= timeElapsed; // count down 
    }
    // _updateBounds();
}
/// @brief  Initialises the application.
/// @return Returns true if the initialisation was successful, false otherwise.
bool ServerGraphics::initApplication (void)
{
    // Select and load the relevant resources
    mResourcesCfg = "../../media/resources.cfg";
#ifdef _DEBUG
    mPluginsCfg = "plugins_d.cfg";
#else
    mPluginsCfg = "plugins.cfg";
#endif
    mRoot = new Ogre::Root(mPluginsCfg, "ogre.cfg", "");
    setupResources();
    
    // Configure the renderer and exit if no configuration was provided.
    if (!configureRenderer())
        return false;

    // Create the window and viewport to go in it.
    NameValuePairList windowParameters;
    windowParameters["border"] = "fixed";
    mRoot->initialise(false);
    mWindow = mRoot->createRenderWindow("Collision Domain Server", 640, 480, false, &windowParameters);
    GameCore::mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);

    createCamera();
    createViewports();
    
    // Load the required resources
    // Create the splash screen (preloading its required resources in the process)
    SplashScreen splashScreen(mRoot);
    splashScreen.draw();
    //Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);   // Set default mipmap level
    //loadResources();                    // Load resources

    GameCore::initialise(this); // Initialise other game elements
    GameCore::load(&splashScreen, 0);
    GameCore::mNetworkCore->init(NULL);     // Initialise the server networking

    createScene();                          // Create the scene (in the server's case loading physics meshes)
    createFrameListener();                  // Create the frame listener to be used during rendering

    return true;
}