Rail3D*


 

Using3d Modelling Programs With Rail3d



1 Introduction

Love it or hate it, until recently the only way to build models for Rail3D has been by using the text-based interface of the Rail3D Editor. However, additions to the syntax of the Rail3D modelling language to allow us to make models render more quickly in DirectX have had the interesting side-effect that it becomes much easier to convert models from external formats, including those used in some popular 3D modelling programs.

Be aware that this is a new area for most of us — if you have relevant 3d modelling experience and manage to apply it to Rail3D, please tell us about it in this Wiki or via the discussion group.

2 Indexed Triangles and Vertex Buffers

The key to all this is the new Vertex Buffer / Indexed Triangle syntax, which looks roughly like this:


        x/y/z    nx/ny/nz    tu,tv
    --repeat--



        a,b,c
  --repeat--


where
    x,y,z       are coordinates of vertex
    nx,ny,nz    is normal of vertex
    tu,tv       are texture coordinates of vertex

    a,b,c       are zero based indexes of vertexes forming a triangle.

This allows you to build meshes as complicated as you like, with much more flexibility than Strips, and apparently it renders extremely fast. The idea is that you collect together all the vertices of a Rail3D component in one vertex buffer, and then build triangles out of them. Obvious drawback: except for the simplest model, it is virtually impossible to edit by hand. Imagine if you have a list of a hundred vertices, how are you going to remember which is which?

The good news is that this kind of structure is much easier to generate with an external program than the classic Strip and Fill syntax of Rail3D was.

3 So what’s wrong with the Rail3D Editor?

Text-based editing with the Rail3D Editor is quick, precise, and fairly easy to learn for most people.

A general-purpose 3d modelling program can be very hard to learn. Most such programs have huge numbers of features, many of which are irrelevant to our purposes. Working with a mouse in 3d, it is often tricky to stick to the precise dimensions of the thing you’re modelling. Because you are detached from the detailed structure of the model, you may end up with far more faces and vertices than in a model built “by hand” in the editor.

On the other hand, using a third-party modelling tool for Rail3D could have a lot of advantages:

  • The Rail3D editor only has very limited tools for manipulating objects once you’ve created them (moving, scaling, rotating, deforming, etc.) — all 3d modelling programs have a good selection of these
  • There are a lot more tools for creating basic shapes quickly (lathe, extrude, etc.)
  • Most 3d modelling programs allow you to use a bitmap drawing as a background template, which makes modelling irregular shapes a lot easier than reading dimensions off a drawing
  • U,V mapping can be done graphically, without having to read coordinates for each individual point off a bitmap
  • Someone else is responsible for maintaining the modelling tool, and we can focus our efforts on the railway aspects of Rail3D

4 3d Modelling Software

It should be possible to write an export script or plugin to create this Vertex buffer/Indexed triangle format from most general purpose modelling tools. Most 3d modelling programs have a steep learning curve: writing the plug-in for a program you know is likely to be quicker and more efficient than learning to use a different program.

Bear in mind that many programs that are advertised as “freeware” are cut-down versions of expensive commercial software. The bits that are cut out are usually precisely the bits we need for Rail3D — support for plugins or standard export formats.

The basic requirements to work with Rail3D are:

  • Uses an internal data format that can readily be converted into vertex buffers/indexed triangles
  • Supports U,V-mapped textures, preferably including bmp and tga formats.
  • Allows scripting or plugin creation

Desirable features (not essential, but make life easier):

  • able to work in metric and imperial units
  • allows objects to be scaled and positioned accurately in real-world units
  • allows use of 2d background images as modelling templates
  • supports tga transparency

As an alternative to scripting, it might be worth looking into creating conversion utilities for some standard 3d formats — it has been suggested that Lightwave .obj format is similar in structure to vertex buffers/indexed triangles. Another, less elegant solution is to go via msts format (see ConvertingMSTS Models).

4.1 Abacus Train Sim Modeller

This is (a) no longer being developed and (b) tied to a single export format. If you have it and know how to use it, it might be worth trying it in combination with the ConvertingMSTS Models.

4.2 gmax

The free version of 3DS Max, in principle no longer available and tied to a single export format. It is supposed to be possible to adapt at least some 3DS plugins to work with gmax — I don’t know if this would be possible or legal for an export plugin.

4.3 3D Studio Max

Flagship program from Autodesk: Does everything we would need and much more besides, but priced at a level (ca. us$3000 for a single licence) that takes it well outside the reach of amateur modellers. Could be interesting if you have access to it professionally or as part of your studies.

4.4 3DCanvas

3DCanvas is a popular, relatively inexpensive 3D modelling program (in early 2006 the version needed for use with Rail3D cost approx. us$70). It seems to be one of the most popular tools for creating content for other simulators like msts, so there is a lot of rail-related 3DCanvas expertise available for us to build on. The program even comes with handy third-party tools for things like building steam locomotive wheels. 3DCanvas will also support the much-hyped Kuju Rail simulator, if it ever emerges.

What is really interesting for us is that it has an open programming interface which makes it easy to write export and import plugins for external file formats. Drawbacks: the current version (6.5) is a bit fussy about hardware, and tends to crash on some types of graphics card; the u,v-mapping tools are a little difficult to use, until you get used to them.

Canvas Plugins for Rail3D

We have created a basic set of plugins for exporting models created in 3dCanvas to Rail3D format, and for importing existing Rail3D models into 3dCanvas for further editing. See Building Rail3d Models In3d Canvas for the plugins and notes on using them.

Update, December 2007 : the Rail3D Export plugin is now built into the 3DCanvas Pro download.

4.5 Google Sketchup

Google Sketchup is a free version of Sketchup, a 3D modelling program designed to have a very easy user interface. It allows plugin creation using the Ruby language.

Paul Gausden has written an export plugin for converting Sketchup models to msts format, so it should be possible to do the same for Rail3D without too much difficulty.

And there is now a direct Rail3D plugin for Sketchup. You can download it at http://www.rail3d.info/tools/sketchup.zip - it’s still being developed, so please report any problems with exporting models and we’ll try and fix them. mrg, 27.04.08

Our first tests of Sketchup suggest that it lives up to its claim to be easy to use, and it is a very quick way of roughing out simple shapes. By using keyboard entry and construction lines it isn’t difficult to get models dimensionally correct. However, texture support is a bit limited at the moment, and it is not possible to texture a curved surface all in one go with a skin, which makes it difficult to use for rolling stock modelling. It might still be interesting for modelling simple buildings.

See also Sketchup A Viaduct

4.6 Blender

Blender is a free open-source modelling program that looks as though it should do everything we need. It comes with built-in Python scripting, so it should be possible to get it to talk to Rail3D. It has a bit of an odd user-interface, but people who know it seem to like it.

4.7 Wings3d

Another option to consider might be Wings3D — as far as I can see, this is free, and would do everything we need apart from texture mapping, which you’d have to do in an external program.

4.8 Anim8or

http://www.anim8or.com — still in beta, and seems to be a single-developer project. No-one has reported testing it for Rail3D yet. From the website, it looks as though it’s mainly intended for modelling organic shapes.



import