• Create Account

### #ActualSimonForsman

Posted 03 April 2012 - 06:26 AM

Your problem most likely resides here (as I have tried to point out several times before in multiple threads). Have you tried debugging the problem? (I'm inferring a Visual Studio/Windows setup here.)

nope.avi

strcat is fine, its the way the object memory is handeled

throw strcat("Unable to load ", filename.c_str());

is not fine, read the strcat documentation, while it isn't the cause of your problem it will cause problems if a model fails to load.

i see a few more things:

you are assuming that you'll have 3 times as many vertices and tex coords as faces, this isn't necessarily the case. It shouldn't be possible to have more than 3x the facecount though so in worst case you're only wasting memory, the 3ds format however does support indices which you aren't using, (so i assume you are exporting it so that faces never share vertices (otherwise it wouldn't render properly) its not a very efficient way to do things though. (as your VBOs will be alot bigger than they need to be).
(Other model formats might also allow the number of texcoords to be different from the number of vertices (.3ds doesn't seem to support that though)
(Its still worth reading the vertex and texcoord count from the mesh data rather than making assumptions about it)

This part might warrant a error check and could possibly be the source of your problem:

if(mesh->texels)
{
memcpy(&texCoords[FinishedFaces*3 + i], mesh->texelL[face->points[ i ]], sizeof(Lib3dsTexel));
//NEW
}



If there are no texture coordinates exported in the 3ds file nothing will get copied to texCoords and you'll be using an uninitialized buffer (containing random data) which could be the cause of your wierd results.

### #1SimonForsman

Posted 03 April 2012 - 06:22 AM

Your problem most likely resides here (as I have tried to point out several times before in multiple threads). Have you tried debugging the problem? (I'm inferring a Visual Studio/Windows setup here.)

nope.avi

strcat is fine, its the way the object memory is handeled

throw strcat("Unable to load ", filename.c_str());

is not fine, read the strcat documentation, while it isn't the cause of your problem it will cause problems if a model fails to load.

i see a few more things:

you are assuming that you'll have 3 times as many vertices and tex coords as faces, this isn't necessarily the case. It shouldn't be possible to have more than 3x the facecount though so in worst case you're only wasting memory, the 3ds format however does support indices which you aren't using, (so i assume you are exporting it so that faces never share vertices (otherwise it wouldn't render properly) its not a very efficient way to do things though. (as your VBOs will be alot bigger than they need to be).
(Other model formats might also allow the number of texcoords to be different from the number of vertices (.3ds doesn't seem to support that though)

This part might warrant a error check and could possibly be the source of your problem:

if(mesh->texels)
{
memcpy(&texCoords[FinishedFaces*3 + i], mesh->texelL[face->points[ i ]], sizeof(Lib3dsTexel));
//NEW
}



If there are no texture coordinates exported in the 3ds file nothing will get copied to texCoords and you'll be using an uninitialized buffer (containing random data) which could be the cause of your wierd results.

PARTNERS