Beispiel #1
0
		private void GenerateGrid(int x, int y)
		{
			VertexPositionColor[] vs = new VertexPositionColor[24];
			Color c = Color.LightSteelBlue;
			vs[0] = new VertexPositionColor(new Vector3((x + 0) * Size, (y + 0) * Size, 0), c);
			vs[1] = new VertexPositionColor(new Vector3((x + 1) * Size, (y + 0) * Size, 0), c);
			vs[2] = new VertexPositionColor(new Vector3((x + 1) * Size, (y + 0) * Size, 0), c);
			vs[3] = new VertexPositionColor(new Vector3((x + 1) * Size, (y + 1) * Size, 0), c);
			vs[4] = new VertexPositionColor(new Vector3((x + 1) * Size, (y + 1) * Size, 0), c);
			vs[5] = new VertexPositionColor(new Vector3((x + 0) * Size, (y + 1) * Size, 0), c);
			vs[6] = new VertexPositionColor(new Vector3((x + 0) * Size, (y + 1) * Size, 0), c);
			vs[7] = new VertexPositionColor(new Vector3((x + 0) * Size, (y + 0) * Size, 0), c);

			for (int i = 0; i < cells[x, y].VertexCount; i++)
			{
				float vx = cells[x, y].VertexPositions[i].X;
				float vy = cells[x, y].VertexPositions[i].Y;
				float r = 2;
				vs[8 + i * 8] = new VertexPositionColor(new Vector3(vx - r, vy - r, 0), Color.Red);
				vs[9 + i * 8] = new VertexPositionColor(new Vector3(vx + r, vy - r, 0), Color.Red);
				vs[10 + i * 8] = new VertexPositionColor(new Vector3(vx + r, vy - r, 0), Color.Red);
				vs[11 + i * 8] = new VertexPositionColor(new Vector3(vx + r, vy + r, 0), Color.Red);
				vs[12 + i * 8] = new VertexPositionColor(new Vector3(vx + r, vy + r, 0), Color.Red);
				vs[13 + i * 8] = new VertexPositionColor(new Vector3(vx - r, vy + r, 0), Color.Red);
				vs[14 + i * 8] = new VertexPositionColor(new Vector3(vx - r, vy + r, 0), Color.Red);
				vs[15 + i * 8] = new VertexPositionColor(new Vector3(vx - r, vy - r, 0), Color.Red);
			}
			OutlineBuffer.SetData<VertexPositionColor>(OutlineLocation * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 8 + cells[x, y].VertexCount * 8, VertexPositionColor.VertexDeclaration.VertexStride);
			OutlineLocation += 8 + cells[x, y].VertexCount * 8;
		}
Beispiel #2
0
        public void ConstructTreeGrid(QuadtreeNode node)
        {
            if (node == null)
            {
                return;
            }
            VertexPositionColor[] vs = new VertexPositionColor[16];
            int   x = (int)node.position.X * this.Size;
            int   y = (int)node.position.Y * this.Size;
            Color c = Color.LightSteelBlue;
            Color v = Color.Red;

            float size = node.size * this.Size;

            vs[0] = new VertexPositionColor(new Vector3(x + 0 * size, y + 0 * size, 0), c);
            vs[1] = new VertexPositionColor(new Vector3(x + 1 * size, y + 0 * size, 0), c);
            vs[2] = new VertexPositionColor(new Vector3(x + 1 * size, y + 0 * size, 0), c);
            vs[3] = new VertexPositionColor(new Vector3(x + 1 * size, y + 1 * size, 0), c);
            vs[4] = new VertexPositionColor(new Vector3(x + 1 * size, y + 1 * size, 0), c);
            vs[5] = new VertexPositionColor(new Vector3(x + 0 * size, y + 1 * size, 0), c);
            vs[6] = new VertexPositionColor(new Vector3(x + 0 * size, y + 1 * size, 0), c);
            vs[7] = new VertexPositionColor(new Vector3(x + 0 * size, y + 0 * size, 0), c);

            if (node.type != QuadtreeNodeType.Leaf || node.draw_info.index == -1)
            {
                OutlineBuffer.SetData <VertexPositionColor>(OutlineLocation * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 8, VertexPositionColor.VertexDeclaration.VertexStride);
                OutlineLocation += 8;
            }
            else
            {
                x += (int)(node.draw_info.position.X * (float)this.Size);
                y += (int)(node.draw_info.position.Y * (float)this.Size);
                float r = 2;
                vs[8]  = new VertexPositionColor(new Vector3(x - r, y - r, 0), v);
                vs[9]  = new VertexPositionColor(new Vector3(x + r, y - r, 0), v);
                vs[10] = new VertexPositionColor(new Vector3(x + r, y - r, 0), v);
                vs[11] = new VertexPositionColor(new Vector3(x + r, y + r, 0), v);
                vs[12] = new VertexPositionColor(new Vector3(x + r, y + r, 0), v);
                vs[13] = new VertexPositionColor(new Vector3(x - r, y + r, 0), v);
                vs[14] = new VertexPositionColor(new Vector3(x - r, y + r, 0), v);
                vs[15] = new VertexPositionColor(new Vector3(x - r, y - r, 0), v);
                OutlineBuffer.SetData <VertexPositionColor>(OutlineLocation * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 16, VertexPositionColor.VertexDeclaration.VertexStride);
                OutlineLocation += 16;
            }

            if (node.type != QuadtreeNodeType.Leaf)
            {
                for (int i = 0; i < 4; i++)
                {
                    ConstructTreeGrid(node.children[i]);
                }
            }
        }
Beispiel #3
0
        private void Polygonize(int x, int y, int z)
        {
            if (Cells[x, y, z] == null)
            {
                return;
            }

            int cube_index = 0;

            for (int i = 0; i < 8; i++)
            {
                if (Sampler.Sample(new Vector3(x, y, z) + CornerDeltas[i]) < 0)
                {
                    cube_index |= 1 << i;
                }
            }

            if (cube_index == 0 || cube_index == 255)
            {
                return;
            }

            Cells[x, y, z].Vertices = new Vertex[VerticesNumberTable[cube_index]];

            /*for (int i = 0; i < 12; i++)
             * {
             *      Cells[x, y, z].Edges[i].A = new Vector3(x, y, z) + CornerDeltas[EdgePairs[i, 0]];
             *      Cells[x, y, z].Edges[i].B = new Vector3(x, y, z) + CornerDeltas[EdgePairs[i, 1]];
             *
             *      Cells[x, y, z].Edges[i].ValueA = Sampler.Sample(Cells[x, y, z].Edges[i].A);
             *      Cells[x, y, z].Edges[i].ValueB = Sampler.Sample(Cells[x, y, z].Edges[i].B);
             * }*/

            int v_index = 0;

            Cells[x, y, z].Vertices[0] = new Vertex();
            for (int e = 0; e < EdgesTable.GetLength(1); e++)
            {
                if (EdgesTable[cube_index, e] == -2)
                {
                    break;
                }
                if (EdgesTable[cube_index, e] == -1)
                {
                    v_index++;
                    if (v_index < Cells[x, y, z].Vertices.Length)
                    {
                        Cells[x, y, z].Vertices[v_index] = new Vertex();
                    }
                    continue;
                }

                //Cells[x, y, z].Vertices[v_index].Index = v_index;
                Cells[x, y, z].Vertices[v_index].Edges.Add(EdgesTable[cube_index, e]);
                Cells[x, y, z].Edges[EdgesTable[cube_index, e]].Vertices.Add(Cells[x, y, z].Vertices[v_index]);
                //Cells[x, y, z].Edges[EdgesTable[cube_index, e]].Flipped = Cells[x, y, z].Edges[EdgesTable[cube_index, e]].ValueA < 0;
            }

            foreach (Vertex v in Cells[x, y, z].Vertices)
            {
                Vertex tx = v;
                if (v == null)                 //for edges 241/243, which were originally marked as having 2 vertices...?
                {
                    continue;
                }
                Vector3 point = new Vector3();

                if (VertexMode != VertexModes.Block)
                {
                    //QEF3D qef = new QEF3D();
                    QEFProper.QEFSolver qef = new QEFProper.QEFSolver();
                    VertexPlacement     qem = new VertexPlacement();
                    for (int e_i = 0; e_i < tx.Edges.Count; e_i++)
                    {
                        Edge e = Cells[x, y, z].Edges[tx.Edges[e_i]];
                        if (VertexMode == VertexModes.Edges)
                        {
                            point += e.GetIntersection();
                        }
                        else if (VertexMode == VertexModes.QEF)
                        {
                            qef.Add(e.GetIntersection() - new Vector3(x, y, z), Sampler.GetNormal(e.GetIntersection()));
                        }
                        else
                        {
                            qem.AddPlane(e.GetIntersection() - new Vector3(x, y, z), Sampler.GetNormal(e.GetIntersection()));
                        }
                    }

                    if (VertexMode == VertexModes.Edges)
                    {
                        point /= (float)tx.Edges.Count;
                    }
                    else if (VertexMode == VertexModes.QEF)
                    {
                        point = qef.Solve(1e-6f, 4, 1e-6f) + new Vector3(x, y, z);
                    }
                    else
                    {
                        point = qem.Solve() + new Vector3(x, y, z);
                    }
                }
                else
                {
                    point = new Vector3(x, y, z) + Vector3.One * 0.5f;
                }
                //point = Vector3.Clamp(point, new Vector3(x, y, z), new Vector3(x + 1, y + 1, z + 1));

                tx.Position = point;
                Vector3 norm = Sampler.GetNormal(point);
                Vector3 c_v  = norm * 0.5f + Vector3.One * 0.5f;
                c_v.Normalize();
                Color clr = new Color(c_v);
                if (!UseFlatShading)
                {
                    tx.Index = Vertices.Count;
                    VertexPositionColorNormal pv = new VertexPositionColorNormal(tx.Position, clr, norm);
                    Vertices.Add(pv);
                }
                else
                {
                    tx.Index = CalculatedVertices.Count;
                    VertexPositionColor pv = new VertexPositionColor(tx.Position, clr);
                    CalculatedVertices.Add(pv);
                }

                VertexPositionColor[] vs = new VertexPositionColor[24];
                Color c  = Color.Red;
                float vx = tx.Position.X;
                float vy = tx.Position.Y;
                float vz = tx.Position.Z;
                float r  = 0.25f;
                vs[0] = new VertexPositionColor(new Vector3((vx + 0), (vy + 0), (vz + 0)), c);
                vs[1] = new VertexPositionColor(new Vector3((vx + r), (vy + 0), (vz + 0)), c);
                vs[2] = new VertexPositionColor(new Vector3((vx + r), (vy + 0), (vz + 0)), c);
                vs[3] = new VertexPositionColor(new Vector3((vx + r), (vy + r), (vz + 0)), c);
                vs[4] = new VertexPositionColor(new Vector3((vx + r), (vy + r), (vz + 0)), c);
                vs[5] = new VertexPositionColor(new Vector3((vx + 0), (vy + r), (vz + 0)), c);
                vs[6] = new VertexPositionColor(new Vector3((vx + 0), (vy + r), (vz + 0)), c);
                vs[7] = new VertexPositionColor(new Vector3((vx + 0), (vy + 0), (vz + 0)), c);

                vs[8]  = new VertexPositionColor(new Vector3((vx + 0), (vy + 0), (vz + r)), c);
                vs[9]  = new VertexPositionColor(new Vector3((vx + r), (vy + 0), (vz + r)), c);
                vs[10] = new VertexPositionColor(new Vector3((vx + r), (vy + 0), (vz + r)), c);
                vs[11] = new VertexPositionColor(new Vector3((vx + r), (vy + r), (vz + r)), c);
                vs[12] = new VertexPositionColor(new Vector3((vx + r), (vy + r), (vz + r)), c);
                vs[13] = new VertexPositionColor(new Vector3((vx + 0), (vy + r), (vz + r)), c);
                vs[14] = new VertexPositionColor(new Vector3((vx + 0), (vy + r), (vz + r)), c);
                vs[15] = new VertexPositionColor(new Vector3((vx + 0), (vy + 0), (vz + r)), c);

                vs[16] = new VertexPositionColor(new Vector3((vx + 0), (vy + 0), (vz + 0)), c);
                vs[17] = new VertexPositionColor(new Vector3((vx + 0), (vy + 0), (vz + r)), c);
                vs[18] = new VertexPositionColor(new Vector3((vx + 0), (vy + r), (vz + 0)), c);
                vs[19] = new VertexPositionColor(new Vector3((vx + 0), (vy + r), (vz + r)), c);

                vs[20] = new VertexPositionColor(new Vector3((vx + r), (vy + 0), (vz + 0)), c);
                vs[21] = new VertexPositionColor(new Vector3((vx + r), (vy + 0), (vz + r)), c);
                vs[22] = new VertexPositionColor(new Vector3((vx + r), (vy + r), (vz + 0)), c);
                vs[23] = new VertexPositionColor(new Vector3((vx + r), (vy + r), (vz + r)), c);

                OutlineBuffer.SetData <VertexPositionColor>(OutlineLocation * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 24, VertexPositionColor.VertexDeclaration.VertexStride);
                OutlineLocation += 24;
            }
        }
Beispiel #4
0
        public void GenerateAt(int x, int y)
        {
            int corners = 0;

            for (int i = 0; i < 4; i++)
            {
                if (map[x + i / 2, y + i % 2] < 0)
                {
                    corners |= 1 << i;
                }
            }

            if (corners == 0 || corners == 15)
            {
                return;
            }

            VertexPositionColor[] vs = new VertexPositionColor[10];
            Color c = Color.LightSteelBlue;

            vs[0] = new VertexPositionColor(new Vector3((x + 0) * Size, (y + 0) * Size, 0), c);
            vs[1] = new VertexPositionColor(new Vector3((x + 1) * Size, (y + 0) * Size, 0), c);
            vs[2] = new VertexPositionColor(new Vector3((x + 1) * Size, (y + 0) * Size, 0), c);
            vs[3] = new VertexPositionColor(new Vector3((x + 1) * Size, (y + 1) * Size, 0), c);
            vs[4] = new VertexPositionColor(new Vector3((x + 1) * Size, (y + 1) * Size, 0), c);
            vs[5] = new VertexPositionColor(new Vector3((x + 0) * Size, (y + 1) * Size, 0), c);
            vs[6] = new VertexPositionColor(new Vector3((x + 0) * Size, (y + 1) * Size, 0), c);
            vs[7] = new VertexPositionColor(new Vector3((x + 0) * Size, (y + 0) * Size, 0), c);
            OutlineBuffer.SetData <VertexPositionColor>(OutlineLocation * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 8, VertexPositionColor.VertexDeclaration.VertexStride);
            OutlineLocation += 8;

            QEF     qef            = new QEF();
            Vector3 average_normal = new Vector3();

            for (int i = 0; i < 4; i++)
            {
                int c1 = edges[i, 0];
                int c2 = edges[i, 1];

                int m1 = (corners >> c1) & 1;
                int m2 = (corners >> c2) & 1;
                if (m1 == m2)
                {
                    continue;
                }

                float d1 = map[x + c1 / 2, y + c1 % 2];
                float d2 = map[x + c2 / 2, y + c2 % 2];

                Vector2 p1 = new Vector2((float)((c1 / 2)), (float)((c1 % 2)));
                Vector2 p2 = new Vector2((float)((c2 / 2)), (float)((c2 % 2)));

                Vector2 intersection = Sampler.GetIntersection(p1, p2, d1, d2);
                Vector2 normal       = Sampler.GetNormal(intersection + new Vector2(x, y));          //GetNormal(x, y);
                average_normal += new Vector3(normal, 0);

                qef.Add(intersection, normal);
            }

            average_normal /= (float)qef.Intersections.Count;
            average_normal.Normalize();

            vertices[x, y] = qef.Solve2(0, 16, 0);

            Vector2 p   = vertices[x, y];
            Color   n_c = new Color(average_normal * 0.5f + Vector3.One * 0.5f);
            VertexPositionColorNormal v = new VertexPositionColorNormal(new Vector3((p.X + x) * Size, (p.Y + y) * Size, 0), n_c, average_normal);

            Vertices.Add(v);
            vertex_indexes[x, y] = VertexCount;
            VertexCount++;
        }
Beispiel #5
0
        public void GenerateAt(int x, int y, int z)
        {
            int corners = 0;

            for (int i = 0; i < 8; i++)
            {
                if (map[x + i / 4, y + i % 4 / 2, z + i % 2] < 0)
                {
                    corners |= 1 << i;
                }
            }

            if (corners == 0 || corners == 255)
            {
                return;
            }

            VertexPositionColor[] vs = new VertexPositionColor[24];
            Color c = Color.LightSteelBlue;

            vs[0] = new VertexPositionColor(new Vector3((x + 0), (y + 0), (z + 0)), c);
            vs[1] = new VertexPositionColor(new Vector3((x + 1), (y + 0), (z + 0)), c);
            vs[2] = new VertexPositionColor(new Vector3((x + 1), (y + 0), (z + 0)), c);
            vs[3] = new VertexPositionColor(new Vector3((x + 1), (y + 1), (z + 0)), c);
            vs[4] = new VertexPositionColor(new Vector3((x + 1), (y + 1), (z + 0)), c);
            vs[5] = new VertexPositionColor(new Vector3((x + 0), (y + 1), (z + 0)), c);
            vs[6] = new VertexPositionColor(new Vector3((x + 0), (y + 1), (z + 0)), c);
            vs[7] = new VertexPositionColor(new Vector3((x + 0), (y + 0), (z + 0)), c);

            vs[8]  = new VertexPositionColor(new Vector3((x + 0), (y + 0), (z + 1)), c);
            vs[9]  = new VertexPositionColor(new Vector3((x + 1), (y + 0), (z + 1)), c);
            vs[10] = new VertexPositionColor(new Vector3((x + 1), (y + 0), (z + 1)), c);
            vs[11] = new VertexPositionColor(new Vector3((x + 1), (y + 1), (z + 1)), c);
            vs[12] = new VertexPositionColor(new Vector3((x + 1), (y + 1), (z + 1)), c);
            vs[13] = new VertexPositionColor(new Vector3((x + 0), (y + 1), (z + 1)), c);
            vs[14] = new VertexPositionColor(new Vector3((x + 0), (y + 1), (z + 1)), c);
            vs[15] = new VertexPositionColor(new Vector3((x + 0), (y + 0), (z + 1)), c);

            vs[16] = new VertexPositionColor(new Vector3((x + 0), (y + 0), (z + 0)), c);
            vs[17] = new VertexPositionColor(new Vector3((x + 0), (y + 0), (z + 1)), c);
            vs[18] = new VertexPositionColor(new Vector3((x + 0), (y + 1), (z + 0)), c);
            vs[19] = new VertexPositionColor(new Vector3((x + 0), (y + 1), (z + 1)), c);

            vs[20] = new VertexPositionColor(new Vector3((x + 1), (y + 0), (z + 0)), c);
            vs[21] = new VertexPositionColor(new Vector3((x + 1), (y + 0), (z + 1)), c);
            vs[22] = new VertexPositionColor(new Vector3((x + 1), (y + 1), (z + 0)), c);
            vs[23] = new VertexPositionColor(new Vector3((x + 1), (y + 1), (z + 1)), c);

            OutlineBuffer.SetData <VertexPositionColor>(OutlineLocation * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 24, VertexPositionColor.VertexDeclaration.VertexStride);
            OutlineLocation += 24;

            QEF3D   qef            = new QEF3D();
            Vector3 average_normal = new Vector3();

            for (int i = 0; i < 12; i++)
            {
                int c1 = edges[i, 0];
                int c2 = edges[i, 1];

                int m1 = (corners >> c1) & 1;
                int m2 = (corners >> c2) & 1;
                if (m1 == m2)
                {
                    continue;
                }

                float d1 = map[x + c1 / 4, y + c1 % 4 / 2, z + c1 % 2];
                float d2 = map[x + c2 / 4, y + c2 % 4 / 2, z + c2 % 2];

                Vector3 p1 = new Vector3((float)((c1 / 4)), (float)((c1 % 4 / 2)), (float)((c1 % 2)));
                Vector3 p2 = new Vector3((float)((c2 / 4)), (float)((c2 % 4 / 2)), (float)((c2 % 2)));

                Vector3 intersection = Sampler.GetIntersection(p1, p2, d1, d2);
                Vector3 normal       = Sampler.GetNormal(intersection + new Vector3(x, y, z));          //GetNormal(x, y);
                average_normal += normal;

                qef.Add(intersection, normal);
            }

            Vector3 p = qef.Solve2(0, 16, 0);

            Vector3 n = average_normal / (float)qef.Intersections.Count;

            VertexPositionColorNormal[] v2 = new VertexPositionColorNormal[1];
            Vector3 c_v = n * 0.5f + Vector3.One * 0.5f;

            c_v.Normalize();
            Color clr = new Color(c_v);

            v2[0] = new VertexPositionColorNormal(new Vector3((p.X + x), (p.Y + y), (p.Z + z)), clr, n);
            VertexBuffer.SetData <VertexPositionColorNormal>(VertexCount * VertexPositionColorNormal.VertexDeclaration.VertexStride, v2, 0, 1, VertexPositionColorNormal.VertexDeclaration.VertexStride);
            vertex_indexes[x, y, z] = VertexCount;
            VertexCount++;

            /*vs[0] = new VertexPositionColor(new Vector3((x + 0) , (y + 0) , 0), Color.Black);
             * vs[1] = new VertexPositionColor(new Vector3((x + 1) , (y + 0) , 0), Color.Black);
             * vs[2] = new VertexPositionColor(new Vector3((x + 1) , (y + 0) , 0), Color.Black);
             * vs[3] = new VertexPositionColor(new Vector3((x + 1) , (y + 1) , 0), Color.Black);
             * vs[4] = new VertexPositionColor(new Vector3((x + 1) , (y + 1) , 0), Color.Black);
             * vs[5] = new VertexPositionColor(new Vector3((x + 0) , (y + 1) , 0), Color.Black);
             * vs[6] = new VertexPositionColor(new Vector3((x + 0) , (y + 1) , 0), Color.Black);
             * vs[7] = new VertexPositionColor(new Vector3((x + 0) , (y + 0) , 0), Color.Black);
             *
             * vs[8] = new VertexPositionColor(new Vector3((p.X + x) , (p.Y + y) , 0), Color.Black);
             * vs[9] = new VertexPositionColor(new Vector3((p.X + x + .1f) , (p.Y + y + .1f) , 0), Color.Black);
             * index = 10;
             *
             * VertexBuffer.SetData<VertexPositionColor>(VertexCount * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, index, VertexPositionColor.VertexDeclaration.VertexStride);
             * VertexCount += index;*/
        }
Beispiel #6
0
        public void ConstructTreeGrid(OctreeNode node)
        {
            if (node == null)
            {
                return;
            }
            VertexPositionColor[] vs = new VertexPositionColor[24];
            int   x = (int)node.position.X;
            int   y = (int)node.position.Y;
            int   z = (int)node.position.Z;
            Color c = Color.LightSteelBlue;
            Color v = Color.Red;

            float size = node.size;

            vs[0] = new VertexPositionColor(new Vector3(x + 0 * size, y + 0 * size, z + 0 * size), c);
            vs[1] = new VertexPositionColor(new Vector3(x + 1 * size, y + 0 * size, z + 0 * size), c);
            vs[2] = new VertexPositionColor(new Vector3(x + 1 * size, y + 0 * size, z + 0 * size), c);
            vs[3] = new VertexPositionColor(new Vector3(x + 1 * size, y + 1 * size, z + 0 * size), c);
            vs[4] = new VertexPositionColor(new Vector3(x + 1 * size, y + 1 * size, z + 0 * size), c);
            vs[5] = new VertexPositionColor(new Vector3(x + 0 * size, y + 1 * size, z + 0 * size), c);
            vs[6] = new VertexPositionColor(new Vector3(x + 0 * size, y + 1 * size, z + 0 * size), c);
            vs[7] = new VertexPositionColor(new Vector3(x + 0 * size, y + 0 * size, z + 0 * size), c);

            vs[8]  = new VertexPositionColor(new Vector3(x + 0 * size, y + 0 * size, z + 1 * size), c);
            vs[9]  = new VertexPositionColor(new Vector3(x + 1 * size, y + 0 * size, z + 1 * size), c);
            vs[10] = new VertexPositionColor(new Vector3(x + 1 * size, y + 0 * size, z + 1 * size), c);
            vs[11] = new VertexPositionColor(new Vector3(x + 1 * size, y + 1 * size, z + 1 * size), c);
            vs[12] = new VertexPositionColor(new Vector3(x + 1 * size, y + 1 * size, z + 1 * size), c);
            vs[13] = new VertexPositionColor(new Vector3(x + 0 * size, y + 1 * size, z + 1 * size), c);
            vs[14] = new VertexPositionColor(new Vector3(x + 0 * size, y + 1 * size, z + 1 * size), c);
            vs[15] = new VertexPositionColor(new Vector3(x + 0 * size, y + 0 * size, z + 1 * size), c);

            vs[16] = new VertexPositionColor(new Vector3(x + 0 * size, y + 0 * size, z + 0 * size), c);
            vs[17] = new VertexPositionColor(new Vector3(x + 0 * size, y + 0 * size, z + 1 * size), c);
            vs[18] = new VertexPositionColor(new Vector3(x + 0 * size, y + 1 * size, z + 0 * size), c);
            vs[19] = new VertexPositionColor(new Vector3(x + 0 * size, y + 1 * size, z + 1 * size), c);

            vs[20] = new VertexPositionColor(new Vector3(x + 1 * size, y + 0 * size, z + 0 * size), c);
            vs[21] = new VertexPositionColor(new Vector3(x + 1 * size, y + 0 * size, z + 1 * size), c);
            vs[22] = new VertexPositionColor(new Vector3(x + 1 * size, y + 1 * size, z + 0 * size), c);
            vs[23] = new VertexPositionColor(new Vector3(x + 1 * size, y + 1 * size, z + 1 * size), c);

            OutlineBuffer.SetData <VertexPositionColor>(OutlineLocation * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 24, VertexPositionColor.VertexDeclaration.VertexStride);
            OutlineLocation += 24;

            /*if (node.type != OctreeNodeType.Leaf || node.draw_info.index == -1 || true)
             * {
             *      OutlineBuffer.SetData<VertexPositionColor>(outline_location * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 8, VertexPositionColor.VertexDeclaration.VertexStride);
             *      outline_location += 8;
             * }
             * else
             * {
             *      x += (int)(node.draw_info.position.X * (float)this.size);
             *      y += (int)(node.draw_info.position.Y * (float)this.size);
             *      float r = 2;
             *      vs[8] = new VertexPositionColor(new Vector3(x - r, y - r, 0), v);
             *      vs[9] = new VertexPositionColor(new Vector3(x + r, y - r, 0), v);
             *      vs[10] = new VertexPositionColor(new Vector3(x + r, y - r, 0), v);
             *      vs[11] = new VertexPositionColor(new Vector3(x + r, y + r, 0), v);
             *      vs[12] = new VertexPositionColor(new Vector3(x + r, y + r, 0), v);
             *      vs[13] = new VertexPositionColor(new Vector3(x - r, y + r, 0), v);
             *      vs[14] = new VertexPositionColor(new Vector3(x - r, y + r, 0), v);
             *      vs[15] = new VertexPositionColor(new Vector3(x - r, y - r, 0), v);
             *      OutlineBuffer.SetData<VertexPositionColor>(outline_location * VertexPositionColor.VertexDeclaration.VertexStride, vs, 0, 16, VertexPositionColor.VertexDeclaration.VertexStride);
             *      outline_location += 16;
             * }*/

            if (node.type == NodeType.Internal && node.vertices.Length == 0)
            {
                for (int i = 0; i < 8; i++)
                {
                    ConstructTreeGrid(node.children[i]);
                }
            }
        }