2626using Microsoft . Xna . Framework . Graphics ;
2727using ORTS . Common ;
2828using Orts . Simulation . RollingStocks ;
29+ using Orts . Viewer3D . RollingStock ;
2930
3031namespace Orts . Viewer3D
3132{
@@ -47,7 +48,7 @@ public class ParticleEmitterViewer
4748 int InputCycle ;
4849#endif
4950
50- public ParticleEmitterViewer ( Viewer viewer , ParticleEmitterData data , WorldPosition worldPosition )
51+ public ParticleEmitterViewer ( Viewer viewer , ParticleEmitterData data , MSTSWagonViewer car , WorldPosition worldPosition )
5152 {
5253 Viewer = viewer ;
5354 EmitterData = data ;
@@ -338,6 +339,8 @@ struct ParticleVertex
338339
339340 internal WorldPosition WorldPosition ;
340341
342+ internal MSTSWagonViewer CarViewer ;
343+
341344 // Particle buffer goes like this:
342345 // +--active>-----new>--+
343346 // | |
@@ -370,6 +373,7 @@ public ParticleEmitterPrimitive(ParticleEmitterViewer particleViewer, ParticleEm
370373 ParticleDuration = 3 ;
371374 ParticleColor = Color . White ;
372375
376+ CarViewer = car ;
373377 WorldPosition = worldPosition ;
374378
375379 // Initialize the particle accumulator to a random value to de-sync particle emitters from eachother
@@ -413,35 +417,6 @@ public ParticleEmitterPrimitive(ParticleEmitterViewer particleViewer, ParticleEm
413417 0.9f + ( float ) Viewer . Random . NextDouble ( ) * 0.2f ,
414418 } ;
415419 }
416-
417- // Initialization step for emitter shape attachment
418- if ( EmitterData . ShapeIndex != - 1 )
419- {
420- if ( EmitterData . ShapeIndex < 0 || EmitterData . ShapeIndex >= CarViewer . TrainCarShape . ResultMatrices . Count ( ) )
421- {
422- Trace . TraceWarning ( "Particle emitter in car {0} has invalid shape index defined, shape index {1} does not exist" ,
423- ( CarViewer . Car as MSTSWagon ) . WagFilePath , EmitterData . ShapeIndex ) ;
424- EmitterData . ShapeIndex = 0 ;
425- }
426- }
427- else
428- {
429- if ( ! String . IsNullOrEmpty ( EmitterData . ShapeHierarchy ) )
430- {
431- if ( CarViewer . TrainCarShape . SharedShape . MatrixNames . Contains ( EmitterData . ShapeHierarchy ) )
432- {
433- EmitterData . ShapeIndex = CarViewer . TrainCarShape . SharedShape . MatrixNames . IndexOf ( EmitterData . ShapeHierarchy ) ;
434- }
435- else
436- {
437- Trace . TraceWarning ( "Particle emitter in car {0} has invalid shape index defined, matrix name {1} does not exist" ,
438- ( CarViewer . Car as MSTSWagon ) . WagFilePath , EmitterData . ShapeHierarchy ) ;
439- EmitterData . ShapeIndex = 0 ;
440- }
441- }
442- else
443- EmitterData . ShapeIndex = 0 ;
444- }
445420 }
446421
447422 void VertexBuffer_ContentLost ( )
@@ -561,7 +536,7 @@ public void Update(float currentTime, ElapsedTime elapsedTime)
561536 {
562537 Matrix transform = WorldPosition . XNAMatrix ;
563538 transform . Translation = Vector3 . Zero ; // Only want rotation data for this step
564- transform = CarViewer . TrainCarShape . ResultMatrices [ EmitterData . ShapeIndex ] * transform ;
539+ // rotation = CarViewer.TrainCarShape.ResultMatrices[EmitterData.ShapeIndex] * rotation; // Future: ShapeHierarchy goes here
565540
566541 Matrix rotation = transform ;
567542 rotation . Translation = Vector3 . Zero ; // Last step needed translational effects, next step does not
0 commit comments