Sign in to follow this  
  • entries
    135
  • comments
    130
  • views
    52445

ARGH!

Sign in to follow this  
VisualLR

133 views

I'm really pulling my hair out on this one...

So, I'm filling up this vertex buffer with data imported from a file. When I build up the buffer, I'm printing out the texture coordinates to my log file, at this point they are correct. When I build my index buffer, I'm printing out all the contents of the vertex buffer, using the indices into the vertex buffer (I started doing this for debugging). Now on this pass, the UV's have changed, they are no longer correct, EXCEPT, for the last 2 faces (the last 6 tris are correct).

What's scary is that I'm not doing anything with the vertex buffer at between those two things, so something is not telling the truth, I wish I could say that the printing out of the full vertex buffer was wrong, but the scary part is that I see the wrong results in the rendering.

I've gone over the code so many times, everything looks fine...

This is just bizarre, check this out:


for ( i=0; i < mesh->_topo->_NbFaces; i++ )
{
CImpFace* srcFace = mesh->_topo->_Faces;

DPrint("--- Face: %d", i);
for ( uint16 ref = 0; ref < 3; ++ref )
{
uint16 vIndex = srcFace->VertexRef[ref];
vertices[vIndex].u = srcFace->UV[ref][0].u;
vertices[vIndex].v = srcFace->UV[ref][0].v;

DPrint("%d: %.2f %.2f %.2f [ %.2f %.2f ]", vIndex, vertices[vIndex].x, vertices[vIndex].y, vertices[vIndex].z, vertices[vIndex].u, vertices[vIndex].v);
}
}




This prints out correctly:

--- Face: 0
0: -20.00 -20.00 0.00 [ 1.00 0.00 ]
2: -20.00 20.00 0.00 [ 1.00 1.00 ]
3: 20.00 20.00 0.00 [ 0.00 1.00 ]


Now, when I do this:


for ( i=0; i < mesh->_topo->_NbFaces; i++ )
{
CImpFace* srcFace = mesh->_topo->_Faces;

for ( uint16 ref = 0; ref < 3; ++ref )
{
uint16 vIndex = srcFace->VertexRef[ref];

DPrint("%d: %.2f %.2f %.2f [ %.2f %.2f ]", vIndex, vertices[vIndex].x, vertices[vIndex].y, vertices[vIndex].z, vertices[vIndex].u, vertices[vIndex].v);
}
}












If you notice, I'm not doing anything except printing the data again (I got rid of anything else other than this just to isolate this behavior).

This is the result:

0: -20.00 -20.00 0.00 [ 1.00 0.00 ]
2: -20.00 20.00 0.00 [ 0.00 0.00 ]
3: 20.00 20.00 0.00 [ 0.00 0.00 ]

And my cube reflects the incorrect texture mapping.

So annoying, I hate problems like this.

Here's what it looks like:

Sign in to follow this  


2 Comments


Recommended Comments

What happens if you put those code snippets immediately after each other, with no other code inbetween. Does it print the correct values then?

Share this comment


Link to comment

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