コード例 #1
0
ファイル: DrawableHexSphere.cs プロジェクト: sin-us/sdhk
        private VertexPositionColorNormal CreateVertex(Vector3 position, CustomTile t)
        {
            Vector3 tileNorm   = Vector3.Zero;
            Vector3 tileCenter = new Vector3(t.X, t.Y, t.Z);

            for (int i = 0; i < t.Corners.Length - 1; ++i)
            {
                Vector3 a = new Vector3(t.Corners[i].X, t.Corners[i].Y, t.Corners[i].Z);
                Vector3 b = new Vector3(t.Corners[i + 1].X, t.Corners[i + 1].Y, t.Corners[i + 1].Z);

                tileNorm += ((tileCenter - a) * (tileCenter - b));
            }

            tileNorm.Normalize();

            return(new VertexPositionColorNormal(position, tileCenter, GetColorByHeight(t.Height)));
        }
コード例 #2
0
ファイル: DrawableHexSphere.cs プロジェクト: sin-us/sdhk
            private void AddTile(CustomTile tile, int currentDepth, ref BoundingBox box)
            {
                BoundingBox = box;

                if (currentDepth >= MaxDepth)
                {
                    if (Tiles == null)
                    {
                        Tiles = new List <CustomTile>();
                    }

                    Tiles.Add(tile);
                }
                else
                {
                    var dividedBoxes = DivideBoundingBox(ref box, currentDepth);

                    var leftBoundingBox  = dividedBoxes.Item1;
                    var rightBoundingBox = dividedBoxes.Item2;

                    var leftContainment  = leftBoundingBox.Contains(tile.BoundingBox);
                    var rightContainment = rightBoundingBox.Contains(tile.BoundingBox);

                    if (leftContainment == ContainmentType.Contains || leftContainment == ContainmentType.Intersects)
                    {
                        if (Left == null)
                        {
                            Left = new IntersectionCheckNode();
                        }
                        Left.AddTile(tile, currentDepth + 1, ref leftBoundingBox);
                    }

                    if (rightContainment == ContainmentType.Contains || rightContainment == ContainmentType.Intersects)
                    {
                        if (Right == null)
                        {
                            Right = new IntersectionCheckNode();
                        }
                        Right.AddTile(tile, currentDepth + 1, ref rightBoundingBox);
                    }
                }
            }
コード例 #3
0
ファイル: DrawableHexSphere.cs プロジェクト: sin-us/sdhk
 public CustomTileIntersection(CustomTile tile, float distance)
 {
     Tile     = tile;
     Distance = distance;
 }