RubyTMIX: A TrainzXML Exporter for Google SketchUp

Make the texture size variable form 512 to 2048 to let the user pick.

Sounds reasonable, thanks for the input.

It is also becoming apparent that I may need an option that allows the generation of (a) multiple altases with the embedded textures at their original sizes, or (b) restricts the export to 1 atlas only, in which case the original textures would need to be scaled down to fit (i.e. to 50% or 25% of original size) - with a potential loss of quality.
 
Last edited:
RubyTMIX is a plug-in for Google™ SketchUp® that provides direct export of SketchUp models to Trainz, with all geometry, materials and textures intact and the polygon count minimized. Using a combination of its own built-in functionality as well as fully-automated interaction with various freely-available external utility programs, the plug-in produces all files required to import a SketchUp model directly into Trainz Content Manager, where it is immediately available for use in Surveyor. The plug-in is compatible with Google SketchUp 7 and 8; with Windows XP and Windows 7; and with TS2009, TS2010 and TS12. An overview of the process with screen shots is provided in the next post.

Implementation
* Ruby plugin, runs inside Google SketchUp 7 or 8
* Integrates into the SketchUp menu bar
* User interface is provided via Ruby-SketchUp 'WebDialogs'
* Requires Trainz Mesh Importer (included) and IrfanView (obtained separately)
* Supports preview of produced IM file in PEV's Trainz Mesh Viewer (obtained separately) prior to import into CM

Main Features
* Automated production of all files required for use with TS2009, TS2010 and TS12
* Immediate error- and warning-free import of all files into Content Manger from a single folder
* Imported assets are ready for immediate use in Surveyor
* No other content-creation tools required (e.g. Blender or G-Max)
* Documented with PDF manuals
* IT'S FREE

How It Works
* Requires each SketchUp model (SKP file) to be in its own folder
* Automatically creates all required files and folders based on file name information from SketchUp
* Exports geometry directly to TrainzXML format
* Automatic geometry selection logic minimizes poly count by exporting only the faces required
* Manual selection of front/back/both/textured-only geometry is also provided
* Export full model or selection only
* Correctly handles mirrored components and projected textures
* Exports SketchUp colors as non-textured materials, fully defined in the TrainzXML file
* Exports SketchUp textures as image files with auto-resizing to closest-power-of-2 dimensions and 1:8 max ratio as needed
* Auto-converts JPG material and photo-texture files to TGA format
* Auto-converts PNG textures with transparency to TGA format and maintains alpha information
* Automatic creation of 'config.txt' file -- you specify the defaults for all required items
* Creates a thumbnail from the SketchUp model and auto-resizes it to 240x180
* Automatically runs Trainz Mesh Importer at conclusion of process (also creates CMD file for manual re-run)
* All post-processing options can be turned on or off, so you can tweak the results yourself
* Retains geometry-selection and post-processing options separately for every model
* Creates a log file for each export run that documents the conversion process to aid in troubleshooting

Acknowledgements
A huge thank-you goes out to Peter V (PEV) for graciously providing some valuable tips about materials and geometry in TrainzXML files, and for allowing me to reference his Trainz Mesh Viewer as the preview part of my tool. Thanks also to philskene for allowing me to use his routes as backdrops for my screen shots.


Hi!

It's really great news!
I've made a lot of models for Trainz using Sketchup !
It'll be nice to export them in the future directly to trainz.
I hope you'll can find a way to include attachment points so it'll be possible to make locos and rolling stock for trainz using Sketchup!

Thanx a lot for all your work , wonderfull
 
even if you can't do attachment points. You could always make up the parts in SkU & then use PEV's Attachment Maker to add attachment points.

peter
 
ModelerMJ: This is what I have done in Sketch 8 and I love doing it..so if you find away to get this into Trainz and also find away to animate Wow..
9000.jpg
 
It is possible to map the textures one size at export and then later replace with a higher quality/resolution one later, as long as it still agrees with where everything is mapped.
 
It is possible to map the textures one size at export and then later replace with a higher quality/resolution one later, as long as it still agrees with where everything is mapped.

I have the binning algorithm for the Texture Atlas working now. Not yet writing images out, not yet modifying UVs, but I'm getting there (one step at a time).

I need advice from you gurus here. Should I always strive to create just one atlas, even if it means scaling the original textures down (maybe significantly)? For example, in the case of the Salty Dawg Saloon it looks like all 76 textures would fit into one 2048 x 1024 atlas if I scale them down to 25% of their original size.

Or is it acceptable to have multiple atlases so the textures can remain at their original quality?

Or is there some balance between quality and number of atlases I should be working toward?

Any advice will be much appreciated.


Regards,
-Mike
 
Last edited:
Allow for the creation of multiple atlases or only one atlas. Track side objects are closer to the camera and thus need to look better. That means using multiple maps. Now for really far objects, you can reduce the quality and use fewer maps.
 
Allow for the creation of multiple atlases or only one atlas. Track side objects are closer to the camera and thus need to look better. That means using multiple maps. Now for really far objects, you can reduce the quality and use fewer maps.

Thanks for the input, that's good advice.

So basically I'm thinking the options at export time (for Textures) will be:

(*) Use Texture Atlas(es) - Must have 2 or more textures in model
......Max Dimension (X or Y)
.....( ) 512 pixels
.....( ) 1024 pixels
.....(*) 2048 pixels

.....Scaling
.....(*) Scale images to fit into 1 Atlas (down to 25% original size)
.....( ) Keep images at original size and use multiple Atlases if needed

( ) Export Textures as Individual Files - Works for any number of textures
.....- options for individual files here, as I have them today -

--------
( ) is an option button, * is the default selection.


If 1 Atlas is selected and I cannot fit the images into it with the parameters given then the export would stop and an error message would be issued.

Sound reasonable?


Regards,
-Mike
 
...So basically I'm thinking the options at export time (for Textures) will be...

Mike,

The defaults as shown seem reasonable but if I were you I would consider how any defaults could be made "user definable" - some people will want quality at the expense of performance and vice versa. Personally I find it annoying when you go into an application and have to change the same settings every time you use it. Not exactly a high priority function though!

Your utility is an interesting bit of programming, I could never get my head around all those graphics issues - too much maths! Out of interest what's it written in?

Chris
 
Chris,

The settings are saved individually for every model, so the next time you open that model and go to export it, all the settings for that model will come back as you had them the last time.

The exporter core is written in Ruby; the dialogs are a combination of HTML and javascript. This is actually my first Ruby program - although I am a software engineer by profession, I usually work in MS Visual Studio (VB, C++ and C#) and with PLC tools (Siemens Step-7) so this was a nice change of pace. As far as the math goes, the SketchUp API provides functions for quite a bit of that so it's not as bad as you might think - although there are a few tricky bits that took some figuring on my part.


Regards,
-Mike
 
Last edited:
...The settings are saved individually for every model...

Mike,

That is good solution.

I wish I had never asked what it was written in :) ! I have some sort of mental block with "C style" languages, all those brackets I think! I just about get by with VB.Net, but then my background is more business analyst (now retired) than coding.

Carry on the good work, RubyTMIX will be a great asset to the Trainz community.

Cheers

Chris
 
Texture Atlas Progress

Texture Atlas for Salty Dawg Saloon
atlas1.png


This is all 76 textures from the original model, automatically collated by RubyTMIX into just 1 image - a 1024 x 1024 PNG (it was scaled down by ImageShack so it is shown slightly smaller than actual size here) with all textures scaled to 25% of original size. As you can see, transparency is also being maintained where needed. This image will ultimately be auto-converted to TGA to make it ready for import into CM.

Still got a long way to go, of course -- at this point I'm just trying to get Texture Atlases to work 'at all', so there are certainly still many optimizations to be applied. One step at a time, though, and it may still turn out that this whole scheme will not even work... mixed alpha/transparency values and handling of tiled textures are still potential show-stoppers. :eek:


Regards
-Mike
 
Last edited:
This is turning out to be quite the project. I just started modelling in Sketchup (doing buildings of course, not locos) and I've been having trouble with my first project, which a friend edited and exported to a 3DS file into Gmax, then exported as an IM. Not all the textures came out and CCP claims they need locking, so I think I may as well just wait in anticipation for this. Kudos to you.
 
Texture Reduction will be 'Phase 2'

After putting a fair bit of effort into the Texture Atlas feature I have found that there are several significant shortcomings in the SketchUp API that will not allow me to fully automate the process. I do know how to achieve what we are all after, but access to the features I need to make it work properly is simply not available from within a Ruby script. It was also making the exporter code much too convoluted, trying to deal with all the special cases and potentially conflicting options.

I am therefore going to set this activity aside for now, and instead concentrate on getting the core functionality of the exporter as bulletproof as I can so it can be released. At this point I think the proper approach is to let the exporter export... and let texture reduction (atlases or any other method) be a separate process that is used to optimize a model before it is exported.


Regards,
-Mike
 
Last edited:
Status of Project Was Updated

The 1st and 3rd posts in this thread have been updated to reflect the current status of this project as of 01-Nov-2011.


Regards,
-MIke
 
Last edited:
testing

Hi People i have bean testing the RubyTMIX exporting plugin for Sketch-up and is really a amazing tool very direct, intuitive and very simple to use it. They have all instruction how to install but anybody almost install this plugin whit any help if have the minimum acknowledgement of instal plugins.
I have exported more then 10 models at the moment whit out any crash or any issue. Of course some times textures names and the texture txt extension must be renamed because of illegal characters but is very easy to rectifies.
This exemple below take me 1 minute and 12 seconds to export in to a complete kuid asset and already all configured and ready to committed in trainz (whit thumbnail picture already) directly from Sketch-up, i dont make any modification only export like they are. I must to say to all they have around 40 textures because don't have the atlas textures ready yet, but all this job make it throw 3dmax exporting converting etc , i estimate they going to take me around 3 hours at least.

a2436170418ad18d8cb79fb0bf35e73a.jpg


I show now a simple model station Sketch-up image and the other image is a result conversion export whit only 626 polys, they take me 1minute to export the station and 25 seconds to export the steam loco whit 1.9 k polys they have in the other image a wagon from Sketch-up only as a static scenery objects of course, i think if wee use in trainz vehicles to populate our layouts, wee can use to many of this locos and wagons from Sketch-up to for populate the scenary, like a damage loco, directlight abandoned locos in a desativated track etc .....
arraial
09aa3cdd4dc6b7457dacba18237f1b04.jpg


b7b53c7bbf492615803b80e4cdc70883.jpg


e72191491b11ce62532b8e36132ed0ae.jpg
 
Last edited:
@arraial,

Thanks very much for your post. Nice modeling! I'm glad the exporter is working well for you.

I noticed you mentioned some 'invalid characters' in file names - please be sure to let me know what's going on there.


Regards,
-Mike
 
Back
Top