Skip to content

Commit 086d502

Browse files
committed
Add opacity, update documentation, continued tweaking of particle behavior
1 parent 1d7643d commit 086d502

File tree

9 files changed

+212
-151
lines changed

9 files changed

+212
-151
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 93 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,9 +2415,9 @@ OR supports the following special visual effects in a steam locomotive:
24152415

24162416
OR supports the following special visual effects in a diesel locomotive:
24172417

2418-
- Exhaust (named ``Exhaustnumber``) -- is a diesel exhaust. Multiple exhausts can
2419-
be defined, simply by adjusting the numerical value of the number after the key
2420-
word exhaust.
2418+
- Exhaust (named ``Exhaustnumber``, eg: ``Exhaust2``) -- is a diesel exhaust. Multiple
2419+
exhausts can be defined, simply by adjusting the numerical value of the number after
2420+
the key word Exhaust.
24212421

24222422
OR supports the following special visual effects in a wagon (also the wagon section of
24232423
an ENG file):
@@ -2446,16 +2446,16 @@ Each effect is defined by inserting a code block into the ENG/WAG file similar t
24462446
the one shown below::
24472447

24482448
Cylinders11FX (
2449-
-1.0485 1.0 2.8
2450-
-1 0 0
2451-
0.1
2449+
Comment ( Required parameters. )
2450+
ORTSPosition ( -1.0485m 1.0m 2.8m )
2451+
ORTSInitialVelocity ( -1 0 0 )
2452+
ORTSParticleDiameter ( 0.1m )
24522453

2453-
Comment ( ORTS parameters come after MSTS data! )
2454+
Comment ( Optional parameters. )
24542455
ORTSPositionVariation ( 0m 0m 0m )
2455-
ORTSInitialVelocityVariation ( 0.1 0.1 0.1 )
2456-
ORTSEmissionSpeedLimit ( 150m/s )
2456+
ORTSInitialVelocityVariation ( 0.1 )
24572457
ORTSFinalVelocity ( 0 1m/s 0 )
2458-
ORTSFinalVelocityVariation ( 0.75m/s 0.75m/s 0.75m/s )
2458+
ORTSFinalVelocityVariation ( 0.75m/s )
24592459

24602460
ORTSLifespanMultiplier ( 1.0 )
24612461
ORTSLifespanVariation ( 0.5 )
@@ -2467,24 +2467,22 @@ the one shown below::
24672467
ORTSRotationVariation ( 0.25 )
24682468
ORTSWindMultiplier ( 1.0 )
24692469
2470+
ORTSParticleOpacity ( 1.0 )
24702471
ORTSPipeArea ( 0.03m^2 )
2471-
ORTSMaxParticles ( 2500 )
24722472
ORTSRateMultiplier ( 1.0 )
24732473
ORTSUseChaoticRandomization ( false )
2474-
2474+
2475+
Comment ( Advanced optional parameters. )
2476+
ORTSMaxParticles ( 2500 )
2477+
ORTSEmissionSpeedLimit ( 150m/s )
24752478
ORTSGraphic ( "smokemain.ace" )
24762479
ORTSGraphicAtlasLayout ( 4 4 )
24772480
)
24782481

2479-
The code block consists of the following elements:
2480-
2481-
- Effect name -- as described above,
2482-
- Effect location on the locomotive (given as an x, y, z offset in metres
2483-
from the origin of the wagon shape)
2484-
- Effect direction of emission (given as a normal x, y and z)
2485-
- Effect nozzle width (in metres)
2486-
24872482
.. index::
2483+
single: ORTSPosition
2484+
single: ORTSInitialVelocity
2485+
single: ORTSParticleDiameter
24882486
single: ORTSPositionVariation
24892487
single: ORTSInitialVelocityVariation
24902488
single: ORTSEmissionSpeedLimit
@@ -2502,42 +2500,51 @@ The code block consists of the following elements:
25022500
single: ORTSMaxParticles
25032501
single: ORTSRateMultiplier
25042502
single: ORTSUseChaoticRandomization
2503+
single: ORTSParticleOpacity
25052504
single: ORTSGraphic
25062505
single: ORTSGraphicAtlasLayout
25072506

2508-
After including these settings, additional *optional* parameters unique to OR can
2509-
be included to further customize effect emitters:
2507+
While there are many parameters available to customize the appearance and behavior of emitted particles, most are set
2508+
to reasonable values by default and should be considered optional unless further customization is desired. The only
2509+
*required* parameters are as follows:
2510+
2511+
- ``ORTSPosition ( x y z )`` -- REQUIRED parameter which defines the (+/-) right/left, up/down,
2512+
forward/backward location of the emitter (in meters by default, other units are accepted)
2513+
- ``ORTSInitialVelocity ( x y z )`` -- REQUIRED to define the (+/-) right/left, up/down, forward/backward
2514+
components of emission direction (no units of measure, the particle speed is multiplied by
2515+
this vector to determine the 3D velocity of particles. Speed can be divided by inserting values
2516+
less than 1, or multiplied by inserting values greater than 1.)
2517+
- And ``ORTSParticleDiameter ( d )`` -- REQUIRED to set the nozzle width (default units meters, other units accepted),
2518+
which sets the initial size of each particle
2519+
2520+
The *optional* parameters unique to OR are as follows:
25102521

25112522
- ``ORTSPositionVariation ( x y z )`` -- Specifies the amplitude of random variation
25122523
in the right/left, up/down, and front/back emission location of a particle (default units
25132524
are meters). Useful for non-circular exhaust ports, as it allows one particle emitter
25142525
to be used to spawn particles from an area, rather than a single point. Note that
2515-
``ORTSPositionVariation ( x y z )`` would allow particles to emit 1 meter right and
2526+
``ORTSPositionVariation ( 1 0 0 )`` would allow particles to emit 1 meter right and
25162527
1 meter left of the initial position, for a total variation of 2 meters. Similar is
25172528
true of all other parameters related to randomness, the total variation is double what's
25182529
specified. Feature is disabled by default.
2519-
- ``ORTSInitialVelocityVariation ( x y z )`` -- Defines the randomization of initial particle
2520-
velocity in the right/left, up/down, and front/back directions, as a function of the
2521-
particle's initial speed (values are unitless). The default value is ( 0.1 0.1 0.1 ),
2522-
meaning the speed in each direction can be increased or decreased by 10% of the initial
2523-
particle speed. Larger values make the particle exhaust seem less directed and more diffuse.
2524-
- ``ORTSEmissionSpeedLimit ( v )`` -- Some particle emitters are driven by the simulated flow
2525-
rate of exhaust, which has to make some assumptions about the pressure and volume of exhaust.
2526-
This can lead to unrealistically high speed particles being emitted, so a speed limit can be
2527-
set (default units are meters per second) to keep particle speed reasonable. This is not a hard
2528-
limit, it is gradually enforced as the simulation calculates higher and higher exhaust speed.
2529-
The limit is also applied before considering the emitter velocity factor, so actual exhaust speed
2530-
will vary depending on other settings.
2531-
By default, the limit is 150 meters per second, which will be suitable in most cases.
2530+
- ``ORTSInitialVelocityVariation ( i )`` -- Defines the randomization of initial particle
2531+
velocity in all directions, multiplied by the particle's initial speed (no units of measure).
2532+
The default value is ( 0.1 ), meaning the speed in each direction can be increased or
2533+
decreased by 10% of the initial particle speed. Larger values make the particle exhaust seem
2534+
less directed and more diffuse. Alternately, 3 values can be provided in the format
2535+
``ORTSInitialVelocityVariation ( x y z )`` to specify the initial velocity variation in each
2536+
individual direction.
25322537
- ``ORTSFinalVelocity ( x y z )`` -- Determines the final right/left, up/down, and front/back
25332538
velocity of particles after they have settled (default units of meters per second). The default
25342539
is 1 m/s directly upward, and can be changed to fine tune the appearance of the particle trail
25352540
produced. Note that wind velocity is added to this value afterward.
2536-
- ``ORTSFinalVelocityVariation ( x y z )`` -- Unlike initial velocity variation, final velocity
2541+
- ``ORTSFinalVelocityVariation ( f )`` -- Unlike initial velocity variation, final velocity
25372542
variation determines the amplitude of random variation of final velocity in absolute terms
25382543
(default units of meters per second). The default setting is +/- 0.75 m/s in all directions, but
25392544
changing this can adjust the amount of and shape of particle trail spread. Larger variations
2540-
make for exhaust that seems more chaotic and diffuse.
2545+
make for exhaust that seems more chaotic and diffuse. Similar to initial velocity variation,
2546+
``ORTSFinalVelocityVariation ( x y z )`` can be used to specify the variation in each direction
2547+
individually.
25412548
- ``ORTSLifespanMultiplier ( x )`` -- Multiplies the lifetime of particles emitted from this
25422549
emitter by the given (unitless) value. Particle lifetime varies depending on simulation
25432550
data, but if particles seem to last too long a value less than 1 can be entered here, or a
@@ -2579,20 +2586,16 @@ be included to further customize effect emitters:
25792586
A value of 1 is used by default, such that the wind speed used by the simulation is used directly.
25802587
This can be adjusted to prevent particles that shouldn't be influenced by the wind (eg: cylinder
25812588
cocks close to ground level) from flying off in whatever direction the wind is going.
2589+
- ``ORTSParticleOpacity ( o )`` -- Controls how transparent emitted particles are by multiplying
2590+
texture opacity by the given value (unitless number between 0 and 1). The default setting is 1,
2591+
which doesn't change particle appearance at all. Lower values make particles more transparent,
2592+
until 0 would make all particles invisible.
25822593
- ``ORTSPipeArea ( a )`` -- Niche parameter to adjust the area of the exhaust pipe used by
25832594
the simulation (default units square feet). By default, the area is assumed to be a circle with
25842595
the same diameter as the exhaust particles. However, for non-circular exhausts this can be combined
25852596
with ORTSPositionVariation to give more believable results. Larger areas result in lower exhaust
25862597
speed without changing the number of particles emitted per second, which also allows this to
25872598
be used as a speed multiplier, though ORTSinitialVelocity is preferred for that purpose.
2588-
- ``ORTSMaxParticles ( n )`` -- Override for the maximum number of particles this emitter should
2589-
have in the world simultaneously (unitless integer). The default value is 2500 particles, which works
2590-
in many cases but may not be appropriate in some unusual circumstances. The limit can be reduced
2591-
on less extreme particle emitters to reduce memory use, or can be increased for more extreme emitters
2592-
to prevent particles disappearing and/or the reduction in particle emission rate caused by reaching
2593-
the particle limit. Do NOT increase the limit if particles are already overlapping; it is often
2594-
better to simply reduce the number of particles emitted using ORTSRateMultiplier and/or other
2595-
parameters listed here.
25962599
- ``ORTSRateMultiplier ( x )`` -- Multiplies the number of particles emitted per second by the given
25972600
value (unitless). Values less than 1 reduce the rate of particle emission, while values greater than
25982601
1 increase the rate of particle emission. The particle rate is determined by the simulation, but may
@@ -2602,11 +2605,33 @@ be included to further customize effect emitters:
26022605
- ``ORTSUseChaoticRandomization ( 0/1 )`` -- Changes the randomization algorithm used for positions,
26032606
velocities, durations, and so on to be "chaotic" if given a true or 1 value. Default is false or 0,
26042607
giving "smooth" randomization. With the "chaotic" randomization algorithm, the random changes in
2605-
position/velocity/time are entirely random and do not depend on the random values generated for the
2608+
velocity/momentum/time are entirely random and do not depend on the random values generated for the
26062609
previous particle, resulting in sudden dramatic changes. In comparison, the default "smooth"
26072610
randomziation algorithm changes the random values by a small amount for each iteration. The "chaotic"
26082611
algorithm tends to make exhaust that is more spread out and discontinuous, which may be desireable in
26092612
some cases.
2613+
2614+
The following *advanced* parameters have unusual effects that do not directly influence the motion of
2615+
particles and may only be useful in very specific circumstances. Caution should be taken when using any
2616+
of these to ensure the parameter is used correctly, as improper settings can produce displeasing results
2617+
and poor framerates:
2618+
2619+
- ``ORTSMaxParticles ( n )`` -- Override for the maximum number of particles this emitter should
2620+
have in the world simultaneously (unitless integer). The default value is 2500 particles, which works
2621+
in many cases but may not be appropriate in some unusual circumstances. The limit can be reduced
2622+
on less extreme particle emitters to reduce memory use, or can be increased for more extreme emitters
2623+
to prevent particles disappearing and/or the reduction in particle emission rate caused by reaching
2624+
the particle limit. Do NOT increase the limit if particles are already overlapping; it is often
2625+
better to simply reduce the number of particles emitted using ORTSRateMultiplier and/or other
2626+
parameters listed here.
2627+
- ``ORTSEmissionSpeedLimit ( v )`` -- Some particle emitters are driven by the simulated flow
2628+
rate of exhaust, which has to make some assumptions about the pressure and volume of exhaust.
2629+
This can lead to unrealistically high speed particles being emitted, so a speed limit can be
2630+
set (default units are meters per second) to keep particle speed reasonable. This is not a hard
2631+
limit, it is gradually enforced as the simulation calculates higher and higher exhaust speed.
2632+
The limit is also applied before considering the emitter velocity factor, so actual exhaust speed
2633+
will vary depending on other settings.
2634+
By default, the limit is 150 meters per second, which will be suitable in most cases.
26102635
- ``ORTSGraphic ( "tex" )`` -- Gives the name and path to the texture that should be used to render
26112636
particles from this emitter. The default texture is "smokemain.ace" for steam-type emitters and
26122637
"dieselsmoke.ace" for diesel-type emitters. If the texture cannot be found from the engine's/wagon's
@@ -2624,29 +2649,31 @@ be included to further customize effect emitters:
26242649
rendered as a square. Rectangular textures will be stretched/squished. Do not change the atlas setting unless you
26252650
are certain of the texture used, as improper settings will be very aesthetically unpleasing.
26262651

2627-
2628-
.. index::
2629-
single: ORTSPosition
2630-
single: ORTSInitialVelocity
2631-
single: ORTSParticleDiameter
26322652

2633-
Alternatively, the legacy MSTS data can be skipped entirely and replaced with
2634-
equivalent OR specific parameters. In this case, order of data entry does not
2635-
matter:
2653+
Note that legacy special effects from MSTS and prior versions of OR use different syntax, simply listing
2654+
a series of numbers rather than using named parameters. The order and arrangement of these values is
2655+
critical, and is interpreted in this order:
2656+
2657+
- Effect location on the locomotive (given as 3 values forming an x, y, z offset in metres
2658+
from the origin of the wagon shape)
2659+
- Effect direction of emission (given as 3 values giving a normal x, y and z)
2660+
- Effect nozzle width (a single number given in metres)
2661+
2662+
To make special effect settings easier to understand, it is recommended to use ``ORTSPosition``, ``ORTSInitialVelocity``,
2663+
and ``ORTSParticleDiameter`` to provide these same values. However, if it is desired to continue using the legacy data,
2664+
all ORTS parameters must be entered *after* the legacy numbers, like so::
26362665

26372666
FXName (
2638-
ORTSPosition ( -1.0485m 1.0m 2.8m )
2639-
ORTSInitialVelocity ( -1 0 0 )
2640-
ORTSParticleDiameter ( 0.1m )
2641-
Comment ( Insert other ORTS parameters as desired, but skip MSTS data! )
2642-
)
2667+
-1.0485 1.0 2.8
2668+
-1 0 0
2669+
0.1
2670+
2671+
Comment ( ORTS parameters come after MSTS data! )
26432672

2644-
- ``ORTSPosition ( x y z )`` -- defines the width, height, length location of the emitter (in meters by default)
2645-
- ``ORTSInitialVelocity ( x y z )`` -- defines the (+/-) right/left, up/down, forward/backward components of emission direction
2646-
(unitless, the particle speed is multiplied by this vector to determine the 3D velocity of particles.
2647-
Speed can be divided by inserting values less than 1, or multiplied by inserting values greater than 1.)
2648-
- And ``ORTSParticleDiameter ( d )`` -- gives the nozzle width (in meters by default), which sets the initial
2649-
size of each particle
2673+
ORTSInitialVelocityVariation ( 0.25 )
2674+
ORTSFinalVelocityVariation ( 1.0m/s )
2675+
...etc...
2676+
)
26502677

26512678
Auxiliary Water Tenders
26522679
'''''''''''''''''''''''

Source/Orts.Simulation/MultiPlayer/Message.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2012, 2013 by the Open Rails project.
1+
// COPYRIGHT 2012, 2013 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -3695,17 +3695,18 @@ class MSGExhaustItem
36953695
public int iCar;
36963696
public float exhPart;
36973697
public float exhMag;
3698-
public float exhColorR, exhColorG, exhColorB;
3698+
public float exhColorR, exhColorG, exhColorB, exhColorA;
36993699

3700-
public MSGExhaustItem(string u, int n, int i, float eP, float eM, float eCR, float eCG, float eCB)
3700+
public MSGExhaustItem(string u, int n, int i, float eP, float eM, float eCR, float eCG, float eCB, float eCA)
37013701
{
3702-
user = u; num = n; iCar = i; exhPart = eP; exhMag = eM; exhColorR = eCR; exhColorG = eCG; exhColorB = eCB;
3702+
user = u; num = n; iCar = i; exhPart = eP; exhMag = eM; exhColorR = eCR; exhColorG = eCG; exhColorB = eCB; exhColorA = eCA;
37033703
}
37043704

37053705
public override string ToString()
37063706
{
37073707
return user + " " + num + " " + iCar + " " + exhPart.ToString(CultureInfo.InvariantCulture) + " " + exhMag.ToString(CultureInfo.InvariantCulture) +
3708-
" " + exhColorR.ToString(CultureInfo.InvariantCulture) + " " + exhColorG.ToString(CultureInfo.InvariantCulture) + " " + exhColorB.ToString(CultureInfo.InvariantCulture);
3708+
" " + exhColorR.ToString(CultureInfo.InvariantCulture) + " " + exhColorG.ToString(CultureInfo.InvariantCulture) + " " + exhColorB.ToString(CultureInfo.InvariantCulture)
3709+
+ " " + exhColorA.ToString(CultureInfo.InvariantCulture);
37093710
}
37103711
}
37113712
List<MSGExhaustItem> items;
@@ -3714,18 +3715,19 @@ public MSGExhaust(string m)
37143715
{
37153716
m = m.Trim();
37163717
string[] areas = m.Split(' ');
3717-
if (areas.Length % 8 != 0)
3718+
if (areas.Length % 9 != 0)
37183719
{
37193720
throw new Exception("Parsing error " + m);
37203721
}
37213722
try
37223723
{
37233724
int i = 0;
37243725
items = new List<MSGExhaustItem>();
3725-
for (i = 0; i < areas.Length / 8; i++)
3726-
items.Add(new MSGExhaustItem(areas[8 * i], int.Parse(areas[8 * i + 1]), int.Parse(areas[8 * i + 2]),
3727-
float.Parse(areas[8 * i + 3], CultureInfo.InvariantCulture), float.Parse(areas[8 * i + 4], CultureInfo.InvariantCulture),
3728-
float.Parse(areas[8 * i + 5], CultureInfo.InvariantCulture), float.Parse(areas[8 * i + 6], CultureInfo.InvariantCulture), float.Parse(areas[8 * i + 7], CultureInfo.InvariantCulture)));
3726+
for (i = 0; i < areas.Length / 9; i++)
3727+
items.Add(new MSGExhaustItem(areas[9 * i], int.Parse(areas[9 * i + 1]), int.Parse(areas[9 * i + 2]),
3728+
float.Parse(areas[9 * i + 3], CultureInfo.InvariantCulture), float.Parse(areas[9 * i + 4], CultureInfo.InvariantCulture),
3729+
float.Parse(areas[9 * i + 5], CultureInfo.InvariantCulture), float.Parse(areas[9 * i + 6], CultureInfo.InvariantCulture),
3730+
float.Parse(areas[9 * i + 7], CultureInfo.InvariantCulture), float.Parse(areas[9 * i + 8], CultureInfo.InvariantCulture)));
37293731
}
37303732
catch (Exception e)
37313733
{
@@ -3742,7 +3744,7 @@ public void AddNewItem(string u, Train t, int c)
37423744
if (items == null) items = new List<MSGExhaustItem>();
37433745
MSTSDieselLocomotive l = t.Cars[c] as MSTSDieselLocomotive;
37443746
items.Add(new MSGExhaustItem(u, t.Number, c, l.ExhaustParticles.SmoothedValue, l.ExhaustMagnitude.SmoothedValue,
3745-
l.ExhaustColorR.SmoothedValue, l.ExhaustColorG.SmoothedValue, l.ExhaustColorB.SmoothedValue));
3747+
l.ExhaustColorR.SmoothedValue, l.ExhaustColorG.SmoothedValue, l.ExhaustColorB.SmoothedValue, l.ExhaustColorA.SmoothedValue));
37463748
}
37473749

37483750
public bool OKtoSend()
@@ -3769,7 +3771,7 @@ public override void HandleMsg()
37693771
if (t != null && t.Cars.Count > m.iCar && t.Cars[m.iCar] is MSTSDieselLocomotive)
37703772
{
37713773
MSTSDieselLocomotive remoteDiesel = t.Cars[m.iCar] as MSTSDieselLocomotive;
3772-
remoteDiesel.RemoteUpdate(m.exhPart, m.exhMag, m.exhColorR, m.exhColorG, m.exhColorB);
3774+
remoteDiesel.RemoteUpdate(m.exhPart, m.exhMag, m.exhColorR, m.exhColorG, m.exhColorB, m.exhColorA);
37733775
}
37743776
}
37753777
}

0 commit comments

Comments
 (0)