Does bParticles add particles onto each vertex of a mesh?

Discussions about Coding and Scripting
Post Reply
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Does bParticles add particles onto each vertex of a mesh?

Post by PrinceOfFunky »

I was trying to find out how we can have meshes made of particles when there's a respawn or a teleport. I still don't get where's the effect spawned in PlayRespawnEffect(), but I found out how the teleport effect is spawned in PlayTeleportEffect(). I should begin saying I never made any effect in UT, but I read this "bParticles" variable which is commented as "Mesh is a particle system.". Now, I know particle systems can handle particles in different ways and one of these ways is to place each particle on the mesh vertices, I was wondering if this is the case here, cause if so, we could view mesh vertices in game without using "rmode" command.

JKu6a11BZ70
Why nobody ever told me this? :twisted:

I think it goes by mesh vertices:
bossparticles.png
"Your stuff is known to be buggy and unfinished/not properly tested"
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Does bParticles add particles onto each vertex of a mesh

Post by JackGriffin »

In the more advanced mesh commands that 227 has you can influence individual points in the mesh. You can attach emitters, spawn effects, really anything. I've seen tests where skaarj have glowing red eyes for example. You should look at some of the things Qtit did.
So long, and thanks for all the fish
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Does bParticles add particles onto each vertex of a mesh

Post by Feralidragon »

Yes, bParticles will render a texture at each vertex of the mesh instead of the mesh itself.
However, when you do so, the Drawscale property will affect the size of the particles and not the size of the mesh, meaning that with bParticles the base mesh always stays with a scale of 1.0 (its original scale).

It's also worth noting that the engine will instantly crash if you have bParticles=True in an actor with Texture=None, you must always have the Texture with a texture assigned to it, even if a dummy one.

With bRandomFrame you can also use the MultiSkins as the textures for those particles instead, the difference being that it will "randomly" put a different one of textures from those at different vertices (it has a deterministic logic to it though, it only looks random, so the same vertices will always use the same MultiSkins slot).

From there, there's also a trick which I discovered several years ago, which allows for the Drawscale to affect both the scale of the mesh and the particles themselves at the same time.
It only requires 2 things:
1 - Your particles actor needs to have another actor as its Owner;
2 - The particles actor must set bAnimByOwner=True.

This also means that the particles actor will always have the same animation as its owner, unless it hasn't the corresponding animations, but which, if I recall correctly, doesn't really matter, the behavior will be the same.
I am not sure if this is intended behavior or a bug, but works in all UT versions as far as I know, although I am not sure if it works with Unreal 227 for example.

I used and abused this trick throughout NW3, with my personal biggest FX achievement being the clouds you can see in some oversurrections and nuclear explosions in general, such as thunder clouds (BoltRifle oversurrection), for example:

Mwlb0tK9JFA
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Does bParticles add particles onto each vertex of a mesh

Post by PrinceOfFunky »

JackGriffin wrote:In the more advanced mesh commands that 227 has you can influence individual points in the mesh. You can attach emitters, spawn effects, really anything. I've seen tests where skaarj have glowing red eyes for example. You should look at some of the things Qtit did.
I'm willing to make a DamageType that makes a pulverizing effect on the actor, that would be awesome if I could make all the particles to move to the opposite direction of the center of the mesh. Changing the Fatness could probably do the trick.
Feralidragon wrote:It's also worth noting that the engine will instantly crash if you have bParticles=True in an actor with Texture=None, you must always have the Texture with a texture assigned to it, even if a dummy one.
Maybe I'm wrong but to me it looks like bParticles set to true slows down the engine.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Does bParticles add particles onto each vertex of a mesh

Post by Feralidragon »

PrinceOfFunky wrote: Maybe I'm wrong but to me it looks like bParticles set to true slows down the engine.
It only slows down the rendering, in a similar way as if you had the same amount of standalone sprites in the same places, but not more than that, especially if you set them to a blending style like translucent or modulated and you get to see a lot of them in the same place, overlapping into each other, which is to this date still a rendering nightmare and rather heavy (not Z-buffer friendly at all).

They're also affected by the mesh LOD so the particles will move and appear and disappear as the vertices do while they morph into other LOD levels with the distance, and will disappear entirely in the same way the mesh disappears if you're not seeing the mesh pivot (although this can be fixed for meshes in general, but that's a talk for another day).

I used them heavily in NW3 and you won't notice them slowing down anything most of the time (like the cloud effect I have shown above, it has a lot of particles yet it runs fine), to not mention the UltimaProtos oversurrection which spawns clouds all around the sun it spawns in the same fashion and which also performs fine.

You only need to take into account the number of vertices the mesh has, the size of the particles you want to render, their rendering style, and whether too many overlap each other in any angle.
If you take these into account, you won't have any performance problems whatsoever.

If you want a standard UT example of the usage of these particles, you should check the redeemer missile trailing smoke. I don't remember which class is it, but it's also a mesh with bParticles, where the particles are smoke textures.
I also use in the same way, although I made more realistic smoke for some stuff (like the Ionizer rocket).
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Does bParticles add particles onto each vertex of a mesh

Post by JackGriffin »

If you can find the Chimeric tuts online he has a page on this. In the repository it's at "chimeric_tutorials/data/Unreal_Particle_Effects.htm".

I'll copy the text below because it's increasingly harder to find online.
The Unreal Particle Effects Engine

Unreal has a very simple, yet effective particle system in the engine, which is used in few effects in Unreal and Unreal Tournament. These effects can be seen in the ASMD 'projectile' in Unreal, and the spawning effect in Unreal Tournament. You can create your own particle effects quite easily, with a modelling program such as 3ds Max and some basic knowledge of Scripting in Unreal/Unreal Tournament.

Creating the particle animations and 'cloud' shapes:
Take a simple sphere in 3dsMax, and delete all the faces apart from one face. This face is important, because there's some strange need for at least one face for the importing of a 3ds model. Move the vertices around into a shape you like. This will be your first frame. Name the object Frame01.

To make further frames, clone the object and then move the vertices one by one by a small amount. This is kind of tedious, but the more time you spend on it, the more fluid the motion.

Repeat this process until your animation is finished.

There are a few things you should make sure of:
a) Have the same amount of vertices in each frame (object)
b) You cannot change the mesh scale of the particles in game, so try taking a guess at the size of the model in game, and don't make the model too small or big.

Save and Export your model as Particles.3ds

Create your particle textures:

As usual make the sizes powers of 2, i.e. 256x256, 64x8 etc, and have the textures palleted to 256 colours. If you want the particles to be transparent there are three ways of doing it:

a) Masking:
Make the last colour in the pallet the colour you want as transparent.

b) Transparency 1:
The darker the colour the more transparent the part of the texture is, and vice versa.

c) Transparency 2:
If you would like some dark parts of the texture to show, but don't need greys to be opaque then use this method. The nearer the colour is to RGB: 128,128,128 the more transparent it is. This method can create strong looking colours.

Save the file as PCX.

Use the 3ds2unr.exe to convert the model to Unreal / Unreal Tournament.

Modify the uc file before the compile. Perform these changes:
Remove:
#exec TEXTURE IMPORT NAME=xxx FILE=MODELS\xxx.PCX GROUP=Skins FLAGS=2 // Material #1
Remove:
#exec MESHMAP SETTEXTURE MESHMAP=Particles NUM=1 TEXTURE=xxx
For each of your particle textures add this line, changing the ? to the texture number:
#exec TEXTURE IMPORT NAME=Particle? FILE=.PCX GROUP=Particles

Find the section containing the lines:
defaultproperties
{
DrawType=DT_Mesh
Mesh=Particles
}
Add before the: "DrawType=DT_Mesh":
bParticles=true
Texture=Texture'..'


If you have more than one particle texture you want to use then Add:
bRandomFrame=true

Then for each Particle Texture add the following: (n starts at 0)
MultiSkins[] = Texture'..'

Compile the package.

Add your code to play the animation(s) just like a normal model.

If you want to change the size of the particles use the DrawScale for the sprite images.
So long, and thanks for all the fish
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Does bParticles add particles onto each vertex of a mesh

Post by Feralidragon »

Yeah, that's pretty much what I already explained, but that one is specifically in the context of 3dsMax, so it's a bit outdated, and it also has a few misconceptions, such as:
b) You cannot change the mesh scale of the particles in game, so try taking a guess at the size of the model in game, and don't make the model too small or big.
is not true:
- the scale can be changed with the trick I explained previously, although it will affect both the mesh and particle scales at the same time;
- you don't need to guess the scale in-game from the editor, it only matters that it stays within a specific bounding box in the case of .3d files, and from there you can just scale it up or down in the import directives.

Still, those pages are very useful and should be kept, they just need to be updated someday. :)
Post Reply