Example #1
0
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
}
Example #2
0
void Pod::generateGlow(PodColor color, PodShape shape)
{
    if (!glowNode)
    {
        std::string particleName = "General/GlowPod";
        Ogre::ColourValue particleValue;
        switch (color)
        {
            case POD_COLOR_BLUE:
                particleValue.r = 0.1;
                particleValue.g = 0.3;
                particleValue.b = 1.0;
                break;
            case POD_COLOR_GREEN:
                particleValue.r = 0.0;
                particleValue.g = 1.0;
                particleValue.b = 0.0;
                break;
            case POD_COLOR_PINK:
                particleValue.r = 1.0;
                particleValue.g = 0.0;
                particleValue.b = 0.0;
                break;
            case POD_COLOR_YELLOW:
                particleValue.r = 1.0;
                particleValue.g = 1.0;
                particleValue.b = 0.0;
                break;
            default:
                particleValue.r = 0.5;
                particleValue.g = 0.5;
                particleValue.b = 1.0;
                break;
        }
        
        switch (shape)
        {
            case POD_SHAPE_CONE:
                particleName += "Cylinder";
                break;
            case POD_SHAPE_DIAMOND:
                particleName += "Box";
                break;
            case POD_SHAPE_SPHERE:
                particleName += "Ellipsoid";
                break;
            case POD_SHAPE_TRIANGLE:
                particleName += "Ellipsoid"; // No ogre particle shape for tris
                break;
            case POD_SHAPE_HOLDOUT:
                particleName += "Ellipsoid";
                break;
            default:
                particleName += "Cylinder";
                break;
        }
        
        // Make independent to avoid rotation orientions when translating.
        glowNode = OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode()->createChildSceneNode("GlowNode" + Util::toStringInt(glowID));
        glowEffect = glowNode->getCreator()->createParticleSystem("GlowEffect" + Util::toStringInt(glowID), particleName);
        ParticleEmitter* glowEmitter = glowEffect->getEmitter(0); // Assuming only one emitter
        
        glowEmitter->setColour(particleValue);
        
        glowNode->attachObject(glowEffect);
        glowNode->setPosition(head->_getDerivedPosition());
        ++glowID;
    }
}
Example #3
0
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);
            }
        }
    }
}
Example #4
0
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++)
	{
		pss[i]->getEmitter(0)->setEnabled(false);
	}
	allocated=0;
}