예제 #1
0
        protected override void InitializeInner()
        {
            DeviceContextHolder.Set <IMaterialsFactory>(new TrackMapMaterialsFactory());

            if (_aiLane != null)
            {
                RootNode = new RenderableList("_root", Matrix.Identity, new [] {
                    AiLaneObject.Create(_aiLane, AiLaneActualWidth ? (float?)null : AiLaneWidth)
                });
                _aiLaneDirty = false;
            }
            else if (_kn5 != null)
            {
                RootNode = ToRenderableList(Convert(_kn5.RootNode));
            }
            else if (_description != null)
            {
                RootNode = new RenderableList("_root", Matrix.Identity, _description.GetEntries().Select(x => {
                    var node         = ToRenderableList(Convert(x.Kn5.RootNode));
                    node.LocalMatrix = x.Matrix;
                    return(node);
                }));
            }
            else
            {
                RootNode = new RenderableList();
            }

            _buffer0 = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm);
            _buffer1 = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm);
        }
예제 #2
0
 private void RebuildAiLane()
 {
     RootNode.Dispose();
     RootNode = new RenderableList("_root", Matrix.Identity, new[] {
         AiLaneObject.Create(_aiLane, AiLaneActualWidth ? (float?)null : AiLaneWidth)
     });
     UpdateFiltered();
     _aiLaneDirty = false;
 }
예제 #3
0
            private void Initialize(IDeviceContextHolder holder)
            {
                // TODO: errors handling!

                // DisposeHelper.Dispose(ref _view);
                DisposeHelper.Dispose(ref _obj);

                _dirty = false;
                if (AiLaneMode)
                {
                    if (_lane == null)
                    {
                        _lane = AiLane.FromFile(GetAiLaneFastFilename(Filename));
                    }

                    _obj = AiLaneObject.Create(_lane, AiLaneWidth);
                    _obj.ParentMatrix = Matrix.Identity;
                    _obj.UpdateBoundingBox();

                    if (MapSize == default(Vector2))
                    {
                        var size = (_obj.BoundingBox ?? default(BoundingBox)).GetSize();
                        MapSize = new Vector2(size.X, size.Z);
                    }
                }
                else
                {
                    if (_view == null)
                    {
                        using (var map = Texture2D.FromFile(holder.Device, Filename)) {
                            if (MapSize == default(Vector2))
                            {
                                MapSize = new Vector2(map.Description.Width, map.Description.Height);
                            }

                            _view = new ShaderResourceView(holder.Device, map);
                        }
                    }
                }
            }