Ejemplo n.º 1
0
CNewParticleEffect *CParticleProperty::Create( CParticleSystemDefinition *pDef, ParticleAttachment_t iAttachType, int iAttachmentPoint, Vector vecOriginOffset, matrix3x4_t *matOffset )
{
	int nBatchMode = cl_particle_batch_mode.GetInt();
	bool bRequestedBatch = ( nBatchMode == 2 ) || ( ( nBatchMode == 1 ) && pDef && pDef->ShouldBatch() ); 
	if ( ( iAttachType == PATTACH_CUSTOMORIGIN ) && bRequestedBatch )
	{
		int iIndex = FindEffect( pDef->GetName() );
		if ( iIndex >= 0 )
		{
			CNewParticleEffect *pEffect = m_ParticleEffects[iIndex].pParticleEffect.GetObject();
			pEffect->Restart();
			return pEffect;
		}
	}

	int iIndex = m_ParticleEffects.AddToTail();
	ParticleEffectList_t *newEffect = &m_ParticleEffects[iIndex];
	newEffect->pParticleEffect = CNewParticleEffect::Create( m_pOuter, pDef, pDef->GetName() );

	if ( !newEffect->pParticleEffect->IsValid() )
	{
		// Caused by trying to spawn an unregistered particle effect. Remove it.
		ParticleMgr()->RemoveEffect( newEffect->pParticleEffect.GetObject() );
		return NULL;
	}

	AddControlPoint( iIndex, 0, GetOuter(), iAttachType, iAttachmentPoint, vecOriginOffset, matOffset );

	if ( m_pOuter )
	{
		m_pOuter->OnNewParticleEffect( pDef->GetName(), newEffect->pParticleEffect.GetObject() );
	}

	return newEffect->pParticleEffect.GetObject();
}
Ejemplo n.º 2
0
BezierCurve::BezierCurve(vector<Vec2d> &iPoints, double error)
{
  FitCurveWrapper fitcurve;
  _currentSegment = new BezierCurveSegment;
  vector<Vec2d> curve;

  fitcurve.FitCurve(iPoints, curve, error);
  int i = 0;
  vector<Vec2d>::iterator v, vend;
  for (v = curve.begin(), vend = curve.end(); v != vend; ++v) {
    if ((i == 0) || (i % 4 != 0))
      AddControlPoint(*v);
    ++i;
  }
}
CNewParticleEffect *CParticleProperty::Create( const char *pszParticleName, ParticleAttachment_t iAttachType, int iAttachmentPoint, Vector vecOriginOffset )
{
	if ( GameRules() )
	{
		pszParticleName = GameRules()->TranslateEffectForVisionFilter( "particles", pszParticleName );
	}

	int nBatchMode = cl_particle_batch_mode.GetInt();
	CParticleSystemDefinition *pDef = g_pParticleSystemMgr->FindParticleSystem( pszParticleName );
	bool bRequestedBatch = ( nBatchMode == 2 ) || ( ( nBatchMode == 1 ) && pDef && pDef->ShouldBatch() ); 
	if ( ( iAttachType == PATTACH_CUSTOMORIGIN ) && bRequestedBatch )
	{
		int iIndex = FindEffect( pszParticleName );
		if ( iIndex >= 0 )
		{
			CNewParticleEffect *pEffect = m_ParticleEffects[iIndex].pParticleEffect.GetObject();
			pEffect->Restart();
			return pEffect;
		}
	}

	if ( !pDef )
	{
		AssertMsg( 0, "Attempting to create unknown particle system" );
		Warning( "Attempting to create unknown particle system '%s' \n", pszParticleName );
		return NULL;
	}

	int iIndex = m_ParticleEffects.AddToTail();
	ParticleEffectList_t *newEffect = &m_ParticleEffects[iIndex];
	newEffect->pParticleEffect = CNewParticleEffect::Create( m_pOuter, pDef );

	if ( !newEffect->pParticleEffect->IsValid() )
	{
		// Caused by trying to spawn an unregistered particle effect. Remove it.
		ParticleMgr()->RemoveEffect( newEffect->pParticleEffect.GetObject() );
		return NULL;
	}

	AddControlPoint( iIndex, 0, GetOuter(), iAttachType, iAttachmentPoint, vecOriginOffset );

	if ( m_pOuter )
	{
		m_pOuter->OnNewParticleEffect( pszParticleName, newEffect->pParticleEffect.GetObject() );
	}
	
	return newEffect->pParticleEffect.GetObject();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CParticleProperty::AddControlPoint( CNewParticleEffect *pEffect, int iPoint, C_BaseEntity *pEntity, ParticleAttachment_t iAttachType, const char *pszAttachmentName, Vector vecOriginOffset )
{
	int iAttachment = INVALID_PARTICLE_ATTACHMENT;
	if ( pszAttachmentName )
	{
		iAttachment = GetParticleAttachment( pEntity, pszAttachmentName, pEffect->GetEffectName() );
	}

	for ( int i = 0; i < m_ParticleEffects.Count(); i++ )
	{
		if ( m_ParticleEffects[i].pParticleEffect == pEffect )
		{
			AddControlPoint( i, iPoint, pEntity, iAttachType, iAttachment, vecOriginOffset );
		}
	}
}
Ejemplo n.º 5
0
bool JSpline::Load(const char *filename, float xscale, float yscale)
{
	JFileSystem *fileSystem = JFileSystem::GetInstance();

	if (fileSystem == NULL) return false;
	if (!fileSystem->OpenFile(filename)) return false;

	int size = fileSystem->GetFileSize();
	char *xmlBuffer = new char[size];
	fileSystem->ReadFile(xmlBuffer, size);

	TiXmlDocument doc;
	doc.Parse(xmlBuffer);

	mCount = 0;

	mMidPoints.clear();
	mPixels.clear();


	TiXmlNode* node = 0;
	//TiXmlElement* todoElement = 0;
	TiXmlElement* element;

	node = doc.RootElement();

	float xx, yy;

	for(element = node->FirstChildElement(); element; element = element->NextSiblingElement())
	{
		xx = 0.0f;
		yy = 0.0f;
		element->QueryFloatAttribute("x", &xx);
		element->QueryFloatAttribute("y", &yy);

		Point pt(xx*xscale, yy*yscale);
		AddControlPoint(pt);
		
	}

	fileSystem->CloseFile();
	delete[] xmlBuffer;

	return true;
}
Ejemplo n.º 6
0
 void AddControlPoint( Base::Vector3 v1, Base::Vector3 v2 ) { AddControlPoint( v1.x,v1.y,v1.z,v2.x,  v2.y,v2.z ); }
Ejemplo n.º 7
0
 void AddControlPoint( float x1, float y1, float z1,  Base::Vector3 v2 ) { AddControlPoint( x1,y1,z1,  v2.x,v2.y,v2.z ); }
Ejemplo n.º 8
0
 void AddControlPoint( Base::Vector3 v ) { AddControlPoint( v.x,v.y,v.z ); }