> > i've just found a bug which caused some 3ds models to not be loaded at all. some of you may have noticed it. anyway, the bug turned out to be caused exactly by something i had suspected months ago, maybe a year ago, but i only bothered to check it now. also, the code to correct it was already written by me but i had remarked it out to put something else in it's place. maybe someday i will explain to you why i'm so strange sometimes :D
> Maybe you could explain what causes the bug?
ok if that makes you happy. there were chunks labelled shininess amount which i use to multiply to the reflection amount. i actually don't know why they added this variable because they already have red, green, and blue reflectiveness written in one single color chunk. that's enough, but since they included another variable which seems to be overall reflection i decided to include that too and just multiply it to the color components. actually there are 3 different chunks which are labelled as shininess. honestly i think they are not that at all but something else and whoever wrote the document doesn't know what they are talking about. anyway i just went along with it. i thought if it was wrong then 3dsmax users would notice and tell me. unfortunately they haven't done that yet, probably because anyone who can use 3ds max cannot use my viewer until now hopefully, since i've made it a windows program finally.
anyway, these shininess chunks each contain just one other chunk which is a percentage chunk. there are 2 different percentage chunks: one chunk ID signifies that the percentage is written as a 2 byte integer and the other signifies that it's a 4 byte float. i originally wrote my code to check which of the 2 chunks the percentage chunk was. but then i thought my code looked too messy and i thought they probably just used one of those all the time in there. so i rewrote the code to assume only one of those percentage chunks was used all the time in there and then i checked a few models and they all worked fine. then later i started seeing few models that didn't load anything at all; they were just invisible models, and i had forgotten about what i had done with that shininess chunk. anyway after a while i suspected that the reason those models were not loading was because my loader function had become derailed because i was reading something to the wrong length so it would then just be reading things all wrongly after that point; it would be reading raw data and thinking it was chunk IDs or vice versa and basically not looking at the right spots to find any more of the chunks at all. a complete mess. then i remembered how i had made that assumption with the shininess chunks and i thought to myself, that would cause it to derail if the assumption was wrong. i finally decided now to check if I was right about the cause that i had suspected all these months. it took me a few seconds to reinstate the old code. those models now worked. the end.