public override void Create(Vector3 wpos, Transformation railTransformation, Transformation localTransformation, int sectionIndex, double startingDistance, double endingDistance, double trackPosition, double brightness)
 {
     if (AspectNumbers.Length != 0)
     {
         AnimatedObjectCollection aoc = new AnimatedObjectCollection(currentHost)
         {
             Objects = new[]
             {
                 new AnimatedObject(currentHost)
             }
         };
         aoc.Objects[0].States = new ObjectState[AspectNumbers.Length];
         for (int l = 0; l < AspectNumbers.Length; l++)
         {
             aoc.Objects[0].States[l] = new ObjectState((StaticObject)Objects[l].Clone());
         }
         CultureInfo Culture = CultureInfo.InvariantCulture;
         string      expr    = "";
         for (int l = 0; l < AspectNumbers.Length - 1; l++)
         {
             expr += "section " + AspectNumbers[l].ToString(Culture) + " <= " + l.ToString(Culture) + " ";
         }
         expr += (AspectNumbers.Length - 1).ToString(Culture);
         for (int l = 0; l < AspectNumbers.Length - 1; l++)
         {
             expr += " ?";
         }
         aoc.Objects[0].StateFunction = new FunctionScript(currentHost, expr, false);
         aoc.Objects[0].RefreshRate   = 1.0 + 0.01 * new Random().NextDouble();
         aoc.CreateObject(wpos, railTransformation, localTransformation, sectionIndex, startingDistance, endingDistance, trackPosition, brightness);
     }
 }
Example #2
0
 internal void CreateObject(UnifiedObject Prototype, OpenBveApi.Math.Vector3 Position, Transformation BaseTransformation, Transformation AuxTransformation, int SectionIndex, bool AccurateObjectDisposal, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness, bool DuplicateMaterials)
 {
     if (Prototype is StaticObject)
     {
         StaticObject s = (StaticObject)Prototype;
         CreateStaticObject(s, Position, BaseTransformation, AuxTransformation, AccurateObjectDisposal, 0.0, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness);
     }
     else if (Prototype is AnimatedObjectCollection)
     {
         AnimatedObjectCollection a = (AnimatedObjectCollection)Prototype;
         a.CreateObject(Position, BaseTransformation, AuxTransformation, SectionIndex, AccurateObjectDisposal, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness, DuplicateMaterials);
     }
 }
Example #3
0
 internal void CreateObject(UnifiedObject Prototype, Vector3 Position, Transformation BaseTransformation, Transformation AuxTransformation, int SectionIndex, bool AccurateObjectDisposal, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness)
 {
     if (Prototype is StaticObject)
     {
         StaticObject s = (StaticObject)Prototype;
         if (s.Mesh.Faces.Length == 0)
         {
             return;
         }
         CreateStaticObject(s, Position, BaseTransformation, AuxTransformation, AccurateObjectDisposal, 0.0, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness);
     }
     else if (Prototype is AnimatedObjectCollection)
     {
         AnimatedObjectCollection a = (AnimatedObjectCollection)Prototype;
         a.CreateObject(Position, BaseTransformation, AuxTransformation, SectionIndex, AccurateObjectDisposal, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness, true);
     }
 }
Example #4
0
        public override void Create(Vector3 wpos, Transformation RailTransformation, Transformation LocalTransformation, int SectionIndex, double StartingDistance, double EndingDistance, double TrackPosition, double Brightness)
        {
            if (SignalTextures.Length != 0)
            {
                int m  = Math.Max(SignalTextures.Length, GlowTextures.Length);
                int zn = 0;
                for (int l = 0; l < m; l++)
                {
                    if (l < SignalTextures.Length && SignalTextures[l] != null || l < GlowTextures.Length && GlowTextures[l] != null)
                    {
                        zn++;
                    }
                }

                AnimatedObjectCollection aoc = new AnimatedObjectCollection(Plugin.CurrentHost)
                {
                    Objects = new[]
                    {
                        new AnimatedObject(Plugin.CurrentHost)
                        {
                            States = new ObjectState[zn]
                        }
                    }
                };

                int    zi   = 0;
                string expr = "";
                for (int l = 0; l < m; l++)
                {
                    bool         qs = l < SignalTextures.Length && SignalTextures[l] != null;
                    bool         qg = l < GlowTextures.Length && GlowTextures[l] != null;
                    StaticObject so = new StaticObject(Plugin.CurrentHost);
                    StaticObject go = null;
                    if (qs & qg)
                    {
                        if (BaseObject != null)
                        {
                            so = BaseObject.Clone(SignalTextures[l], null);
                        }

                        if (GlowObject != null)
                        {
                            go = GlowObject.Clone(GlowTextures[l], null);
                        }

                        so.JoinObjects(go);
                        aoc.Objects[0].States[zi] = new ObjectState(so);
                    }
                    else if (qs)
                    {
                        if (BaseObject != null)
                        {
                            so = BaseObject.Clone(SignalTextures[l], null);
                        }

                        aoc.Objects[0].States[zi] = new ObjectState(so);
                    }
                    else if (qg)
                    {
                        if (GlowObject != null)
                        {
                            go = GlowObject.Clone(GlowTextures[l], null);
                        }

                        //BUG: Should we join the glow object here? Test what BVE4 does with missing state, but provided glow
                        aoc.Objects[0].States[zi] = new ObjectState(so);
                    }

                    if (qs | qg)
                    {
                        CultureInfo Culture = CultureInfo.InvariantCulture;
                        if (zi < zn - 1)
                        {
                            expr += "section " + l.ToString(Culture) + " <= " + zi.ToString(Culture) + " ";
                        }
                        else
                        {
                            expr += zi.ToString(Culture);
                        }

                        zi++;
                    }
                }

                for (int l = 0; l < zn - 1; l++)
                {
                    expr += " ?";
                }

                aoc.Objects[0].StateFunction = new FunctionScript(Plugin.CurrentHost, expr, false);
                aoc.Objects[0].RefreshRate   = 1.0 + 0.01 * Plugin.RandomNumberGenerator.NextDouble();
                aoc.CreateObject(wpos, RailTransformation, LocalTransformation, SectionIndex, StartingDistance, EndingDistance, TrackPosition, 1.0);
            }
        }