@@ -92,7 +92,7 @@ public Texture2D Get(string path, Texture2D defaultTexture, bool required = fals
9292 else if ( Path . GetExtension ( path ) == ".ace" )
9393 {
9494 var alternativeTexture = Path . ChangeExtension ( path , ".dds" ) ;
95-
95+
9696 if ( File . Exists ( alternativeTexture ) )
9797 {
9898 DDSLib . DDSFromFile ( alternativeTexture , GraphicsDevice , true , out texture ) ;
@@ -189,7 +189,7 @@ public static Texture2D Get(GraphicsDevice graphicsDevice, string path)
189189 DDSLib . DDSFromFile ( path , graphicsDevice , true , out ddsTexture ) ;
190190 return ddsTexture ;
191191 }
192-
192+
193193 using ( var stream = File . OpenRead ( path ) )
194194 {
195195 if ( ext == ".gif" || ext == ".jpg" || ext == ".png" )
@@ -209,6 +209,7 @@ public static Texture2D Get(GraphicsDevice graphicsDevice, string path)
209209 return SharedMaterialManager . MissingTexture ;
210210 }
211211 }
212+
212213 public static Texture2D Get ( GraphicsDevice graphicsDevice , string path , Microsoft . Xna . Framework . Rectangle MapRectangle )
213214 {
214215 if ( path == null || path == "" )
@@ -246,6 +247,7 @@ public static Texture2D Get(GraphicsDevice graphicsDevice, string path, Microsof
246247 }
247248 }
248249 }
250+
249251 public void Mark ( )
250252 {
251253 TextureMarks . Clear ( ) ;
@@ -431,7 +433,7 @@ public Material Load(string materialName, string textureName = null, int options
431433 return Materials [ materialKey ] ;
432434 }
433435
434- public bool LoadNightTextures ( )
436+ public bool LoadNightTextures ( )
435437 {
436438 int count = 0 ;
437439 foreach ( SceneryMaterial material in from material in Materials . Values
@@ -452,11 +454,11 @@ where material is SceneryMaterial
452454 }
453455 }
454456 return true ;
455- }
457+ }
456458
457- public bool LoadDayTextures ( )
458- {
459- int count = 0 ;
459+ public bool LoadDayTextures ( )
460+ {
461+ int count = 0 ;
460462 foreach ( SceneryMaterial material in from material in Materials . Values
461463 where material is SceneryMaterial
462464 select material )
@@ -473,9 +475,9 @@ where material is SceneryMaterial
473475 return false ; // too bad, no more space, other night textures won't be loaded
474476 }
475477 }
476- }
477- return true ;
478- }
478+ }
479+ return true ;
480+ }
479481
480482 public void Mark ( )
481483 {
@@ -500,7 +502,7 @@ public void Sweep()
500502 {
501503 foreach ( var path in MaterialMarks . Where ( kvp => ! kvp . Value ) . Select ( kvp => kvp . Key ) )
502504 Materials . Remove ( path ) ;
503- }
505+ }
504506
505507 public void LoadPrep ( )
506508 {
@@ -533,13 +535,13 @@ public string GetStatus()
533535 float distance = 1000 ;
534536 internal void UpdateShaders ( )
535537 {
536- if ( Viewer . Settings . UseMSTSEnv == false )
538+ if ( Viewer . Settings . UseMSTSEnv == false )
537539 sunDirection = Viewer . World . Sky . SolarDirection ;
538540 else
539541 sunDirection = Viewer . World . MSTSSky . mstsskysolarDirection ;
540542
541543 SceneryShader . SetLightVector_ZFar ( sunDirection , Viewer . Settings . ViewingDistance ) ;
542-
544+
543545 // Headlight illumination
544546 if ( Viewer . PlayerLocomotiveViewer != null
545547 && Viewer . PlayerLocomotiveViewer . lightDrawer != null
@@ -578,13 +580,13 @@ internal void UpdateShaders()
578580 else if ( sunDirection . Y >= 0.15 )
579581 {
580582 clampValue = 0.5f ; // at daytime min headlight
581- distance = lightDrawer . LightConeDistance * 0.1f ; // and min distance
583+ distance = lightDrawer . LightConeDistance * 0.1f ; // and min distance
582584
583585 }
584586 else
585587 {
586588 clampValue = 1 - 2.5f * ( sunDirection . Y + 0.05f ) ; // in the meantime interpolate
587- distance = lightDrawer . LightConeDistance * ( 1 - 4.5f * ( sunDirection . Y + 0.05f ) ) ; //ditto
589+ distance = lightDrawer . LightConeDistance * ( 1 - 4.5f * ( sunDirection . Y + 0.05f ) ) ; //ditto
588590 }
589591 SceneryShader . SetHeadlight ( ref lightDrawer . LightConePosition , ref lightDrawer . LightConeDirection , distance , lightDrawer . LightConeMinDotProduct , ( float ) ( Viewer . Simulator . GameTime - fadeStartTimer ) , fadeDuration , clampValue , ref lightDrawer . LightConeColor ) ;
590592 }
@@ -640,7 +642,7 @@ public int KeyLengthRemainder() //used as a "pseudorandom" number
640642 {
641643 if ( String . IsNullOrEmpty ( Key ) )
642644 return 0 ;
643- return Key . Length % 10 ;
645+ return Key . Length % 10 ;
644646 }
645647
646648 [ CallOnThread ( "Loader" ) ]
@@ -770,7 +772,8 @@ public class SceneryMaterial : Material
770772 IEnumerator < EffectPass > ShaderPassesImage ;
771773 IEnumerator < EffectPass > ShaderPassesVegetation ;
772774 IEnumerator < EffectPass > ShaderPasses ;
773- public static readonly DepthStencilState DepthReadCompareLess = new DepthStencilState {
775+ public static readonly DepthStencilState DepthReadCompareLess = new DepthStencilState
776+ {
774777 DepthBufferWriteEnable = false ,
775778 DepthBufferFunction = CompareFunction . Less ,
776779 } ;
@@ -785,13 +788,13 @@ public SceneryMaterial(Viewer viewer, string texturePath, SceneryMaterialOptions
785788 Texture = SharedMaterialManager . MissingTexture ;
786789 NightTexture = SharedMaterialManager . MissingTexture ;
787790 // <CSComment> if "trainset" is in the path (true for night textures for 3DCabs) deferred load of night textures is disabled
788- if ( ! String . IsNullOrEmpty ( texturePath ) && ( Options & SceneryMaterialOptions . NightTexture ) != 0 && ( ( ! viewer . IsDaytime && ! viewer . IsNighttime )
791+ if ( ! String . IsNullOrEmpty ( texturePath ) && ( Options & SceneryMaterialOptions . NightTexture ) != 0 && ( ( ! viewer . IsDaytime && ! viewer . IsNighttime )
789792 || TexturePath . Contains ( @"\trainset\" ) ) )
790793 {
791794 var nightTexturePath = Helpers . GetNightTextureFile ( Viewer . Simulator , texturePath ) ;
792795 if ( ! String . IsNullOrEmpty ( nightTexturePath ) )
793796 NightTexture = Viewer . TextureManager . Get ( nightTexturePath . ToLower ( ) ) ;
794- Texture = Viewer . TextureManager . Get ( texturePath , true ) ;
797+ Texture = Viewer . TextureManager . Get ( texturePath , true ) ;
795798 }
796799 else if ( ( Options & SceneryMaterialOptions . NightTexture ) != 0 && viewer . IsDaytime )
797800 {
@@ -822,31 +825,31 @@ public SceneryMaterial(Viewer viewer, string texturePath, SceneryMaterialOptions
822825
823826 }
824827
825- public bool LoadNightTexture ( )
826- {
828+ public bool LoadNightTexture ( )
829+ {
827830 bool oneMore = false ;
828- if ( ( ( Options & SceneryMaterialOptions . NightTexture ) != 0 ) && ( NightTexture == SharedMaterialManager . MissingTexture ) )
831+ if ( ( ( Options & SceneryMaterialOptions . NightTexture ) != 0 ) && ( NightTexture == SharedMaterialManager . MissingTexture ) )
829832 {
830833 var nightTexturePath = Helpers . GetNightTextureFile ( Viewer . Simulator , TexturePath ) ;
831834 if ( ! String . IsNullOrEmpty ( nightTexturePath ) )
832- {
835+ {
833836 NightTexture = Viewer . TextureManager . Get ( nightTexturePath . ToLower ( ) ) ;
834837 oneMore = true ;
835838 }
836839 }
837840 return oneMore ;
838841 }
839842
840- public bool LoadDayTexture ( )
841- {
842- bool oneMore = false ;
843- if ( Texture == SharedMaterialManager . MissingTexture && ! String . IsNullOrEmpty ( TexturePath ) )
844- {
843+ public bool LoadDayTexture ( )
844+ {
845+ bool oneMore = false ;
846+ if ( Texture == SharedMaterialManager . MissingTexture && ! String . IsNullOrEmpty ( TexturePath ) )
847+ {
845848 Texture = Viewer . TextureManager . Get ( TexturePath . ToLower ( ) ) ;
846849 oneMore = true ;
847- }
848- return oneMore ;
849- }
850+ }
851+ return oneMore ;
852+ }
850853
851854 public override void SetState ( GraphicsDevice graphicsDevice , Material previousMaterial )
852855 {
@@ -956,7 +959,7 @@ public override void SetState(GraphicsDevice graphicsDevice, Material previousMa
956959 shader . ImageTexture = NightTexture ;
957960 shader . ImageTextureIsNight = true ;
958961 }
959- else
962+ else
960963 {
961964 shader . ImageTexture = Texture ;
962965 shader . ImageTextureIsNight = false ;
@@ -1047,7 +1050,8 @@ public override SamplerState GetShadowTextureAddressMode()
10471050 SamplerStates . Add ( textureAddressMode , new Dictionary < float , SamplerState > ( ) ) ;
10481051
10491052 if ( ! SamplerStates [ textureAddressMode ] . ContainsKey ( mipMapBias ) )
1050- SamplerStates [ textureAddressMode ] . Add ( mipMapBias , new SamplerState {
1053+ SamplerStates [ textureAddressMode ] . Add ( mipMapBias , new SamplerState
1054+ {
10511055 AddressU = textureAddressMode ,
10521056 AddressV = textureAddressMode ,
10531057 Filter = TextureFilter . Anisotropic ,
@@ -1089,11 +1093,11 @@ public ShadowMapMaterial(Viewer viewer)
10891093 var shadowMapResolution = Viewer . Settings . ShadowMapResolution ;
10901094 BlurVertexBuffer = new VertexBuffer ( Viewer . RenderProcess . GraphicsDevice , typeof ( VertexPositionTexture ) , 4 , BufferUsage . WriteOnly ) ;
10911095 BlurVertexBuffer . SetData ( new [ ] {
1092- new VertexPositionTexture ( new Vector3 ( - 1 , + 1 , 0 ) , new Vector2 ( 0 , 0 ) ) ,
1093- new VertexPositionTexture ( new Vector3 ( - 1 , - 1 , 0 ) , new Vector2 ( 0 , shadowMapResolution ) ) ,
1094- new VertexPositionTexture ( new Vector3 ( + 1 , + 1 , 0 ) , new Vector2 ( shadowMapResolution , 0 ) ) ,
1095- new VertexPositionTexture ( new Vector3 ( + 1 , - 1 , 0 ) , new Vector2 ( shadowMapResolution , shadowMapResolution ) ) ,
1096- } ) ;
1096+ new VertexPositionTexture ( new Vector3 ( - 1 , + 1 , 0 ) , new Vector2 ( 0 , 0 ) ) ,
1097+ new VertexPositionTexture ( new Vector3 ( - 1 , - 1 , 0 ) , new Vector2 ( 0 , shadowMapResolution ) ) ,
1098+ new VertexPositionTexture ( new Vector3 ( + 1 , + 1 , 0 ) , new Vector2 ( shadowMapResolution , 0 ) ) ,
1099+ new VertexPositionTexture ( new Vector3 ( + 1 , - 1 , 0 ) , new Vector2 ( shadowMapResolution , shadowMapResolution ) ) ,
1100+ } ) ;
10971101 }
10981102
10991103 public void SetState ( GraphicsDevice graphicsDevice , Mode mode )
@@ -1186,9 +1190,9 @@ public void SetState(GraphicsDevice graphicsDevice, Texture2D screen)
11861190 shader . Screen = screen ;
11871191 shader . GlassColor = Color . Black ;
11881192
1189- graphicsDevice . BlendState = BlendState . NonPremultiplied ;
1190- graphicsDevice . RasterizerState = RasterizerState . CullNone ;
1191- graphicsDevice . DepthStencilState = DepthStencilState . None ;
1193+ graphicsDevice . BlendState = BlendState . NonPremultiplied ;
1194+ graphicsDevice . RasterizerState = RasterizerState . CullNone ;
1195+ graphicsDevice . DepthStencilState = DepthStencilState . None ;
11921196 }
11931197
11941198 public void Render ( GraphicsDevice graphicsDevice , RenderPrimitive renderPrimitive , ref Matrix XNAWorldMatrix , ref Matrix XNAViewMatrix , ref Matrix XNAProjectionMatrix )
@@ -1208,9 +1212,9 @@ public void Render(GraphicsDevice graphicsDevice, RenderPrimitive renderPrimitiv
12081212
12091213 public override void ResetState ( GraphicsDevice graphicsDevice )
12101214 {
1211- graphicsDevice . BlendState = BlendState . Opaque ;
1212- graphicsDevice . RasterizerState = RasterizerState . CullCounterClockwise ;
1213- graphicsDevice . DepthStencilState = DepthStencilState . Default ;
1215+ graphicsDevice . BlendState = BlendState . Opaque ;
1216+ graphicsDevice . RasterizerState = RasterizerState . CullCounterClockwise ;
1217+ graphicsDevice . DepthStencilState = DepthStencilState . Default ;
12141218 }
12151219
12161220 public override bool GetBlending ( )
@@ -1318,7 +1322,7 @@ public SolidColorMaterial(Viewer viewer, float a, float r, float g, float b)
13181322 {
13191323 basicEffect = new BasicEffect ( Viewer . RenderProcess . GraphicsDevice ) ;
13201324 basicEffect . Alpha = a ;
1321- basicEffect . DiffuseColor = new Vector3 ( r , g , b ) ;
1325+ basicEffect . DiffuseColor = new Vector3 ( r , g , b ) ;
13221326 basicEffect . SpecularColor = new Vector3 ( 0.25f , 0.25f , 0.25f ) ;
13231327 basicEffect . SpecularPower = 5.0f ;
13241328 basicEffect . AmbientLightColor = new Vector3 ( 0.2f , 0.2f , 0.2f ) ;
0 commit comments