private TextureAtlas(float roadWidthInTexture)
        {
            var roadWidth     = UnscaledRoadWidth * roadWidthInTexture;
            var halfRoadWidth = roadWidth / 2;

            _coordinates = new Dictionary <RoadTextureType, TextureCoordinates>();

            _coordinates.Add(
                RoadTextureType.Straight,
                TextureCoordinates.LeftTopRightBottom(
                    0f,
                    TileCenter(0) - halfRoadWidth,
                    1f,
                    TileCenter(0) + halfRoadWidth));

            _coordinates.Add(
                RoadTextureType.TCrossing,
                TextureCoordinates.LeftTopRightBottom(
                    TileCenter(2) - halfRoadWidth,
                    TileCenter(1) - LengthToIncomingRoad,
                    TileCenter(2) + LengthToIncomingRoad,
                    TileCenter(1) + LengthToIncomingRoad));

            _coordinates.Add(
                RoadTextureType.XCrossing,
                TextureCoordinates.LeftTopRightBottom(
                    TileCenter(2) - LengthToIncomingRoad,
                    TileCenter(2) - LengthToIncomingRoad,
                    TileCenter(2) + LengthToIncomingRoad,
                    TileCenter(2) + LengthToIncomingRoad));

            _coordinates.Add(
                RoadTextureType.AsymmetricYCrossing,
                TextureCoordinates.LeftTopWidthHeight(
                    0.395f - halfRoadWidth,
                    0.645f,
                    1.2f * UnscaledRoadWidth + halfRoadWidth,
                    0.335f));

            _coordinates.Add(
                RoadTextureType.SymmetricYCrossing,
                TextureCoordinates.LeftTopRightBottom(
                    TileCenter(1) - 0.2f,
                    0.504f - 0.135f,
                    TileCenter(1) + 0.2f,
                    0.504f + 0.135f));

            _coordinates.Add(
                RoadTextureType.BroadCurve,
                TextureCoordinates.Curve(
                    TileCenter(0),
                    halfRoadWidth,
                    MathUtility.ToRadians(30)));

            // TODO: TightCurve, Join
        }
Beispiel #2
0
        private TextureAtlas(float roadWidthInTexture)
        {
            var roadWidth     = UnscaledRoadWidth * roadWidthInTexture;
            var halfRoadWidth = roadWidth / 2;

            _coordinates = new Dictionary <RoadTextureType, TextureCoordinates>();

            _coordinates.Add(
                RoadTextureType.Straight,
                TextureCoordinates.LeftTopRightBottom(
                    0f,
                    TileCenter(0) - halfRoadWidth,
                    1f,
                    TileCenter(0) + halfRoadWidth));

            _coordinates.Add(
                RoadTextureType.TCrossing,
                TextureCoordinates.LeftTopRightBottom(
                    TileCenter(2) - halfRoadWidth,
                    TileCenter(1) - LengthToIncomingRoad,
                    TileCenter(2) + LengthToIncomingRoad,
                    TileCenter(1) + LengthToIncomingRoad));

            _coordinates.Add(
                RoadTextureType.XCrossing,
                TextureCoordinates.LeftTopRightBottom(
                    TileCenter(2) - LengthToIncomingRoad,
                    TileCenter(2) - LengthToIncomingRoad,
                    TileCenter(2) + LengthToIncomingRoad,
                    TileCenter(2) + LengthToIncomingRoad));

            _coordinates.Add(
                RoadTextureType.AsymmetricYCrossing,
                TextureCoordinates.LeftTopWidthHeight(
                    0.395f - halfRoadWidth,
                    0.645f,
                    1.2f * UnscaledRoadWidth + halfRoadWidth,
                    0.335f));

            _coordinates.Add(
                RoadTextureType.SymmetricYCrossing,
                TextureCoordinates.LeftTopRightBottom(
                    TileCenter(1) - 0.2f,
                    0.504f - 0.135f,
                    TileCenter(1) + 0.2f,
                    0.504f + 0.135f));

            _coordinates.Add(
                RoadTextureType.BroadCurve,
                TextureCoordinates.Curve(
                    TileCenter(1),
                    halfRoadWidth,
                    RoadConstants.BroadCurveRadius));

            _coordinates.Add(
                RoadTextureType.TightCurve,
                TextureCoordinates.Curve(
                    TileCenter(2),
                    halfRoadWidth,
                    RoadConstants.TightCurveRadius));

            _coordinates.Add(
                RoadTextureType.EndCap,
                TextureCoordinates.LeftTopRightBottom(0.146f, 0.697f, 0.238f, 0.961f));
        }