当前位置: 首页>>代码示例>>C++>>正文


C++ ParticleEmitter::setTimeToLive方法代码示例

本文整理汇总了C++中ParticleEmitter::setTimeToLive方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEmitter::setTimeToLive方法的具体用法?C++ ParticleEmitter::setTimeToLive怎么用?C++ ParticleEmitter::setTimeToLive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParticleEmitter的用法示例。


在下文中一共展示了ParticleEmitter::setTimeToLive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateVisuals

void Turboprop::updateVisuals(RoR::GfxActor* gfx_actor)
{
    RoR::GfxActor::NodeData* node_buf = gfx_actor->GetSimNodeBuffer();

    //smoke
    if (smokeNode)
    {
        smokeNode->setPosition(node_buf[nodeback].AbsPosition);
        ParticleEmitter* emit = smokePS->getEmitter(0);
        Vector3 dir = node_buf[nodeback].AbsPosition - node_buf[noderef].AbsPosition;
        emit->setDirection(dir);
        emit->setParticleVelocity(propwash - propwash / 10, propwash + propwash / 10);
        if (!failed)
        {
            if (ignition)
            {
                emit->setEnabled(true);
                emit->setColour(ColourValue(0.0, 0.0, 0.0, 0.03 + throtle * 0.05));
                emit->setTimeToLive((0.03 + throtle * 0.05) / 0.1);
            }
            else
            {
                emit->setEnabled(false);
            }
        }
        else
        {
            emit->setDirection(Vector3(0, 1, 0));
            emit->setParticleVelocity(5, 9);
            emit->setEnabled(true);
            emit->setColour(ColourValue(0.0, 0.0, 0.0, 0.1));
            emit->setTimeToLive(0.1 / 0.1);
        }
    }

#ifdef USE_ANGELSCRIPT
    if (failed != failedold)
    {
        TRIGGER_EVENT(SE_TRUCK_ENGINE_FIRE, trucknum);
        failedold = failed;
    }
#endif
}
开发者ID:Speciesx,项目名称:rigs-of-rods,代码行数:43,代码来源:TurboProp.cpp

示例2: Update


//.........这里部分代码省略.........
			//LogO(toStr(w)+" wht "+fToStr(wht[w],3,5));

		///  emit rates +
		Real sq = squeal* std::min(1.f, whTemp[w]), l = pSet->particles_len * onGr;
		Real emitS = sq * (whVel * 30) * l * 0.45f;  ///*
		Real emitM = slide < 1.4f ? 0.f :  (8.f * sq * std::min(5.f, slide) * l);
		Real emitD = (std::min(140.f, whVel) / 3.5f + slide * 1.f ) * l;  
		Real sizeD = (0.8f + 0.6f * std::min(140.f, whVel) / 140.f) * (w < 2 ? 0.7f : 1.1f);

		//  ter mtr factors
		int mtr = std::max(0, std::min(whMtr-1, (int)(sc->td.layers.size()-1)));
		int rd  = sc->td.road1mtr ? 0 : std::max(0, std::min(3, whRd));

		TerLayer& lay = whMtr==0 ? sc->td.layerRoad[rd] : sc->td.layersAll[sc->td.layers[mtr]];
		emitD *= lay.dust;  emitM *= lay.mud;  sizeD *= lay.dustS;  emitS *= lay.smoke;

		if (pipe)  emitD = 0;  // no dust in pipes
		if (posInfo.whH[w] > 0.1f)  emitD = 0;  // no dust in fluids

		bool ghost = isGhost();  // opt dis for ghost
		bool ghPar = !(ghost && !pSet->rpl_ghostpar);
		if (!ghPar)
		{	emitD = 0.f;  emitM = 0.f;  emitS = 0.f;  }

		///  emit particles
		Vector3 vpos = posInfo.whPos[w];
		if (pSet->particles)
		{
			ParticleSystem* ps = par[PAR_Smoke][w];
			if (ps)  //  smoke
			{	ParticleEmitter* pe = ps->getEmitter(0);
				pe->setPosition(vpos + posInfo.carY * wR*0.7f);  ///*
				ps->getAffector(0)->setParameter("alpha", toStr(-0.2f - 0.023f * whVel));  // fade out speed
				pe->setTimeToLive( std::max(0.12f, 2.f - whVel * 0.06f) );  // live time
				pe->setDirection(-posInfo.carY);	pe->setEmissionRate(emitS);
			}
			ps = par[PAR_Mud][w];
			if (ps)	 //  mud
			{	ParticleEmitter* pe = ps->getEmitter(0);
				//pe->setDimensions(sizeM,sizeM);
				pe->setPosition(vpos + posInfo.carY * wR*0.7f);
				pe->setDirection(-posInfo.carY);	pe->setEmissionRate(emitM);
			}
			ps = par[PAR_Dust][w];
			if (ps)	 //  dust
			{	ps->setDefaultDimensions(sizeD,sizeD);
				ParticleEmitter* pe = ps->getEmitter(0);
				pe->setPosition(vpos + posInfo.carY * wR*0.31f);
				pe->setDirection(-posInfo.carY);	pe->setEmissionRate(emitD);
			}

			//  fluids .::.
			ps = par[PAR_Water][w];
			int idPar = posInfo.whP[w];
			if (ps)  //  Water ~
			{
				float vel = posInfo.speed;  // depth.. only on surface?
				bool e = idPar == 0 && ghPar &&  vel > 10.f && posInfo.whH[w] < 1.f;
				float emitW = e ?  std::min(80.f, 5.0f * vel)  : 0.f;

				ParticleEmitter* pe = ps->getEmitter(0);
				pe->setPosition(vpos + posInfo.carY * wR*0.51f);
				pe->setMinParticleVelocity(0.07* vel);
				pe->setMaxParticleVelocity(0.20* vel);
				pe->setDirection(-posInfo.carY);	pe->setEmissionRate(emitW * pSet->particles_len);
			}
开发者ID:Mixone-FinallyHere,项目名称:stuntrally,代码行数:67,代码来源:CarModel_Update.cpp

示例3: updateVisuals

void Turbojet::updateVisuals()
{
    //nozzle
    nzsnode->setPosition(nodes[nodeback].AbsPosition);
    //build a local system
    Vector3 laxis = nodes[nodefront].RelPosition - nodes[nodeback].RelPosition;
    laxis.normalise();
    Vector3 paxis = Plane(laxis, 0).projectVector(nodes[noderef].RelPosition - nodes[nodeback].RelPosition);
    paxis.normalise();
    Vector3 taxis = laxis.crossProduct(paxis);
    Quaternion dir = Quaternion(laxis, paxis, taxis);
    nzsnode->setOrientation(dir);
    //afterburner
    if (afterburner)
    {
        absnode->setVisible(true);
        float flamelength = (afterburnthrust / 15.0) * (rpm / 100.0);
        flamelength = flamelength * (1.0 + (((Real)rand() / (Real)RAND_MAX) - 0.5) / 10.0);
        absnode->setScale(flamelength, radius * 2.0, radius * 2.0);
        absnode->setPosition(nodes[nodeback].AbsPosition + dir * Vector3(-0.2, 0.0, 0.0));
        absnode->setOrientation(dir);
    }
    else
        absnode->setVisible(false);
    //smoke
    if (smokeNode)
    {
        smokeNode->setPosition(nodes[nodeback].AbsPosition);
        ParticleEmitter* emit = smokePS->getEmitter(0);
        ParticleEmitter* hemit = 0;
        if (heathazePS)
            hemit = heathazePS->getEmitter(0);
        emit->setDirection(-axis);
        emit->setParticleVelocity(exhaust_velocity);
        if (hemit)
        {
            hemit->setDirection(-axis);
            hemit->setParticleVelocity(exhaust_velocity);
        }
        if (!failed)
        {
            if (ignition)
            {
                emit->setEnabled(true);
                emit->setColour(ColourValue(0.0, 0.0, 0.0, 0.02 + throtle * 0.03));
                emit->setTimeToLive((0.02 + throtle * 0.03) / 0.1);
                if (hemit)
                {
                    hemit->setEnabled(true);
                    hemit->setTimeToLive((0.02 + throtle * 0.03) / 0.1);
                }
            }
            else
            {
                emit->setEnabled(false);
                if (hemit)
                    hemit->setEnabled(false);
            }
        }
        else
        {
            emit->setDirection(Vector3(0, 1, 0));
            emit->setParticleVelocity(7.0);
            emit->setEnabled(true);
            emit->setColour(ColourValue(0.0, 0.0, 0.0, 0.1));
            emit->setTimeToLive(0.1 / 0.1);

            if (hemit)
            {
                hemit->setDirection(Vector3(0, 1, 0));
                hemit->setParticleVelocity(7.0);
                hemit->setEnabled(true);
                hemit->setTimeToLive(0.1 / 0.1);
            }
        }
    }
}
开发者ID:disloyalpick,项目名称:rigs-of-rods,代码行数:77,代码来源:TurboJet.cpp

示例4: update

void DustPool::update(float gspeed)
{
	gspeed=fabs(gspeed);
	for (int i=0; i<allocated; i++)
	{
		ParticleEmitter *emit = pss[i]->getEmitter(0);
		Vector3 ndir = velocities[i];
		Real vel = ndir.length();
		ColourValue col = colours[i];

		if (vel == 0)
			vel += 0.0001;
		ndir = ndir / vel;

		emit->setEnabled(true);

		if (types[i] != DUST_RIPPLE)
		{
			emit->setDirection(ndir);
			emit->setParticleVelocity(vel);
			sns[i]->setPosition(positions[i]);
		}
		

		if (types[i]==DUST_NORMAL)
		{
			ndir.y=0;
			ndir=ndir/2.0;

			col.a=(vel+(gspeed/10.0))*0.05;
			emit->setTimeToLive((vel+(gspeed/10.0))*0.05/0.1);
		}
		else if (types[i]==DUST_CLUMP)
		{
			ndir=ndir/2.0;
			if (ndir.y<0) ndir.y=-ndir.y;

			col.a=1.0;
		} 
		else if (types[i]==DUST_RUBBER)
		{
			ndir.y=0;
			ndir=ndir/4.0;

			col.a = vel*0.05;
			col.b = 0.9;
			col.g = 0.9;
			col.r = 0.9;

			emit->setTimeToLive(vel*0.05/0.1);
		} 
		else if (types[i]==DUST_SPARKS)
		{
			//ugh
		} 
		else if (types[i]==DUST_VAPOUR)
		{
			emit->setParticleVelocity(vel/2.0);

			col.a = rates[i] * 0.03;
			col.b = 0.9;
			col.g = 0.9;
			col.r = 0.9;

			emit->setTimeToLive(rates[i]*0.03/0.1);
		} 
		else if (types[i]==DUST_DRIP)
		{
			emit->setEmissionRate(rates[i]);
		} 
		else if (types[i]==DUST_SPLASH)
		{
			if (ndir.y<0) 
				ndir.y=-ndir.y/2.0;

			emit->setDirection(ndir);

			col.a = vel*0.05;
			col.b = 0.9;
			col.g = 0.9;
			col.r = 0.9;

			emit->setTimeToLive(vel*0.05/0.1);
		} 
		else if (types[i]==DUST_RIPPLE)
		{
			positions[i].y = gEnv->terrainManager->getWater()->getHeight() - 0.02;
			sns[i]->setPosition(positions[i]);

			col.a = vel*0.04;
			col.b = 0.9;
			col.g = 0.9;
			col.r = 0.9;

			emit->setTimeToLive(vel*0.04/0.1);
		}

		emit->setColour(col);
	}
	for (int i=allocated; i<size; i++)
//.........这里部分代码省略.........
开发者ID:Clever-Boy,项目名称:rigs-of-rods,代码行数:101,代码来源:DustPool.cpp


注:本文中的ParticleEmitter::setTimeToLive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。