Elvas Tower: MSTS/OR Blender exporter, selective export? - Elvas Tower

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

MSTS/OR Blender exporter, selective export? Is this a feature that others would like? Rate Topic: -----

#1 User is offline   Eldorado.Railroad 

  • Foreman Of Engines
  • Group: Status: Contributing Member
  • Posts: 932
  • Joined: 31-May 10
  • Gender:Male
  • Country:

Posted 18 March 2021 - 08:57 AM

This topic is aimed at Wayne, but also others like myself who are using Wayne's Blender exporter for MSTS/OR shapefiles.

Over the last several months I have been increasingly using/experimenting exporting MSTS/OR shapefiles from Blender 2.65/2.79. I think i attempted once to do animations, though not impossible to do, it does require a slightly different "way of thinking" compared to 3D Canvas/Crafter. The animation aspect is part of the reason for writing this topic.

In 3D Canvas/Crafter, it was possible (and painfully so at times!) to select certain objects for export to a MSTS/OR shapefile. This is useful as it allows the model builder to assemble the whole model 3D Canvas/Crafter and decide what parts should be exported for Freight Animations, etc, but also to selectively export parts that are to be animated, to see how they look/perform in Shapeviewer, as a minimum.

As of this writing, the exporter for Blender does not have the feature to export only selected objects. Other exporters in Blender (OBJ for example) allow the user to export only selected parts/objects. I have not investigated the Python code at any length to see if the "selection" code can be grafted into the MSTS/OR exporter without too much trouble. Currently, the only way to accomplish selective export for the MSTS/OR exporter is to "hide" objects from the hierarchy of MAIN. This involves moving objects around into other hierarchies that are not called MAIN, etc. Alternately, the user must have multiple versions of the .blend file that have objects "deleted" to avoid being part of the export. I thought that "layers" might be the answer, to "hide" things, but from what I read, Blender 2.8+ no longer has layers? The MSTS/OR exporter, exports all layers, regardless. I also tried to "hide" objects in the hierarchy/outliner, by making them "not visible" (the eye icon), alas, everything still is exported.

This of course consumes time, but also disrupts workflow. If I am alone in this paradigm, then there will be no interest to modify the exporter. Hopefully that is not the case. Maybe I am going about this all wrong, so any suggestions for selective exporting, without having to move/delete objects would be most welcome.

Otherwise, is allowing for selective export in some form, too hard to implement?

Thanks,
Steve

#2 User is offline   superheatedsteam 

  • Conductor
  • Group: Status: Active Member
  • Posts: 357
  • Joined: 28-June 08
  • Location:Perth, WA
  • Country:

Posted 19 March 2021 - 04:08 AM

View PostEldorado.Railroad, on 18 March 2021 - 08:57 AM, said:

so any suggestions for selective exporting, without having to move/delete objects would be most welcome.


I find Collections and the Outliner a great way to organise alternate parts, items like lighting/cameras and rigs/templates that are used for model creation but are not part of the final export.

With the existing 2.8 exporter, may I suggest the following workaround for your consideration.

Maintain the MAIN>MAIN_LOD distance collection structure for your primary geometry as usual.

At the same level as MAIN create a collection called FREIGHT_ANIM, and below that other collections for the LOD distances as you would for the MAIN collection.

Move the parts you want to use in the freight anim into the appropriate LOD level under the FREIGHT_ANIM collection.

Now when you export, the objects within the MAIN collection export as normal but will not include the parts in the FREIGHT_ANIM collection.

When you want to export your freight anim, rename the MAIN collection to MAIN.ORG and then rename the FREIGHT_ANIM collection to MAIN. Export again and this time just the objects that comprise the freight anim are exported.

Renaming (using the F2 key) these 2 top level collections toggles between which group of objects are exported. Another advantage is that you can tick the check box to the left of the collection name to quickly toggle the visibility of the objects within that collection in the the 3D viewport.

Cheers,

Marek.

Attached File(s)



#3 User is online   wacampbell 

  • Member since Nov. 2003
  • Group: Fan: Traction Nuts
  • Posts: 2,239
  • Joined: 22-November 03
  • Gender:Male
  • Location:British Columbia, Canada
  • Country:

Posted 19 March 2021 - 05:22 AM

Marek's suggestions are good.

I also use scripting when I want to do something more complicated. Consider Marek's two collections, MAIN and FREIGHT_ANIM. This script will export them to two mesh files:
Note: this example is for Blender version 2.8 and above.

import MSTSExporter

MSTSExporter.ExportShapeFile( 'MAIN', r'c:\MSTS\Routes\LPS\Shapes\boxcar.s' )
MSTSExporter.ExportShapeFile( 'FREIGHT_ANIM', r'c:\MSTS\Routes\LPS\Shapes\boxcar_extras.s' ) 


The first parameter is the name of the collection to export and the second parameter is the file name.
Now you can have multiple collections and name them anything you want.


You can do more with this. For example if I want to make several different colored cars from the same mesh, export the mesh multiple times with a different texture applied for each like this.

import MSTSExporter
import bpy

bpy.data.images['BodyTexture'].filepath = r'bluecar.tga'
MSTSExporter.ExportShapeFile( 'MAIN', r'c:\MSTS\Routes\LPS\Shapes\bluecar.s' )

bpy.data.images['BodyTexture'].filepath = r'greencar.tga'
MSTSExporter.ExportShapeFile( 'MAIN', r'c:\MSTS\Routes\LPS\Shapes\greencar.s' )

bpy.data.images['BodyTexture'].filepath = r'redcar.tga'
MSTSExporter.ExportShapeFile( 'MAIN', r'c:\MSTS\Routes\LPS\Shapes\redcar.s' )



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

I know Steve (Eldorado.Railroad) is the last surviving Blender 2.65 user so here is the syntax for 2.79 and earlier versions

import MSTSExporter

MSTSExporter.ExportShapeFile( 'MAIN', r'c:\MSTS\Routes\LPS\Shapes\boxcar.s', True )  
MSTSExporter.ExportShapeFile( 'FREIGHT_ANIM', r'c:\MSTS\Routes\LPS\Shapes\boxcar_extras.s', True )  


The first parameter is the name of the root object to export and the second parameter is the file name. The third parameter tells the exporter to use the scene center as the origin of the exported mesh.

#4 User is offline   Eldorado.Railroad 

  • Foreman Of Engines
  • Group: Status: Contributing Member
  • Posts: 932
  • Joined: 31-May 10
  • Gender:Male
  • Country:

Posted 19 March 2021 - 01:11 PM

View Postsuperheatedsteam, on 19 March 2021 - 04:08 AM, said:

When you want to export your freight anim, rename the MAIN collection to MAIN.ORG and then rename the FREIGHT_ANIM collection to MAIN. Export again and this time just the objects that comprise the freight anim are exported.

Renaming (using the F2 key) these 2 top level collections toggles between which group of objects are exported. Another advantage is that you can tick the check box to the left of the collection name to quickly toggle the visibility of the objects within that collection in the the 3D viewport.

Hi Marek,

In essence, I wanted to avoid renaming and moving things around, however this idea combined with Wayne's "scripted" might do the trick. It would mean that I could have multiple sections. That could be compiled individually, as needed to test things, such as animations. In the end, I am still faced with having to (carefully) move things into one hierarchy to do the final export.

Thanks for your time and suggestion,

Steve

#5 User is offline   Eldorado.Railroad 

  • Foreman Of Engines
  • Group: Status: Contributing Member
  • Posts: 932
  • Joined: 31-May 10
  • Gender:Male
  • Country:

Posted 19 March 2021 - 01:30 PM

View Postwacampbell, on 19 March 2021 - 05:22 AM, said:

Marek's suggestions are good.

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

I know Steve (Eldorado.Railroad) is the last surviving Blender 2.65 user so here is the syntax for 2.79 and earlier versions

import MSTSExporter

MSTSExporter.ExportShapeFile( 'MAIN', r'c:\MSTS\Routes\LPS\Shapes\boxcar.s', True )  
MSTSExporter.ExportShapeFile( 'FREIGHT_ANIM', r'c:\MSTS\Routes\LPS\Shapes\boxcar_extras.s', True )  


The first parameter is the name of the root object to export and the second parameter is the file name. The third parameter tells the exporter to use the scene center as the origin of the exported mesh.

So, even though I will test this, to be sure, the way the passing of parameters works in scripting mode, I need not have the global group in the hierarchy named "MAIN" to achieve an export? If I have several dozen objects, as long as the names are correctly identified in the script, I will have separate shapefiles exported?

Thanks for tolerating my obstinate love affair with 2.65!

Wayne, I have tried to take a stab at 2.8 and 2.9, but there is something "wrong" with how .blend files from an earlier version are imported and displayed. Notably, for basic modelling I kill ALL lights. In version 2.65, this leads to a nice uniform ambient lighting to work with. In 2.8-2.9 I get some awful lighting that is highly directional and VERY dark. It is impossible to work with. I gave up in frustration, even though there are some features in 2.8-2.9 I would like to use. I guess I would have to export from 2.65 into .obj, but then it means having redo the hierarchy from scratch, not to mention, texturing and animations. Any pointers would be helpful.

So big thanks for the 2.65 scripting idea, I hope it works for me!

Many thanks,
Steve

#6 User is online   wacampbell 

  • Member since Nov. 2003
  • Group: Fan: Traction Nuts
  • Posts: 2,239
  • Joined: 22-November 03
  • Gender:Male
  • Location:British Columbia, Canada
  • Country:

Posted 19 March 2021 - 03:17 PM

View PostEldorado.Railroad, on 19 March 2021 - 01:30 PM, said:

I need not have the global group in the hierarchy named "MAIN" to achieve an export?

Yes, you can use any name, but it is case sensitive ( as all of Blender is ).

Quote

If I have several dozen objects, as long as the names are correctly identified in the script, I will have separate shapefiles exported?

Yes.


I share your frustration about moving old files to 2.8 and beyond. If I open an old file in new Blender, I get the mesh and fortunately also the uv data. But I always have to redo all the materials. Using the materials panel its only one click, but its still a job to do.

Wayne

#7 User is offline   superheatedsteam 

  • Conductor
  • Group: Status: Active Member
  • Posts: 357
  • Joined: 28-June 08
  • Location:Perth, WA
  • Country:

Posted 19 March 2021 - 07:22 PM

View PostEldorado.Railroad, on 19 March 2021 - 01:30 PM, said:

In 2.8-2.9 I get some awful lighting that is highly directional and VERY dark. It is impossible to work with. I gave up in frustration, even though there are some features in 2.8-2.9 I would like to use. I guess I would have to export from 2.65 into .obj, but then it means having redo the hierarchy from scratch, not to mention, texturing and animations. Any pointers would be helpful.


In which shading mode do you find the lighting to dark, Rendered, Solid or Material Preview?

If it's in Rendered or Material Preview mode then you do need to apply lighting to the scene. If you find the default light objects to harsh. look at using an emission shader as a light source/s instead.

There are many tutorials on youtube on how to do this but basically you create a plane, scale it so it's the size of your object and move and rotate it to where you want the light coming from, like a studio photographers flash umbrella. Then create a new material and change the emission colour and strength value to suit. Blender 2.9.2 allows and even greater emission strength than previous versions to really blow out the scene. Change the properties for the plane so it's not visible in 3D viewport but still emits light. Enable denoising for a cleaner image.

If the issue is in Solid shading mode, play around with the viewport shading options (screenshot below). There are many to choose from and you can have the shading fixed or have it move with the view. If you enable cavity and adjust the values you get greater definition to raised and recessed geometry.

Attached File(s)



#8 User is offline   Eldorado.Railroad 

  • Foreman Of Engines
  • Group: Status: Contributing Member
  • Posts: 932
  • Joined: 31-May 10
  • Gender:Male
  • Country:

Posted 20 March 2021 - 06:01 AM

View Postsuperheatedsteam, on 19 March 2021 - 07:22 PM, said:

In which shading mode do you find the lighting to dark, Rendered, Solid or Material Preview?

If it's in Rendered or Material Preview mode then you do need to apply lighting to the scene. If you find the default light objects to harsh. look at using an emission shader as a light source/s instead.


This is quite opposite of what happens in 2.65, where deleting all light sources, automagically engages ambient lighting with only a hint of directional lighting in solid mode. I have no problems at all viewing in textured mode in 2.65. Alas, as stated above, trying to import a .blend file from 2.65 into 2.8-2.9 leads to "the dark side"!

One day I will try again, but something is quite broken for me, which kills the joy of Blender 2.8-2.9. Spending an hour or two, just trying to see stuff is quite frustrating.

Thanks,

Steve

#9 User is offline   Eldorado.Railroad 

  • Foreman Of Engines
  • Group: Status: Contributing Member
  • Posts: 932
  • Joined: 31-May 10
  • Gender:Male
  • Country:

Posted 20 March 2021 - 06:10 AM

View Postwacampbell, on 19 March 2021 - 03:17 PM, said:

Yes, you can use any name, but it is case sensitive ( as all of Blender is ).


I share your frustration about moving old files to 2.8 and beyond. If I open an old file in new Blender, I get the mesh and fortunately also the uv data. But I always have to redo all the materials. Using the materials panel its only one click, but its still a job to do.



Wayne,

Thanks, this alternate method is doable, and it works. After looking at the Blender API, and going down a rabbit hole, I still like the idea of being able to have only visible objects exported from the outliner. There must be an object.visible identifier someplace that could be used as a boolean to either export of not. Aside from the extra work, that I guess you wish to avoid, any thoughts on this idea?

Very grateful for your help and hard work,

Steve

#10 User is online   wacampbell 

  • Member since Nov. 2003
  • Group: Fan: Traction Nuts
  • Posts: 2,239
  • Joined: 22-November 03
  • Gender:Male
  • Location:British Columbia, Canada
  • Country:

Posted 20 March 2021 - 06:23 AM

View PostEldorado.Railroad, on 20 March 2021 - 06:10 AM, said:

Aside from the extra work, that I guess you wish to avoid, any thoughts on this idea?


Its not terrible.

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users