示例#1
0
        public void FromGenMesh(GraphicsDevice _gd, GenMesh _mesh, bool _bComputeBounds)
        {
            //Clear GPU Buffers
            ClearGPUVBOBuffers();

            //Init
            m_npartsCount = 0;



            for (int i = 0; i < _mesh.m_genMeshParts.Count; i++)
            {
                GenMeshPart part    = _mesh.m_genMeshParts[i];
                MeshGPUPart partGPU = m_meshParts[i];

                //Vertices
                partGPU.m_gpuVertexBuffer = new VertexBuffer(_gd, typeof(VertexPosColorNorm), part.m_vertices.Count, BufferUsage.WriteOnly);
                partGPU.m_gpuVertexBuffer.SetData(part.m_vertices.ToArray(), 0, part.m_vertices.Count);

                //Indices
                partGPU.m_gpuIndexBuffer = new IndexBuffer(_gd, typeof(ushort), part.m_indices.Count, BufferUsage.WriteOnly);
                partGPU.m_gpuIndexBuffer.SetData(0, part.m_indices.ToArray(), 0, part.m_indices.Count);

                m_npartsCount++;
            }
        }
示例#2
0
        public int AddVertex(ref Vector3 _p, ref Color _c, ref Vector3 _norm)
        {
            m_vcount++;
            GenMeshPart part = m_genMeshParts[m_ncurPartIdx];

            part.m_vertices.Add(new VertexPosColorNorm(_p, _c, _norm));
            return(part.m_vertices.Count - 1);
        }
示例#3
0
        private void AddNewPart()
        {
            GenMeshPart part = new GenMeshPart();

            part.m_vertices = new List <VertexPosColorNorm>();
            part.m_indices  = new List <ushort>();
            m_genMeshParts.Add(part); //New part
            m_ncurPartIdx++;
            m_icount = 0;
        }
示例#4
0
        public void AddQuad(ushort _v0, ushort _v1, ushort _v2, ushort _v3)
        {
            GenMeshPart part = m_genMeshParts[m_ncurPartIdx];

            //Tri1
            part.m_indices.Add(_v0);
            part.m_indices.Add(_v1);
            part.m_indices.Add(_v2);
            //Tri2
            part.m_indices.Add(_v0);
            part.m_indices.Add(_v2);
            part.m_indices.Add(_v3);

            m_icount += 6;

            //Create New part if index buffer too big (>65536)
            if (m_icount > ushort.MaxValue - 6)
            {
                AddNewPart();
            }
        }
示例#5
0
        /// <summary>
        /// Clear vertices and indices
        /// </summary>
        public void Clear()
        {
            m_bGPUDirty = true;

            m_vcount      = 0;
            m_icount      = 0;
            m_ncurPartIdx = -1;

            for (int i = 0; i < m_genMeshParts.Count; i++)
            {
                GenMeshPart part = m_genMeshParts[i];
                if (part.m_vertices != null)
                {
                    part.m_vertices.Clear();
                }
                if (part.m_indices != null)
                {
                    part.m_indices.Clear();
                }
            }

            m_genMeshParts.Clear();
            AddNewPart();
        }