Exemple #1
0
        // this function will count the number of quads for our terrain
        int Primitive_Count(CVolumeBuffer volume)
        {
            int count = 0;

            int size = volume.Size;

            for (int z = 0; z < size; ++z)
            {
                for (int y = 0; y < size; ++y)
                {
                    for (int x = 0; x < size; ++x)
                    {
                        int value = volume.GetData(new Vector3(x, y, z));
                        // if we are in the blank space check and see if there is any valid terrain around us
                        if (value == 0)
                        {
                            if (volume.GetData_BoundarySafe(new Vector3(x + 1, y, z)) > 0)
                            {
                                count++;
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x - 1, y, z)) > 0)
                            {
                                count++;
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y + 1, z)) > 0)
                            {
                                count++;
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y - 1, z)) > 0)
                            {
                                count++;
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y, z + 1)) > 0)
                            {
                                count++;
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y, z - 1)) > 0)
                            {
                                count++;
                            }
                        }
                    }
                }
            }

            return(count);
        }
Exemple #2
0
        public void Generate(CVolumeBuffer outVolume)
        {
            int size = outVolume.Size;

            for (int z = 1; z < size - 1; ++z)
            {
                for (int y = 1; y < size - 1; ++y)
                {
                    for (int x = 1; x < size - 1; ++x)
                    {
                        float xf = (float)x / size;
                        float yf = (float)y / size;
                        float zf = (float)z / size;
                    }
                }
            }
        }
        public void Generate(CVolumeBuffer outVolume)
        {
            int size = outVolume.Size;

            for (int z = 1; z < size - 1; ++z)
            {
                for (int y = 1; y < size - 1; ++y)
                {
                    for (int x = 1; x < size - 1; ++x)
                    {
                        float xf = (float)x / size;
                        float yf = (float)y / size;
                        float zf = (float)z / size;

                    }
                }
            }
        }
        public void Generate(CVolumeBuffer outVolume)
        {
            int size = outVolume.Size;

            for (int z = 1; z < size - 1; ++z)
            {
                for (int y = 1; y < size - 1; ++y)
                {
                    for (int x = 1; x < size - 1; ++x)
                    {
                        Byte value = 1;
                        outVolume.SetData(value, new Vector3(x, y, z));
                    }
                }
            }

            //outVolume.SetData(1, new Vector3(size/2, size/2, size/2));
        }
Exemple #5
0
        public void Generate(CVolumeBuffer outVolume)
        {
            int size = outVolume.Size;

            for (int z = 1; z < size - 1; ++z)
            {
                for (int y = 1; y < size - 1; ++y)
                {
                    for (int x = 1; x < size - 1; ++x)
                    {
                        Byte value = 1;
                        outVolume.SetData(value, new Vector3(x, y, z));
                    }
                }
            }

            //outVolume.SetData(1, new Vector3(size/2, size/2, size/2));
        }
Exemple #6
0
        public void Load()
        {
            m_BasicRenderer.Load();
            m_currPostprocessChain = new CPostprocessor();

            CVolumeBuffer volData = new CVolumeBuffer();
            volData.Initialize(32);

            // generator
            var dataGenerator = new CVolumeDataGenerator_Rnd();
            dataGenerator.Generate(volData);

            // terrain graphic
            CVolumeRenderer dataRenderer = new CVolumeRenderer();
            dataRenderer.Load();
            dataRenderer.Generate(volData);
            m_TerrainRenderer = dataRenderer;

            m_ParticleRenderer.Load();
        }
        public void Generate(CVolumeBuffer outVolume)
        {
            Random rnd = new Random();
            int size = outVolume.Size;

            for (int z = 1; z < size - 1; ++z)
            {
                for (int y = 1; y < size - 1; ++y)
                {
                    for (int x = 1; x < size - 1; ++x)
                    {
                        Byte value = 0;
                        if (rnd.NextDouble() > 0.5f)
                        {
                            value = 1;
                        }
                        outVolume.SetData(value, new Vector3(x, y, z));
                    }
                }
            }
        }
Exemple #8
0
        public void Generate(CVolumeBuffer outVolume)
        {
            Random rnd  = new Random();
            int    size = outVolume.Size;

            for (int z = 1; z < size - 1; ++z)
            {
                for (int y = 1; y < size - 1; ++y)
                {
                    for (int x = 1; x < size - 1; ++x)
                    {
                        Byte value = 0;
                        if (rnd.NextDouble() > 0.5f)
                        {
                            value = 1;
                        }
                        outVolume.SetData(value, new Vector3(x, y, z));
                    }
                }
            }
        }
Exemple #9
0
        public void Generate(CVolumeBuffer volume)
        {
            int quad_count = Primitive_Count(volume);
            int tri_count  = quad_count * 2;
            int vert_count = tri_count * 3;
            // calculate total vertices we need
            List <FatVertex> verts = new List <FatVertex>(vert_count);

            int size = volume.Size;

            for (int z = 0; z < size; ++z)
            {
                for (int y = 0; y < size; ++y)
                {
                    for (int x = 0; x < size; ++x)
                    {
                        int value = volume.GetData(new Vector3(x, y, z));
                        if (value == 0)
                        {
                            if (volume.GetData_BoundarySafe(new Vector3(x + 1, y, z)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[1].Clone();
                                newQuad.Translate(new Vector3(x + 1, y, z));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x - 1, y, z)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[0].Clone();
                                newQuad.Translate(new Vector3(x - 1, y, z));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y + 1, z)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[3].Clone();
                                newQuad.Translate(new Vector3(x, y + 1, z));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y - 1, z)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[2].Clone();
                                newQuad.Translate(new Vector3(x, y - 1, z));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y, z + 1)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[5].Clone();
                                newQuad.Translate(new Vector3(x, y, z + 1));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y, z - 1)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[4].Clone();
                                newQuad.Translate(new Vector3(x, y, z - 1));
                                verts.AddRange(newQuad.verts);
                            }
                        }
                    }
                }
            }

            var vb = Engine.Global.Device3d.CreateBuffer(new Device3dD3d11.SCreateBufferCmd()
            {
                Name            = "VolumeDataVB",
                SizeInBytes     = (int)vert_count * m_VertDesc.SizeInBytes,
                BufferBindFlags = BindFlags.VertexBuffer
            });

            m_MeshDesc.VBBinding = new VertexBufferBinding(vb, m_VertDesc.SizeInBytes, 0);

            // update data buffer
            Engine.Global.Device3d.UpdateBufferData("VolumeDataVB", new DataStream(verts.ToArray(), false, false));
            m_MeshDesc.VertexCount = vert_count;
        }
        public void Generate(CVolumeBuffer volume)
        {
            int quad_count = Primitive_Count(volume);
            int tri_count = quad_count * 2;
            int vert_count = tri_count * 3;
            // calculate total vertices we need
            List<FatVertex> verts = new List<FatVertex>(vert_count);

            int size = volume.Size;

            for (int z = 0; z < size; ++z)
            {
                for (int y = 0; y < size; ++y)
                {
                    for (int x = 0; x < size; ++x)
                    {
                        int value = volume.GetData(new Vector3(x, y, z));
                        if (value == 0)
                        {
                            if (volume.GetData_BoundarySafe(new Vector3(x + 1, y, z)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[1].Clone();
                                newQuad.Translate(new Vector3(x + 1, y, z));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x - 1, y, z)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[0].Clone();
                                newQuad.Translate(new Vector3(x - 1, y, z));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y + 1, z)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[3].Clone();
                                newQuad.Translate(new Vector3(x, y + 1, z));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y - 1, z)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[2].Clone();
                                newQuad.Translate(new Vector3(x, y - 1, z));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y, z + 1)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[5].Clone();
                                newQuad.Translate(new Vector3(x, y, z + 1));
                                verts.AddRange(newQuad.verts);
                            }
                            if (volume.GetData_BoundarySafe(new Vector3(x, y, z - 1)) > 0)
                            {
                                CQuad newQuad = m_LookupMesh[4].Clone();
                                newQuad.Translate(new Vector3(x, y, z - 1));
                                verts.AddRange(newQuad.verts);
                            }
                        }
                    }
                }
            }

            var vb = Engine.Global.Device3d.CreateBuffer(new Device3dD3d11.SCreateBufferCmd()
            {
                Name = "VolumeDataVB",
                SizeInBytes = (int)vert_count * m_VertDesc.SizeInBytes,
                BufferBindFlags = BindFlags.VertexBuffer
            });
            m_MeshDesc.VBBinding = new VertexBufferBinding(vb, m_VertDesc.SizeInBytes, 0);

            // update data buffer
            Engine.Global.Device3d.UpdateBufferData("VolumeDataVB", new DataStream(verts.ToArray(), false, false));
            m_MeshDesc.VertexCount = vert_count;
        }
        // this function will count the number of quads for our terrain
        int Primitive_Count(CVolumeBuffer volume)
        {
            int count = 0;

            int size = volume.Size;

            for (int z = 0; z < size; ++z)
            {
                for (int y = 0; y < size; ++y)
                {
                    for (int x = 0; x < size; ++x)
                    {
                        int value = volume.GetData(new Vector3(x, y, z));
                        // if we are in the blank space check and see if there is any valid terrain around us
                        if (value == 0)
                        {
                            if (volume.GetData_BoundarySafe(new Vector3(x + 1, y, z)) > 0) count++;
                            if (volume.GetData_BoundarySafe(new Vector3(x - 1, y, z)) > 0) count++;
                            if (volume.GetData_BoundarySafe(new Vector3(x, y + 1, z)) > 0) count++;
                            if (volume.GetData_BoundarySafe(new Vector3(x, y - 1, z)) > 0) count++;
                            if (volume.GetData_BoundarySafe(new Vector3(x, y, z + 1)) > 0) count++;
                            if (volume.GetData_BoundarySafe(new Vector3(x, y, z - 1)) > 0) count++;
                        }
                    }
                }
            }

            return count;
        }