Page 1 of 2

Particle System info?

Posted: Tue Nov 11, 2014 12:54 am
by gambit37
We can find out the name of the particle system used by an entity by invoking "entity.particle.getParticleSystem()". This reveals names such as "teleporter", "torch" or "mine_support_lantern", etc.

According to the Scripting Reference, there's also an emitter descriptor table for each particle system. But how do I access that in existing particle systems, and change its values?

Re: Particle System info?

Posted: Tue Nov 11, 2014 1:14 am
by NutJob
gambit37 wrote:We can find out the name of the particle system used by an entity by invoking "entity.particle.getParticleSystem()". This reveals names such as "teleporter", "torch" or "mine_support_lantern", etc.

According to the Scripting Reference, there's also an emitter descriptor table for each particle system. But how do I access that in existing particle systems, and change its values?
I hope you get an answer, I've asked nearly identical questions about this several times and I really don't think anyone knows, yet.

Re: Particle System info?

Posted: Tue Nov 11, 2014 1:20 am
by gambit37
Ah. Oh well. Perhaps this is one of those "needs asset pack to be released first" questions... :(

I guess I could try defining a new particle system through trial and error, but it's very time consuming.

Re: Particle System info?

Posted: Tue Nov 11, 2014 1:29 am
by NutJob
At least the Advanced Search on this site finally finds something about emitters! =)

Re: Particle System info?

Posted: Tue Nov 11, 2014 1:36 am
by gambit37
Ha! Emitter Inception?

Re: Particle System info?

Posted: Tue Nov 11, 2014 2:00 am
by minmay
I very much doubt that you can dynamically change a particle system's emitters. The scripting reference specifies (most?) of the particle system fields, and if you want examples, the particle systems defined in the Grimrock 1 asset pack should suffice.

Re: Particle System info?

Posted: Tue Nov 11, 2014 2:28 am
by NutJob
So if a particle systems emitters can be highly refined within the defineParticleSystems we still don't have a programmatic way to access and change something, such as, emissionRate or color0?
SpoilerShow
defineParticleSystem(desc)
Defines a new particle system or replaces an existing particle system definition. desc is a table with the following fields:

name: the name of the particle system to define or replace.
emitters: a table of emitter descriptors. See below.

An emitter descriptor is a table which contains the parameters for a particle emitter. The following parameters are supported:

emitterShape: type of the emitter, either “BoxShape” (default) or “MeshShape”.
emissionRate: number of particles to emit per second.
emissionTime: duration of emission in seconds. If set to zero, emission time is infinite.
maxParticles: maximum number of active particles. Sensible values are between 100 and 1000.
spawnBurst: if enabled maximum number of particles are emitted in a single burst when the particle system is started.
boxMin: a 3D vector defining the minimum extents for particle emission.
boxMax: a 3D vector defining the maximum extents for particle emission.
sprayAngle: a table whose first and second elements set the minimum and maximum spraying angle in degrees.
velocity: a table whose first and second elements set the minimum and maximum velocity in units per second.
size: a table whose first and second elements set the minimum and maximum size for for emitted particles.
lifeTime: a table whose first and second elements set the minimum and maximum lifetime for emitted particles.
texture: a valid texture asset reference. The texture may contain multiple frames laid out on a grid.
frameSize: (optional) pixel size of a frame in the particle animation sequence. Typically 32 or 64.
frameCount: (optional) total number of frames in the particle animation sequence.
frameRate: (optional) frame rate of the particle animation sequence.
color0: a table containing R,G,B values in range 0-1 for initial particle color.
color1,color2,color3: (optional) particle color sequence. These parameters have no effect if colorAnimation is not enabled.
colorAnimation: a boolean which enables particle color animation.
opacity: particle opacity value between 0 and 1.
fadeIn: particle’s fade in time in seconds.
fadeOut: particle’s fade out time in seconds.
gravity: a 3D gravity vector.
airResistance: air resistance parameter. Sensible values are between 0 and 10.
rotationSpeed: rotation speed of particles in degrees.
randomInitialRotation: a boolean flag, if enabled particles’ initial rotation angle is randomized.
blendMode: blending mode for particle rendering. Must be either “Additive” or “Translucent”.
objectSpace: a boolean flag, if enabled particles are emitted to object space rather than world space.
clampToGroundPlane: a boolean flag, if enabled particles collide against the ground.
depthBias: depth bias value in world space units.

Re: Particle System info?

Posted: Tue Nov 11, 2014 3:02 am
by gambit37
I totally forgot there was an asset pack for Log1 (I didn't do any modding for that game). Downloaded and looked at the Lua for particles and it's made things clearer. Thanks :)

Re: Particle System info?

Posted: Tue Nov 11, 2014 4:34 am
by NutJob
So here's the torch emitters from LoG1
SpoilerShow

Code: Select all

defineParticleSystem{
	name = "torch",
	emitters = {
		-- smoke
		{
			emissionRate = 5,
			emissionTime = 0,
			maxParticles = 50,
			boxMin = {-0.03, 0.1, -0.03},
			boxMax = { 0.03, 0.1,  0.03},
			sprayAngle = {0,30},
			velocity = {0.1,0.5},
			texture = "assets/textures/particles/smoke_01.tga",
			lifetime = {1,1.75},
			color0 = {0.15, 0.15, 0.15},
			opacity = 1,
			fadeIn = 0.5,
			fadeOut = 0.5,
			size = {0.3, 0.6},
			gravity = {0,0,0},
			airResistance = 0.1,
			rotationSpeed = 0.6,
			blendMode = "Translucent",
		},

		-- flames
		{
			emissionRate = 50,
			emissionTime = 0,
			maxParticles = 100,
			boxMin = {-0.03, -0.03, 0.03},
			boxMax = { 0.03, 0.03,  -0.03},
			sprayAngle = {0,10},
			velocity = {0.2, 1},
			texture = "assets/textures/particles/torch_flame.tga",
			frameRate = 35,
			frameSize = 64,
			frameCount = 16,
			lifetime = {0.25, 0.85},
			colorAnimation = true,
			color0 = {2, 2, 2},
			color1 = {1.0, 1.0, 1.0},
			color2 = {1.0, 0.5, 0.25},
			color3 = {1.0, 0.3, 0.1},
			opacity = 1,
			fadeIn = 0.15,
			fadeOut = 0.3,
			size = {0.35, 0.015},
			gravity = {0,0,0},
			airResistance = 1.0,
			rotationSpeed = 1,
			blendMode = "Additive",
			depthBias = -0.002,
		},

		-- glow
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0,0,-0.1},
			boxMax = {0,0,-0.1},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {1000000, 1000000},
			colorAnimation = false,
			color0 = {0.23, 0.11, 0.08},
			opacity = 1,
			fadeIn = 0.1,
			fadeOut = 0.1,
			size = {2, 2},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 0,
			blendMode = "Additive",
			depthBias = -0.002,
		}
	}
}
In LoG1, not LoG2, how did the modders change the colors through a script?

Mock up script:

Code: Select all

         local o = findEntity("torch_inTheHall041")
         o.particle.emitter:setColor0(vec(0.3,0.5,1.0))
Would that work in LoG1? Forget LoG2, I went completely mad attempting to do it; how was it done in LoG1?

Re: Particle System info?

Posted: Tue Nov 11, 2014 4:43 am
by Batty
In LoG1, if I recall correctly, torches were hardcoded.

You had to define a new particle system with your preferred color or spawn an fx entity if you wanted to change the color via script.