Swaying in Trainz

PEV

Active member
In the never-ending search for realism in the simulation, the concept of wagon and loco sway has so far eluded us, except for one solution offered by our Russian members. N3V have not included vehicle sway as yet, though I notice that cabin sway now works in TS12.

I have been working on a method of my own for swaying and I am pleased to announce that I have a low overhead method that works. As is usual for me my implementation is a tool that, in this case, does all the work for you.

The method places the loco or wagon body on an invisible mesh with an animated attachment point at the origin. The bogey, limback and limfront attachments are transferred to this invisible mesh.

The tool does all the necessary file modifications and installations, and automatically chooses the correct script for a loco or wagon. Steam locos are a liitle more complicated but the end result is the same.

At present I am in the process of figuring out a way to add my system to rolling stock that already has a script (or library) controlling some other features. I do have a simple example of this working already, but I need to test it with things like Andi06's superscripts.

The tool program will be called by an Openwith macro in CM2 or CM3.

In the last few tests I have done, the process has worked as follows:-

1.. Choose a rolling stock item and clone it..
2.. Use OpenWith menu in CM2/3 to run the Swayer utility on the clone. The program opens, executes, and closes automatically with no input required from the user.
3.. Commit into the game.
4.. Use the new asset in the game. Simple eh????


The swaying is fairly subtle and can be adjusted with settings stored in the config.txt file.

The scripting should be low impact on performance as it spends most of its time sleeping, It just controls the start of various parts on ONE animation, again helping with performance by not having a bunch of animations that have to be loaded.. The invisible mesh has 4 polys and 3 attachments plus what ever bogey attachments that were in the parent mesh.

The scripting has been compiled to suit TS2009 and will NOT work in TRS2006. It requires script functions not supported by TRS2006... I don't know whether TC will run it.

I expect being able to release this new tool package in a couple of weeks.
 
Last edited:
Well, I must say I'm looking forward to giving this a bash. You never cease to amaze with your almost fool-proof tools. Thanks.
 
Wow

Sounds like you have done it again, well done, sounds like a real nice peice of kit. Great work.

Big thing will be how big is that overhead, I have some 135 car coal trains and some 10,000ft stack trains will be intereting to test it on those and see what happens.

Cheers

Lots
 
N3V have not included vehicle sway as yet
have included... Built-in assets BU_Plazkart-013-30588 & BU_Plazkart-014-10430 have this script, though they are not included to the scenarios.

The bogey, limback and limfront attachments are transferred to this invisible mesh.
Good job. Are you using SetMeshAnimationSpeed() for controlling of swaying ? :)
 
Last edited:
Good job. Are you using SetMeshAnimationSpeed() for controlling of swaying ?

No, it doesn't work for what I do. Here is a snippet of the code in the script.

Code:
ActNum = Math.Rand(1,7);
     switch(ActNum)
    {
	case 1: 
                        Amount = 14 - RockAmplitude;
                        if (ActCount<1) ActCount = 5;
                        if (Speed > 15.0) {
                        SetMeshAnimationFrame("default",14);
                        SetMeshAnimationFrame("default",Amount,Rate);
                        Sleep(Rate);
                        SetMeshAnimationFrame("default",14,Rate);
                        Sleep(Rate);
                                      }
                        else Sleep(1);
	           break;

	case 2: etc.
The SetMeshAnimationFrame instructions move the animation a number of frames in a specified time (called rate here), or instantaneously if you use only two arguments. As you can see there are Sleep instructions everywhere, so the script is not busy. Speed is vehicle speed and is in km/hr to make the thing more understandable.

Remember I only use one animation and move around within it to get each effect.
 
Last edited:
Double wow, sounds great. You have a wonderful ability to write these programs. Well done that man. :wave:
 
Just out of curiosity could your method be used to create tilting trains or super elevation, if that is the correct term?

I don't know what a super elevation is but I believe that it may work for a tilt train. I think there is a script function to get the rate of a vehicle's rotation as it goes around curves. If so the tilt train could be a go-er..

I am in the process of testing my gizmo with vehicles that use Andi06's Superscript. I have just managed to get my script to run along with Andi's.. So I now have some swaying carriages with working couplers and all the other fruit that Andi offers..

I have some test samples of his wood-panelled LNER Gresley coach sets and it all works and looks fantastic.. the HTML's and all.... very pleasing.

And it was all done completely transparently.. Just "open with" the Swayer utility in CM3 and re-commit and away they go.

I'm nearly there.. though I still have to complete a "help" system for the tool and do the multi-language support. English (aus) only at present.
 
There is already built-in support for this using Vehicle.SetRollBasedOnTrack() No need to reinvent the wheel.


Hi,

As a new user of ts2010 I was not aware of there being support for this swaying action, perhaps you would be kind enough to point me in the direction of more information please.
 
I don't know what a super elevation is but I believe that it may work for a tilt train. I think there is a script function to get the rate of a vehicle's rotation as it goes around curves. If so the tilt train could be a go-er..

I am in the process of testing my gizmo with vehicles that use Andi06's Superscript. I have just managed to get my script to run along with Andi's.. So I now have some swaying carriages with working couplers and all the other fruit that Andi offers..

I have some test samples of his wood-panelled LNER Gresley coach sets and it all works and looks fantastic.. the HTML's and all.... very pleasing.

And it was all done completely transparently.. Just "open with" the Swayer utility in CM3 and re-commit and away they go.

I'm nearly there.. though I still have to complete a "help" system for the tool and do the multi-language support. English (aus) only at present.


Hi,

The Super elevation I have read about refers to the Track being angled to create the tilt rather than the stock, very much along the lines of "bve" simulator.

Also, thank you for the commitment you are putting into developing tools and improvements to make Trainz better for all.

Mike
 
Back
Top