Rolling Line

Rolling Line

평점이 부족합니다.
Animations in Blender for train mods
Franks 님이 작성
Learn how to create animated wheels using Blender for use in the new train modding system
   
어워드
즐겨찾기
즐겨찾기됨
즐겨찾기 해제
Introduction


Animations are one of the more complicated parts of 3D modelling, but luckily you only need to know that basics to make mechanical animations (like spinning wheels and pistons).

You don't need to worry about lots of the more complex parts of 3D animation, like bone weights and blending.

You can use any software you like to make animations for use in Rolling Line, but this tutorial will use Blender (which Is what I have used for the entire development of Rolling Line, and it's 100% free).
Any software that can export your animation as an FBX file will be fine.

Example files

You can find a range of example files (both final FBX models + raw Blender files) in the train mods template folder, which is found here:

...(Program Files)\Steam\steamapps\common\Rolling Line\Modding\templates\train mod examples\animated wheels examples

Model structure
Firstly, here is an overview of what a properly set up animation should look like.

You will need two objects in your Blender file, the 3D model for the wheels themselves, and an armature (animation rig/skeleton).
Using the side-rod's wheels as an example, you can see that the rig has 5 bones. These bones are:
  • Rod - the moving rod which connects the wheels (this controls the rods on both sides, since the model is mirrored)
  • Main - This is a bone which stays still. It is used to lock the rest of the model in one place, since unassigned parts of the mesh can sometimes behave in strange ways.
  • Wheel 1, 2, 3 - These bones are assigned to each rotating part (the two wheels and the gear in the middle).



Each bone has a set of vertices assigned to it.
(These are the parts of the mesh each bone will affect).

In Blender, these are represented by vertex groups, which have the same name as the bone.
E.g. the vertex group "rod" contains the vertexes that will be moved along with the "rod" bone.

Here is a visual example of how the "WHEEL3" bone has control over all of the vertexes in the "WHEEL3" vertex group:



In terms of hierarchy structure, the mesh for your wheels should be parented to the armature.
When you parent a mesh to an armature, it will automatically create the necessary components and vertex groups to make animations work.



If you switch over to the "Animation" view (or just open an "Action editor" window) you should only have one animation created to store your wheel movement.
(it doesn't matter what you name it)



You should also make sure your Blender file's animation frame-rate is set to 60fps instead of the default 24fps.
The location of this setting varies depending on your version of Blender and project setup.

But that's all you need!
To sum up:
  • A mesh for your wheels
  • An armature with bones for each part of your mesh
  • Vertex groups for each bone, assigned to the required parts of the mesh
  • A single animation containing movement data

If your Blender file ticks all these boxes, you can export your scene as an FBX model using the default options, and it should work inside Rolling Line.

If your animation is not playing in-game, one cause might be that the "animation index" is set wrong. Try changing this value and see if the animation has accidentally been loaded onto a different index.

Creating a model and rig from scratch
This section will cover the rough steps to create an animated set of wheels from scratch.

Create the base mesh

Simply make a 3D model for the wheels as you normally would, without thinking about animations just yet.
This mesh will have no vertex groups:



Create an armature (rig/skeleton)

The next step is to create a new armature object with just a few simple bones.
For this example, just 3 bones:
  • Wheel 1
  • Wheel 2
  • Rod
Make sure the wheel bones are perfectly centred, otherwise the wheel will have a wonky spin.



Parent the mesh to the armature

Next, simply select the mesh, then hold shift and select the armature.
With both selected, press Ctrl-P to open the parent options popup.
Select the option "Armature deform -> with empty groups"



This will link up the animation rig with the mesh.
Plus it will create the named vertex groups mentioned in the introduction.

Your vertex groups and scene structure should look like this now:



Assigning parts of the mesh to bones

You'll need to set up each vertex group to contain each part of the mesh.
To do this, select all the relevant vertexes on your model in edit mode, then click "Assign" with the corresponding vertex group selected.



You can click "select" and "deselect" to view which vertexes are assigned to this vertex group.



Do the same step for each one of the bones (e.g. assign all the vertexes of the moving rod to the "Rod" vertex group).

You can test that the armature is working by selecting it and going into "pose mode".



While in pose mode you should be able to move the bones around and the see the assigned vertexes move around as well:



Once all these vertex groups are set up you are ready to start animating.



Creating an animation
Once your model and rig is all set up and working correctly, the next step is to create an animation for the wheels' movement.

Firstly, switch over to the "Animation" window view in Blender:



Once in the animation view, find the "action editor" window.
It may be set to "Dope sheet" by default, in which case simply click on where it says "Dope sheet" and change it to the "Action editor" option.

Make sure you have the armature selected (not the mesh) and then click the "+ New" button:



Now that you have an animation created, the next step is to actually animate your wheels.
Since this is a broad topic which isn't unique to Rolling Line, I won't go into detail about how to make animations, as there are plenty of other tutorials around this topic.

Long story short, you want to create a short animation loop which includes your wheels doing a single 360degree rotation.
Once in-game, this animation will be played as a loop to create the effect of spinning wheels.

For example, the animation for the rod should look something like this, with a range of keyframes that form a completed loop:



You can use the "Graph editor" below the action editor window to fine-tune the movement of the wheels (though this can get a bit complicated).

Once your animation is done you can switch back over to the "Default view" and your model should appear like this:
(you can press Alt-A to play/stop the current animation)

Exporting as .FBX
The last step to get your models in-game is to export them as .FBX models.
FBX models are able to contain animation data (unlike OBJs).

Simply use the menu "File -> export -> FBX":



The default FBX export options will work fine.
Export this file to the "Custom Assets" rolling Line folder so you can access them using the in-game modding system.

...(Program Files)\Steam\steamapps\common\Rolling Line\Modding\custom assets

Using the new model in-game

Please refer to the full modding guide, which explains how to set up models for in-game mods if you haven't already:

https://steamcommunity.com/sharedfiles/filedetails/?id=2664192139

Once you have set one of the wheel blocks of your mod to use your newly exported animated model, it should play automatically when your train mod moves along the track, and should look something like this:



Remember, if your animation is not playing, it might be caused by the animation using a different "Clip index" due to more than one animation being included in the FBX export.

Try changing the "Model options -> animation -> clip index" option and see if the animation has accidentally been loaded onto a different index.



If you are expeincing other issues with your animation (like some parts not moving, or strange movement you are not expecting) then this may be caused by the animation importer interpreting the data wrong.

The animation importer Rolling Line uses is called "Trilib" and you can use this online version of the tool to test out your models:

https://ricardoreis.net/trilib/demo/



If your model appears incorrectly on the online viewer, then sadly the issue is caused by the models formatting and you'll have to double-check if there is anything in the model/export that could be causing this.

A common issue is caused by parts of the mesh not being assigned to any bones, or being assigned to multiple bones overlapping.
댓글 17
A_Person 2024년 6월 13일 오전 1시 42분 
Which is weird becuase when I try to make one it's always a "group"
A_Person 2024년 6월 13일 오전 1시 24분 
Except for the fact it didn't automatically create a vertex group.
A_Person 2024년 6월 13일 오전 1시 17분 
nvm found it
A_Person 2024년 6월 13일 오전 1시 11분 
Where do you find Vertex Groups at?
Ozzie_Warrior 2023년 9월 26일 오전 5시 26분 
Thanks for this - very helpful +++++++++++++
Franks  [작성자] 2022년 7월 3일 오후 4시 47분 
@Pyro Tank best to zoom in a lot and try and get it as accurate as possible. In blender there are a few tricks like snapping the 3D cursor to the centre of the wheel, then aligning the bone with the 3D cursor
Max 2022년 5월 11일 오후 2시 00분 
Wow
Globin347 2021년 12월 17일 오후 3시 06분 
Never mind, I figured it out. For some arcane reason, the animated model displays roughly 100 times smaller than the non-animated model.
Globin347 2021년 12월 17일 오후 12시 00분 
So, I'm having a bit of trouble. If I import a static model to Rolling Line, it works as expected. However, If I Import an animated fbx file, the entire model won't render. It turns invisible.
Spooky Month Boi 2021년 12월 14일 오후 10시 06분 
E P I C