Add-ons and 3ds model files

The place to discuss creating, porting and modifying Celestia's source code.
Avatar
Topic author
piellepi M
Posts: 124
Joined: 25.09.2003
Age: 69
With us: 21 years 2 months
Location: Rome, Italy

Add-ons and 3ds model files

Post #1by piellepi » 28.01.2004, 15:22

Hi to you all!
I'd like to draw your attention to a fact concerning the use of model files (3ds) in Celestia.
Please pay attention and be very careful when you modify "3ds" files with Hexadecimal editors or other similar tools, whenever you want to change the name of texture files: as far as I can see, it happens that these tools don't correct all the relevant records in the file. 8O

The worst thing happens when you "add" bytes to the file (for example when you want to "correct" a shorter name with a longer one): in such a case the file becomes thoroughly corrupted. :(

I have started examining 3ds files with a hexadecimal reader and a good knowledge of the files: "3ds" files are record based files, each record made of these fields:
- a marker (a specific 16 bit pattern that describes the record)
- the length of the record itself (a long value, 32 bits) (marker+length+data)
- the record data

I found that many Celestia "3ds" files cannot be opened with Anim8or :? : so I started reading them with a Visual Basic parser (found in internet) and I always found that the culprit is one of the fields that is corrupted. :cry:
Perhaps Celestia doesn't complain about these strange records : I do wonder how it can show a model correctly, when neither anim8or nor the VB parser succeed in this task :)

As an example I read the file "graticule-blue.3ds" from Selden add-on (I have not yet tried it in Celestia...) : the parser bails out after reading the name of the texture ("graticule-blue.*") at the offset 0x170 of the file. :?:
This file can't be read because its length (0x1722 bytes) is wrong as compared with the length in the first record : at offset 0x2 you can read 0x171E, perhaps the original length of the file. (in this case we have : marker=0x4d4d, len=0x171e, data= the file itself!) :idea:
The worst thing is now that the string ("graticule-blue.*") is inside a record (starting at offset 0x16A, with the marker=0xA300), whose length is 0x13.
In such a record the string is practically truncated to a otherwise useless "graticule-blu" without any extension at all! :o

With this in mind, I can suppose that Celestia simply "searches" all the wanted records (a lot of them!), without worrying about "previous" or "following" records or record lengths, without parsing the file... and without bailing out! :D

This behavior is obviously correct: the important is that you can see the object in Celestia. :D
BTW I don't know if 3DStudio (or other 3D program) can import those files... :( :(

I will further investigate 8) other situations in which also Celestia has a strange behavior showing objects: I'll be clearer if you are interested in this matter. :roll:

Good bye
Pierluigi

jestr
Posts: 612
Joined: 14.09.2003
With us: 21 years 2 months
Location: Bridgwater,UK

Post #2by jestr » 28.01.2004, 15:45

You are right,I cannot open these files in 3DS Max.I havent tried the one you were on about I'll try now but when I tried to open Billboard files from Seldens site it said something like 'unknown file format' or something like this-even though it was a 3DS File.I'll try with the file you mention and see what happens,cheers Jestr

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #3by selden » 28.01.2004, 15:57

PierLuigi,

As I've mentioned often, I use Emacs to modify the filename within 3DS files. I only care that the resulting model file is readable by Celestia.

It's usually inappropriate to edit one of those files in a 3D modelling tool, anyhow, since they aren't the originals. In most cases, the original file specification format is 8.3, so I expect that using Emacs to restore the filespec to that size (8 characters in the name, 3 in the filetype, separated by a dot) would make such a file readable again by 3D modelling programs.

The models that I create are in AN8 format, which Celestia can't use. I'll consider including a copy of the .AN8 file in future Addons or when I update older ones.

It'd be nice if Celestia directly supported .AN8 format, since it's a plain-text file and provides many features that Chris has mentioned would be desirable.
Selden

Avatar
Topic author
piellepi M
Posts: 124
Joined: 25.09.2003
Age: 69
With us: 21 years 2 months
Location: Rome, Italy

Post #4by piellepi » 29.01.2004, 16:35

Hi,
today, at office, I was searching a free 3ds file reader and I found an interesting site about Delphi programming (http://www.delphi-gems.com/3ds.php). 8O
If you are interested in the matter, here you can find a program (opener.exe) by which you can open 3ds file and look at their secrets. 8)

The "graticule-blue.3ds" file can be read without problems, but instead there are problems with some of the files comprised in some add-ons by MindToAsk (in particular "M65.3ds" shows a bad format). :(

Selden, I don't know Emacs :cry: (instead I could suggest you "Hex Workshop") and I didn't understand what you said about 8.3 file name convention: I am a very old-but-skilled :D programmer (I started in the ancient "DOS 3.1 + ASM" epoch!! 8O ) and AFAIK the name "graticule-blue.3ds" does NOT follow the old and infamous :x 8.3 convention. :wink:

I'll continue my investigations.

Pierluigi

PS: IMHO Celestia is the GREATEST :lol: program I have ever used and I find it VERY useful in my hobby !!
I am an amateur astronomer: I started studying astronomy just the night (for Italy...) Louis Armstrong first set foot upon the moon, in 1969!

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #5by selden » 29.01.2004, 17:15

Pierluigi,

If you want to "fix" one of the 3DS graticule files that I created, you need to edit them using a binary-friendly editor (like Emacs) and change the length of the name so that it has a total length of 12 characters. The original filename was "12345678.jpg" which is 8.3.

"graticule-blue.*" is 14.1 -- 16 characters long. If you change the name to "gratblue.jpg" the file probably will be readable by a 3D modelling program.

Ensuring that my *very* simple models are editible by 3D modelling programs is not one of my goals. Having filenames that are understandable by people and by Celestia is.

The graticules are only three objects: two squares and a sphere.
Selden

bh
Posts: 1547
Joined: 17.12.2002
With us: 21 years 11 months
Location: Oxford, England

Post #6by bh » 30.01.2004, 00:17

This is very interesting...I personally have not had any trouble importing 3ds models into Anim8tor...although if there are any any problems with the models I'm producing...I'd like to know about it.

Regards..bh.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #7by selden » 30.01.2004, 00:27

bh,

This filename length problem is due to the way I edit the 3DS model files to change the texture image file name after Anim8or has exported the 3DS files. I suspect most models won't have this particular problem. Since the models have to be edited to specify Celestia's wildcard filetype, and that's not compatible with Anim8or either, I simply can't get excited about the fact that the different length causes problems, too.

I've heard rumors that Anim8or does choke on some other 3DS models (models not intended for Celestia), but I don't know the details.
Selden


Return to “Development”