Steve's Modding Tool
Keyframe Generator
VehicleUtils Generator
TransF Converter
Metadata Generator and Value Converter
New TransF Matrix - What is it?
Well, it's not exactly new. This is a hangover from Train Fever and TpF1. "Discovered" by Killakanz, this matrix is a far more readable version of the one used in the game and generated by the model editor.
This matrix is unique for describing angles and degrees of rotation in simple notation. And is formatted like this:
transf = transf.scaleRotZYXTransl( vec3.new(1.0,1.0,1.0), transf.degToRad( 0.0, 0.0, 0.0), vec3.new( 0.0, 0.0, 0.0), ),
How it works
vec3.new(1.0,1.0,1.0),
This is the scale, these values mean no scaling is applied to your model. A value of 0.5,0.5,0.5 would scale your model by half.
transf.degToRad( 0.0, 0.0, 0.0)
This is your rotation along Z Y X axis respectively. These are in degrees, so to rotate a mesh 90 degrees along the Y, your value would be (0.0,90,0.0)
vec3.new( 0.0, 0.0, 0.0),
This is your position, unchanged from the normal TransF matrix.
Animations for steam locos using VehicleUtil
To use the vehicleutil animations, and the classic keyframes, first define these variables in your .MDL file.
local vec2 = require "vec2" local vec3 = require "vec3" local transf = require "transf" local vehicleutil = require "vehicleutil"
Lets cover the 3 basic animation types
Pistons
drive = vehicleutil.makePistonAnim(vec2.new(0,0), vec2.new(0,0), vec2.new(0,0))
Connecting Rod (Crank rod)
drive = vehicleutil.makeConnectingRodAnim(vec2.new(0,0), vec2.new(0,0), vec2.new(0,0))
Coupling Rod
drive = vehicleutil.makeCouplingRodAnim(vec2.new(0,0), vec2.new(0,0), vec2.new(0,0))
How to get the correct values for proper animation
We will take the most complex, connecting rod, and take it apart to see what each bit does
drive
The animation trigger. This means it animates when moving in relation to the speed of the vehicle.
= vehicleutil.
Uses the vehicleutil function
makeCouplingRodAnim
Defines the kind of animation
(vec2.new(0,0),
This first vec2 defines the animation duration. (vec2.new(0,WHEEL_AXLE_HEIGHT)
(vec2.new(0,0),
The second vec2 defines the animation extent. How far your rods move. (vec2.new(0,ROD_HEIGHT)
(vec2.new(0,0),
The last vec2 defines the motion of the connecting rod and piston animations. (vec2.new(ROD_LENGTH,ROD_HEIGHT)
This will get you all you need for locomotives without outside valve gear
If you have Walschearts Valve Gear
There are 2 more tricks for getting smooth movement of the rods before we go to keyframes.
Make a wheel mesh with the offset crank on the wheel itself, or make the offset crank have its origin the same as a wheel, and define it as an axle. This will ensure smooth rotation.
The return rod
There is a trick you can do with the return rod to make it work like the other animations and not need keyframes. Make sure to origin the return rod at the end that connects to the offset crank.
drive = vehicleutil.makeConnectingRodAnim(vec2.new(0,AXLE_HEIGHT), vec2.new(ROD_OFFSET_X,AXLE_HEIGHT), vec2.new(ROD_LENGTH,AXLE_HEIGHT))
Local declares for VehicleUtil compatibility
local transf = require "transf" local vec2 = require "vec2" local vec3 = require "vec3" local vehicleutil = require "vehicleutil"
.mdl file module
{ materials = { "vehicle/train/material.mtl", }, mesh = "vehicle/train/mesh_file.msh", transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, }, },
Group file name
groupFileName = "vehicle/train/model_menu.mdl",
vehicle crew template
{ animation = "idle", crew = true, forward = true, group = 1, transf = { 1, 0, -0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -3, -0.5, 1.5, 1, }, },
Engines and metadata template for steam loco (50mph, 1000hp, 50000lb/f)
engines = { { power = 745.71, tractiveEffort = 222.22, type = "STEAM", }, }, soundSet = { name = "soundset_name", }, topSpeed = 22.35, weight = 105, },
Particle emissions template for steam loco (taken from Big Bertha locomotive)
particleSystem = { emitters = { { position = {4.2, .0, 3.8589}, velocity = { .0, .0, 8.0 }, color = { .2, .2, .2 }, frequency = 50, lifeTime = 20.0, size01 = { 1.2, 16.0 }, child = 1 }, { position = {-3, .0, 3.7}, velocity = { .0, .0, 5.0 }, color = { .9, .9, .9 }, frequency = 70, lifeTime = 5.0, size01 = { .2, 3.0 }, child = 1 }, { position = { 4.2, 1.283, 1.5 }, velocity = { .0, 3.0, 0.0 }, color = { .9, .9, .9 }, frequency = 9, lifeTime = 2.5, size01 = { .4, 5.0 }, child = 1 }, { position = { 4.2, -1.283, 1.5 }, velocity = { .0, -3.0, 0.0 }, color = { .9, .9, .9 }, frequency = 9, lifeTime = 2.5, size01 = { .4, 5.0 }, child = 1 }, }, },