Ejemplo n.º 1
0
        /// <summary>
        ///     Adds the relevant vertices to the quad node.
        /// </summary>
        private void AddVertices()
        {
            // The specific case vertices
            switch (Type)
            {
                case NodeType.TopLeft:
                    VertexTopLeft = Parent.VertexTopLeft;
                    VertexTopRight = Parent.VertexTop;
                    VertexBottomLeft = Parent.VertexLeft;
                    VertexBottomRight = Parent.VertexCenter;
                    break;
                case NodeType.TopRight:
                    VertexTopLeft = Parent.VertexTop;
                    VertexTopRight = Parent.VertexTopRight;
                    VertexBottomLeft = Parent.VertexCenter;
                    VertexBottomRight = Parent.VertexRight;
                    break;
                case NodeType.BottomLeft:
                    VertexTopLeft = Parent.VertexLeft;
                    VertexTopRight = Parent.VertexCenter;
                    VertexBottomLeft = Parent.VertexBottomLeft;
                    VertexBottomRight = Parent.VertexBottom;
                    break;
                case NodeType.BottomRight:
                    VertexTopLeft = Parent.VertexCenter;
                    VertexTopRight = Parent.VertexRight;
                    VertexBottomLeft = Parent.VertexBottom;
                    VertexBottomRight = Parent.VertexBottomRight;
                    break;
                case NodeType.FullNode: // Really, if it's a full node.
                    VertexTopLeft = new QuadNodeVertex
                        {
                            Activated = true,
                            Index = 0
                        };
                    VertexTopRight = new QuadNodeVertex
                        {
                            Activated = true,
                            Index = VertexTopLeft.Index + size
                        };
                    VertexBottomLeft = new QuadNodeVertex
                        {
                            Activated = true,
                            Index = (size + 1) * parentTree.TopNodeSize
                        };
                    VertexBottomRight = new QuadNodeVertex
                        {
                            Activated = true,
                            Index = VertexBottomLeft.Index + size
                        };
                    break;
                default:
                    throw new InvalidOperationException("Unknown node type");
            }

            int halfSize = size / 2;
            // The vertices common for all node types
            VertexTop = new QuadNodeVertex
                {
                    Activated = false,
                    Index = VertexTopLeft.Index + halfSize
                };

            VertexLeft = new QuadNodeVertex
                {
                    Activated = false,
                    Index = VertexTopLeft.Index + (parentTree.TopNodeSize + 1) * (halfSize)
                };

            VertexCenter = new QuadNodeVertex
                {
                    Activated = false,
                    Index = VertexLeft.Index + halfSize
                };

            VertexRight = new QuadNodeVertex
                {
                    Activated = false,
                    Index = VertexLeft.Index + size
                };

            VertexBottom = new QuadNodeVertex
                {
                    Activated = false,
                    Index = VertexBottomLeft.Index + halfSize
                };
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Adds the relevant vertices to the quad node.
        /// </summary>
        private void AddVertices()
        {
            // The specific case vertices
            switch (Type)
            {
            case NodeType.TopLeft:
                VertexTopLeft     = Parent.VertexTopLeft;
                VertexTopRight    = Parent.VertexTop;
                VertexBottomLeft  = Parent.VertexLeft;
                VertexBottomRight = Parent.VertexCenter;
                break;

            case NodeType.TopRight:
                VertexTopLeft     = Parent.VertexTop;
                VertexTopRight    = Parent.VertexTopRight;
                VertexBottomLeft  = Parent.VertexCenter;
                VertexBottomRight = Parent.VertexRight;
                break;

            case NodeType.BottomLeft:
                VertexTopLeft     = Parent.VertexLeft;
                VertexTopRight    = Parent.VertexCenter;
                VertexBottomLeft  = Parent.VertexBottomLeft;
                VertexBottomRight = Parent.VertexBottom;
                break;

            case NodeType.BottomRight:
                VertexTopLeft     = Parent.VertexCenter;
                VertexTopRight    = Parent.VertexRight;
                VertexBottomLeft  = Parent.VertexBottom;
                VertexBottomRight = Parent.VertexBottomRight;
                break;

            case NodeType.FullNode:     // Really, if it's a full node.
                VertexTopLeft = new QuadNodeVertex
                {
                    Activated = true,
                    Index     = 0
                };
                VertexTopRight = new QuadNodeVertex
                {
                    Activated = true,
                    Index     = VertexTopLeft.Index + size
                };
                VertexBottomLeft = new QuadNodeVertex
                {
                    Activated = true,
                    Index     = (size + 1) * parentTree.TopNodeSize
                };
                VertexBottomRight = new QuadNodeVertex
                {
                    Activated = true,
                    Index     = VertexBottomLeft.Index + size
                };
                break;

            default:
                throw new InvalidOperationException("Unknown node type");
            }

            int halfSize = size / 2;

            // The vertices common for all node types
            VertexTop = new QuadNodeVertex
            {
                Activated = false,
                Index     = VertexTopLeft.Index + halfSize
            };

            VertexLeft = new QuadNodeVertex
            {
                Activated = false,
                Index     = VertexTopLeft.Index + (parentTree.TopNodeSize + 1) * (halfSize)
            };

            VertexCenter = new QuadNodeVertex
            {
                Activated = false,
                Index     = VertexLeft.Index + halfSize
            };

            VertexRight = new QuadNodeVertex
            {
                Activated = false,
                Index     = VertexLeft.Index + size
            };

            VertexBottom = new QuadNodeVertex
            {
                Activated = false,
                Index     = VertexBottomLeft.Index + halfSize
            };
        }