Exemplo n.º 1
0
void CParticleJetEffectPainter::CreateLinearParticles (CSpaceObject *pObj, int iCount, const CVector &vInitialPos, const CVector &vInitialVel)

//	CreateLinearParticles
//
//	Creates new particles on a straight line

	{
	int i;

	//	Compute some basic stuff

	const Metric rJitterFactor = LIGHT_SPEED / 100000.0;
	Metric rCurRotation = AngleToRadians(180 + m_iXformRotation + m_iCurDirection);

	//	Compute the spread angle, in radians

	Metric rSpread = AngleToRadians(Max(0, m_SpreadAngle.Roll()));
	Metric rHalfSpread = 0.5 * rSpread;

	//	Calculate where last tick's particles would be based on the last rotation.

	Metric rAveSpeed = m_EmitSpeed.GetAveValue() * LIGHT_SPEED / 100.0;
	CVector vCurStart = (m_vLastEmitPos + (m_rXformTime * ::PolarToVectorRadians(rCurRotation, rAveSpeed * g_SecondsPerUpdate))) - vInitialPos;

	//	Create particles

	for (i = 0; i < iCount; i++)
		{
		Metric rSlide = mathRandom(0, 9999) / 10000.0;

		//	We place the particle along the line betwen the current
		//	and last emit positions

		CVector vPos = vInitialPos + rSlide * vCurStart;

		//	Generate a random velocity backwards

		Metric rRotation = rCurRotation + (rHalfSpread * mathRandom(-1000, 1000) / 1000.0);
		Metric rSpeed = m_EmitSpeed.Roll() * LIGHT_SPEED / 100.0;
		CVector vVel = m_rXformTime * (vInitialVel + ::PolarToVectorRadians(rRotation, rSpeed + rJitterFactor * mathRandom(-500, 500)));

		//	Lifetime

		int iLifeLeft = m_ParticleLifetime.Roll();

		//	Add the particle

		m_Particles.AddParticle(vPos, vVel, iLifeLeft, AngleToDegrees(rRotation));
		}

	//	Remember the last position

	m_iLastDirection = m_iCurDirection;
	m_vLastEmitPos = vInitialPos;
	}
Exemplo n.º 2
0
void scCachedStyle::ComputeExtentsnCursor( void )
{
	if ( GetDeviceValues() ) {
		scXRect 		rect;
		MicroPoint		a,b,c,d;

		FIgetDEVFontExtents( fSpec, a, b, c, d, rect );

		if ( fFlowDir.IsHorizontal() ) {
			scAssert( rect.Valid( eFirstQuad ) );
			rect.FirstToFourth( GetPtSize() );
			scAssert( rect.Valid( eFourthQuad ) );
			
			fInkExtents.y1	= rect.y1;
			fInkExtents.y2	= rect.y2;
			fInkExtents.x1	= rect.x1;
			fInkExtents.x2	= rect.x2;
		}
		else {
			fInkExtents.y1	= 0;
			fInkExtents.y2	= rect.y1 - rect.y2;
			fInkExtents.x1	= -(rect.x2/2) - rect.x1;
			fInkExtents.x2	= rect.x2/2;
		}
	}
	else {
		scRLURect		rect;
		RLU 			a,b,c,d;

		FIgetRLUFontExtents( fSpec, a, b, c, d, rect );

		if ( fFlowDir.IsHorizontal() ) {
			scAssert( rect.Valid( eFirstQuad ) );
			rect.FirstToFourth( scBaseRLUsystem );
		}
		scAssert( rect.Valid( eFourthQuad ) );

		fInkExtents.y1	= scRoundMP( fPtConv * rect.rluTop );
		fInkExtents.y2	= scRoundMP( fPtConv * rect.rluBottom );
		fInkExtents.x1	= scRoundMP( fSetConv * rect.rluLeft );
		fInkExtents.x2	= scRoundMP( fSetConv * rect.rluRight );		

	}

	REAL obliqOff = 0;
	if (  GetHorzOblique()	)
		obliqOff = (REAL)tan( AngleToRadians( GetHorzOblique() ) );

	if ( GetHorzOblique() < 0 )
		 fInkExtents.x1 += scRoundMP( GetPtSize() * obliqOff );

	if ( GetHorzOblique() < 0 ) 
		fInkExtents.x2 += scRoundMP( GetPtSize() * obliqOff );

	scAssert( fInkExtents.Valid( eFourthQuad ) );
	
	if ( fFlowDir.IsHorizontal() )
		fInkExtents.Translate( 0, -GetBaseline() );
	else 
		fInkExtents.Translate( GetBaseline(), 0 );	
	
	if ( fFlowDir.IsHorizontal() ) {
		scLEADRefData	ld;

		ld.Set( GetPtSize(), fFlowDir );
		fLogicalExtents.Set( 0, -ld.GetAboveLead(),
							 GetSetSize(), ld.GetBelowLead() ); 												
	}
	else
		fLogicalExtents.Set( -GetSetSize()/2, 0, GetSetSize()/2, GetPtSize() );

	
	if ( fFlowDir.IsHorizontal() ) {
		fCursorY1		= -scRoundMP( fPtConv * RLU_BASEfmTop );
		fCursorY2		= scRoundMP( fPtConv * RLU_BASEfmBottom );
	}
	else {
		fCursorX1		= -GetSetSize() / 2;
		fCursorX2		= GetSetSize() / 2;
	}
}
Exemplo n.º 3
0
void CParticleJetEffectPainter::CreateInterpolatedParticles (CSpaceObject *pObj, int iCount, const CVector &vInitialPos, const CVector &vInitialVel)

//	CreateInterpolatedParticles
//
//	Creates particles interpolated between to directions.

	{
	int i;

	//	Compute some basic stuff

	const Metric rJitterFactor = LIGHT_SPEED / 100000.0;
	Metric rLastRotation = AngleToRadians(180 + m_iXformRotation + m_iLastDirection);
	Metric rCurRotation = AngleToRadians(180 + m_iXformRotation + m_iCurDirection);

	//	Compute the spread angle, in radians

	Metric rSpread = AngleToRadians(Max(0, m_SpreadAngle.Roll()));
	Metric rHalfSpread = 0.5 * rSpread;

	//	Calculate where last tick's particles would be based on the last rotation.

	Metric rAveSpeed = m_EmitSpeed.GetAveValue() * LIGHT_SPEED / 100.0;
	CVector vLastStart = (m_vLastEmitPos + (m_rXformTime * ::PolarToVectorRadians(rLastRotation, rAveSpeed * g_SecondsPerUpdate))) - vInitialPos;

	//	Calculate where last tick's particles would be IF we have used the current
	//	rotation. This allows us to interpolate a turn.

	CVector vCurStart = (m_vLastEmitPos + (m_rXformTime * ::PolarToVectorRadians(rCurRotation, rAveSpeed * g_SecondsPerUpdate))) - vInitialPos;

	//	Create particles

	for (i = 0; i < iCount; i++)
		{
		Metric rSlide = mathRandom(0, 9999) / 10000.0;

		//	Compute two points along the two slide vectors (last and current)

		CVector vSlide1 = rSlide * vLastStart;
		CVector vSlide2 = rSlide * vCurStart;
		CVector vAdj = (rSlide * vSlide1) + ((1.0 - rSlide) * vSlide2);

		//	We place the particle along the line betwen the current
		//	and last emit positions

		CVector vPos = vInitialPos + vAdj;

		//	We blend the rotation as well

		if (Absolute(rCurRotation - rLastRotation) > g_Pi)
			{
			if (rLastRotation < rCurRotation)
				rLastRotation += g_Pi * 2.0;
			else
				rCurRotation += g_Pi * 2.0;
			}

		Metric rSlideRotation = (rSlide * rLastRotation) + ((1.0 - rSlide) * rCurRotation);

		//	Generate a random velocity backwards

		Metric rRotation = rSlideRotation + (rHalfSpread * mathRandom(-1000, 1000) / 1000.0);
		Metric rSpeed = m_EmitSpeed.Roll() * LIGHT_SPEED / 100.0;
		CVector vVel = m_rXformTime * (vInitialVel + ::PolarToVectorRadians(rRotation, rSpeed + rJitterFactor * mathRandom(-500, 500)));

		//	Lifetime

		int iLifeLeft = m_ParticleLifetime.Roll();

		//	Add the particle

		m_Particles.AddParticle(vPos, vVel, iLifeLeft, AngleToDegrees(rRotation));
		}

	//	Remember the last position

	m_iLastDirection = m_iCurDirection;
	m_vLastEmitPos = vInitialPos;
	}