Example #1
0
        /// <summary>Creates the animated object within the game world</summary>
        /// <param name="Position">The absolute position</param>
        /// <param name="BaseTransformation">The base transformation (Rail 0)</param>
        /// <param name="AuxTransformation">The auxilary transformation (Placed rail)</param>
        /// <param name="SectionIndex">The index of the section if placed using a SigF command</param>
        /// <param name="TrackPosition">The absolute track position</param>
        /// <param name="Brightness">The brightness value at the track position</param>
        public void Create(Vector3 Position, Transformation BaseTransformation, Transformation AuxTransformation, int SectionIndex, double TrackPosition, double Brightness)
        {
            int            a = currentHost.AnimatedWorldObjectsUsed;
            Transformation FinalTransformation = new Transformation(AuxTransformation, BaseTransformation);

            var o = this.Object.Clone();

            currentHost.CreateDynamicObject(ref o.internalObject);
            AnimatedWorldObjectStateSound currentObject = new AnimatedWorldObjectStateSound(currentHost)
            {
                Position      = Position,
                Direction     = FinalTransformation.Z,
                Up            = FinalTransformation.Y,
                Side          = FinalTransformation.X,
                Object        = o,
                SectionIndex  = SectionIndex,
                TrackPosition = TrackPosition,
                Buffers       = Buffers,
                SingleBuffer  = SingleBuffer,
                PlayOnShow    = PlayOnShow,
                PlayOnHide    = PlayOnHide
            };

            for (int i = 0; i < currentObject.Object.States.Length; i++)
            {
                if (currentObject.Object.States[i].Prototype == null)
                {
                    currentObject.Object.States[i].Prototype = new StaticObject(currentHost);
                }
            }

            currentObject.Object.internalObject.Brightness = Brightness;

            double r = 0.0;

            for (int i = 0; i < currentObject.Object.States.Length; i++)
            {
                for (int j = 0; j < currentObject.Object.States[i].Prototype.Mesh.Vertices.Length; j++)
                {
                    double t = this.Object.States[i].Prototype.Mesh.Vertices[j].Coordinates.NormSquared();
                    if (t > r)
                    {
                        r = t;
                    }
                }
            }

            currentObject.Radius  = System.Math.Sqrt(r);
            currentObject.Visible = false;
            currentObject.Object.Initialize(0, false, false);
            currentHost.AnimatedWorldObjects[a] = currentObject;
            currentHost.AnimatedWorldObjectsUsed++;
        }
Example #2
0
        /// <summary>Clones this object</summary>
        /// <returns>The new object</returns>
        public virtual WorldObject Clone()
        {
            WorldObject wo = (WorldObject)MemberwiseClone();

            wo.Object = Object?.Clone();

            if (wo.Object != null)
            {
                currentHost.CreateDynamicObject(ref wo.Object.internalObject);
            }

            return(wo);
        }