Elvas Tower: Condition for creation of "animations (" in .s file, MSTSExporter.py? - Elvas Tower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Condition for creation of "animations (" in .s file, MSTSExporter.py? Rate Topic: -----

#1 User is offline   Eldorado.Railroad 

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

Posted 22 November 2020 - 06:06 PM

I am trying to understand the condition in MSTSExporter.py that creates the "animations (" section in a .s file exported in Blender.

in "def IsAnimated( nodeObject ):" of the MSTSExporter.py file I see the following line(s):

animatedParts = ('BOGIE1','BOGIE2','WHEELS11','WHEELS12','WHEELS21','WHEELS22' )
if animatedParts.count( nodeObject.name.upper() ) > 0: return True



Can I assume here that if the model hierarchy contains these names:
MAIN
BOGIE1
WHEELS11
WHEELS12


that the "animations (" section near the end of the exported .s will/should be created with the subsections MAIN, BOGIE1, WHEELS11, WHEELS12?

Thank you for your help,
Steve

#2 User is offline   wacampbell 

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

Posted 23 November 2020 - 07:20 AM

 Eldorado.Railroad, on 22 November 2020 - 06:06 PM, said:

...
Can I assume here that if the model hierarchy contains these names:

....

that the "animations (" section near the end of the exported .s will/should be created with the subsections MAIN, BOGIE1, WHEELS11, WHEELS12?



No, that's not the purpose of that function. The function "def IsAnimated( nodeObject ):" is involved with reducing draw calls in the model. If a part is animated it cannot be combined with other parts to reduce draw calls. There are two types of animated parts - manually animated ones have their motion defined in Blender - and automatic animated parts, such as the wheels, where they are moved in the simulator according to the speed of the train etc. The wheels don't appear in the animation section of the .s file because they are not 'manually' animated by the model builder.

I understand from your prior posts that you are trying to fix the 'animations( 0 )' crash that occurs in ShapeViewer when exporting from older versions of the exporter. The current version of the exporter has this bug fixed. See lines 2780 in the V4.3 of the exporter.
        def WriteAnimations(self, stf ):
                count = len( self.Animations )
                if count > 0:    # ShapeViewer crashes if you have animations( 0 )
                    stf.WriteLine( '    animations ( {0}'.format( count ) )
                    for i in range(0,count):
                        self.Animations[i].Write(stf)
                    stf.WriteLine( '    )')


I am not sure what old version of the exporter you are trying to use, but maybe the above code will give you an idea.

Wayne

#3 User is offline   Eldorado.Railroad 

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

Posted 23 November 2020 - 11:45 AM

 wacampbell, on 23 November 2020 - 07:20 AM, said:

...
The wheels don't appear in the animation section of the .s file because they are not 'manually' animated by the model builder.

I understand from your prior posts that you are trying to fix the 'animations( 0 )' crash that occurs in ShapeViewer when exporting from older versions of the exporter. The current version of the exporter has this bug fixed. See lines 2780 in the V4.3 of the exporter.
        def WriteAnimations(self, stf ):
                count = len( self.Animations )
                if count > 0:    # ShapeViewer crashes if you have animations( 0 )
                    stf.WriteLine( '    animations ( {0}'.format( count ) )
                    for i in range(0,count):
                        self.Animations[i].Write(stf)
                    stf.WriteLine( '    )')


I am not sure what old version of the exporter you are trying to use, but maybe the above code will give you an idea.

Wayne, thank you for the clarification. I have tried everything, up to version 3.0 with the same results. These work with Blender 2.6.5. I have noted in my tests that, if I create a "dummy" animation in Blender that is not related to any automatic animations (WHEELS11, WHEELS12, etc) the animations section is created with WHEELS11, WHEELS12 in the exported .s file. Shapeviewer does not crash with the fully "filled" animation for all objects in the model hierarchy. Nor does Shapeviewer crash if you decide to delete the animations section of the exported .s file.

The undesirable side effect of this is that Shapeviewer will allow you to animate the model for visual testing in Shapeviewer, but WHEELS11, WHEELS12 etc are animated "spastically", not rotating a full 360 degrees. This is not good if you are trying to determine if the polygons that comprise a eg WHEELS11, are truly centered around the location of the object which leads to eccentric rotations. I exported your test model which has pantographs, but decided to eliminate the animations section manually with a text editor. In this condition, WHEELS11 etc rotate a full 360 degrees as desired. Of course when you delete the animation section, the pantographs will no longer work as desired!

I hope I can modify the exporter file to include what you have kindly posted in your message.

Otherwise the workaround seems to be to create a "dummy" animation in Blender and then delete that same animation in Blender before exporting to .s. The exported .s file contains an animation section that includes all members of the model hierarchy. Because of the aforementioned spastic animations in Shapeviewer for objects that are automagically animated in MSTS/OR, deleting the animations section in the exported .s file removes animations that you would otherwise want to keep.

I think this is a bug in Blender as the hierarchy view in Blender refuses to delete the "animation" entry. However, even if you save the model in Blender, the next time you reload that model from a "cold start" of Blender, that "animation" entry will still be there, but exporting it reverts back to an "animation (0" in the exported .s file.

There is the option I guess of animating in Blender through a full 360 degree turn things like WHEELS11 etc for a more realistic view in Shapeviewer, rather tedious I would think. I mention all of this, because I assume/hope the 4.3 version of the exporter behaves the way the 3D Crafter/Canvas does, namely that the animations section is only created in .s file when you have a non automatic animation in the model.

I just looked at version 3.5 of the exporter, here at Elvas Tower, and noticed that it does not have the "fix" from 4.3. Is there any reason it has not been ported over to 3.5?
From BlenderToMSTSV35.zip:

    	def WriteAnimations(self, stf ): 
            	count = len( self.Animations ) 
            	stf.WriteLine( '	animations ( {0}'.format( count ) ) 
            	for i in range(0,count): 
                	self.Animations[i].Write(stf) 
            	stf.WriteLine( '	)')

Sorry for the length of this response, I do try to be thorough,
Steve

#4 User is offline   wacampbell 

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

Posted 23 November 2020 - 12:09 PM

What version of the exporter are you trying to use?

#5 User is offline   Eldorado.Railroad 

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

Posted 23 November 2020 - 12:46 PM

 wacampbell, on 23 November 2020 - 12:09 PM, said:

What version of the exporter are you trying to use?


 Eldorado.Railroad, on 23 November 2020 - 11:45 AM, said:

I have tried everything, up to version 3.0 with the same results. These work with Blender 2.6.5.



Let's go with 3.0.

#6 User is offline   wacampbell 

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

Posted 23 November 2020 - 12:58 PM

 Eldorado.Railroad, on 23 November 2020 - 12:46 PM, said:

Let's go with 3.0.

OK. I don't have that one in my archive. Please send me a copy of that version of the exporter and I'll try to install the fix in it.

#7 User is offline   Eldorado.Railroad 

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

Posted 26 November 2020 - 09:45 AM

 wacampbell, on 23 November 2020 - 12:58 PM, said:

OK. I don't have that one in my archive. Please send me a copy of that version of the exporter and I'll try to install the fix in it.


Wayne,
I will try to do this tonight. I do not have access to my Blender/OR machine at the moment. Too many fingers in too many pies!

Thanks for you help and patience,
Steve

#8 User is offline   Eldorado.Railroad 

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

Posted 26 November 2020 - 06:09 PM

Wayne,

While I was looking at my MSTSExporter cache I discovered version 3.4. So that is what is attached here. I also have version 3.0 and 3.3 if required.

Thanks for your help and patience,
Steve

Attached File  BlenderToMSTSv3.4(LastFor2.65).zip (2.65MB)
Number of downloads: 5

#9 User is offline   Eldorado.Railroad 

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

Posted 30 November 2020 - 08:41 AM

Wayne,

You have PM

Thanks,
Steve

Page 1 of 1
  • 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