Пример #1
0
        private PositionTexture Midpoint(PositionTexture positionNormalTextured, PositionTexture positionNormalTextured_2)
        {
            var a1 = Vector3d.Lerp(positionNormalTextured.Position, positionNormalTextured_2.Position, .5f);
            var a1uv = Vector2d.Lerp(new Vector2d(positionNormalTextured.Tu, positionNormalTextured.Tv), new Vector2d(positionNormalTextured_2.Tu, positionNormalTextured_2.Tv), .5f);

            a1.Normalize();
            return new PositionTexture(a1, a1uv.X, a1uv.Y);
        }
Пример #2
0
        private void InitializeGrids()
        {
            bounds = new PositionTexture[3, 3];

            if (Level > 0)
            {
                if (Parent == null)
                {
                    return;
                }

                var xIndex = X % 2;
                var yIndex = Y % 2;

                if (Level > 1)
                {
                    backslash = Parent.backslash;
                }
                else
                {
                    backslash = xIndex == 1 ^ yIndex == 1;
                }

                bounds[0, 0] = Parent.bounds[xIndex, yIndex];
                bounds[1, 0] = Midpoint(Parent.bounds[xIndex, yIndex], Parent.bounds[xIndex + 1, yIndex]);
                bounds[2, 0] = Parent.bounds[xIndex + 1, yIndex];
                bounds[0, 1] = Midpoint(Parent.bounds[xIndex, yIndex], Parent.bounds[xIndex, yIndex + 1]);

                if (backslash)
                {
                    bounds[1, 1] = Midpoint(Parent.bounds[xIndex, yIndex], Parent.bounds[xIndex + 1, yIndex + 1]);
                }
                else
                {
                    bounds[1, 1] = Midpoint(Parent.bounds[xIndex + 1, yIndex], Parent.bounds[xIndex, yIndex + 1]);
                }

                bounds[2, 1] = Midpoint(Parent.bounds[xIndex + 1, yIndex], Parent.bounds[xIndex + 1, yIndex + 1]);
                bounds[0, 2] = Parent.bounds[xIndex, yIndex + 1];
                bounds[1, 2] = Midpoint(Parent.bounds[xIndex, yIndex + 1], Parent.bounds[xIndex + 1, yIndex + 1]);
                bounds[2, 2] = Parent.bounds[xIndex + 1, yIndex + 1];

                if (Properties.Settings.Default.ShowElevationModel)
                {
                    bounds[0, 0].Tu = 0;
                    bounds[0, 0].Tv = 0;
                    bounds[1, 0].Tu = .5f;
                    bounds[1, 0].Tv = 0;
                    bounds[2, 0].Tu = 1;
                    bounds[2, 0].Tv = 0;

                    bounds[0, 1].Tu = 0;
                    bounds[0, 1].Tv = .5f;
                    bounds[1, 1].Tu = .5f;
                    bounds[1, 1].Tv = .5f;
                    bounds[2, 1].Tu = 1;
                    bounds[2, 1].Tv = .5f;

                    bounds[0, 2].Tu = 0;
                    bounds[0, 2].Tv = 1;
                    bounds[1, 2].Tu = .5f;
                    bounds[1, 2].Tv = 1;
                    bounds[2, 2].Tu = 1;
                    bounds[2, 2].Tv = 1;
                }
                else
                {
                    bounds[0, 0].Tu = 0 + .002f;
                    bounds[0, 0].Tv = 0 + .002f;
                    bounds[1, 0].Tu = .5f + .002f;
                    bounds[1, 0].Tv = 0 + .002f;
                    bounds[2, 0].Tu = 1 + .002f;
                    bounds[2, 0].Tv = 0 + .002f;

                    bounds[0, 1].Tu = 0 + .002f;
                    bounds[0, 1].Tv = .5f + .002f;
                    bounds[1, 1].Tu = .5f + .002f;
                    bounds[1, 1].Tv = .5f + .002f;
                    bounds[2, 1].Tu = 1 + .002f;
                    bounds[2, 1].Tv = .5f + .002f;

                    bounds[0, 2].Tu = 0 + .002f;
                    bounds[0, 2].Tv = 1 + .002f;
                    bounds[1, 2].Tu = .5f + .002f;
                    bounds[1, 2].Tv = 1 + .002f;
                    bounds[2, 2].Tu = 1 + .002f;
                    bounds[2, 2].Tv = 1 + .002f;
                }
            }
            else
            {

                if (Properties.Settings.Default.ShowElevationModel)
                {
                    bounds[0, 0] = new PositionTexture(0, -1, 0, 0, 0);
                    bounds[1, 0] = new PositionTexture(0, 0, -1, .5f, 0);
                    bounds[2, 0] = new PositionTexture(0, -1, 0, 1, 0);
                    bounds[0, 1] = new PositionTexture(1, 0, 0, 0, .5f);
                    bounds[1, 1] = new PositionTexture(0, 1, 0, .5f, .5f);
                    bounds[2, 1] = new PositionTexture(-1, 0, 0, 1, .5f);
                    bounds[0, 2] = new PositionTexture(0, -1, 0, 0, 1);
                    bounds[1, 2] = new PositionTexture(0, 0, 1, .5f, 1);
                    bounds[2, 2] = new PositionTexture(0, -1, 0, 1, 1);

                }
                else
                {
                    bounds[0, 0] = new PositionTexture(0, -1, 0, 0 + .002f, 0 + .002f);
                    bounds[1, 0] = new PositionTexture(0, 0, -1, .5f + .002f, 0 + .002f);
                    bounds[2, 0] = new PositionTexture(0, -1, 0, 1 + .002f, 0 + .002f);
                    bounds[0, 1] = new PositionTexture(1, 0, 0, 0 + .002f, .5f + .002f);
                    bounds[1, 1] = new PositionTexture(0, 1, 0, .5f + .002f, .5f + .002f);
                    bounds[2, 1] = new PositionTexture(-1, 0, 0, 1 + .002f, .5f + .002f);
                    bounds[0, 2] = new PositionTexture(0, -1, 0, 0 + .002f, 1 + .002f);
                    bounds[1, 2] = new PositionTexture(0, 0, 1, .5f + .002f, 1 + .002f);
                    bounds[2, 2] = new PositionTexture(0, -1, 0, 1 + .002f, 1 + .002f);
                }
            }
        }