Skip to content

Commit 99b646c

Browse files
authored
Merge pull request #417 from jonas-or/AnimatedClocks_RegByHands
Animated Clocks recognized by ClockHands without extern Files http://www.elvastower.com/forums/index.php?/topic/29546-station-clocks/page__view__findpost__p__271797
2 parents 0f5f7a3 + eca996f commit 99b646c

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

Source/Documentation/Manual/features-route.rst

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -922,10 +922,6 @@ You will need:
922922

923923
For each shape of clock in the route, a reference to the shape file in the reference file.
924924

925-
#. Animated Clocks List File
926-
927-
A file listing the shape file for each clock that Open Rails is to animate.
928-
929925
#. World File
930926

931927
The location of each clock in the world must be given in the world file.
@@ -990,26 +986,6 @@ Details
990986
Description ( "ChurchClock" )
991987
)
992988

993-
#. Animated Clocks List File
994-
995-
Create a file ROUTES\\<route_name>\\animated.clocks-or file the file for each shape of clock that Open Rails will animate.
996-
The type parameter is always "analog" as "digital" types are not yet supported.::
997-
998-
[
999-
{
1000-
"Name": "Clock01.s",
1001-
"ClockType": "analog"
1002-
},
1003-
{
1004-
"Name": "ChurchClock.s",
1005-
"ClockType": "analog"
1006-
},
1007-
{
1008-
"Name": "PlatformClock.s",
1009-
"ClockType": "analog"
1010-
}
1011-
]
1012-
1013989
#. World File
1014990

1015991
Use a route editor to locate the clocks in the world file.

Source/RunActivity/Viewer3D/Scenery.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
using System.Diagnostics;
5252
using System.IO;
5353
using System.Linq;
54+
using System.Text.RegularExpressions;
5455

5556
namespace Orts.Viewer3D
5657
{
@@ -327,7 +328,6 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
327328

328329
var shadowCaster = (worldObject.StaticFlags & (uint)StaticFlag.AnyShadow) != 0 || viewer.Settings.ShadowAllShapes;
329330
var animated = (worldObject.StaticFlags & (uint)StaticFlag.Animate) != 0;
330-
var isAnalogClock = GetClockType(worldObject.FileName) == ClockType.Analog;
331331
var global = (worldObject is TrackObj) || (worldObject is HazardObj) || (worldObject.StaticFlags & (uint)StaticFlag.Global) != 0;
332332

333333
// TransferObj have a FileName but it is not a shape, so we need to avoid sanity-checking it as if it was.
@@ -480,7 +480,11 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
480480
}
481481
else if (worldObject.GetType() == typeof(StaticObj))
482482
{
483-
if (isAnalogClock)
483+
// preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
484+
StaticShape preTestShape = (new StaticShape(viewer, shapeFilePath, worldMatrix, shadowCaster ? ShapeFlags.ShadowCaster : ShapeFlags.None));
485+
var animNodes = preTestShape.SharedShape.Animations?[0]?.anim_nodes ?? new List<anim_node>();
486+
var isAnimatedClock = animNodes.Exists(node => Regex.IsMatch(node.Name, @"^orts_[hmsc]hand_clock", RegexOptions.IgnoreCase));
487+
if (isAnimatedClock)
484488
{
485489
sceneryObjects.Add(new AnalogClockShape(viewer, shapeFilePath, worldMatrix, shadowCaster ? ShapeFlags.ShadowCaster : ShapeFlags.None));
486490
}

0 commit comments

Comments
 (0)