Exemplo n.º 1
0
        /// <summary>
        /// Called prior to loading the vert data.  Allocates the memory arrays to hold
        /// the pristine vertex data.
        /// </summary>
        /// <param name="Format">Which type of vertex this mesh uses.</param>
        /// <param name="Count">How many verts are in the mesh.</param>
        public void AllocateVertexBuffer(MeshFormat Format, int Count)
        {
            m_MeshFormat  = Format;
            m_VertexCount = Count;

            if (m_MeshFormat == MeshFormat.Model)
            {
                //local (non-DX) copy of verts
                m_ModelVerts = new MODEL_VERT[Count];
                for (int i = 0; i < Count; i++)
                {
                    m_ModelVerts[i] = new MODEL_VERT();
                }

                //allocate DX buffer (this is the one that will get recreated on device reset)
                m_VertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionNormalTextured), m_ModelVerts.Length, MdxRender.Dev,
                                                  Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionNormalTextured.Format, Pool.Default);
            }
            else if (m_MeshFormat == MeshFormat.Bsp)
            {
                //local (non-DX) copy of verts
                m_BspVerts = new PositionTexture2[Count];
                for (int i = 0; i < Count; i++)
                {
                    m_BspVerts[i] = new PositionTexture2();
                }

                //allocate DX buffer (this is the one that will get recreated on device reset)
                m_VertexBuffer = new VertexBuffer(typeof(PositionTexture2), m_BspVerts.Length, MdxRender.Dev,
                                                  Usage.WriteOnly, PositionTexture2.Format, Pool.Default);
            }

            //add an event handler to recreate verts on device reset
            m_VertexBuffer.Created += new EventHandler(this.OnVertexBufferCreate);
        }
Exemplo n.º 2
0
 public void LoadVertex(int index, float X, float Y, float Z, float Nx, float Ny, float Nz, float U, float V)
 {
     m_ModelVerts[index]        = new MODEL_VERT();
     m_ModelVerts[index].dxv.X  = X;
     m_ModelVerts[index].dxv.Y  = Y;
     m_ModelVerts[index].dxv.Z  = Z;
     m_ModelVerts[index].dxv.Nx = Nx;
     m_ModelVerts[index].dxv.Ny = Ny;
     m_ModelVerts[index].dxv.Nz = Nz;
     m_ModelVerts[index].dxv.Tu = U;
     m_ModelVerts[index].dxv.Tv = V;
     boundingBox.Update(X, Y, Z);
 }
Exemplo n.º 3
0
        public void LoadH1ModelVertexData(int VertIndex, ref BinaryReader br, byte[] buffer, float UScale, float VScale, MapfileVersion ver)
        {
            m_ModelVerts[VertIndex] = new MODEL_VERT();

            if (ver == MapfileVersion.XHALO1)
            {
                m_ModelVerts[VertIndex].LoadCompressed(ref br, buffer, UScale, VScale);
            }
            else
            {
                m_ModelVerts[VertIndex].Load(ref br, buffer, UScale, VScale);
            }

            boundingBox.Update(m_ModelVerts[VertIndex].dxv.X, m_ModelVerts[VertIndex].dxv.Y, m_ModelVerts[VertIndex].dxv.Z);
        }