Blender 3DS export project

rayvel

New member
Current Version: 0.99

For those interested in creating RF models using Blender, you are painfully aware of the issues with the current 3DS export files. The python export script contained several issues, primarily the node structure was not exported as part of the 3DS file. I have been working to fix these problems and have a functional script ready for public testing.

The attached zip contains an updated blender 3DS export script. Unzip the file export_3ds2kex.py into the blender scripts directory (C:\Program Files\Blender Foundation\Blender\.blender\scripts). This is the same directory that will contain the original 3ds_export.py file.

Once the file is copied, next step is to open blender. It will automatically add a new export option under File->Export, "3D Studio 4KEX".

I'll cover a few points in this thread:
1. Naming
2. Parenting
3. Pivot points

The end goal of this project is to completely eliminate the need for post-processing and to simply use the Knife Edge tool 3DS2KEX. i.e. No using 3D Studio, no use of Deep Exploration either.

Naming convention

The naming convention exported to 3DS and into the KEX file comes from the object names and UV texture name. Whatever name you give the object "Fuselage", "~CS_RMW", "~CS_RMA", etc are the ones you will see in the RF aircraft editor. Simply name your object what you would like to see in RF. This is done on the Object panel (F7) in the Buttons window. For example, "OB: ~CS_RMW"

The colour scheme name comes from the UV texture name. This is set on the UV/Image Editor window. When you texture map the model, open the TGA image on the UV/Image Editor window and the default name will be "YourFilename.TGA". Rename this to whatever you want the colour scheme to be called on import.



Updated Nov 7/07: Script updated to v0.94 with a lot of help from maxkop and his DG-800A model! Some highlights:
- Can now completely create aircraft model in Blender!
- Just run 3ds2kex to complete the process
- Rotations now work correctly for multiple levels of hierarchy
- Fixed material naming with UV textures
- Will only export UV textures (not the blender 'game engine' texture)
- Material reflectivity exported (e.g. Lambert shader)
- Material specularity exported (e.g. CookTor shader)
- Material alpha exported (aka Opacity for easy canopies)
- Note: Texture filenames must be less than or equal to 12 characters long (e.g. "12345678.tif") and must be in the same directory as the exported 3DS file for 3ds2kex to find the texture file

Once again thanks to maxkop for all the assitance and being the guinea-pig to iron out all the bugs in the script!! Look for his DG-800A soon!

Update Nov 12/07: New version 0.96 includes automatic creation of custom SUP file and is able to call 3DS2KEX utility for 1-click KEX file creation!
- Can include NUP_ parameters such as "NUP_LandingGear" and "NUP_MaxRotationXDEG", etc.
- Refer to page 2 of thread for screenshots and explanation
- Pending work on NUP parameters for lighting effects and smoothing. Might not be possible since 3DS2KEX does not appear to support these features (only in the 3ds max plugin...)
- NOTE renamed script so if you have the old version please delete the file '3ds_export_4kex.py' from blender script directory

Update Nov 12/07: Version 0.97 includes ability for alternate pivot objects.

Update Dec 16/07: Not a version update, just changed the attachment format. Script is attached as both .TXT file (place in Blender scripts directory and rename from .TXT to .PY). Also attached ZIP file with .G3X extension to avoid the forum's "corrupt archive" problem. Rename the .G3X file to .ZIP and extract the script.

Update Jan 20/08: Version 0.98. Lots of improvements:
1. Will detect ~CS_GLOBALOPTIONS object and will automatically copy any parameters of this object to all other objects
2. Objects can override the ~CS_GLOBALOPTIONS parameter with their own value
3. Objects can override their 'IsPivot', 'Pivot', 'Parent' and even 'Name' values in the SUP file by using a parameter
4. See the 3ds2kex output in the console window for blender, which uses the "-s -v3" command-line parameters to call 3ds2kex
5. Once you run the script once you will have a new option in the SCRIPTS CONFIGURATION editor which lets you turn on BETA 3ds2kex.exe features. This will include the "STRING:" "BOOL:" "FLOAT:" qualifiers in the SUP file.
6. Parent name: It will first use the value from the blender object hierarchy, next will use the CS_GLOBALOPTIONS Parent property (should never use this!!), finally will take the value from the object's Parent property

Update Dec 16/08: Version 0.99 updated with proper encoding. No longer throw error with latest version of blender.
 

Attachments

  • export_3ds2kex_v099.g3x
    12.2 KB · Views: 1,782
  • export_3ds2kex.txt
    43.8 KB · Views: 2,785
Last edited:
Parenting

The parenting selection available in blender is used to determine the node structure of the output.

Parenting is straightforward to configure in blender:
  1. First select the child node with right-click (in the example it is the right aileron ~CS_RMA)
  2. Hold shift and select the parent node with right-click (~CS_RMW)
  3. Once both objects are selected hit Ctrl-P to assign parent
  4. Click on the 'Make Parent' option to complete the assignment

It is important to select the child node first otherwise the parenting goes in the wrong direction. Take a look at the Outliner window to see and confirm the node structure.
 

Attachments

  • 1_make_parent.gif
    1_make_parent.gif
    11.9 KB · Views: 327
Pivot Points - Positioning

Proper configuration of the pivot points is crutial to functioning ailerons and other moving parts of the model. This script makes use of the object centre point as the pivot point of the object. There are two steps to get the pivot points right. First the pivot point must be positioned relative to the object.

We need to position the cursor where we want the pivot point, then using the cursor we can assign a new centre to our object.

Position cursor
  • Switch to edit mode (dropdown in the first image, bottom near the middle)
  • Make sure you are in vertex selection mode (button with 4 dots in the first image, bottom right)
  • The goal is to get the selection point (white circle with red/green/blue arrows) where you want the pivot point to go
  • The selection point will move to the average between the vertexes you select, so if you select 2 vertexes then the selection point will be placed between these 2 points
  • In the example I have selected the 2 vertexes at the leading edge/middle of the aileron
  • Now we "snap" the cursor to the selection point
  • Shift-S, then select "Cursor -> Selection"

Okay, at this point the cursor is where you want your pivot point. Let's take a look where the object's centre really is.

Show the object axis
  • Showing the object axis tells us where the centre point is and where your pivot point will go.
  • Switch back to object mode and go to the object panel on the buttons window (F7).
  • Under 'Draw Extra' click the 'Axis' button as shown in the attachment.

The object axis is shown as the pink X/Y/Z axis and pink centre point. As you can see from the attached image this is currently at the centre of the object, not where we want it.

Move the centre point

Finally go to the editing panel on the buttons window (F9). In the 'Mesh' area click 'Center Cursor' to move the pivot point to the cursor location.

The third picture shows the correctly placed centre/pivot point.
 

Attachments

  • 2_snap_cursor.jpg
    2_snap_cursor.jpg
    85 KB · Views: 245
  • 3_show_axis.jpg
    3_show_axis.jpg
    63.7 KB · Views: 231
  • 4_move_center.jpg
    4_move_center.jpg
    92.9 KB · Views: 215
Pivot Points - Rotating

Often the case is the aileron is not directly positioned along the worldspace axis. We might need to rotate the pivot point. This is done using a two step process in blender.

First, rotate the object (and pivot point). Next, rotate the underlying mesh points in the opposite direction. The end result is the pivot point is rotated and the object itself has not moved.

This is easiest done by typing in the rotation angles rather than using the mouse.

Rotate the Object
  • In 'Object' mode type 'R' to enter rotation mode.
  • Next type 'Y' to force rotation along the Y axis.
  • Type in the value '90' which rotates the object as shown in the first image.

Rotate the mesh
  • Switch to 'Edit' mode
  • Select all the vertexes hit 'A' once or twice to do this
  • Type 'R' to enter rotation mode
  • Next type 'Y' to force rotation along the Y axis
  • Type in the value '-90' which rotates the object back to its original orientation (see second image)

Take a look at the final product in the third image. The pivot point/centre axis has been rotated 90 degrees around the Y axis so that the X axis now points down and the Z to the right.
 

Attachments

  • 5_rotate_object.gif
    5_rotate_object.gif
    10.1 KB · Views: 123
  • 6_rotate_mesh.gif
    6_rotate_mesh.gif
    12.1 KB · Views: 118
  • 7_final_centre.gif
    7_final_centre.gif
    8.1 KB · Views: 135
This is still a work in progress script and has not been completely tested - your mileage may vary.

So far I have confirmed importing a simple block-mesh with uv texture mapping and rotating ailerons. Engine parts, gear, etc have not been put through this yet so I would appreciate any input.

If someone has a good blend file I'd be happy to work with you over PM to fix any remaining issues with the script.

The script could be altered to run the 3ds2kex.exe file so the output from the script is not a 3DS but the final KEX product. This would involve some user preferences being set to point to the installed 3ds2kex directory. Really it is not a problem to run 3ds2kex from the command-line but if there is a big call for this I'll look to include in the script at some point in the future.
 
Interesting. Since the 3DS import in Blender 2.44 seems to be completely broken, I suspected the export is broken as well. If it isn't, improving it is a way to go as well.

About the Pivots: moving the object center seems a little tricky, especially when it comes to rotating. Wouldn't it be easier to use an empty object as pivot and make it the child of the actual object?
Then when exporting, an empty called "pivot" would be used as the object's pivot.
 
Yes, the 3DS import is also completely broken. It seems the previous code caused 3D Studio to crash and it was disabled, but still there. There were issues with the way it handled the object positioning and rotation. Hopefully the fixes result in a 3DS output that doesn't crash 3D Studio.

Your point about adding a child object called 'pivot' is interesting, but using the native feature of blender to move the object centre around seems more intuitive (to me anyways). How does 3D Studio handle object pivots? I don't have the software so can't make any basis of comparison.

One benefit to using object centre as the pivot point is you can type 'R' 'X' 'X' (R then two times X). This forces rotation about the object's local X axis and will show you how the object will rotate in RF. Using a child object would not allow for this test. The other option might be to use the armatures/bones feature of Blender but my limited reading on the subject made it look like not a great fit to serve as pivot points.

As I said before, if anyone is seriously attempting to use Blender for RF models I'd be happy to work with you over PM/email to iron out any remaining issues in the script. For those who don't want to or can't shell out to buy (or otherwise 'acquire') Deep Exploration or 3D Studio this should be a good/free alternative!
 
rayvel said:
Yes, the 3DS import is also completely broken. It seems the previous code caused 3D Studio to crash and it was disabled, but still there. There were issues with the way it handled the object positioning and rotation. Hopefully the fixes result in a 3DS output that doesn't crash 3D Studio.
Ok, I began to wonder if I'm the only one who noticed it...

rayvel said:
Your point about adding a child object called 'pivot' is interesting, but using the native feature of blender to move the object centre around seems more intuitive (to me anyways). How does 3D Studio handle object pivots? I don't have the software so can't make any basis of comparison.
In GMax/3DSMax you can either move/rotate only the pivot or only the object or both. With the pivot in place, you can use it as transform gizmo, e.g. for rotation around the axes of the pivot.

One benefit to using object centre as the pivot point is you can type 'R' 'X' 'X' (R then two times X). This forces rotation about the object's local X axis and will show you how the object will rotate in RF. Using a child object would not allow for this test. The other option might be to use the armatures/bones feature of Blender but my limited reading on the subject made it look like not a great fit to serve as pivot points.
My original idea was to use the empty as parent of the object. This way you could easily simulate rotation (not all control surfaces rotate along the X axis by the way). The drawback of this approach would be that AFAIK you can't move the parent (empty/pivot) without moving the child object then. But I guess this is also true for the object center. Then again, with the empty as parent, you could still remove the prent-child relation for the moment, move both objects separately and recreate the parent-child relation.
The other way round (empty as child) would be more comfortable to edit, but then you couldn't really use it as pivot inside Blender.

As I said before, if anyone is seriously attempting to use Blender for RF models I'd be happy to work with you over PM/email to iron out any remaining issues in the script. For those who don't want to or can't shell out to buy (or otherwise 'acquire') Deep Exploration or 3D Studio this should be a good/free alternative!
At the moment, I don't think I have the time or enthusiasm to start a new model in blender. I'm currently trying to become comfortable with Blender though despite all of its quirks. So chances are that if I find a nice plane that motivates me to create my 4th RF model, I'll do it with Blender then.

Besides, I'd guess it would be better if KE released the KEX specs so we could create a KEX exporter instead of messing around in 3DSMax scripts which will change with every new version of blender.
 
With the pivot in place, you can use it as transform gizmo, e.g. for rotation around the axes of the pivot.

Using the transformation, rotation or scaling gizmo in blender you can rotate about the pivot point. For example, type Ctrl-Alt-R to activate the rotate gizmo. Now Alt-Space to select your gizmo space: Either world for the global x-y-z axis, or local for the object centre/pivot axis. Now use your left-mouse button to do a rotation about the local axis. This would be the same as R-X-X or R-Y-Y or R-Z-Z depending on how you need to line things up.

About not everything rotating about the X, I noticed that in some other postings. Looks like the spinner and some other objects rotate about the Y instead so I'll keep my eye on that.


Pros and cons to each approach... It is possible to build a new python script that only rotates the object centre, avoiding the confusion to have to rotate the centre then rotate the mesh back. Honestly it seems the parenting and pivot points don't need to get configured until the last step in model creation, so probably don't need to worry about it too much.

Joining this community recently I have some previous experience with Blender so have been looking at that option. I'll keep pursuing the blender script, next step is dealing with empty objects and continue to verify the output. So far the results in RF look good and texture map correctly. Need to work on an appropriate scale of the blend file - worldview coordinates about 50 wide and 50 long seem to map well to the default physics model without too much graphical scaling.

KEX export would be ideal, if we had the specs it would be great to cut out the officially-undocumented 3DS format from the middle. Thanks again for your input!
 
Script updated and fully functional! Thanks maxkop for all your assistance in working out the bugs!

The script attached to the first post in this thread (v0.94) is the latest. Simply extract 'export_3ds2kex.py' to blender scripts directory (default 'C:\Program Files\Blender Foundation\Blender\.blender\scripts') and you are good to go!
 
Last edited:
Thanks Dan for doing the script :)

When I've finished my DG-800-A I will post the .blend - file here, that you can have a look at my setup and all that stuff and how you setup your materials in blender.

Greets,

Max
 
Just let me say that while I don't have the time currently to pursue any Blender modeling topics, I appreciate it very much that you (and maxkop) invest your spare time to create the first completely free approach to G3 model creation.
I'm looking forward to creating my first G3 model with Blender as soon as I have the time to.
I understand the smoothing issues are fixed now?
While this is not really necessary, I still hope you might be able to add a little Python script/GUI to make pivot rotation a tad easier.
 
0xdeadbeef said:
I understand the smoothing issues are fixed now?
While this is not really necessary, I still hope you might be able to add a little Python script/GUI to make pivot rotation a tad easier.

All issues look to be resolved. Though we didn't touch on anything with smoothing so if there is a blender issues here please let me know I'll take a look at fixing it in the export script.

As for the pivot points blender does offer the two options:
1. Rotate the object itself but leave the pivot unchanged (rotate in 'edit' mode)
2. Rotate the object itself and the pivot (rotate in 'object' mode)

I understand you are looking to be able to easily rotate the pivot without rotating the object. I will take a look at how difficult it would be to make a new rotation script that does this.

Perhaps max could speak to his experiences with the pivot points in blender and maybe he found an elegant solution to do this already.
 
rayvel said:
Though we didn't touch on anything with smoothing so if there is a blender issues here please let me know I'll take a look at fixing it in the export script.
Max posted something about smoothing not working at some point. Looks like I misread it though if I look at Max' post above.

rayvel said:
I understand you are looking to be able to easily rotate the pivot without rotating the object. I will take a look at how difficult it would be to make a new rotation script that does this.
Yep, exactly. A little rotation script would be swell :)
 
Last edited:
WOW! You just noticed. I've been using Blender for YEARS! ever sense some of the very first version went public! This will be interesting, I'll watch and see what happens with this thread.
 
Why you want to wait? Start right away with the new script. Everything is working how it is explained in the post by rayvel.

Greets,

Max
 
v0.96: Added parameters.


Parameters will now be output as part of the custom SUP file. For example the NUP_LandingGear and max rotation angles can be output like so:


Code:
[~CS_GD1_L]
IsPivot=No
NUP_LandingGear=~CS_SG
NUP_MaxRotationXDEG=91.
NUP_MaxRotationYDEG=0.
NUP_MaxRotationZDEG=0.
Name=~CS_GD1_L
Parent=FUSELAGE
Pivot=

This is done using the properties control on the Logic panel in Blender (F4). I will not try to explain the usage of the NUP parameters here, simply inform about the capability to export these as part of the automated SUP file creation.

See screenshot attached.
 

Attachments

  • blender_parameters.gif
    blender_parameters.gif
    98.3 KB · Views: 162
v0.96: Added script configuration data.

Every time the script runs it will save some configuration data in the blender bpydata configuration directory.

You must run the script once to create the configuration data before trying the below... It is enough to just run the 3ds2kex exporter and hit escape to cancel this will create the configuration settings.

To modify the settings switch to the 'Scripts' window in blender and run System -> Scripts Configuration Editor (see screenshot)

Once this script is run, select 'export_3ds2kex' from the "Export" dropdown. This will allow you to enable automatic KEX creation (click the 'Export KEX' button) and browse to point to the location of the 3DS2KEX.exe file.

See the second screenshot for the configuration window. There is a BROWSE button on the far right beside the 'kex file' entry. I'm not sure why blender has cut off the browse button but it is there...
 

Attachments

  • config_edit1.gif
    config_edit1.gif
    12.1 KB · Views: 82
  • config_edit2.gif
    config_edit2.gif
    8.6 KB · Views: 101
Next version of the script should have the ability to use custom pivot points as a separate object. This will involve overriding the 'Pivot' and 'IsPivot' properties in the custom SUP file (that one's for you 0xdeadbeef!)

Also we are attempting to create a ~CS_GLOBALOPTIONS object, however seem to have difficultly in getting 3ds2kex to pick up the NUP parameters from the ~CS_GLOBALOPTIONS object. If anyone has experience using the ~CS_GLOBALOPTIONS object through .3DS file and/or .SUP file -> 3ds2kex.exe please PM me.
 
Back
Top