XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Vertex Format - duplication pos?

Last post 08-30-2008 10:21 AM by Ralf Kornmann. 1 replies.
  • 08-27-2008 12:12 AM

    Vertex Format - duplication pos?

    Consider this output I got from my maya exporter that I wrote, when exporting a textured cube:

    ----------------------------------------
    // Mesh Name
    pCubeShape1
    
    // Vertices
    // 
    // Format:
    // v[index] x y z
    v[0] -0.5 -0.5 0.5
    v[1] 0.5 -0.5 0.5
    v[2] -0.5 0.5 0.5
    v[3] 0.5 0.5 0.5
    v[4] -0.5 0.5 -0.5
    v[5] 0.5 0.5 -0.5
    v[6] -0.5 -0.5 -0.5
    v[7] 0.5 -0.5 -0.5
    
    // Colors
    // 
    // Format:
    // c[index] r g b a
    c[0] -1 -1 -1 -1
    c[1] -1 -1 -1 -1
    c[2] -1 -1 -1 -1
    c[3] -1 -1 -1 -1
    c[4] -1 -1 -1 -1
    c[5] -1 -1 -1 -1
    c[6] -1 -1 -1 -1
    c[7] -1 -1 -1 -1
    c[8] -1 -1 -1 -1
    c[9] -1 -1 -1 -1
    c[10] -1 -1 -1 -1
    c[11] -1 -1 -1 -1
    c[12] -1 -1 -1 -1
    c[13] -1 -1 -1 -1
    c[14] -1 -1 -1 -1
    c[15] -1 -1 -1 -1
    c[16] -1 -1 -1 -1
    c[17] -1 -1 -1 -1
    c[18] -1 -1 -1 -1
    c[19] -1 -1 -1 -1
    c[20] -1 -1 -1 -1
    c[21] -1 -1 -1 -1
    c[22] -1 -1 -1 -1
    c[23] -1 -1 -1 -1
    c[24] -1 -1 -1 -1
    c[25] -1 -1 -1 -1
    c[26] -1 -1 -1 -1
    c[27] -1 -1 -1 -1
    c[28] -1 -1 -1 -1
    c[29] -1 -1 -1 -1
    c[30] -1 -1 -1 -1
    c[31] -1 -1 -1 -1
    c[32] -1 -1 -1 -1
    c[33] -1 -1 -1 -1
    c[34] -1 -1 -1 -1
    c[35] -1 -1 -1 -1
    
    // Normals
    // 
    // Format:
    // n[index] x y z
    n[0] 0 0 1
    n[1] 0 0 1
    n[2] 0 0 1
    n[3] 0 0 1
    n[4] 0 1 0
    n[5] 0 1 0
    n[6] 0 1 0
    n[7] 0 1 0
    n[8] 0 0 -1
    n[9] 0 0 -1
    n[10] 0 0 -1
    n[11] 0 0 -1
    n[12] 0 -1 0
    n[13] 0 -1 0
    n[14] 0 -1 0
    n[15] 0 -1 0
    n[16] 1 0 0
    n[17] 1 0 0
    n[18] 1 0 0
    n[19] 1 0 0
    n[20] -1 0 0
    n[21] -1 0 0
    n[22] -1 0 0
    n[23] -1 0 0
    
    // UV Set
    // 
    // Format:
    // Set Name
    // uv[index] u v
    map1
    uv[0] 0.998102, 0.747899
    uv[1] 0.332801, 0.998073
    uv[2] 0.664636, 0.748652
    uv[3] 0.332383, 0.748515
    uv[4] 0.664103, 0.500466
    uv[5] 0.33185, 0.500133
    uv[6] 0.663684, 0.249599
    uv[7] 0.331431, 0.250208
    uv[8] 0.66323, 0.001333
    uv[9] 0.330977, 0.0019455
    uv[10] 0.000774436, 0.500205
    uv[11] 0.00138454, 0.748372
    uv[12] 0.998518, 0.499788
    uv[13] 0.665054, 0.998491
    
    
    // Polygon Set
    // 
    // Format:
    // Polygon Set Name
    // Texture Filepath
    // Faces Indices
    blinn1SG
    c:/Users/cpisz.HOMENETWORK/Documents/Visual Studio 2005/Projects/Maya_Import/dice.png
    0 1 2 3 4 5 6 7 8 9 10 11 
    
    
    // Faces
    // 
    // Format:
    // 'Face Index' 'Vertex Index' 'Normal Index' 'Color Index' 'UV Index - map1'
    0 0 0 0 13
    0 1 1 1 1
    0 2 2 2 2
    
    1 1 1 3 1
    1 3 3 4 3
    1 2 2 5 2
    
    2 2 4 6 2
    2 3 5 7 3
    2 4 6 8 4
    
    3 3 5 9 3
    3 5 7 10 5
    3 4 6 11 4
    
    4 4 8 12 4
    4 5 9 13 5
    4 6 10 14 6
    
    5 5 9 15 5
    5 7 11 16 7
    5 6 10 17 6
    
    6 6 12 18 6
    6 7 13 19 7
    6 0 14 20 8
    
    7 7 13 21 7
    7 1 15 22 9
    7 0 14 23 8
    
    8 1 16 24 11
    8 7 17 25 10
    8 3 18 26 3
    
    9 7 17 27 10
    9 5 19 28 5
    9 3 18 29 3
    
    10 6 20 30 12
    10 0 21 31 0
    10 4 22 32 4
    
    11 0 21 33 0
    11 2 23 34 2
    11 4 22 35 4
    


    Question 1)
    It would appear that the DirectX "Vertices" would be created for each face index in the maya file, making 36 vertices, although there are only 8 unique vertex positions. There are 24 unique vertex position & normal combinations. And then 12? extra unique postion-normal-uv combinations? All the examples in the SDK I saw contain both position and normal data in each vertex. Therefore I am duplicating position data 3 times for each vertex, as there are 3 possible normals, that seems rather wasteful...

    Is there a more efficient way to represent vertex positions, normals, and UVs, to minimize the duplication when creating a vertex for each unqiue combination of the 3?

    Question 2)
    I also don't understand why I have 14 UV coordinates.
    Since it is a cube, I understand 8 vertex positions, one for each corner of the cube. I also unerstand the 24 normals, as each corner is used 3 times for 3 differant faces of the cube. I don't understand how there are 14 UV coordinates.
    any idea why it came out that way?

    Question 3)
    Given the format of the incoming data from the exporter. How would you go about defining your vertices, buffers, and input layours in dx 10?

  • 08-30-2008 10:21 AM In reply to

    Re: Vertex Format - duplication pos?

    1.       No,  a cube with normals always needs 24 vertices. This may waste some memory but safe the GPU from implementing complex vertex fetch logic.

    2.       As the faces of your cubes are connected maya trys to create a UV mapping were connected point share the same UV coordinates. Again for a cube 14 UV coordinates is the best you can get.

    3.       The layout of your vertices should be dependent on your needs for rendering and not based on the output format of the exporter. Therefore most people use converters to transform the data offline and store the results.

Page 1 of 1 (2 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG