コード例 #1
0
ファイル: HeightArrayDb.cs プロジェクト: defacto2k15/PwMgr
        public async Task <CoordedPart <MySimpleArray <float> > > GeneratePartAsync(MyRectangle queryArea)
        {
            var heightTexture = (await _terrainShapeDb.Query(new TerrainDescriptionQuery()
            {
                QueryArea = queryArea,
                RequestedElementDetails = new List <TerrainDescriptionQueryElementDetail>()
                {
                    new TerrainDescriptionQueryElementDetail()
                    {
                        Type = TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY,
                        Resolution = _resolution
                    }
                }
            })).GetElementOfType(TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY);

            var encodedTexture = await _transformator.PlainToEncodedHeightTextureAsync(
                heightTexture.TokenizedElement.DetailElement.Texture);

            var heightArray = HeightmapUtils.EncodedHeightToArray(encodedTexture);

            return(new CoordedPart <MySimpleArray <float> >()
            {
                Coords = queryArea,
                Part = heightArray
            });
        }
コード例 #2
0
        private MyRectangle RecalculateMergeRectangles3(Vector2 worldSpaceTravellerPosition, Vector2 pyramidCenterUv, float transitionLimit,
                                                        ELevelAndRingIndexes levelAndRingIndexes, Dictionary <HeightPyramidLevel, Vector2> levelCentersWorldSpace)
        {
            var travellerPositionInLevelUv = TravellerWorldPositionToConstantLevelUv(worldSpaceTravellerPosition, levelAndRingIndexes);

            var isuv_x1 = 0.5f * transitionLimit + travellerPositionInLevelUv.x + 0.5f - pyramidCenterUv.x;
            var isuv_x2 = -0.5f * transitionLimit + travellerPositionInLevelUv.x + 0.5f - pyramidCenterUv.x;
            var isuv_y1 = 0.5f * transitionLimit + travellerPositionInLevelUv.y + 0.5f - pyramidCenterUv.y;
            var isuv_y2 = -0.5f * transitionLimit + travellerPositionInLevelUv.y + 0.5f - pyramidCenterUv.y;

            var minValuesUvSpace = new Vector2(
                Mathf.Min(isuv_x1, isuv_x2),
                Mathf.Min(isuv_y1, isuv_y2)
                );

            var maxValuesUvSpace = new Vector2(
                Mathf.Max(isuv_x1, isuv_x2),
                Mathf.Max(isuv_y1, isuv_y2)
                );

            var minValuesWorldSpace = ConstantLevelUvSpaceToWorldSpace(minValuesUvSpace, levelAndRingIndexes);
            var maxValuesWorldSpace = ConstantLevelUvSpaceToWorldSpace(maxValuesUvSpace, levelAndRingIndexes);

            var worldSpaceRectangle = new MyRectangle(minValuesWorldSpace.x, minValuesWorldSpace.y, maxValuesWorldSpace.x - minValuesWorldSpace.x,
                                                      maxValuesWorldSpace.y - minValuesWorldSpace.y);

            return(worldSpaceRectangle);
        }
コード例 #3
0
        public static MyRectangle TerrainShapeSegmentAlignedPositionToWorldSpaceArea(HeightPyramidLevel level, HeightPyramidPerLevelConfiguration perLevelConfiguration,
                                                                                     IntVector2 segmentAlignedPosition)
        {
            var segmentLength = perLevelConfiguration.BiggestShapeObjectInGroupLength;

            if (level == HeightPyramidLevel.Mid)
            {
                segmentAlignedPosition = segmentAlignedPosition + new IntVector2(-1, 0);
            }
            else if (level == HeightPyramidLevel.Top)
            {
                segmentAlignedPosition = segmentAlignedPosition + new IntVector2(-8, -4);
            }

            var surfaceWorldSpaceRectangle = new MyRectangle(segmentAlignedPosition.X * segmentLength, segmentAlignedPosition.Y * segmentLength
                                                             , segmentLength, segmentLength);

            //if (level == HeightPyramidLevel.Mid)
            //{
            //    surfaceWorldSpaceRectangle = RectangleUtils.MoveBy(surfaceWorldSpaceRectangle, new Vector2(90 * 8 * 1, 0));
            //}
            //else if (level == HeightPyramidLevel.Top)
            //{
            //    surfaceWorldSpaceRectangle = RectangleUtils.MoveBy(surfaceWorldSpaceRectangle, new Vector2(90 * -8, 90*-4));
            //}
            return(surfaceWorldSpaceRectangle);
        }
コード例 #4
0
 public static Vector2 RandomPointInRectalngle(this MyRectangle rectangle, System.Random random)
 {
     return(new Vector2(
                NextBetween(random, rectangle.X, rectangle.MaxX),
                NextBetween(random, rectangle.Y, rectangle.MaxY)
                ));
 }
コード例 #5
0
        public async Task <GrassBandInfo> GrowGrassBandAsync(MyRectangle growingArea)
        {
            var retrived = (await _grassIntensityMapProvider.ProvideMapsAtAsync(_providerGenerationRepositioner.Move(growingArea)));
            List <GrassTypeWithUvedIntensity> grassTypeIntensities = retrived.CoordedPart.Part
                                                                     .Select(c => new GrassTypeWithUvedIntensity()
            {
                Type   = c.GrassType,
                Figure = new IntensityFieldFigureWithUv()
                {
                    FieldFigure = c.IntensityFigure,
                    Uv          = retrived.Uv
                }
            })
                                                                     .Where(c => _supportedGrassTypes.Contains(c.Type))
                                                                     .ToList();

            var groupIds = new List <GrassGroupId>();

            foreach (var intensityData in grassTypeIntensities)
            {
                var intensityProvider =
                    new IntensityFromRandomFigureProvider(intensityData.Figure);
                var newGroupId = _grassGroupsPlanter.AddGrassGroup(growingArea, intensityData.Type, intensityProvider);
                groupIds.Add(newGroupId);
            }

            return(new GrassBandInfo()
            {
                GroupIds = groupIds
            });
        }
コード例 #6
0
        private void CreateChart()
        {
            charts     = new MyRectangle[7];
            scaleLabel = new MyLabel[4];
            nameDay    = new string[] { "Niedz", "Pon", "Wt", "Śr", "Czw", "Pt", "Sob" };

            for (int i = 0; i < 59; i++)
            {
                new MyRectangle(contentCanvas, 3, 1, Color.FromArgb(150, 150, 150, 150), 30 + (i * 6), 50);
            }
            for (int i = 0; i < 4; i++)
            {
                scaleLabel[i] = new MyLabel(contentCanvas, "", 50, 26, 12, 24, 56 + (i * 40), Color.FromArgb(180, 150, 150, 150), Color.FromArgb(0, 20, 20, 20));
                new MyRectangle(contentCanvas, 30, 1, Color.FromArgb(100, 150, 150, 150), 30, 80 + (i * 40));
            }
            int numberDayOfWeek = (int)DateTime.Now.DayOfWeek;

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 25; j++)
                {
                    new MyRectangle(contentCanvas, 1, 3, Color.FromArgb(100, 150, 150, 150), 88 + (i * 40), 50 + (j * 6));
                }
                charts[i] = new MyRectangle(contentCanvas, 16, 150, Color.FromArgb(255, 190, 190, 190), 80 + (i * 40), 50);
                charts[i].EnableResizeToolTip(false);
                if (i == 6)
                {
                    charts[i].SetFillColor(Color.FromArgb(255, 117, 203, 255));
                }
                new MyCircle(contentCanvas, 4, 0, Color.FromArgb(255, 180, 180, 180), 86 + (i * 40), 48, 1, true);
                new MyLabel(contentCanvas, nameDay[GetNumberDayOfWeek(i)], 50, 26, 12, 64 + (i * 40), 24, Color.FromArgb(180, 150, 150, 150), Color.FromArgb(0, 20, 20, 20));
            }
            new MyRectangle(contentCanvas, 358, 1, Color.FromArgb(150, 150, 150, 150), 30, 200);
        }
コード例 #7
0
ファイル: UndoRedoManager.cs プロジェクト: dralong10/DoHoa2D
        private List <MyShape> parseStringDataToListShapeObject(string data)
        {
            List <MyShape> myShapes  = new List <MyShape>();
            string         firstWord = null;

            string[] listShape = data.Split('\n');
            for (int i = 0; i < listShape.Length; i++)
            {
                if (listShape[i] != "")
                {
                    firstWord = listShape[i].Substring(0, listShape[i].IndexOf(" "));
                }
                switch (firstWord)
                {
                case "Line":
                    MyShape myLine = new MyLine();
                    myLine.Open(listShape[i]);
                    myShapes.Add(myLine);
                    break;

                case "Rectangle":
                    MyShape myRectangle = new MyRectangle();
                    myRectangle.Open(listShape[i]);
                    myShapes.Add(myRectangle);
                    break;

                case "Circle":
                    MyShape myCircle = new MyCircle();
                    myCircle.Open(listShape[i]);
                    myShapes.Add(myCircle);
                    break;

                case "Ellipse":
                    MyShape myEllipse = new MyEllipse();
                    myEllipse.Open(listShape[i]);
                    myShapes.Add(myEllipse);
                    break;

                case "Polygon":
                    MyShape myPolygon = new MyPolygon();
                    myPolygon.Open(listShape[i]);
                    myShapes.Add(myPolygon);
                    break;

                case "Bezier":
                    MyShape myBezier = new MyBezier();
                    myBezier.Open(listShape[i]);
                    myShapes.Add(myBezier);
                    break;

                case "Polyline":
                    MyShape myPolyline = new MyPolyline();
                    myPolyline.Open(listShape[i]);
                    myShapes.Add(myPolyline);
                    break;
                }
                firstWord = "";
            }
            return(myShapes);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: d0vbysh/Task-2-Rectangle
        static void MovingDemo()
        {
            Console.WriteLine("Moving Demo");

            try
            {
                Console.WriteLine("Lets move rectangle 1 to the top right corner by 10.");
                MyRectangle rect1 = new MyRectangle(new Point2D(4, 4), 4, 4);

                rect1.Move(Direction.TopRight, 10);

                PrintfRectInfo(rect1);

                Console.WriteLine();

                Console.WriteLine("Lets move rectangle 1 to the previous position.");

                rect1.Move(Direction.BottomLeft, 10);

                PrintfRectInfo(rect1);
            }
            catch (Exception e)
            {
                throw e;
            }

            Console.WriteLine(new string('-', 30));
        }
コード例 #9
0
ファイル: Draw.cs プロジェクト: Rajnish-Ranjan/DrawCli
        /// <summary>
        /// The method creates rectangle object and save it in the list MyBoardObjects and also
        /// prints it on Canvas "MyBoard"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private object getRectangle(object sender, MouseEventArgs e)
        {
            Rectangle rect = new Rectangle()
            {
                Stroke = DrawTools.colorStroke,
                //IsEnabled = true,
                StrokeThickness = DrawTools.thicknessVal,
                //Fill = DrawTools.colorStroke,
                //Width = Math.Abs(_end.X - _start.X),
                //Height = Math.Abs(_end.Y - _start.Y)
                Width  = 2,
                Height = 2
            };

            rect.SetValue(LeftProperty, _start.X);
            rect.SetValue(TopProperty, _start.Y);
            MyBoard.Children.Add(rect);
            Canvas.SetLeft(rect, Math.Min(_start.X, _end.X));
            Canvas.SetTop(rect, Math.Min(_start.Y, _end.Y));

            MyRectangle newRect = new MyRectangle(rect);

            MyBoardObjects.Add(newRect);

            return(rect);
        }
コード例 #10
0
        public async Task <TokenizedESurfaceTexturesPackToken> ProvideSurfaceDetail(MyRectangle inGamePosition, FlatLod flatLod)
        {
            var internalToken = GenerateInternalToken(inGamePosition, flatLod);
            var queryOutput   = await _cache.TryRetriveAsync(internalToken);

            if (queryOutput.Asset != null)
            {
                return(new TokenizedESurfaceTexturesPackToken()
                {
                    Pack = queryOutput.Asset.Pack,
                    Token = internalToken
                });
            }
            else
            {
                var detailElement = await _provider.ProvideSurfaceDetailAsync(inGamePosition, flatLod);

                var  queryOutputCreationObligationToken = queryOutput.CreationObligationToken.Value;
                bool wasAdded = await _cache.AddAssetAsync(queryOutputCreationObligationToken, internalToken, new NullableESurfaceTexturesPack()
                {
                    Pack = detailElement
                });

                var tokenToPassOut = internalToken;
                if (!wasAdded)
                {
                    tokenToPassOut = null;
                }
                return(new TokenizedESurfaceTexturesPackToken()
                {
                    Pack = detailElement,
                    Token = tokenToPassOut
                });
            }
        }
コード例 #11
0
        public void GetSquare_ShouldReturn_ExpectedValues()
        {
            bool flag = true; //for more than one test

            MyRectangle rect     = new MyRectangle(new Point2D(1, 1), 10, 20);
            int         expected = 200;

            if (rect.GetSquare() != expected)
            {
                flag = false;
            }

            rect     = new MyRectangle(1, 6);
            expected = 6;

            if (rect.GetSquare() != expected)
            {
                flag = false;
            }

            rect     = new MyRectangle(0, 0);
            expected = 0;

            if (rect.GetSquare() != expected)
            {
                flag = false;
            }

            Assert.IsTrue(flag);
        }
コード例 #12
0
 public TerrainDetailElementToken(MyRectangle queryArea, TerrainCardinalResolution resolution, TerrainDescriptionElementTypeEnum type, CornersMergeStatus mergeStatus)
 {
     _queryArea   = queryArea;
     _resolution  = resolution;
     _type        = type;
     _mergeStatus = mergeStatus;
 }
コード例 #13
0
        public void Intersects_ShouldReturn_False()
        {
            MyRectangle r1 = new MyRectangle(10, 10);
            MyRectangle r2 = new MyRectangle(new Point2D(-1, -8), 3, 3);

            Assert.IsFalse(r1.Intersects(r2));
        }
コード例 #14
0
ファイル: Assignment.aspx.cs プロジェクト: sstarview/Project
    protected void Button1_Click(object sender, EventArgs e)
    {
        Graphics myGraphics = Graphics.FromImage(myBitmap);

        myGraphics.Clear(Color.Black);
        Pen myPen = new Pen(Color.White, 2);


        if (ValueX.Text.Length > 0 && ValueY.Text.Length > 0 && ValueWidth.Text.Length > 0 &&
            ValueHeight.Text.Length > 0)
        {
            int valueX      = Convert.ToInt32(ValueX.Text);
            int valueY      = Convert.ToInt32(ValueY.Text);
            int valueWidth  = Convert.ToInt32(ValueWidth.Text);
            int valueHeight = Convert.ToInt32(ValueHeight.Text);

            MyRectangle myRectangle = new MyRectangle(valueX, valueY, valueWidth, valueHeight);
            myRectangle.DrawRectangle(myGraphics, myPen);

            string path = Server.MapPath("~/Image/Canvas.jpg");
            myBitmap.Save(path, ImageFormat.Jpeg);
            Image1.ImageUrl = "~/Image/Canvas.jpg";
            myGraphics.Dispose();
            myBitmap.Dispose();
        }
        else
        {
            Label1.Text = "Enter the value of all fields";
        }
    }
コード例 #15
0
 public GRing2SurfaceProvider(GRing2PatchesCreatorProxy patchesCreator, MyRectangle inGamePosition,
                              FlatLod flatLod)
 {
     _patchesCreator = patchesCreator;
     _inGamePosition = inGamePosition;
     _flatLod        = flatLod;
 }
コード例 #16
0
        public void Start()
        {
            TaskUtils.SetGlobalMultithreading(false);

            _debugGrassPlanterUnderTest = new DebugBushPlanterUnderTest();
            _debugGrassPlanterUnderTest.Start(ComputeShaderContainer);
            var grassGroupsPlanter = _debugGrassPlanterUnderTest.GrassGroupsPlanter;

            var generationArea = new MyRectangle(0, 0, 90, 90);

            var randomFigureGenerator = new RandomFieldFigureGeneratorUTProxy(
                new Ring2RandomFieldFigureGenerator(new TextureRenderer(),
                                                    new Ring2RandomFieldFigureGeneratorConfiguration()
            {
                PixelsPerUnit = new Vector2(1, 1)
            }));
            var randomFigure = randomFigureGenerator.GenerateRandomFieldFigureAsync(
                RandomFieldNature.FractalSimpleValueNoise3, 312,
                new MyRectangle(0, 0, 30, 30)).Result;

            var intensityFigureProvider = new IntensityFromRandomFiguresCompositionProvider(
                PoissonDiskSamplingDebugObject.CreateDebugRandomFieldFigure(),
                randomFigure, 0.3f);

            grassGroupsPlanter.AddGrassGroup(generationArea, GrassType.Debug1, intensityFigureProvider);

            _debugGrassPlanterUnderTest.FinalizeStart();
            CreateDebugIntensityTexture(intensityFigureProvider);
        }
コード例 #17
0
 public GRingTripletProvider(MyRectangle inGamePosition, Repositioner repositioner,
                             HeightDenormalizer heightDenormalizer)
 {
     this._inGamePosition = inGamePosition;
     _repositioner        = repositioner;
     _heightDenormalizer  = heightDenormalizer;
 }
コード例 #18
0
 private ESurfaceTexturesPackToken GenerateInternalToken(MyRectangle inGamePosition, FlatLod flatLod)
 {
     return(new ESurfaceTexturesPackToken(
                new IntRectangle(Mathf.RoundToInt(inGamePosition.X), Mathf.RoundToInt(inGamePosition.Y)
                                 , Mathf.RoundToInt(inGamePosition.Width), Mathf.RoundToInt(inGamePosition.Height))
                , flatLod.ScalarValue));
 }
コード例 #19
0
        private async Task <TerrainDetailElement> GenerateTerrainDetailElementAsync(
            MyRectangle queryArea, TerrainCardinalResolution cardinalResolution, CornersMergeStatus requiredMerge,
            Func <MyRectangle, TerrainCardinalResolution, TextureWithSize, Task <TextureWithSize> > cornerMergingFunc,
            Func <MyRectangle, TerrainCardinalResolution, RequiredCornersMergeStatus, Task <TextureWithSize> > generateElementFunc
            )
        {
            var newTerrainArea = _alignmentCalculator.ComputeAlignedTerrainArea(queryArea, cardinalResolution);
            RetrivedTerrainDetailTexture texture = null;
            CornersMergeStatus           outCornersMergeStatus;

            TextureWithSize outTexture = null;

            var baseTexture = await generateElementFunc(newTerrainArea, cardinalResolution, RequiredCornersMergeStatus.NOT_MERGED);

            if (requiredMerge == CornersMergeStatus.NOT_MERGED)
            {
                outTexture            = baseTexture;
                outCornersMergeStatus = CornersMergeStatus.NOT_MERGED;
            }
            else
            {
                outTexture = await cornerMergingFunc(queryArea, cardinalResolution, baseTexture);

                outCornersMergeStatus = CornersMergeStatus.MERGED;
            }


            return(new TerrainDetailElement()
            {
                DetailArea = newTerrainArea,
                Resolution = cardinalResolution,
                Texture = outTexture,
                CornersMergeStatus = outCornersMergeStatus
            });
        }
コード例 #20
0
        private void CreateBackground()
        {
            MyRectangle r = new MyRectangle(MainCanvasStatistics, 600, 320, Color.FromArgb(0, 0, 0, 0), 0, 40, 1);

            r.SetStroke(Color.FromArgb(255, 20, 29, 83));
            chartCanvas = CanvasCreator.CreateCanvas(MainCanvasStatistics, 590, 350, Color.FromArgb(0, 0, 0, 0), 5, 40);
            new MyRectangle(chartCanvas, 600, 1, Color.FromArgb(255, 20, 29, 83), 0, 240);
            new MyRectangle(chartCanvas, 600, 1, Color.FromArgb(255, 20, 29, 83), 0, 160);
            new MyRectangle(chartCanvas, 600, 1, Color.FromArgb(255, 20, 29, 83), 0, 80);
            chartContentCanvas = new Canvas()
            {
                Width = 590, Height = 362
            };
            ScrollViewer sv = ScrollViewerCreator.CreateScrollViewer(chartCanvas, 590, 364, 0, 0, chartContentCanvas);

            sv.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scalePercent    = new MyLabel[3];
            scalePercent[0] = new MyLabel(chartCanvas, "", 40, 30, 11, -20, 225, Color.FromArgb(160, 255, 255, 255), Color.FromArgb(0, 0, 0, 0));
            scalePercent[1] = new MyLabel(chartCanvas, "", 40, 30, 11, -20, 145, Color.FromArgb(160, 255, 255, 255), Color.FromArgb(0, 0, 0, 0));
            scalePercent[2] = new MyLabel(chartCanvas, "", 40, 30, 11, -20, 65, Color.FromArgb(160, 255, 255, 255), Color.FromArgb(0, 0, 0, 0));

            CommandParameters parameters = new CommandParameters();

            parameters.StartDate = DateTime.Now.AddDays(-5).ToShortDateString();
            parameters.EndDate   = DateTime.Now.ToShortDateString();
            List <Activity>          activity      = allData_db.GetDailyActivity(parameters);
            List <ActiveApplication> otherActivity = allData_db.GetActiveApplication(parameters, true);

            CreateChartActivity(activity, parameters, otherActivity);
        }
コード例 #21
0
ファイル: Table.cs プロジェクト: CaseStudyKHTN/DP-Graphics
        private void button1_Click(object sender, EventArgs e)
        {
            Graphics g = this.panel1.CreateGraphics();
            g.Clear(Color.White);

            if(this.radioButton1.Checked)
                draw = new CairoAdapter(g);
            else
                draw = new GDIPlusAdapter(g);

            Random r = new Random();
            switch (r.Next(0, 5) % 3)
            {
                case 0:
                    MyRectangle rect = new MyRectangle(100, 150, 50, 50);
                    listshapeGraphics.addShape(rect);
                    rect.Draw(draw);
                    break;
                case 1:
                    MyRectangle rect1 = new MyRectangle(300, 150, 150, 50);
                    rect1.Draw(draw);
                    listshapeGraphics.addShape(rect1);
                    break;
                case 2:
                    MyEllipse ellipse = new MyEllipse(150, 170, 200, 100);
                    listshapeGraphics.addShape(ellipse);
                    ellipse.Draw(draw);
                    break;
            }

            g.Dispose();
        }
コード例 #22
0
        public async Task <TextureWithSize> GenerateHeightDetailElementAsync(MyRectangle requestedArea,
                                                                             TerrainCardinalResolution resolution, RequiredCornersMergeStatus cornersMergeStatus)
        {
            var textureWithSize = await RetriveFoundationTextureAsync(requestedArea, resolution, cornersMergeStatus);

            var workTexture = new TextureWithCoords(sizedTexture: textureWithSize, coords: requestedArea);

            foreach (var applier in _featureAppliers.Where(c => c.AvalibleResolutions.Contains(resolution))
                     .OrderBy(c => c.Rank))
            {
                workTexture = await applier.Applier.ApplyFeatureAsync(workTexture, resolution, false); //todo

                var localTexture = workTexture;
                await _commonExecutor.AddAction(() => localTexture.Texture.wrapMode = TextureWrapMode.Clamp);
            }

            var textureWithMipMaps = await GenerateTextureWithMipMapsAsync(new TextureWithSize()
            {
                Size    = textureWithSize.Size,
                Texture = workTexture.Texture
            });

            return(new TextureWithSize()
            {
                Size = textureWithSize.Size,
                Texture = textureWithMipMaps
            });
        }
コード例 #23
0
        public override async Task <TerrainDetailElementOutput> RetriveTerrainDetailAsync(
            TerrainDescriptionElementTypeEnum type, MyRectangle queryArea,
            TerrainCardinalResolution resolution, RequiredCornersMergeStatus cornersMergeStatus)
        {
            TerrainDetailElement detailElement = null;
            CornersMergeStatus   status        = CornersMergeStatus.MERGED;

            if (cornersMergeStatus == RequiredCornersMergeStatus.NOT_MERGED)
            {
                status = CornersMergeStatus.NOT_MERGED;
            }
            if (type == TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY)
            {
                detailElement = await _provider.GenerateHeightDetailElementAsync(queryArea, resolution, status);
            }
            else if (type == TerrainDescriptionElementTypeEnum.NORMAL_ARRAY)
            {
                detailElement = await _provider.GenerateNormalDetailElementAsync(queryArea, resolution, status);
            }
            else
            {
                Preconditions.Fail("Not supported type: " + type);
            }

            return(new TerrainDetailElementOutput()
            {
                TokenizedElement = new TokenizedTerrainDetailElement()
                {
                    DetailElement = detailElement,
                    Token = null
                },
                UvBase = null
            });
        }
コード例 #24
0
        public void Intersects_ShouldReturn_True()
        {
            MyRectangle r1 = new MyRectangle(10, 10);
            MyRectangle r2 = new MyRectangle(new Point2D(-1, -2), 13, 13);

            Assert.IsTrue(r1.Intersects(r2));
        }
コード例 #25
0
        private void ChaoticPointGeneration(MyArea area, List <MyNode> result, int count, double h = -1)
        {
            MyRectangle rect      = MyRectangle.GetAreaRectangle(area);
            int         maxNodes  = count;
            Random      generator = new Random((int)DateTime.Now.Ticks);

            for (int i = 0; result.Count < maxNodes; i++)
            {
                int triesCount = (int)nudTriesCount.Value;
                do
                {
                    double x = rect.minX + generator.NextDouble() * rect.Width;
                    double y = rect.minY + generator.NextDouble() * rect.Height;
                    MyNode p = new MyNode(x, y);
                    if (PointFits(area, result, p, h))
                    {
                        p.Id = ++nodesCount;
                        result.Add(p);
                        break;
                    }
                } while (--triesCount > 0);
                if (triesCount == 0)
                {
                    break;
                }
            }
        }
コード例 #26
0
        private void CreateChartActiveApplication(List <ActiveApplication> activeApplication, List <ActiveApplication> otherActivity)
        {
            if (activeApplication.Any())
            {
                activeApplication = activeApplication.OrderBy(x => x.Date).ToList();
                int maxValue = activeApplication.Max(x => x.ActivityTime);
                List <Tuple <int, string> > activeApplicationTupleList = GetTupleList(activeApplication);
                List <int> sumDateList        = GetSumTimeList(activeApplicationTupleList);
                double     scaleMultiplier    = ActionOnNumbers.DivisionD(300, maxValue);
                int        width              = 10;
                int        space              = 0;
                int        lenghtLabelDate    = 0;
                int        positionXLabelDate = 16;
                int        numberElement      = 0;
                int        numberDateLabel    = 0;
                chartContentCanvas.Width = 0;
                for (int i = 0; i < activeApplication.Count; i++)
                {
                    if (i > 0)
                    {
                        if (!activeApplication[i].Date.Equals(activeApplication[i - 1].Date))
                        {
                            space           += 10;
                            lenghtLabelDate += 11;
                            DrawDateLabel(activeApplication[i - 1].Date.Remove(10), lenghtLabelDate, positionXLabelDate, otherActivity, ref numberDateLabel);
                            positionXLabelDate += lenghtLabelDate - 1;
                            lenghtLabelDate     = 0;
                        }
                    }
                    if (!string.IsNullOrEmpty(searchingNames.Text) && !searchingNames.Text.Equals("Wpisz nazwę aktywności") && indexResultFilter > -1)
                    {
                        if (activeApplication[i].ID == Convert.ToInt32(foundList.ElementAt(indexResultFilter).Key))
                        {
                            MyRectangle r = new MyRectangle(chartContentCanvas, width, (int)(activeApplication[i].ActivityTime * scaleMultiplier),
                                                            colorTable[i % 4], 40 + space + ((width + 40) * numberElement) + 2, 320 - activeApplication[i].ActivityTime * scaleMultiplier, 1);
                            SetStrokeAndToolTip(r, activeApplication, i);
                            chartContentCanvas.Width += width * 5;
                            lenghtLabelDate          += width * 5;
                            numberElement++;
                        }
                    }
                    else
                    {
                        MyRectangle r = new MyRectangle(chartContentCanvas, width, (int)(activeApplication[i].ActivityTime * scaleMultiplier),
                                                        colorTable[i % 4], 20 + space + ((width + 2) * i) + 2, 320 - activeApplication[i].ActivityTime * scaleMultiplier, 1);
                        SetStrokeAndToolTip(r, activeApplication, i);
                        chartContentCanvas.Width += (width + 2);
                        lenghtLabelDate          += width + 2;
                    }
                }
                lenghtLabelDate += 21;
                DrawDateLabel(activeApplication[activeApplication.Count - 1].Date.Remove(10), lenghtLabelDate, positionXLabelDate, otherActivity, ref numberDateLabel);
                chartContentCanvas.Width += space + 50;
                SetScalePercent(maxValue, sumDateList.Max());

                countTitleApplication.SetContent(activeApplication.Select(x => x.Title).Distinct().Count().ToString());
                countActivityApplication.SetContent(activeApplication.Select(x => x.IdNameActivity).Distinct().Count().ToString());
            }
        }
コード例 #27
0
        public void RegeneratePatch()
        {
            if (GenerateDebugGrid)
            {
                var root          = new GameObject("rootGrid");
                var segmentLength = 90;
                for (int x = -3; x < 3; x++)
                {
                    for (int y = -3; y < 3; y++)
                    {
                        var inGamePosition = new MyRectangle(x * segmentLength, y * segmentLength, segmentLength, segmentLength);
                        var flatLod        = new FlatLod(1, 0);
                        var detailPack     = _provider.ProvideSurfaceDetailAsync(inGamePosition, flatLod).Result;

                        var quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
                        //StandardMaterialUtils.SetMaterialRenderingModeToAlphablend(quad.GetComponent<MeshRenderer>().material);
                        quad.name = $"Plate {x} : {y}";
                        quad.transform.rotation      = Quaternion.Euler(90, 0, 0);
                        quad.transform.localScale    = new Vector3(segmentLength, segmentLength, 1);
                        quad.transform.localPosition = new Vector3(inGamePosition.X + inGamePosition.Width / 2, 1, inGamePosition.Y + inGamePosition.Height / 2);
                        quad.transform.SetParent(root.transform);
                        if (detailPack != null)
                        {
                            quad.GetComponent <MeshRenderer>().GetComponent <MeshRenderer>().material.mainTexture = detailPack.MainTexture;
                        }
                        else
                        {
                            GameObject.Destroy(quad);
                        }
                    }
                }
            }
            else
            {
                MyRectangle inGamePosition = new MyRectangle(PatchArea.x, PatchArea.y, PatchArea.z - PatchArea.x, PatchArea.w - PatchArea.y);
                var         flatLod        = new FlatLod(1, 0);

                var detailPack = _provider.ProvideSurfaceDetailAsync(inGamePosition, flatLod).Result;
                DummyPlate1.GetComponent <MeshRenderer>().material.mainTexture = detailPack.MainTexture;
                //DummyPlate2.GetComponent<MeshRenderer>().material.SetTexture("_BumpMap", detailPack.NormalTexture);

                //var devisedPatches = _patchesCreatorProxy.CreatePatchAsync(inGamePosition.ToRectangle(), flatLod.ScalarValue).Result;
                //var onlyPatch = devisedPatches.First();

                //var repositioner = Repositioner.Default; //todo
                //var templates = new List<Ring2PlateStampTemplate>();
                //foreach (var sliceInfo in onlyPatch.SliceInfos)
                //{
                //    var propertyBlock = sliceInfo.Uniforms.ToPropertyBlockTemplate();

                //    templates.Add(new Ring2PlateStampTemplate( new MaterialTemplate(
                //            Ring2ShaderNames.RuntimeTerrainTexture, sliceInfo.Keywords, propertyBlock), repositioner.Move(onlyPatch.SliceArea), flatLod.ScalarValue));
                //}

                //var material = Ring2PlateStamper_CreateRenderMaterial(templates.First());
                //material.EnableKeyword("GENERATE_COLOR");
                //DummyPlate2.GetComponent<MeshRenderer>().material = material;
            }
        }
コード例 #28
0
        public IPrototype Clone()
        {
            MyRectangle o = new MyRectangle();

            o.Width  = this.Width;
            o.Height = this.Height;
            return(o);
        }
コード例 #29
0
 private void SetStrokeAndToolTip(MyRectangle rectangle, List <Activity> activity, int index)
 {
     rectangle.SetStroke(Color.FromArgb(100, 255, 255, 255));
     rectangle.ToolTip(activity[index].Name + " - [" + ActionOnTime.GetTimeAndDays(activity[index].ActivityTime) + " / "
                       + ActionOnTime.GetTimeAndDays(activity.Where(x => x.Name == activity[index].Name).Sum(x => x.ActivityTime)) + "] [" +
                       ActionOnNumbers.DivisionI(activity[index].ActivityTime * 100, activity.Where(x => x.Date == activity[index].Date).Sum(x => x.ActivityTime))
                       + "% / " + ActionOnNumbers.DivisionI(activity.Where(x => x.Name == activity[index].Name).Sum(x => x.ActivityTime) * 100, activity.Sum(x => x.ActivityTime)) + "%]");
 }
コード例 #30
0
 public async Task <TerrainDetailElement> GenerateNormalDetailElementAsync(MyRectangle queryArea,
                                                                           TerrainCardinalResolution cardinalResolution, CornersMergeStatus requiredMerge)
 {
     return(await GenerateTerrainDetailElementAsync(queryArea, cardinalResolution, requiredMerge,
                                                    ((rectangle, resolution, textureWithSize) => TaskUtils.MyFromResult(textureWithSize)), // we do not have to merge normals - just generate normals from merged heightmap!
                                                    _generator.GenerateNormalDetailElementAsync
                                                    ));
 }
コード例 #31
0
        private void CreateSegmentRecordDay(int xLabelLegend, int yLabelLegend, int index)
        {
            MyRectangle colorLegend = new MyRectangle(canvas, 10, 10, nameColor[index], xLabelLegend, yLabelLegend);

            labelLegend[index] = new MyLabel(canvas, " - ", 65, 25, 10, xLabelLegend + 8, yLabelLegend - 7, Color.FromArgb(255, 47, 79, 79), Color.FromArgb(0, 0, 0, 0),
                                             horizontalAlignment: HorizontalAlignment.Left);
            labels[index] = new MyLabel(canvas, "", 40, 25, 10, 0, 0, Color.FromArgb(255, 47, 79, 79), Color.FromArgb(0, 0, 0, 0), horizontalAlignment: HorizontalAlignment.Center);
        }