Step-by-step particle emitter-on-character tutor NOW $50 reward
by Highlander · in Torque Game Engine · 05/21/2007 (12:02 pm) · 35 replies
I'd like a *specific* step-by-step tutorial on how I can add particle emitters to the legs of my flying robot character so that when I activate jets with the controls below, particles (i.e. smoke) shoot down from them. The character was created in 3d studio max and exported. I added jet functionality to the character in the engine player.cc file and setup the following in the default.bind.cs file:
function jump(%val)
{
$mvTriggerCount2++;
}
function jjforward(%val)
{
$mvTriggerCount5++;
}
(more jet keys etc...)
I have no particular objects added to the robot in 3dmax yet, so the tutorial should cover what I need to add in 3dsmax and how it has to fit on the hierarchy. The robot in 3dmax is comprised of separate body parts, each an individual mesh (left arm, right arm, torso, head, etc) and the lower body is linked part-by-part to a biped for walking animation. The root object is Bip01.
The tutorial should also cover what needs to be added to the cs files and what steps i need to do (if any) in the particle editor. I know nothing about the particle editor other than one key to press to turn it on.
If multiple tutorials are posted, I'll go in chronological order and reward the $20 to the first one that enables me to get the jets working. Links to pre-existing tutorials are fine. You can post the tutorial as a resource afterwards. Have fun!
function jump(%val)
{
$mvTriggerCount2++;
}
function jjforward(%val)
{
$mvTriggerCount5++;
}
(more jet keys etc...)
I have no particular objects added to the robot in 3dmax yet, so the tutorial should cover what I need to add in 3dsmax and how it has to fit on the hierarchy. The robot in 3dmax is comprised of separate body parts, each an individual mesh (left arm, right arm, torso, head, etc) and the lower body is linked part-by-part to a biped for walking animation. The root object is Bip01.
The tutorial should also cover what needs to be added to the cs files and what steps i need to do (if any) in the particle editor. I know nothing about the particle editor other than one key to press to turn it on.
If multiple tutorials are posted, I'll go in chronological order and reward the $20 to the first one that enables me to get the jets working. Links to pre-existing tutorials are fine. You can post the tutorial as a resource afterwards. Have fun!
#2
1) I turned off the crossbow image in first person, but i forget where. I doubt this is the cause because i checked in 3rd person.
2) Maybe I dont have my mounts setup right. How can I tell ? in 3dsmax I have 6 mounts but maybe they didnt export. How should they be setup?
3) I don't know what this means:
"Ok... You are going to have to change the actual emitter blocks. I am using an animated fire texture to set my enemies on fire. They are the first 3 or 4 datablocks."
05/21/2007 (12:55 pm)
Can't get it to work. I followed the instructions, and i dont see any console errors, however here may be some possible reasons:1) I turned off the crossbow image in first person, but i forget where. I doubt this is the cause because i checked in 3rd person.
2) Maybe I dont have my mounts setup right. How can I tell ? in 3dsmax I have 6 mounts but maybe they didnt export. How should they be setup?
3) I don't know what this means:
"Ok... You are going to have to change the actual emitter blocks. I am using an animated fire texture to set my enemies on fire. They are the first 3 or 4 datablocks."
#5
'..\engine\game\shapeBase.cc(4269) : error C2248: 'ShapeBase::mountParticleEmitter' : cannot access private member declared in class 'ShapeBase'..'
but I fixed it with your advice to Caylo:
@Caylo: Move the mountParticleEmitter definition inside the .h file from the private block to the public block. That should fix that error.
it compiled fine. I added the script part to the function GameConnection::createPlayer(%this, %spawnPoint) in game.cs. I tried with mount0, which i had the crossbow on, and to mount1, which theres nothing on. The engine crashed as soon as I fired my weapon. I then cut out the script changes and tried again, but the engine crashed each time i would try to fire, even with the script parts removed.
I then restored the original shapebase.cc and shapebase.h files and it stopped crashing. I am using TGE 1.4.2
05/22/2007 (11:53 pm)
Peter I tried your resource. At first I ran into this error:'..\engine\game\shapeBase.cc(4269) : error C2248: 'ShapeBase::mountParticleEmitter' : cannot access private member declared in class 'ShapeBase'..'
but I fixed it with your advice to Caylo:
@Caylo: Move the mountParticleEmitter definition inside the .h file from the private block to the public block. That should fix that error.
it compiled fine. I added the script part to the function GameConnection::createPlayer(%this, %spawnPoint) in game.cs. I tried with mount0, which i had the crossbow on, and to mount1, which theres nothing on. The engine crashed as soon as I fired my weapon. I then cut out the script changes and tried again, but the engine crashed each time i would try to fire, even with the script parts removed.
I then restored the original shapebase.cc and shapebase.h files and it stopped crashing. I am using TGE 1.4.2
#6
I want to add jets to a player, not a vehicle. As far as I can tell this will not work with a player, will it?
05/22/2007 (11:54 pm)
Matt,I want to add jets to a player, not a vehicle. As far as I can tell this will not work with a player, will it?
#7
One thing you may find to help, is make sure your particle is already defined and loaded, and give it a good name. Make sure your datablock names do not clash with each other (a simple way to test is give them numbers like datablock ParticleData(FireParticle001data) and datablock ParticleEmitterData(FireParticle001emitter). I have in the past had similar problems to what you describe and found it was datablock name clashing.
05/23/2007 (12:52 am)
Peter Simard's 'Mounted particles' is a wonderful way to simply hook any particle to an node. I use it to hook particles onto all types of DTS mesh. One thing you may find to help, is make sure your particle is already defined and loaded, and give it a good name. Make sure your datablock names do not clash with each other (a simple way to test is give them numbers like datablock ParticleData(FireParticle001data) and datablock ParticleEmitterData(FireParticle001emitter). I have in the past had similar problems to what you describe and found it was datablock name clashing.
#8
Have a look at how the Flyingvehicle JetEmitters are created in the Engine. It should be a copy-n-paste affair ;-)
05/23/2007 (2:08 am)
How are you calling the MountObject function?Have a look at how the Flyingvehicle JetEmitters are created in the Engine. It should be a copy-n-paste affair ;-)
#9
05/23/2007 (9:05 am)
Caylo, I removed the script part of the resource entirely and the engine was still crashing.
#10
05/23/2007 (9:16 am)
@Highlander - Try building a debug build. Even a slight error in merging the resource can cause unexpected errors.
#11
" mountPoint = 1; ", you change that to your mount. If you have more then one mountPoint you will need add it to the script.
3) I don't know what this means:
"Ok... You are going to have to change the actual emitter blocks. I am using an animated fire texture to set my enemies on fire. They are the first 3 or 4 datablocks."
This mean in the script you need to change the texture to your texture to get the desire look.
I did quick test to see if it work. If you do some tweaking to datablock you should be able to get some good particles effect. The particles are animated, in Torque they look pretty good.

05/23/2007 (9:42 am)
The link Affectworks gave use mountpoint 1. Open the script and go line 118. Look at that line " mountPoint = 1; ", you change that to your mount. If you have more then one mountPoint you will need add it to the script.
3) I don't know what this means:
"Ok... You are going to have to change the actual emitter blocks. I am using an animated fire texture to set my enemies on fire. They are the first 3 or 4 datablocks."
This mean in the script you need to change the texture to your texture to get the desire look.
I did quick test to see if it work. If you do some tweaking to datablock you should be able to get some good particles effect. The particles are animated, in Torque they look pretty good.

#12
I tried getting it to work some more. I tried a debug mode full rebuild. It still crashes with no script added, but one time it spit out this error:
core\bitstream.h @ 246
out of range read
another time it gave me an invalid packet error
Heres my shapebase masks:
enum ShapeBaseMasks {
NameMask = Parent::NextFreeMask,
DamageMask = Parent::NextFreeMask << 1,
NoWarpMask = Parent::NextFreeMask << 2,
MountedMask = Parent::NextFreeMask << 3,
CloakMask = Parent::NextFreeMask << 4,
ShieldMask = Parent::NextFreeMask << 5,
InvincibleMask = Parent::NextFreeMask << 6,
SkinMask = Parent::NextFreeMask << 7,
SoundMaskN = Parent::NextFreeMask << 8, ///< Extends + MaxSoundThreads bits
mountedParticleMask = Parent::NextFreeMask << 9, //note highlander added for player particle emitters
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
};
and the other section:
if(!stream->writeFlag(mask & (NameMask | DamageMask | SoundMask |
ThreadMask | ImageMask | CloakMask | MountedMask | InvincibleMask |
ShieldMask | SkinMask | mountedParticleMask))) //note highlander added | mountedParticleMask for player particle emitters
return retMask;
See any problems?
05/24/2007 (8:51 am)
Peter,I tried getting it to work some more. I tried a debug mode full rebuild. It still crashes with no script added, but one time it spit out this error:
core\bitstream.h @ 246
out of range read
another time it gave me an invalid packet error
Heres my shapebase masks:
enum ShapeBaseMasks {
NameMask = Parent::NextFreeMask,
DamageMask = Parent::NextFreeMask << 1,
NoWarpMask = Parent::NextFreeMask << 2,
MountedMask = Parent::NextFreeMask << 3,
CloakMask = Parent::NextFreeMask << 4,
ShieldMask = Parent::NextFreeMask << 5,
InvincibleMask = Parent::NextFreeMask << 6,
SkinMask = Parent::NextFreeMask << 7,
SoundMaskN = Parent::NextFreeMask << 8, ///< Extends + MaxSoundThreads bits
mountedParticleMask = Parent::NextFreeMask << 9, //note highlander added for player particle emitters
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
};
and the other section:
if(!stream->writeFlag(mask & (NameMask | DamageMask | SoundMask |
ThreadMask | ImageMask | CloakMask | MountedMask | InvincibleMask |
ShieldMask | SkinMask | mountedParticleMask))) //note highlander added | mountedParticleMask for player particle emitters
return retMask;
See any problems?
#13
maybe I am missing some simple step here. I do what the resource says until the end, where it says
"Alright, now to start the particle emitter emitting particles simply call:
%obj.mountImage(mountedImage,1); // Where %obj is the player to mount to"
I went into game.cs and commented out these lines like so:
//%player.setInventory(Crossbow,8);
//%player.setInventory(CrossbowAmmo,100);
//%player.mountImage(CrossbowImage,0);
then I added:
%player.setInventory(mountedImage,1);
%player.mountImage(mountedImage,0);
I didnt see any particles. Next I went into mountedParticle.cs, line 118 as Fucifer said, and changed the mountPoint to 0. I still didnt see any particles. I noticed that datablock ParticleData(mountedParticle) contains the following:
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.2;
inheritedVelFactor = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 150; // ...more or less
useInvAlpha = true;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
animateTexture = true;
framesPerSec = 12;
animTexName[0] = "~/data/shapes/particles/fire/Fire0";
animTexName[1] = "~/data/shapes/particles/fire/Fire1";
animTexName[2] = "~/data/shapes/particles/fire/Fire2";
animTexName[3] = "~/data/shapes/particles/fire/Fire3";
animTexName[4] = "~/data/shapes/particles/fire/Fire4";
animTexName[5] = "~/data/shapes/particles/fire/Fire5";
animTexName[6] = "~/data/shapes/particles/fire/Fire6";
animTexName[7] = "~/data/shapes/particles/fire/Fire7";
animTexName[8] = "~/data/shapes/particles/fire/Fire7";
while smoke.png exists in the particles folder, there is no folder called fire inside the particles folder with the 9 fire textures.
I opened smoke.png which looked like a white square. Same with fire.png. I grabbed a paintbrush and scribbled gray on them thinking they were invisible. No smoke.
Then I changed the lifetimeMS to 5500 thinking the particles were inside the model and disappearing before they got out. That didnt work.
Then I tried changing the animateTexture = true; to false. nope. Then I tried copying fire.png to Fire1.png, Fire2.png, etc and making a fire folder and sticking them in there. nope.
Did I leave out any steps? Is there anything wrong with what I did above?
05/24/2007 (9:35 am)
Affectworks & Fucifer, maybe I am missing some simple step here. I do what the resource says until the end, where it says
"Alright, now to start the particle emitter emitting particles simply call:
%obj.mountImage(mountedImage,1); // Where %obj is the player to mount to"
I went into game.cs and commented out these lines like so:
//%player.setInventory(Crossbow,8);
//%player.setInventory(CrossbowAmmo,100);
//%player.mountImage(CrossbowImage,0);
then I added:
%player.setInventory(mountedImage,1);
%player.mountImage(mountedImage,0);
I didnt see any particles. Next I went into mountedParticle.cs, line 118 as Fucifer said, and changed the mountPoint to 0. I still didnt see any particles. I noticed that datablock ParticleData(mountedParticle) contains the following:
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.2;
inheritedVelFactor = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 150; // ...more or less
useInvAlpha = true;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
animateTexture = true;
framesPerSec = 12;
animTexName[0] = "~/data/shapes/particles/fire/Fire0";
animTexName[1] = "~/data/shapes/particles/fire/Fire1";
animTexName[2] = "~/data/shapes/particles/fire/Fire2";
animTexName[3] = "~/data/shapes/particles/fire/Fire3";
animTexName[4] = "~/data/shapes/particles/fire/Fire4";
animTexName[5] = "~/data/shapes/particles/fire/Fire5";
animTexName[6] = "~/data/shapes/particles/fire/Fire6";
animTexName[7] = "~/data/shapes/particles/fire/Fire7";
animTexName[8] = "~/data/shapes/particles/fire/Fire7";
while smoke.png exists in the particles folder, there is no folder called fire inside the particles folder with the 9 fire textures.
I opened smoke.png which looked like a white square. Same with fire.png. I grabbed a paintbrush and scribbled gray on them thinking they were invisible. No smoke.
Then I changed the lifetimeMS to 5500 thinking the particles were inside the model and disappearing before they got out. That didnt work.
Then I tried changing the animateTexture = true; to false. nope. Then I tried copying fire.png to Fire1.png, Fire2.png, etc and making a fire folder and sticking them in there. nope.
Did I leave out any steps? Is there anything wrong with what I did above?
#14
Can you be more specific here:
One thing you may find to help, is make sure your particle is already defined and loaded, and give it a good name. Make sure your datablock names do not clash with each other (a simple way to test is give them numbers like datablock ParticleData(FireParticle001data) and datablock ParticleEmitterData(FireParticle001emitter). I have in the past had similar problems to what you describe and found it was datablock name clashing.
I did a search for mountedParticle across all the files in the starter.fps directory:
Searching for: mountedParticle
starter.fps\server\scripts\game.cs(53): exec("./mountedParticles.cs"); //note highlander added for particle emitters
starter.fps\server\scripts\mountedParticle.cs(30): datablock ParticleData(mountedParticle)
starter.fps\server\scripts\mountedParticle.cs(78): particles = mountedParticle;
Found 3 occurrence(s) in 2 file(s)
If I understand correctly, that means there is no name conflict, right?
05/24/2007 (9:38 am)
Caylo,Can you be more specific here:
One thing you may find to help, is make sure your particle is already defined and loaded, and give it a good name. Make sure your datablock names do not clash with each other (a simple way to test is give them numbers like datablock ParticleData(FireParticle001data) and datablock ParticleEmitterData(FireParticle001emitter). I have in the past had similar problems to what you describe and found it was datablock name clashing.
I did a search for mountedParticle across all the files in the starter.fps directory:
Searching for: mountedParticle
starter.fps\server\scripts\game.cs(53): exec("./mountedParticles.cs"); //note highlander added for particle emitters
starter.fps\server\scripts\mountedParticle.cs(30): datablock ParticleData(mountedParticle)
starter.fps\server\scripts\mountedParticle.cs(78): particles = mountedParticle;
Found 3 occurrence(s) in 2 file(s)
If I understand correctly, that means there is no name conflict, right?
#15
05/24/2007 (10:59 am)
Mount image is for mounting weapons. You just want to mount particles to a mount point. look here: www.garagegames.com/mg/forums/result.thread.php?qt=54413
#16
The resource says "This allows you to mount a particle emitter to a players mount# node."
mount# node is for mounting things like weapons to characters, isnt it? Near the end of the resource he says to put this code in:
%obj.mountImage(mountedImage,1); // Where %obj is the player to mount to
so it seems to me that the particles are meant to go on a mount# node and you are supposed to use mountImage to do it. I don't understand what you are saying?
05/24/2007 (11:32 am)
Mb, The resource says "This allows you to mount a particle emitter to a players mount# node."
mount# node is for mounting things like weapons to characters, isnt it? Near the end of the resource he says to put this code in:
%obj.mountImage(mountedImage,1); // Where %obj is the player to mount to
so it seems to me that the particles are meant to go on a mount# node and you are supposed to use mountImage to do it. I don't understand what you are saying?
#17
05/24/2007 (12:15 pm)
Double check your packUpdate and unpackUpdate code. If they are not in exactly the right places, you will receive the errors you posted.
#18
05/24/2007 (12:37 pm)
I wasnt referring to the resource.
#19
I think first off, you need to pick ONE of the two systems, and play with it till you figure out what/how it is doing. And because the one Affectworks mentions is totally scrip base, this would be a batter place for you to start.
05/24/2007 (1:14 pm)
I am referring to the 'Peter Simard' mounted particle system. NOT the one that Affectworks mentions. The Peter Simard system do not require any extra scripts, but adds a new command that will attach a particle to a DTS shape. I think first off, you need to pick ONE of the two systems, and play with it till you figure out what/how it is doing. And because the one Affectworks mentions is totally scrip base, this would be a batter place for you to start.
#20
I went into the client/scripts/default.bind.cs and add key mapping after the crossbow. If you do this you will have to delete the config.cs and config.cs.dso in the client folder. I add key mapping so I could turn on and off.
Here my what change in mountedParticle for the texture. I use the standard fire particles that come with Torque, that what you see in the picture.
I also change the mount point to what you have on lin 118.
You dont need to paint on the texture. You color is control from line 56 to 58. I change the color for one in the picture like this.
05/24/2007 (1:27 pm)
This is what you need to have in the game.cs.// Starting equipment %player.setInventory(mounted,1); %player.setInventory(mountedAmmo,50); %player.mountImage(mountedImage,0);
I went into the client/scripts/default.bind.cs and add key mapping after the crossbow. If you do this you will have to delete the config.cs and config.cs.dso in the client folder. I add key mapping so I could turn on and off.
moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"mounted\");", "");Here my what change in mountedParticle for the texture. I use the standard fire particles that come with Torque, that what you see in the picture.
animTexName[0] = "~/data/shapes/particles/fire"; animTexName[1] = "~/data/shapes/particles/fire"; animTexName[2] = "~/data/shapes/particles/fire"; animTexName[3] = "~/data/shapes/particles/fire"; animTexName[4] = "~/data/shapes/particles/fire"; animTexName[5] = "~/data/shapes/particles/fire"; animTexName[6] = "~/data/shapes/particles/fire"; animTexName[7] = "~/data/shapes/particles/fire"; animTexName[8] = "~/data/shapes/particles/fire"; animTexName[7] = "~/data/shapes/particles/fire"; animTexName[8] = "~/data/shapes/particles/fire";
I also change the mount point to what you have on lin 118.
mountPoint = 0;
You dont need to paint on the texture. You color is control from line 56 to 58. I change the color for one in the picture like this.
colors[0] = "0.8 0.6 0.0 0.1"; colors[1] = "0.8 0.6 0.0 0.1"; colors[2] = "0.0 0.0 0.0 0.0";
Torque 3D Owner Affectworks
This may help!