//-----------------------------------------------------------------------
	void ParticleSystem::startAndStopFade(Real stopTime)
	{
		start();
		stopFade(stopTime);
	}
	//-----------------------------------------------------------------------
	void ParticleSystem::_update(Real timeElapsed)
	{
		// Only update if attached to a node
		if (!mParentNode)
			return;

		// Only update if the particle system is started or prepare the particle system before starting.
		if (mState == ParticleSystem::PSS_STARTED)
		{
			if (mNonvisibleUpdateTimeoutSet)
			{
				long frameDiff = Ogre::Root::getSingleton().getNextFrameNumber() - mLastVisibleFrame;
				if (frameDiff > 1 || frameDiff < 0)
				{
					mTimeSinceLastVisible += timeElapsed;
					if (mTimeSinceLastVisible >= mNonvisibleUpdateTimeout)
					{
						// No update
						return;
					}
				}
			}

			// Speedup or slowdown
			timeElapsed *= mParticleSystemScaleTime;

			// Only update the time since start if the ParticleSystem is in the 'start' state.
			// Stop the ParticleSystem if the fixed timeout has been reached (if applicable).
			mTimeElapsedSinceStart += timeElapsed;
			if (mFixedTimeoutSet)
			{
				if (mTimeElapsedSinceStart >= mFixedTimeout)
				{
					// Stop the ParticleSystem
					if (mStopFadeSet)
					{
						// Stop slowly
						stopFade();
						mFixedTimeoutSet = false;
					}
					else
					{
						// Stop immediately
						stop();
						return;
					}
				}
			}

			// Update bound timer (if not auto updated)
			if (!mBoundsAutoUpdate && mBoundsUpdateTime > 0.0f)
				mBoundsUpdateTime -= timeElapsed;

			// Calculate rotation of the node
			calulateRotationOffset();

			// Determine whether timeElapsed or iterationInterval is used
			size_t particlesLeft = 0;
			if (mIterationIntervalSet)
			{
				// Update time since last update
				mTimeSinceLastUpdate += timeElapsed;
				while (mTimeSinceLastUpdate >= mIterationInterval)
				{
					// Update all techniques using the iteration interval value
					particlesLeft = _updateTechniques(mIterationInterval);
					mTimeSinceLastUpdate -= mIterationInterval;
				}
			}
			else
			{
				// Update all techniques using the time elapsed (since last frame)
				particlesLeft = _updateTechniques(timeElapsed);
			}

			// Handle situation when no particles are emitted anymore
			if (particlesLeft == 0)
			{
				if (mAtLeastOneParticleEmitted)
				{
					// Generate the event
					_pushSystemEvent(PU_EVT_NO_PARTICLES_LEFT);
					mAtLeastOneParticleEmitted = false;
				}

				// Determine whether the particle system should be stopped because of a fade out
				if (mStopFadeSet)
				{
					if (!mFixedTimeoutSet || (mFixedTimeoutSet && mTimeElapsedSinceStart >= mFixedTimeout))
					{
						stop();
						return;
					}
				}
			}
			else
			{
				// At least one particle was emitted, so if 'particlesLef' becomes 0, it concerns the period after the last emitted particle.
				mAtLeastOneParticleEmitted = true;
			}
		}
		else if (mState == ParticleSystem::PSS_PREPARED)
		{
			// Generate the event
			_pushSystemEvent(PU_EVT_SYSTEM_PREPARING);

			// Prepare all techniques (perform some initialisation in advance)
			ParticleTechniqueIterator it;
			ParticleTechniqueIterator itEnd = mTechniques.end();
			for (it = mTechniques.begin(); it != itEnd; ++it)
			{
				(*it)->_prepare();
			}

			// Only do it once.
			mState = ParticleSystem::PSS_STOPPED;

			// Generate the event
			_pushSystemEvent(PU_EVT_SYSTEM_PREPARED);
		}
		else if (mState == ParticleSystem::PSS_PAUSED)
		{
			// Determine whether there is a limit to the pause
			if (mPauseTimeSet)
			{
				mPauseTimeElapsed += timeElapsed;
				if (mPauseTimeElapsed > mPauseTime)
				{
					mPauseTimeElapsed = 0.0f;
					resume();
				}
			}
		}

		// Set the latest position. This value is always needed, whether the Particle System is emitted or not.
		latestPosition = getDerivedPosition();
		mLatestOrientation = getDerivedOrientation();
	}
Beispiel #3
0
int main (int argc, char *argv[]) {
	DMXDATA startCode = (DMXDATA)0;
	DMXDATA cue[512];
	DMXDATA temp[512];
	DMXDATA BO[512];
	//DMXINT Patch[512];
	DMXINT changed[512];
	DMXINT upTime[512];
	DMXINT downTime[512];
	DMXINT waitTime[512];
	int x;
	for(x = 0; x < 512; x++)
	{
		cue[x] = 128;
		BO[x] = 0;
		temp[x] = 0;
		changed[x] = 0;
		upTime[x] = 0;
		downTime[x] = 0;
		waitTime[x] = 0;
	//	Patch[x] = x;
	}
	//for(x = 0; x < 512; x++)
		

	//cout << "before load. \n";
	dmx_handle usb = open((DMXINT)512, (DMXINT)20);
	if(isSimulation(usb))
	{
		std::cout << "Could not open port! Running in simulation mode\n";
		//return;
	}

	std::cout << "after open: " << usb <<" \n";

	close(usb);

	std::cout << "after Close: " << usb <<" \n";
//	Sleep(5000);

	usb = open((DMXINT)512, (DMXINT)20);
	if(isSimulation(usb))
	{
		std::cout << "Could not open port! Running in simulation mode\n";
		//return;
	}

	std::cout << "after open: " << usb <<" \n";
	setStartCode(usb, startCode);
	/*
	Patch[0] = 7;
	Patch[1] = 1;
	Patch[2] = 5;
	Patch[3] = 8;
	Patch[4] = 12;

	Patch[7] = 0;
	Patch[5] = 2;
	Patch[8] = 3;
	Patch[12] = 4;
	*/

/*	for(x = 0; x < 13; x++)
	{
		cout << "Patch[" << x << "] = " << Patch[x] << endl;
	}//*/
		

	//patch(usb, Patch);
//	Sleep(1000);
	//clearPatch(usb);

	quickLoad(usb, BO);
	Sleep(1000);

/*
	cout << "Overlaping Cross Fade Delayed Up and Down Times" << endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		changed[x] = 1;
		//quickLoad(usb, startCode, temp);
		partialLoad(usb, startCode, temp, changed, 6000, 2000, 1000, 5000);
		cout << "Channel: " << x << endl;
		Sleep(7000);
		printDMX(usb);
		temp[x] = 0;
		changed[x] = 0;

	}
	*/

	stopFade(usb);
	std::cout << "Overlaping Cross Fade Level Feedback Test" << std::endl;
	for(x = 0; x < 6; x++){
		temp[x] = (DMXDATA)255;
		changed[x] = 1; //quickLoad(usb, startCode, temp);
		partialLoadSplit(usb, temp, changed, 7000, 7000);
		std::cout << "Channel: " << x << std::endl;
		Sleep(3000);
		printDMX(usb);
		temp[x] = 0;
		changed[x] = 0;

	}
	
	quickLoad(usb, BO);
	Sleep(1000);
	
	setGrandMaster(usb, 128);
	std::cout << "Overlaping Cross Fade Level Feedback Test - GM @ 50" << std::endl;
	for(x = 0; x < 6; x++){
		temp[x] = (DMXDATA)255;
		changed[x] = 1; //quickLoad(usb, startCode, temp);
		partialLoadSplit(usb, temp, changed, 7000, 7000);
		std::cout << "Channel: " << x << std::endl;
		Sleep(3000);
		printDMX(usb);
		temp[x] = 0;
		changed[x] = 0;

	}
	
	quickLoad(usb, BO);
	Sleep(1000);
	
	setGrandMaster(usb, 255);
	setProportionalOutputs(usb, cue);
	std::cout << "Overlaping Cross Fade Level Feedback Test - PO @ 50" << std::endl;
	for(x = 0; x < 6; x++){
		temp[x] = (DMXDATA)255;
		changed[x] = 1; //quickLoad(usb, startCode, temp);
		partialLoadSplit(usb, temp, changed, 7000, 7000);
		std::cout << "Channel: " << x << std::endl;
		Sleep(3000);
		printDMX(usb);
		temp[x] = 0;
		changed[x] = 0;

	}
	
	
	quickLoad(usb, BO);
	Sleep(1000);
	
	setGrandMaster(usb, 126);
	std::cout << "Overlaping Cross Fade Level Feedback Test - PO & GM @ 50" << std::endl;
	for(x = 0; x < 6; x++){
		temp[x] = (DMXDATA)255;
		changed[x] = 1; //quickLoad(usb, startCode, temp);
		partialLoadSplit(usb, temp, changed, 7000, 7000);
		std::cout << "Channel: " << x << std::endl;
		Sleep(3000);
		printDMX(usb);
		temp[x] = 0;
		changed[x] = 0;

	}
	
	setGrandMaster(usb, 255);
	clearProportionalOutputs(usb);

	std::cout << "Simple Bumb Test" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		quickLoad(usb, temp);
		std::cout << "Channel: " << x << std::endl;
		Sleep(1000);
		temp[x] = (DMXDATA)0;

	}//*/
	quickLoad(usb, BO);
	Sleep(1000);
	

	std::cout << "Sectional Cross Fade Test: ON" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		changed[x] = 1;
		upTime[x] = 4000*x;
		downTime[x] = 4000*x;
	}//*/
	complexLoadSplit(usb, temp, changed, upTime, downTime);
	Sleep(24000);


	std::cout << "Sectional Cross Fade Test: OFF" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)0;
		changed[x] = 1;
		upTime[x] = 4000*x;
		downTime[x] = 4000*x;
	}//*/
	complexLoadSplit(usb, temp, changed, upTime, downTime);
	Sleep(24000);
	quickLoad(usb, BO);
	Sleep(1000);

	std::cout << "Overlaping Delayed Bumb Test: ON" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		changed[x] = 1;
		//quickLoad(usb, startCode, temp);
		partialLoadSplit(usb, temp, changed, 0, 0);
		std::cout << "Channel: " << x << std::endl;
		Sleep(1000);
		temp[x] = 0;
		changed[x] = 0;

	}//*/
	Sleep(2000);
	quickLoad(usb, BO);
	Sleep(1000);

	std::cout << "Overlaping Delayed Bumb Test: ON" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		changed[x] = 1;
		waitTime[x] = (7000 - x*1000);
		//quickLoad(usb, startCode, temp);
		complexLoadSplit(usb, temp, changed, upTime, downTime);
		std::cout << "Channel: " << x << std::endl;
		Sleep(1000);
		temp[x] = 0;
		changed[x] = 0;

	}//*/
	Sleep(2000);
	quickLoad(usb, BO);
	Sleep(1000);

	std::cout << "Sectional Cross Fade Test: BUMB ON" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		changed[x] = 1;
		upTime[x] = 0;
		downTime[x] = 0;
	}//*/
	complexLoadSplit(usb, temp, changed, upTime, downTime);
	Sleep(1000);


	std::cout << "Sectional Cross Fade Test: BUMB OFF" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)0;
		changed[x] = 1;
		upTime[x] = 0;
		downTime[x] = 0;
	}//*/
	complexLoadSplit(usb, temp, changed, upTime, downTime);
	Sleep(1000);
	quickLoad(usb, BO);
	Sleep(1000);



//*/
//	quickLoad(usb, startCode, BO);
	Sleep(1000);

	std::cout << "Overlaping Cross Fade Test: OFF" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)0;
		changed[x] = 1;
		partialLoadSplit(usb, temp, changed, 7000, 7000);
		std::cout << "Channel: " << x << std::endl;
		Sleep(3000);
		temp[x] = 0;
		changed[x] = 0;

	}//*/
	quickLoad(usb, BO);
	Sleep(1000);


	std::cout << "Overlaping Cross Fade Test: Bumb On" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		changed[x] = 1;
		partialLoadSplit(usb, temp, changed, 0, 0);
		std::cout << "Channel: " << x << std::endl;
		Sleep(1000);
		temp[x] = 0;
		changed[x] = 0;

	}//*/

	std::cout << "Overlaping Cross Fade Test: Bumb OFF" << std::endl;
	for(x = 0; x < 6; x++){
		temp[x] = (DMXDATA)0;
		changed[x] = 1;
		partialLoadSplit(usb, temp, changed, 0, 0);
		std::cout << "Channel: " << x << std::endl;
		Sleep(1000);
		temp[x] = 0;
		changed[x] = 0;

	}//*/
	quickLoad(usb, BO);
	Sleep(1000);


	std::cout << "Simple Cross Fade Test" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		fullLoadSplit(usb, temp, 5000, 2000);
		std::cout << "Channel: " << x << std::endl;
		Sleep(5000);
		temp[x] = (DMXDATA)0;

	}//*/
	quickLoad(usb, BO);
	Sleep(1000);

	std::cout << "Simple Cross Fade Bumb Test" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		fullLoadSplit(usb, temp, 0, 0);
		std::cout << "Channel: " << x << std::endl;
		Sleep(5000);
		temp[x] = (DMXDATA)0;

	}//*/
	quickLoad(usb, BO);
	Sleep(1000);

	std::cout << "Simple Bumb Test" << std::endl;
	for(x = 0; x < 6; x++)
	{
		temp[x] = (DMXDATA)255;
		quickLoad(usb, temp);
		std::cout << "Channel: " << x << std::endl;
		Sleep(1000);
		temp[x] = (DMXDATA)0;

	}//*/
	quickLoad(usb, BO);
	Sleep(1000);
	
	close(usb);
//	cout << "after close. \n";
}