Exemplo n.º 1
0
            /// <summary>
            /// MSTS WFiles represent some location with a position, 3x3 matrix and tile coordinates
            /// This converts it to the ORTS WorldPosition representation
            /// </summary>
            internal static WorldPosition WorldPositionFromMSTSLocation(PositionHolder holder, uint uid)
            {
                if (holder.LocationSet && holder.PositionSet)
                {
                    holder.Location.Z *= -1;;
                    Matrix xnaMatrix = new Matrix(
                        holder.Position.M00, holder.Position.M01, -holder.Position.M02, 0,
                        holder.Position.M10, holder.Position.M11, -holder.Position.M12, 0,
                        -holder.Position.M20, -holder.Position.M21, holder.Position.M22, 0,
                        0, 0, 0, 1);

                    return(new WorldPosition(holder.TileX, holder.TileZ, MatrixExtension.Multiply(xnaMatrix, Matrix.CreateTranslation(holder.Location))));
                }
                else if (holder.LocationSet && holder.DirectionSet)
                {
                    holder.Direction.Z *= -1;
                    holder.Location.Z  *= -1;;
                    return(new WorldPosition(holder.TileX, holder.TileZ, MatrixExtension.Multiply(Matrix.CreateFromQuaternion(holder.Direction), Matrix.CreateTranslation(holder.Location))));
                }
                else
                {
                    Trace.TraceWarning($"Scenery object UiD {uid} is missing Matrix3x3 and QDirection");
                    return(WorldPosition.None);
                }
            }