Help loading .3DS files

Started by
7 comments, last by slyterence 22 years, 8 months ago
Hi guys, I''m learning to load .3DS files, but I''m having some trouble. I can read all the chunks up to the Face data, which is apparently structured as follows : Chunk ID, Size of the chunk, Number of Faces, Face Data. The text I have on reading files says I should then check to see if there''s a smoothing chunk, and some other chunk as well. In my model, there is a smoothing chunk, which I read as well. However, the end of the smoothing chunk is outside the end of the faces chunk, which means that I''m too far in the file, and everything else I read in is incorrect. Can someone please explain why the faces chunk is larger than it says it is? Also, how can I fix this problem? Thanks We scratch our eternal itch A twentieth century bitch We are grateful for Our Iron Lung
We scratch our eternal itchA twentieth century bitchWe are grateful forOur Iron Lung
Advertisement
After writing two different 3ds loaders I can say that you are probably reading the file wrong. You are probably going to have to count bytes and find out what part of your code is reading too many bytes. This format was discontinued 5 or 6 years ago and the documentation is crap. I often find undocumented chuncks but smoothing groups have never been a problem for me.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato
"... we should have such an empire for liberty as she has never surveyed since the creation ..."Thomas Jefferson
CKW, I dont suppose that you would be willing to give me a basic libarary for loading 3DS files??

I have made a program to load a 3DS file, however, I can only get it to load one mesh from the file. I am quite perplexed.

I can give you the one I wrote for a java program a year of so ago but it is broken in it''s current state. I can''t give the current one away until the group I am programming with decides on a license. If you have problems check with 3ds lib on sourceforge. I have seen many people say it is good. It however has a problem with the models we are using. DOn''t know what the deal was. Other than the occasional undocumented chuck it is a fairly simple format. If you are having problems it is because you are miscounting bytes. I will almost guarentee it. When I had a problem I would go through the binary counting bytes several times and it always came back to my code miscounting bytes. I would often accendentally add in the 6 byte offset more than once.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato
"... we should have such an empire for liberty as she has never surveyed since the creation ..."Thomas Jefferson
Yeah, I guess you''re probably right, because when I get back up to the previous chunk, I''m usually six bytes over, so I''ll double check that...

Thanks

$£¥

We scratch our eternal itch
A twentieth century bitch
We are grateful for
Our Iron Lung
Thanks for the help, I''ve got the problem sorted out now...

However, there''s a new problem. The model I was loading was just a simple box for debug purposes, but now I''m trying to load a model that has a box, and a sphere, as two separate objects. The first object loads properly, but I''m getting garbage after I read (0x4000) for the second object, and I don''t know what the data means.

Any help would be appreciated

Thanks

$£¥

We scratch our eternal itch
A twentieth century bitch
We are grateful for
Our Iron Lung
We scratch our eternal itchA twentieth century bitchWe are grateful forOur Iron Lung
What is the id number of the next chunk?

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato
"... we should have such an empire for liberty as she has never surveyed since the creation ..."Thomas Jefferson
At the moment I'm making a pass through the file first, to see the total number of faces and vertices that I'll need for the model. When I get to the first object's texture map chunk (0x4140 I think), I read in the current file position, and the size of the chunk, the same as I would do for any other chunk, but this is where the error seems to be.

The size data seems about correct, a couple of hundred bytes, but the address seems to be (0xFFFFFFFD) or something very high.

This means that when I skip this chunk, I'm jumping to the filepos (0xFFFFFFFD + about 256), which is way out of the file. The rest of the file (everything up to this point) seems fine, because I can find the other chunks, and the texture chunk, the chunk itself just says it's way outside the file.

We scratch our eternal itch
A twentieth century bitch
We are grateful for
Our Iron Lung

Edited by - slyterence on August 15, 2001 3:35:12 PM
We scratch our eternal itchA twentieth century bitchWe are grateful forOur Iron Lung
You can send me the .3ds file and I will take a look at it.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato
"... we should have such an empire for liberty as she has never surveyed since the creation ..."Thomas Jefferson

This topic is closed to new replies.

Advertisement