Blender 3DS export project

Rayvel,

I'm new on the forums and I was browsing since I just bought G4 and was pleasantly surprised to this thread on exporting models from Blender. I'm one of the blender developers and actually wrote the original 3DS import/export scripts for blender a few years ago (it was even more buggy than the ones included now :eek: ).

Would you mind if I used your script to help update the 3DS export in Blender? If there is anything that I can do to help, please let me know. Also, do you know if KE plans on releasing the KEX format documents? I'd be happy to help build an exporter/importer for it.

cheers,

Bob
 
Hello Bob,

nice to hear that another programmer showing interest in this project. I'm working very long with the scripts from rayvel under blender. So here's an overview what the script does at the moment:

It creates a .3ds - file with working naming conventions (in object, and material names) and correct hierarchy with node support in the .3ds - file. In addition it creates a .sup - file. The empty's of blender are used as pivot points to define the rotational axis for rudder, elevator, ailerons and all that stuff. The connection between which pivot is referring to which 3D - Object is generated over the properties dialog in blender. These properties are exported to the .sup - file. After .3ds - file and .sup - file is exported blender automatically fires up the 3ds2kex.exe, which is reading out .3ds and .sup - file and generates the .kex - file for the Realflight Simulator. The script is compatible with the official version 2.45 of blender, but I'm already working with it under one of the new release candidates 2.46 without problems. The script supports generating aircafts for G3.5 as well as G4.0 (the new beta - 3ds2kex - exporter).

At the moment there are only 2 bugs left, which might not be solveable by changing the script.

1:

It seems that the .3ds - file format is limitated to the convention that one vertex - coordinate can only carry one UV - Texture - Coordinate, so the script is doubling each vertex on a seam line, leading to the effect that one object is getting hard edges, because the faces are surfaced smoothed individually according how you splitting the whole object up into different UV - Regions for texturing. I've already made a bug - report here.

2: Together with the new 3ds2kex - beta exporter, we have control over advanced features like individual surface smoothing of objects and animated light effects. The light effects are already working, but are only accesable by editing the .sup - file manually. Global Surface Smoothing values are crashing G4 during import of the .kex - file. KnifeEdge is (hopefully) already working on this problem.

Point 1 is the big problem. 2 is secondary. If no smoothing values are applied all objects are brutally smoothed under 60°, which can lead to bad shadow - effects on the objects. So in general, I control the surface smoothing over the Edge - Split - Modifier in blender. But this trick only works as long as my UV - Mapping is not interferring the work of the the Edge - Split - Modifier. Many thanks for your interest in this project.

I don't know how much interest KnifeEdge is showing in releasing the .kex - file documentation, to write a direct .kex - exporter for blender. An official statement would be good.

Greets,

Max
 
Bob - I'd be happy to contribute to the official Blender release. In fact I have been planning to circle back with this script to the Blender source but just have not had the time. If you'd like to take it from here I would be more than happy.

Drop me a PM if you'd like to sync up over email.

As for KEX specs they have not shown any signs to release their proprietary format to the public. The only reason at this point would be to overcome the UV-mapping seams and smoothing as Max mentioned. Could always try to export a non-standard 3DS file providing more than 1 UV coordinate for a vertex but I've no idea what impacts this would have on the KEX converter.

... and welcome to the forums and RF!! Look forward to your involvement!

About the script...
The script has had quite extensive modification to properly support 3DS exporting, at least as far as things look good in Deep Exploration and the sim (I don't actually have a copy of 3dsmax).

It needs some cleanup and commenting for a few of the last revisions, but I have tried to identify the areas of change. I'll add some further comments here which may help, you're free to take the script source and use as you please (especially since you are the primary copyright holder!!)

  • Line 54: New imports, needs some cleanup. Use of Blender Registry would probably be removed as this is only used for the KEX features
  • Line 65-117: Would be removed as this is the registry stuff for KEX only
  • Line 124: "sane_name" method added "buckets" to hold unique names per object type (material, img file, objects, etc) and isFilename indicator. If it is a filename a warning is printed if the name is longer than 12 characters (3ds maximum supported). What I have seen other applications do is they will create copy of the file using 12 characters max name but I have not implemented this at this time.
  • Line 175-183: Added 4 new 3DS chunks for specularity, transparency, percentage and masterscale
  • Line 235 & 253 & 367: Needed to change the file packing method for shorts to handle >32767 values separately from others. Changed int packing method. Changed face packing method.
  • Line 521: Re-enabled COLOR2 chunk
  • Line 526: Added PERCENT chunk
  • Line 540: Small fix in add image method
  • Line 560: Image name inclusion in material name (need to review this if needed or not needed)
  • Line 570-580: Added specularity, reflectivity, transparency output. Used default values as noted from Blender (1, 0.2, 0) if no material is used
  • Line 582-584: Removed output of the material image. Exported ONLY uses the UV-mapping image(s). Could possibly make some changes here for more general purpose usage. Exporting both material image and UV image caused problems with KEX converter (KEX wants 1 image only)
  • Line 619: Changes usage of face.v to face.verts
  • Fun begins...
  • Line 796: Must use this function to get the true local space matrix of an object (the localspace returned by the object directly is wrong, or at least not something 3DS is happy to use)
  • Line 817-883: Mesh objects for 3DS must use a matrix relative to the parent object, which is different than Blender. So must do a bunch of math to convert from Blender's matrix to 3DS matrix.
  • Line 885-908: Re-enabled kfdata. I made some changes to the function but really they could be backed out and instead pass the appropriate values to the input parameters (see comments)
  • Line 911-944: Changed math for track chunks. Main thing to watch for is Blender's scripting will sometimes use radians and sometimes degrees so need to make some conversions back and forth here
  • Line 946-1020: Main changes are empties export using their name (not DUMMY) for KEX support. Also the computation of the rotation, scale and position relative to parent.
  • Line 1023-1137: KEX only stuff
  • Line 1170-1182: Note the CS_GLOBALOPTIONS stuff is KEX only
  • Line 1233-1266: Retrieve object matrix and some conversion from radians to degrees, typically pass rotations around as quaternions
  • Line 1309-1337 & 1348: KEX only
 
Rayvel,

Thanks. I'll see about pushing your changes upstream. I should have some time this weekend. I also contacted KE about the KEX format, but have not heard back yet.

Cheers,

Bob
 
blender

hi i have downloaded blender but when i try and open a file, it tells me there is an error, and its not a blender file, can you edit a current aircraft with it or does the file have to be made from scratch thanks bill :mad: oh by the way my version is 2.48a
 
Blender 2.48a is incompatible with the scirpt. Download Blender 2.47 and python 2.5.2....than the 3ds2kex - script should work together with the 3ds2kex converter

Greets,

Max
 
Blender 2.48a work fine but ...

Blender 2.48a work fine for Me but I change this line in script to not use International characters (change international to similar english):
-------------------
__author__ = ["Campbell Barton", "Bob Holcomb", "Richard Larkang", "Damien McGinnes", "Mark Stijnman"]
--------------------

I prepare complete my Edge540 in this blender version and export it do RF G4.5 .
All work fine.

Rads.
 
Hi,

I have tried the script but I'm getting from 3ds max 'Improper file format' error. I'm trying to import 60MB blend file. (23 MB in 3ds format).

please does anybody know that what can be the problem?
 
The script was created to generate a .3ds - file, which is useable for the 3ds2kex - exporter, not to create a .3ds - file for 3dsmax. The internal .3ds - export script from blender is not working with the latest version of 3dsmax....

Greets,

Max
 
Thanks for the tip on the problem with the latest version of blender. There is a new version 0.99 attached to the thread that fixes this problem with the international characters. No other changes in this version.
 
miroslav_karpis said:
Hi,

I have tried the script but I'm getting from 3ds max 'Improper file format' error. I'm trying to import 60MB blend file. (23 MB in 3ds format).

please does anybody know that what can be the problem?

In general the 3ds2kex export script should produce a 3DS file compatible with both Max and Deep Exploration - though this is largely untested. During my (limited) testing everything loaded correctly in Deep Exploration trial version. Since I don't own either Deep Exploration or Max I can't really do any more on this front. If you are able to produce a smaller blend project that doesn't open correctly in Max, I'd be happy to work with you over PM (send me the blend file) and try to make the necessary fixes.

I have been contacted by a person using the script to produce exports for a game called Trackmania and he has altered the script so it works with Trackmania models. It could be his script (Creating Custom Cars with Freeware) will work for your particular blend file and produce a result that works in Max. Give it a try!
 
Corrected Script Version for Blender 2.49a

Hello,

this is the script of rayel added by the small changings of post #67. It will now directly work with blender 2.49a. Attached as .g3x - file and .txt file.

Installation instructions:

1 ) Rename .g3x to .zip
2 ) Extract
3 ) Place the export_3ds2kex.py - file into your blender - scripts folder (Location depends on where you have choosen it during the installation of blender)
4 ) Have fun

or:

1) Rename export_3ds2kex.txt to export_3ds2kex.py
2 ) Place the export_3ds2kex.py - file into your blender - scripts folder (Location depends on where you have choosen it during the installation of blender)
3 ) Have fun

Greets,

Max
 

Attachments

  • export_3ds2kex.g3x
    12.2 KB · Views: 136
  • export_3ds2kex.txt
    43.8 KB · Views: 123
Export script on Vista

Hi I'm new to this forum and am just starting to work on building objects to add to v 4.5. So first off thanks for building this exporter. It seems so much easier than the gmax path (although I'm yet to have success)!

I've had a little bit of trouble getting the export module to work on my system:
Blender: 2.49b
Python: 2.6.2
Windows Vista SP-2

Basically if I use the script from posting #1 (v99a) the export option does not appear in blender (on the above configuration).
However if I use the script from posting #72 the export option does appear in blender.
My suspicion is that there are some spurious characters in the first 3 bytes of the file that cause python/blender to choke on the script (v99a).
Hopefully I've uploaded this version which removes the initial characters and updated the version number to 99b (and a number of lines have automatically had trailing spaces removed - which I hope aren't significant in python)

Oh and for those of you trying to find the blender scripts directory on Vista try:
C:\Users\your_user_name\AppData\Roaming\Blender Foundation\Blender\.blender\scripts
 

Attachments

  • export_3ds2kex.txt
    43.5 KB · Views: 51
how to

Hi,

I have the following configuration:
Blender 2.49b
3ds2kex converter (stable and beta too)

I followed this how to and, all the other i found on this forum, but i still have no success.

I created a realy simple modell (attached), and name everything accordingly to the guidelines, but when i create the KEX file, the parts dosen't show up in RealFlight under Visual Mesh, and i can't associate them with the objects!

I used the ~CS_SOMETHING naming convention, and partented the objects in blender too.

i would be happy if anyone could help.
 

Attachments

  • glider1.zip
    40.6 KB · Views: 26
Here Try This!

Hope the Zipping Worked.See Posts #48 & #49 that's where Problem Was.Twisted Pivot on your Rudder.Look at Shading Button(F5) in .blend file and notice the special Realflight Name given to the Material(~SBS).At the bottom of this Page http://www.knifeedge.com/KEmax/plane_tutorial.php there are some more.Good Luck!... :)
 

Attachments

  • Glider1c.zip
    85.6 KB · Views: 30
Thanks, that was quick, and helpfull!

I'll modify it and post it on the forum later!

lupus

bosshawg said:
Hope the Zipping Worked.See Posts #48 & #49 that's where Problem Was.Twisted Pivot on your Rudder.Look at Shading Button(F5) in .blend file and notice the special Realflight Name given to the Material(~SBS).At the bottom of this Page http://www.knifeedge.com/KEmax/plane_tutorial.php there are some more.Good Luck!... :)
 
dbc1012 said:
Hi I'm new to this forum and am just starting to work on building objects to add to v 4.5. So first off thanks for building this exporter. It seems so much easier than the gmax path (although I'm yet to have success)!

I've had a little bit of trouble getting the export module to work on my system:
Blender: 2.49b
Python: 2.6.2
Windows Vista SP-2

Basically if I use the script from posting #1 (v99a) the export option does not appear in blender (on the above configuration).
However if I use the script from posting #72 the export option does appear in blender.
My suspicion is that there are some spurious characters in the first 3 bytes of the file that cause python/blender to choke on the script (v99a).
Hopefully I've uploaded this version which removes the initial characters and updated the version number to 99b (and a number of lines have automatically had trailing spaces removed - which I hope aren't significant in python)

Oh and for those of you trying to find the blender scripts directory on Vista try:
C:\Users\your_user_name\AppData\Roaming\Blender Foundation\Blender\.blender\scripts

Even with this latest change, for me, the script still didn't appear in the export menu. I had to save it as ANSI instead of UNICODE. There were somehow 3 unicode characters still at the top of the file and Blender doesn't seem to like that.
 
I'm missing something. I can export my models, convert them, import them into realflight and most things are going well for me as I learn this process.

I found the posts in this thread on auto-creating the kex file. That is nice but up until this point I've been editing the .sup file to rename my collision meshes. It seems when I auto generate the kex file with the export script that it doesn't do that. I then, fix the .sup file again and generate the kex again. Am I missing something? It seems there would be a way to not have to edit the .sup file if the point is to generate a kex file with the export script.

Great work all!
 
Hi all,

I'm using Blender 2.49b (the 64-bit version) along with Python 2.6.6 (64-bit version) on Windows 7.

I had to rename the script to "3ds2kex_export.py" to get it to show up. No biggie there.

I have a fairly simple DLG, the MiMi. It's rudder/elevator only. The model has been created an now it's just down to details.

Do you need to have all the object centers (besides movable surfaces) at the CG or some other common point?

Which axis of rotation should the control surfaces have? Should elevators pivot around X while rudders pivot around Z? What about ailerons on a dihedral wing?

Speaking of ailerons, several DLG designs use a split aileron (kinda like a Corsair flap) and usually use tape to connect the aileron parts together for pivoting. If I have 2 or 3 ailerons per wing, what is the best way to actuate these as a single surface?

Now I just need to figure out how to wrap an image around my glider.


Thanks for the help...
 
Orientation of pivots:

As it comes to setting up pivot points in blender you can use empties or dummy objects and assign the local orientation of the empty/dummy object as pivot to the parent object in hierarchy. For the orientation we stick to the KE Documentation, which you can find for aircrafts here. So rotation happens around the x-axis of the pivot by default. When the control surfaces rotate in the wrong direction simply change the rotational axis of the pivot (dummy object or empty).

Central Orientation of objects:


Each pivot point of any object which is not moving should be centered within the object itself. After the modelling phase of the aircraft is over I tend to use the command "Apply Scale and Rotation to ObData" (Shortcut would be STRG+A) reseting the pivots of all objects selected to their three dimensional centers and aligning their orientation to the global axis. Remember not to execute this command when hierarchy between objects is applied. It can lead to strange reorientation of objects.

3D-object setup:

In general the three dimensional model of the aircraft is completely seperated from the physical model/behavior in Realflight. But there are special cases, especially in break up or crash situations where the 3D-object hierarchy has to be a specific form in order to prevent errors. I always say the 3D-object hierarchy has to mimic the physical setup in the aircraft editor. Every control surface or aircraft part in the aircraft editor is forced to have his own unique 3D-object (or no 3D-object at all) to be simulated in the proper way.

Example:

So if you have a left wing consisting of three wing parts ~CS_LMW1, ~CS_LMW2 and ~CS_LMW3 and an aileron which is consisting only of one object you have to split up the aileron into three object (one aileron per wing part) ~CS_LMA1, ~CS_LMA2, ~CS_LMA3 too. Linking every wing part in the aircraft editor to only one aileron object (or vice versa) leads to an error of Realflight, often resulting in the break away of one of the wing parts while the physical simulation of the attached aileron continues. Because every wing part has the same aileron object as control surface, Realflight cannot decide if the aileron is still on the wing or not. This can lead to the weirdest visual effects like planes with no wings attached flying like nothing has happend :)

I hope you now know a little bit more what you have to look for to get you model to fly right in Realflight...

Max
 
Back
Top