Esempio n. 1
0
            public void Draw(DeviceContextHolder holder, EffectSpecialTrackOutline effect, Matrix mapMatrix, MapViewData max)
            {
                if (_dirty)
                {
                    Initialize(holder);
                }

                if (AiLaneMode)
                {
                    Kn5MaterialTrackOutline.Matrix = mapMatrix;

                    if (!_materialsSet)
                    {
                        _materialsSet = true;
                        if (holder.TryToGet <IMaterialsFactory>() == null)
                        {
                            holder.Set <IMaterialsFactory>(new TrackOutlineMaterialsFactory());
                        }
                    }

                    _obj.Draw(holder, max?.GetCamera(holder) ?? GetCamera(holder), SpecialRenderMode.Simple);

                    // revert quad
                    holder.PrepareQuad(effect.LayoutPT);
                }
                else
                {
                    // local transformation matrix: global×local offset (calculated from map.ini)×local scale
                    var localScale = Matrix.Transformation2D(Vector2.Zero, 0f,
                                                             new Vector2(max.DataSize.X / DataSize.X, max.DataSize.Y / DataSize.Y) / DataScale,
                                                             Vector2.Zero, 0f, Vector2.Zero);
                    var localOffset = Matrix.AffineTransformation2D(1f, Vector2.Zero, 0f, new Vector2(
                                                                        (DataOffset.X - max.DataOffset.X) / max.DataSize.X,
                                                                        (DataOffset.Y - max.DataOffset.Y) / max.DataSize.Y));
                    effect.FxMatrix.SetMatrix(mapMatrix * localOffset * localScale);
                    effect.FxInputMap.SetResource(_view);
                    effect.TechFirstStep.DrawAllPasses(holder.DeviceContext, 6);
                }
            }