RubyTMIX: A TrainzXML Exporter for Google SketchUp

ModelerMJ

RubyTMIX, Basemapz
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 & TIF 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.
 
Last edited:
Process Overview

The following screen shots illustrate the RubyTMIX process.

1. The Salty Dawg Saloon (by JCHarrist) - Downloaded from the Google 3D Warehouse, opened in Google SketchUp

rtmfp02.jpg



2. Starting the Export Process - Specify model KUID and lighting, select geometry to export, and set post-processing options

rtmfp03.jpg



3. Export In Progress - Status messages, progress bar and percent-complete display

rtmfp04.jpg



4. Export Complete - Summary of what was done, with options to preview the results before import into CM

rtmfp05.jpg



5. Previewing the IM File in PEV's Trainz Mesh Viewer

rtmfp06.jpg



6. Viewing/Editing the auto-generated config.txt file in Notepad

rtmfp07.jpg



7. Importing the Model into TS12 Content Manager

rtmfp09d.jpg


(Auto-generated Thumbnail)
rtmfp09e.jpg



8. Using the Model in TS12 Surveyor - Port Ogden & Northern as a backdrop, courtesy of philskene

saltydawgex10ts12a2.jpg


saltydawgex10ts12b2.jpg
 
Last edited:
Legal Stuff

RubyTMIX is being released FREE to the Trainz community and may be used for any purpose, personal or commercial, within the following terms:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM OR IN CONNECTION WITH THE SOFTWARE OR ITS USE.

If you don’t agree to these terms... don’t use the software.

Of somewhat greater importance is the way in which the Google SketchUp Terms Of Use apply to this tool. I have exchanged several e-mails with the correct person at Google regarding this, and the following list summarizes what we discussed.

1. The free edition of Google SketchUp may not be used for commercial purposes. This means that you cannot sell the models you create with the free edition – it does not mean you cannot use it to create models for the Trainz environment. What this boils down to is that the only acceptable way of distributing Trainz models created with the free edition of Google SketchUp is to post them on the Trainz DLS so that they are freely available to everyone (the need for a First-Class-Ticket not withstanding).

2. Payware items created for Trainz, e.g. routes, may reference models created with the free edition of Google SketchUp that have been posted on the DLS, but may not directly include any such models in the distributed payware package. This is (I believe) in line with the existing policies of N3V/Auran regarding the use of freeware within payware.

3. Materials, textures, components and Google Street View or Google Earth images that are accessible from within Google SketchUp or other Google products may be used in the creation of Trainz models. However, all such materials must remain part of the model and may not be separated from it for use in any other content creation tool. This means that, even though individual images that represent textures and photos may be accessible at various points in the export/import process, those images must remain part of the single object asset that is held in Trainz and cannot be re-used in any other non-SketchUp-produced asset.

4. Section 8.2 of the Google 3D Warehouse Terms of Service (which can be found at http://sketchup.google.com/intl/en/3dwh/tos.html) includes the statement “For the avoidance of doubt, you may modify, distribute, and create derivative works of Content uploaded by other users in 3D Warehouse.” I have interpreted this to mean that models can be downloaded from the Google 3D Warehouse, converted via RubyTMIX, and placed on the Trainz DLS in either altered or original unchanged form as desired. Proper etiquette dictates, of course, that the permission of the original author should be sought and that they (and the Google 3D Warehouse) should be named as the original sources.

In summary, I was told that nothing I intended to do required a special agreement with Google; therefore I feel safe in saying that we are allowed to use the free edition of Google SketchUp to produce content for Trainz as outlined above.

If you disagree with my assessment... don’t use the software.
 
Last edited:
Current Status

22-Oct-11:
Version 0.1.0 - BETA - Not yet ready for public release.
Supports the processing of static scenery objects only (at the current time).
There are no plans to make this tool compatible with any version of Trainz prior to TS2009.

I am announcing the tool at this time in hopes of finding 3 or 4 serious content creators who are willing to put the tool through its paces, and provide feedback about its operation as well as how to broaden its scope such that it can be used for more than just static scenery objects. Personally the next feature I plan to add is support for object splines (roads and highways), as I have some unique needs in that area for my own route.

Documentation is preliminary but complete to the current level of functionality; I expect to revise it during the Beta process. Google has requested a review cycle of the manuals to allow for approval of trademark usage and that is about to get underway; but I can issue the documents to Beta testers in the mean time without waiting for this to take place.

Comments, thoughts and constructive criticism are welcome. Legal rhetoric and SketchUp-bashing are not... I fully realize that being able to convert a SketchUp model so that it 'works' in Trainz is only part of the battle - it doesn't mean the model is efficient and/or that it adheres to all the myriad content creation rules. On the other hand, what I don't know about content creation would fill a book just about the size of the CCG, so maybe with guidance from some of the more experienced folks here the tool can be improved to address the necessary issues.

So, if you're a serious content creator who wants to be part of the beta test process and/or wants to help shape the future direction of this tool and make it truly useful, then please PM me and we'll go from there.


Regards,
-Mike

--------------------------------------------------------------------------

STATUS UPDATE (01-Nov-11):
- Corrected some bugs related to transparency and completed initial clean-up.
- Updated TS12 screen shots in previous post to reflect fixes.
- Software is now being issued to 2 Beta Testers.

- An experiment was conducted related to creating a Texture Atlas as an attempt to reduce the number of textures associated with a SketchUp model. I was able to create the Atlas (see post later in this thread) but ultimately my initial attempt was defeated due to the inaccessibility of some necessary information from within my Ruby script; I also found that attempting to add this functionality to the exporter made the code very convoluted as I tried to deal with special cases and potentially conflicting options. Therefore I have set this effort aside for now in order to concentrate on getting the exporter itself completed and issued. I will revisit this later with an eye toward letting the exporter do its job and then treating texture reduction as a separate effort/tool that can be applied to optimize a model before the exporter is used.

--------------------------------------------------------------------------

STATUS UPDATE (06-Nov-11):
- Version 0.2.0, issued to 1 Beta Tester.
- Reworked the exporter output section to eliminate a problem with running out of resources on very large models. Exporter can now handle models of any size.
- Reworked code also reduces export time by about 35% vs the previous version.
- An issue was reported with invalid file name characters in a non-"en-US" operating system. A temporary work-around was completed to allow testing to continue, but the resolution is far from an optimum solution and additional work is required to resolve this issue in a more robust fashion.

--------------------------------------------------------------------------

STATUS UPDATE (07-Nov-11):

- Version 0.2.1, issued to 2 Beta Testers.

- The issue with invalid characters in file names is now fully resolved, in the proper fashion. The exporter now creates controlled file names (e.g. RTM_0001.jpg, RTM_0002.png, etc.) for all textures, and so Unicode characters in the actual SketchUp texture file names now have no effect on the export process or on the import into Trainz. Because of this, the exporter now also creates a folder with all the original texture files, with their original names (including Unicode characters if present), along with a cross-reference TXT file that indicates which controlled file names are associated with which actual textures; this also allows the original images to be manipulated manually by the user if desired. Many other clean-ups are also included in this iteration.

- This version will be issued to additional Beta Testers as soon as updates to the User's Guide are completed, as this version has substantial differences from 0.1.0. To all those who have PM'd me asking to test the tool -- Thank you, and rest assured I am not ignoring you. I'm just trying to get the whole package back to the level it needs to be at so I can send it out in the right way.

--------------------------------------------------------------------------

STATUS UPDATE (08-Nov-11):

- Version 0.2.2, issued to 1 Beta Tester.

- Added support for TIF/TIFF images. D'oh! My bad, I somehow overlooked the fact that SketchUp allowed this format. Also, TIF images can carry transparency, but the SketchUp API function that reports whether or not a texture has transparency is broken for TIF images and so I cannot auto-detect this. I will note this in my updated manual.

--------------------------------------------------------------------------

STATUS UPDATE (13-Nov-11):

- Version 0.2.2 issued to all other Beta testers.
- Documentation sent to Google for trademark & copyright clearance (at their request); this should be forthcoming this week as I do not expect any major issues here.
- The web site that will host the software is up and running and essentially ready to go. I'll be giving out the URL here and in the Freeware Announcements forum when it's time.
- Beta testing continues; I want to make sure all of my testers have time to respond. So far V0.2.2 seems to be the best version for a release candidate.

Thanks to everyone who has posted here for their continued interest and kind words, and of course to the Beta Testers for their time and comments.

--------------------------------------------------------------------------
 
Last edited:
ModelerMJ

While I have never used Sketchup, I know it appears to be popular and I heartily congratulate you for making it a viable creation medium for Trainz.

Peter
 
About Rolling Stock Creation.

We need a way to add attachment points to a model. I want to try out this tool and see how good ploy-wise it is.
 
This will open up so many opportunities to get prototypical buildings for routes! Thanks for your great work!
 
Just knowing the amount of items in the Google Sketchup warehouse that could be brought into Trainz is mind numbing.....
 
Wow!~!

Chris --

I agree.

I've just visited Google Sketchup warehouse. There are masses of useful models there. Of particular use for me would be proper 3D people.

Phil
 
Denver Union Station?

dustransparencyissue.jpg

However... just because it can be used, doesn't mean it should :). I know it's easy to get glassy-eyed when you look at all the cool stuff on the 3D warehouse, but during my testing - prowling around looking for really nasty models to throw at my exporter - I have found that a lot of them have monstrous numbers of polygons. On the other hand there are some models that you would swear have a gazillion that have only about 1000 or so.

By the way, this model has 1891 polygons.


Regards,
-Mike

P.S. I just went and grabbed the P42 - it weighs in at 11,016 polygons. A bit on the heavy side? But this is exactly what I'm talking about when I say I would like some knowledgeable collaborators to help me refine the tool. Then again a lot of the responsibility needs to be on the modeler to create a low-poly model in the first place.

amtrakp42.jpg
 
Last edited:
Just by seeing this, I defintely can't wait. It will make everything alot easier. Can you show a screenshot of a railcar or locomotive from sketchup being operating on a piece of track in trainz.
 
just wondering, if we find a 3d model we like at the warehouse, do we need to let the author know what we plan on doing with their model? -inprr
 
Hay YES!!!!!!! Now my Surfliner Cab Car can finally work for Trainz !!!!! and my NEC stuff to :udrool::udrool::udrool::udrool::udrool::udrool::udrool::udrool:




Get Ready Because Funforme3 is back on Track!!!!
 
@inprr - That would be proper etiquette, as I noted in my original post.

@norfolksouthern37 - Just regular meshes right now... It took about 300 hours of research and coding to get to where I am now, so I am kind of thinking "one step at a time". I am however quite willing to put in more time to make this tool as useful as possible for everyone... provided I can find a few 'experts' that are willing to work with me. I'm still very much a beginner when it comes to content creation, so if y'all wait for me to figure it out on my own...:confused: let's just say we'll all be waiting a while.

@malikrthr - As noted in my original post, it currently does static scenery objects only.

Regards,
-Mike
 
Last edited:
Back
Top