title: xna 4 vertex buffer and vertex declaration for varying triangle count
body: <p>I started a project based on the basic effect sample provided by microsoft. Then I appended keys input to move the camera. The final step is to load test 3d data from a DXF file. I wrote the DXF import myself, just simple 3dface objects representing 3d triangles. I adjusted the code in basic effect sample to read the variant vertex count. But I get an error Normal0 missing - even with the vertex declaration and vertex buffer in tact with correctly set vertices. I think the problem is in the vertex declaration. The original sample only have 12 triangles, my first sample DXF has about a thousand.
  I think the problem is in here:</p>
  
  <pre><code>private void CreateVertexBuffer()
  {
  vertexDeclaration = new VertexDeclaration(new VertexElement[]
      {
          new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
          new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
          new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
      }
  );
  vertexBuffer = new VertexBuffer(
      graphics.GraphicsDevice,
      vertexDeclaration,
      number_of_vertices,
      BufferUsage.None
      );
  Vertices = new VertexPositionNormalTexture[number_of_vertices];
  InitializeVerts();
  vertexBuffer.SetData&lt;VertexPositionNormalTexture&gt;(Vertices);
  graphics.GraphicsDevice.SetVertexBuffer(vertexBuffer);
  </code></pre>
  
  <p>}</p>
  
  <p>Vertex Element 12 ... Vertex Element 24 ... Are these the problem areas?</p>