Sign in to follow this  
DJTN

Duplicating Mesh

Recommended Posts

DJTN    207
I’m trying to duplicate a mesh and combine them both into one mesh. I’ve started out with a simple mesh of a cube (box). I then take that working mesh and pass it to a method where I create a new mesh-> 2 times the faces and vertices of the original mesh, with the same vertex format. I then lock the vertex and index buffers and fill them accordingly (based off the original mesh). Then, since I’m rendering with Draw Subsets, I create an attribute table based off the materials.


The original mesh and the duplicate render everything except the sides of each (left and right side of cube missing on both). I checked my indices in the index buffer and it looks like it should however, when creating the data for the second mesh I use the index data from the first and add the original meshes number of vertices to it. If I subtract eight from that number the original mesh renders fine but the duplicated mesh only renders the front and top. Apparently there is something wrong with the index data. How should I calculate the index data for the duplicating mesh?


[b]Index data for missing sides:[/b]

index[0]=0
index[1]=1
index[2]=2
index[3]=2
index[4]=3
index[5]=0
index[6]=4
index[7]=5
index[8]=6
index[9]=6
index[10]=7
index[11]=4
index[12]=8
index[13]=9
index[14]=10
index[15]=10
index[16]=11
index[17]=8
index[18]=12
index[19]=13
index[20]=14
index[21]=14
index[22]=15
index[23]=12
index[24]=24
index[25]=25
index[26]=26
index[27]=26
index[28]=27
index[29]=24
index[30]=28
index[31]=29
index[32]=30
index[33]=30
index[34]=31
index[35]=28
index[36]=32
index[37]=33
index[38]=34
index[39]=34
index[40]=35
index[41]=32
index[42]=36
index[43]=37
index[44]=38
index[45]=38
index[46]=39
index[47]=36



[b]Index data for duplicate only rendering front and top:[/b]

index[0]=0
index[1]=1
index[2]=2
index[3]=2
index[4]=3
index[5]=0
index[6]=4
index[7]=5
index[8]=6
index[9]=6
index[10]=7
index[11]=4
index[12]=8
index[13]=9
index[14]=10
index[15]=10
index[16]=11
index[17]=8
index[18]=12
index[19]=13
index[20]=14
index[21]=14
index[22]=15
index[23]=12
index[24]=16
index[25]=17
index[26]=18
index[27]=18
index[28]=19
index[29]=16
index[30]=20
index[31]=21
index[32]=22
index[33]=22
index[34]=23
index[35]=20
index[36]=24
index[37]=25
index[38]=26
index[39]=26
index[40]=27
index[41]=24
index[42]=28
index[43]=29
index[44]=30
index[45]=30
index[46]=31
index[47]=28

Share this post


Link to post
Share on other sites
DJTN    207
Could this have something to do with my buffer being 16bit? I wouldnt think so as I'm only storing 48 indices. Anyone?

Share this post


Link to post
Share on other sites
DJTN    207
Wow, I feel stupid. For some reason I thought the number of indices would be the same as the number of vertices in the mesh, hence why I was missing sides. I cannot explain my brain fart :(

For anyone else that finds this post with similar issues:


[indent]When you go to fill the indexbuffer you'll need to set the array up to store the number of faces multiplied by 3. Do not configure your indices (index data) in your verticies data loop.


[/indent]Hope this helps someone else...


Cheers,
Dj

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this