What's the formula for number of indices for a vertex array?

Sorry, I should be able to do this but I have coder’s block

I want to use indices into a vertex array to avoid duplication. What I’ve worked out so far is that for an n*n heightmp:

  1. number of unique vertices = n*n
  2. number of quads = (n-1)*(n-1)
  3. number of triangles = 2 * quads

What I want to know is the general formula for calculating the number of indices required. i.e. for a 33 there are 9 unique vertices but 12 indices or for a 44 there are 16 unique vertices but 24 indices.


edit a breath of fresh air can work wonders. (2n)(n-1)

[This message has been edited by swiych (edited 09-14-2003).]

For an mxn map, you will have: