This is an odd problem. I’m reading values from a text file into different arrays. If I print out the array value right after it has been assigned in the loop, it is correct. However, if I try to access the value after the loop is completed, I get zero - EXCEPT for the values assigned during the final loop!
Here is my code:
for(int f=0; f< mesh[i][m].faces; f+=1)
{
x.next();
//System.out.println(x.next());
mesh[i][m].fmaterial[f] = x.nextInt();
mesh[i][m].ftype[f] = x.next();
mesh[i][m].fgeo[f] = x.nextInt();
mesh[i][m].flight[f] = x.nextInt();
mesh[i][m].ftex[f] = x.nextInt();
mesh[i][m].fextralight[f] = x.nextFloat();
mesh[i][m].fverts[f] = x.nextInt();
mesh[i][m].setvert(f);
for(int v=0; v<mesh[i][m].fverts[f]; v+=1)
{
mesh[i][m].fvert[f][v] = x.nextInt();
//System.out.println(mesh[i][m].fvert[v][vnum]);
mesh[i][m].ftexvert[f][v] = x.nextInt();
//System.out.println(mesh[i][m].ftexvert[v][vnum]);
}
}
for(int f=0; f<mesh[i][m].faces; f+=1)
{
for(int v=0; v<mesh[i][m].fverts[f]; v+=1) //only the final loops values are correct??
{
System.out.println(mesh[i][m].fvert[f][v]+", "+mesh[i][m].ftexvert[f][v]);
}
}
And example output:
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
4, 4
7, 3
6, 2
5, 5
Any thoughts on this?