Game Development Community

how to create a smoke in my level

by DieRich · in Torque 3D Professional · 07/31/2011 (10:53 pm) · 3 replies

hi all, I'm new to t3d 1.0, and I'm trying to create a smoke particle emitter in my level manually, but my codes are not worked, why?

codes:
ParticleEmitterData * pSmokeCfgData = dynamic_cast<ParticleEmitterData *>(Sim::findObject("SmokeEmitter"));
m_pSmoke = new ParticleEmitter;
m_pSmoke->setCfgData(pSmokeCfgData);
m_pSmoke->registerObject();
Point3F stPos = pTank->getPosition() + Point3F(2, 2, 2);
m_pSmoke->setPosition(stPos);

and I also and a tick function to call this:
m_pSmoke->emitParticles(pos, true, axis, Point3F(0, 0, 0), dwTick);

thanks in advance.

#1
08/01/2011 (1:29 am)
There is a datablock already for smoke. All you need to do is place an emitter in the level and select smoke for it, and then adjust to your liking. Unless you have another reason for not doing it this way?
#2
08/01/2011 (6:19 am)
As Chris said ... any particular reason you're doing it in cpp?

%emitter = new ParticleEmitterNode()
	{
         active = "1";
         emitter = "SmokeEmitter";
         velocity = "1";
         dataBlock = "SmokeEmitterNode";
         position = "0 0 512";
         rotation = "1 0 0 0";
         scale = "1 1 1";
         locked = "1";
         canSave = "1";
         canSaveDynamicFields = "1";
    };
	   MissionCleanup.add(%emitter);

In script if you don't want to place an emitter via the World Editor.
#3
08/01/2011 (7:17 am)
I think you need to add it to the scene with a:

addToScene();