Go Back   Knife Edge > RealFlight - Designer's Corner > RealFlight G3 - Designer's Corner
Use of this site is subject to our Terms of Use. | Technical Support is available from Great Planes Software Support.

Reply
 
Thread Tools Rating: Thread Rating: 58 votes, 5.00 average. Display Modes
  #1  
Old 07-22-2007, 11:40 PM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
Blender 3DS export project

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.
Attached Files
File Type: g3x export_3ds2kex_v099.g3x (12.2 KB, 1613 views)
File Type: txt export_3ds2kex.txt (43.8 KB, 2621 views)

Last edited by rayvel; 12-16-2008 at 10:18 AM.
Reply With Quote
  #2  
Old 07-22-2007, 11:49 PM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
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.
Attached Images
File Type: gif 1_make_parent.gif (11.9 KB, 278 views)
Reply With Quote
  #3  
Old 07-23-2007, 12:23 AM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
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.
Attached Images
File Type: jpg 2_snap_cursor.jpg (85.0 KB, 196 views)
File Type: jpg 3_show_axis.jpg (63.7 KB, 183 views)
File Type: jpg 4_move_center.jpg (92.9 KB, 173 views)
Reply With Quote
  #4  
Old 07-23-2007, 12:32 AM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
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.
Attached Images
File Type: gif 5_rotate_object.gif (10.1 KB, 111 views)
File Type: gif 6_rotate_mesh.gif (12.1 KB, 106 views)
File Type: gif 7_final_centre.gif (8.1 KB, 124 views)
Reply With Quote
  #5  
Old 07-23-2007, 12:38 AM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
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.
Reply With Quote
  #6  
Old 07-23-2007, 10:45 AM
0xdeadbeef 0xdeadbeef is offline
Registered User
 
Join Date: Aug 2006
Posts: 630
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.
Reply With Quote
  #7  
Old 07-23-2007, 02:20 PM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
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!
Reply With Quote
  #8  
Old 07-23-2007, 03:14 PM
0xdeadbeef 0xdeadbeef is offline
Registered User
 
Join Date: Aug 2006
Posts: 630
Quote:
Originally Posted by rayvel
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...

Quote:
Originally Posted by rayvel
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.

Quote:
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.

Quote:
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.
Reply With Quote
  #9  
Old 07-23-2007, 03:55 PM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
Quote:
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!
Reply With Quote
  #10  
Old 11-07-2007, 07:30 PM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
Thumbs up

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 by rayvel; 01-20-2008 at 09:32 AM.
Reply With Quote
  #11  
Old 11-07-2007, 08:37 PM
maxkop's Avatar
maxkop maxkop is offline
Registered User
 
Join Date: Aug 2005
Posts: 775
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
Reply With Quote
  #12  
Old 11-07-2007, 08:40 PM
0xdeadbeef 0xdeadbeef is offline
Registered User
 
Join Date: Aug 2006
Posts: 630
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.
Reply With Quote
  #13  
Old 11-07-2007, 09:11 PM
maxkop's Avatar
maxkop maxkop is offline
Registered User
 
Join Date: Aug 2005
Posts: 775
Quote:
Originally Posted by 0xdeadbeef
I understand the smoothing issues are fixed now?
I make much use of the edge split modifier. The results are pretty good, and no additional geometry is added to the mesh.

Greets,

Max
Reply With Quote
  #14  
Old 11-07-2007, 09:13 PM
rayvel rayvel is offline
Registered User
 
Join Date: Jun 2007
Posts: 44
Quote:
Originally Posted by 0xdeadbeef
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.
Reply With Quote
  #15  
Old 11-09-2007, 02:32 PM
0xdeadbeef 0xdeadbeef is offline
Registered User
 
Join Date: Aug 2006
Posts: 630
Quote:
Originally Posted by rayvel
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.

Quote:
Originally Posted by rayvel
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 by 0xdeadbeef; 11-09-2007 at 02:44 PM.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:28 PM.