Blender cmod export script (updated)

Post requests, images, descriptions and reports about work in progress here.

Moderator: selden

Blender cmod export script (updated)

Postby cartrite » Thu Sep 17, 2009 5:44 am

After I redid the cmod export script while working with John Van Vliet last week, I decided to try and take it one step further. This script has been tested on a model from the Celestia Motherlode called sts-67. I didn't change anything, I just imported the 3ds file and saved it as a blend file. Then I exported it. This model had 644 meshes and 644 material definitions. If this is not correct, let me know. So the script should be able to export almost anything. Let me know if it doesn't. This script assigns UV textures to each mesh in the cmod file with material indexing. It also assigns diffuse and specular colors to each mesh.

A problem that I still have seems to be with this model and the way Blender imports the 3ds file. Some of the normals get flipped. So the bay doors (as seen from above) and parts of the nose are invisible. I could probably edit the file and flip the normals, but that has nothing to do with the export script.

EDIT. I found problems when I worked with the Atlantis model so I deleted the script. Back to the drawing board. I'll upload it again after it passes further tests.
cartrite
open Suse 11.1 ,Athlon64 3200+ 3gb ram, GeForce9800gt video card with 1gb ram
User avatar
cartrite
 
Posts: 1674
Joined: Thu Sep 15, 2005 7:55 am
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Postby cartrite » Thu Sep 17, 2009 11:55 am

This was tested with Endeavour, Atlantis, and the Asgard Warship. All from the Motherlode. Endeavour came in first place with 644 meshes and materials. 8O :D
Then came Atlantis. That package had 3 models. Normal and in space had 215 meshes and materials. Cargo doors open had 222 meshes and materials. The launch vehicle had 261. The Asgard Warship had 51 meshes and materials. There are probably some 3ds files or blend files that will fail but it's better now than it has been. It should probably do planets just as well. Did John Van Vliet's phobos blend model without any problems.
viewtopic.php?p=117793#p117793
This file was last updated on Sun September 20, 2009.
Updates include a warning for file overwrites and abilities to export more materials. These include emissive, specpower, and opacity. More overwrite protection.

cartrite
Last edited by cartrite on Sun Sep 20, 2009 7:13 am, edited 6 times in total.
open Suse 11.1 ,Athlon64 3200+ 3gb ram, GeForce9800gt video card with 1gb ram
User avatar
cartrite
 
Posts: 1674
Joined: Thu Sep 15, 2005 7:55 am
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Postby Vorthon » Fri Sep 18, 2009 5:18 am

Just one question: Would I just be able to throw somehing together in blender and use the script without saving? Just curious.
http://vorthon.deviantart.com <- My deviantart account
http://vorthon.proboards.com <- WorldBuilding Forum
User avatar
Vorthon
 
Posts: 37
Joined: Tue Apr 21, 2009 5:27 am
Location: Nova Porilad, Tenorias System

Re: Blender cmod export script (updated)

Postby cartrite » Fri Sep 18, 2009 6:09 am

Vorthon wrote:Just one question: Would I just be able to throw somehing together in blender and use the script without saving? Just curious.

I'm not sure what you mean. If you create a model in Blender from scratch, you save it as a .blend file, right? This script doesn't change the blend file unless you change the default name to a file that already exists. It automatically appends a .cmod extension unless you remove that extension. It removes the .blend extension. In other words, if you have a file called foo.blend and want to create foo.cmod, just run the export script. It will automatically remove the .blend and put .cmod in it's place. Now if you change that automatically produced filename, it will overwrite/destroy a file if it already exists. So be careful here. I'll look into adding overwrite protection. But that protection will only be a confirm overwrite tab. I may be able to automatically rename the file so no overwrites are possible. I'll look into this also. Currently, if you already had a file called foo.cmod, it will overwrite it. So be careful here too.
cartrite
open Suse 11.1 ,Athlon64 3200+ 3gb ram, GeForce9800gt video card with 1gb ram
User avatar
cartrite
 
Posts: 1674
Joined: Thu Sep 15, 2005 7:55 am
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Postby Vorthon » Fri Sep 18, 2009 6:56 am

cartrite wrote:
Vorthon wrote:Just one question: Would I just be able to throw somehing together in blender and use the script without saving? Just curious.

I'm not sure what you mean. If you create a model in Blender from scratch, you save it as a .blend file, right? This script doesn't change the blend file unless you change the default name to a file that already exists. It automatically appends a .cmod extension unless you remove that extension. It removes the .blend extension. In other words, if you have a file called foo.blend and want to create foo.cmod, just run the export script. It will automatically remove the .blend and put .cmod in it's place. Now if you change that automatically produced filename, it will overwrite/destroy a file if it already exists. So be careful here. I'll look into adding overwrite protection. But that protection will only be a confirm overwrite tab. I may be able to automatically rename the file so no overwrites are possible. I'll look into this also. Currently, if you already had a file called foo.cmod, it will overwrite it. So be careful here too.
cartrite


What I meant was, If I used the script after making a model from scratch but before saving it.
http://vorthon.deviantart.com <- My deviantart account
http://vorthon.proboards.com <- WorldBuilding Forum
User avatar
Vorthon
 
Posts: 37
Joined: Tue Apr 21, 2009 5:27 am
Location: Nova Porilad, Tenorias System

Re: Blender cmod export script (updated)

Postby cartrite » Fri Sep 18, 2009 7:24 am

What I meant was, If I used the script after making a model from scratch but before saving it.
That is a dangerous practice. Why would you want to do that? I would save the file in blend format before running anything on it. Then you can export it.
For some 3ds models, the model disappeared after exporting so I had to open it again. This doesn't happen with all models and I'm not sure why it happens. Probably because the models I tested were not completely imported into Blender. Object Mode was the only mode available. It hasn't happened with a fully imported functional model.
cartrite
open Suse 11.1 ,Athlon64 3200+ 3gb ram, GeForce9800gt video card with 1gb ram
User avatar
cartrite
 
Posts: 1674
Joined: Thu Sep 15, 2005 7:55 am
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Postby cartrite » Sat Sep 19, 2009 9:12 am

The script was updated today. The updates included a warning for file overwrites, emissive export, specpower export, and opacity export.
cartrite
open Suse 11.1 ,Athlon64 3200+ 3gb ram, GeForce9800gt video card with 1gb ram
User avatar
cartrite
 
Posts: 1674
Joined: Thu Sep 15, 2005 7:55 am
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Postby cartrite » Sun Sep 20, 2009 7:10 am

Updated again on Sunday. This will probably be the last update for a while. But I am going to keep playing around with it. The next thing I want to do is create a QT4 GUI using PyQT4. It will also default to using Blender's FileSelector Window if PyQT4 is not available. I hope. Anyhow this update has more overwrite protection. The Blender File Selector should open up in the current working directory with a default filename called 'untitled.cmod'. If you have a file that is currently being worked on, it will open up with that basename - the .blend extension and + .cmod extension. If the file already exists, it will automatically add a _# before the extension. Where # is a number beyond the latest number. So if you have a file called foo.cmod, it will display foo_1.cmod. If you already have foo_1.cmod, foo_2.cmod will be displayed and so on. If you change the name, it will be possible to change it to another file that already exists. In that case, an overwrite warning should be displayed. If you click on that warning the file will be overwritten. If you move the cursor off of the warning, it should return to the window without overwriting.
blender-cmod-exporter-2.zip
This should be the last update for this unless someone reports problems.
(14.81 KiB) Downloaded 48 times


cartrite
Last edited by cartrite on Thu Sep 24, 2009 1:26 pm, edited 17 times in total.
open Suse 11.1 ,Athlon64 3200+ 3gb ram, GeForce9800gt video card with 1gb ram
User avatar
cartrite
 
Posts: 1674
Joined: Thu Sep 15, 2005 7:55 am
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Postby BobHegwood » Sun Sep 20, 2009 11:26 am

Don't know if I will *ever* be smart enough to figure out how to use Blender correctly, but I
would just like to express my sincere appreciation for all you are doing here, Cartrite. :wink:

Much appreciated by the Brain-Dead (and I'm sure, others.)
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN
User avatar
BobHegwood
 
Posts: 1734
Joined: Fri Oct 12, 2007 2:41 pm

Re: Blender cmod export script (updated)

Postby john Van Vliet » Mon Sep 21, 2009 1:10 pm

i will have a go with the update and let you know if there are any problems .
(USA,Michigan)
running : Arch Linux & CentOS 5.4 - Nvidia GForce 2 mx 400 (NVIDIA-x86-96.43.13-pkg1.run)
I don't pitch Linux to my friends, I let Microsoft do that for me!
http://celestiamotherlode.net/catalog/s ... ator_id=10
User avatar
john Van Vliet
 
Posts: 1293
Joined: Wed Aug 28, 2002 3:08 pm
Location: Michigian U.S.A.

Re: Blender cmod export script (updated)

Postby cartrite » Mon Sep 21, 2009 6:12 pm

Updated again, Monday September 21, 2009.
There was still one thing that bugged me. Blender's File Selection Window can be tricky sometimes. I had gotten careless a few times and overwrote a good file .blend and destroyed it. So I added one more layer of protection from overwrites. Now a backup will be created with a "~" character affixed to the end of the original file. If a name is changed to a Blender .blend file, it will back that up with a "2" affixed to the end. I uploaded the new file to my previous post.
viewtopic.php?p=117793#p117793
cartrite
open Suse 11.1 ,Athlon64 3200+ 3gb ram, GeForce9800gt video card with 1gb ram
User avatar
cartrite
 
Posts: 1674
Joined: Thu Sep 15, 2005 7:55 am
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Postby cartrite » Tue Sep 22, 2009 8:22 pm

Updated again, Tuesday September 22, 2009.
I decided on a different approach to file overwrite protection. Make it impossible. :wink: I decided to rename the file after the export button has been pushed. If a possible overwrite occurs, the script will put a number _ extension at the end of the file. If you run Blender from a terminal, a message will be printed out telling you the new name of the file. If it ever fails, let me know. There are also 3 other messages that should be printed on the terminal every time. There is a counter for materials, meshes, and a test counter. These 3 counters that should all match or something went wrong with the export.

I did get a GTK gui to partially work. I can use the GTK File Chooser to select the filename. QT4 has a ways to go yet though.
I probably won't be uploading them anytime soon though.
The newest file is still here.
viewtopic.php?p=117793#p117793
cartrite
open Suse 11.1 ,Athlon64 3200+ 3gb ram, GeForce9800gt video card with 1gb ram
User avatar
cartrite
 
Posts: 1674
Joined: Thu Sep 15, 2005 7:55 am
Location: Pocono Mountains, Pennsylvania, USA


Return to Add-on development

Who is online

Users browsing this forum: Google [Bot] and 1 guest