Jump to content
  • Advertisement
Allba

Locomotive Rigging

Recommended Posts

Hi guys, just looking for some advice on how to approach doing rigging for a locomotive for use within Unreal.

I currently have my model rigged and ready to go, I am just unsure how to go about actually getting the rig working and animating.  I came across a tutorial on you tube which uses a mixture of constraints and bones, but as I understand it, game engine require a fully boned rig to work.

Building rigs is not one of my strong points so any help is greatly appreciated

I have attached an image of the rig and model I have currently 


Thanks
Stu

Capture1.PNG

Share this post


Link to post
Share on other sites
Advertisement

I've never tried anything this complex, assuming the arms have to stay attached to the wheels and animate accordingly. But there's two options, one is to animate it through code. That's certainly what I would do with an automobile (which I've done). You just parent the wheels to the body and then your code can control the matrix of each wheel to make them spin or turn and such. That's certainly not something I would animate with an animation file, which is the other option. For one thing, you want to control the speed of the wheel rotation in accordance with the velocity of the vehicle. In Unity (or Unreal), they obfuscate the matrix and I hear they actually use quaternions instead, but regardless it's still the same thing. Each object in Unity has it's position, orientation, and scale info and that's what I'm talking about here.

 

In this case, your machine may be complex enough that it's difficult to animate in code. So, you might actually animate it in your animation program and control the playback speed, even possibly reversing it.

Anyway, interesting project! This is something I intend to do one day. I've actually bought half a dozen books or so on how steam engine locomotives work and how to operate them. I'm learning to model now. So, that's on my "to do list".

You need to figure out the math so that the distance the wheel travels in one rotation is the same as the circumference of the wheel. That means smaller wheels will turn faster at the same velocity.

Share this post


Link to post
Share on other sites
On 12/5/2017 at 1:20 PM, Allba said:

I came across a tutorial on you tube which uses a mixture of constraints and bones, but as I understand it, game engine require a fully boned rig to work.

You build the rig in the engine, instead of your 3D application. It's very much the same as doing in your 3D software.

Unreal also allows for a back and forth workflow, using FBX meshes, just don't allow the exporters to attache extra bones.

You will want to learn most of Unreal's skeletal tools: https://docs.unrealengine.com/latest/INT/Engine/Animation/index.html

 

This isn't easy and a train is hard to start with. Maybe just start with a few components first.

You could also make the animation just in your 3D app then export as simple animations. You loose the real time rig but it's easier to do.

Share this post


Link to post
Share on other sites

At least in blender I do not understand this stuff. There are bones, constrains and physics. You never know what to choose in the start of a project and get problems at integrtion. Better integrate bullet into your code. Unreal can't be worse than eg Blender. I'm a coder at heart, so 3d modelling apps usually go against my mark.

Share this post


Link to post
Share on other sites

Make a plan, like Im assuming youre doing with game, It always better to understand how things work in real life, Try youtube or google when people detaching / ataching things in real life

Share this post


Link to post
Share on other sites

So I've found this to be an intriguing problem, and have ended up giving it quite a bit of thought over the past 24 hours. I think my solution somewhat builds on Scouting Ninja's advice.

I'll go back to what I said earlier in that probably the easiest way to do this for you may be to animate it in Blender or whatever animation program you use. Unreal (or Unity) almost certainly has a way to load in non-humanoid (because there's plenty of tutorials on doing basically the same thing with a humanoid armature) and it's animation data and play it back. Then you should just need to control the playback speed. That's skinned animation even though this is a rigid model. For artists, that's almost certain to be the easy way out and I expect it would work just fine.

The programmer side of me wanted this to be rigged animation instead. That requires understanding that bones are actually matrices and a little matrix algebra. I come from a background with XNA and then DX11 and OGL 4.5. There you have to use matrices everywhere. So, in an engine like Unity (where I've seen this) and probably in Unreal a lot of that is obfuscated from you and you are just presented with position, orientation, and scale without realizing that that's basically a game matrix. So, it may not even occur to most to treat them as matrices. But that's exactly what I would do.

The thing that makes this tricky is the "main rod" of the engine. For this discussion I will be using the part names from this picture. The main rod is a problem because one end is attached to the piston rod at the crosshead. The other end is attached to the side rod on the main crankpin which is attached to the driving wheel (unlabeled but that's the wheel being turned most directly by the engine). In the real world, that crankpin is going to move in a circular path because of real world physics and the fact that it is basically on a circular track (the wheel). You don't have real world physics here, so you have to basically simulate what's going on and therein is the primary problem. Additionally, the side rod drives the other two wheels on that side.

It helps substantially here if you've done rigged animation with matrices before, because this is one of the most complex examples of it I've ever done and it helps tremendously if you've done it with something a bit more simple to get the concept down.

But the way rigged animation works is that when you multiply two matrices together the result parent's one matrix to the other. So, you substitute the result of that multiplication for the child's matrix. To start off with, you need to parent the train body to everything else mathematically. You can do that in Blender, for example, as long as the engine reads and understands that relationship when it imports the model. Even if it doesn't you can parent objects in Unreal (or Unity) and it will do the same thing. Or if you could not do that (which you can) you could even do it mathematically yourself by getting a matrix for the parent, maintaining your own matrix for the child, multiplying the two together every draw frame and putting the result matrix back into the child for it's position, orientation, and scale. But I think if you just get these relationships right in Unreal, it will take care of about 80% of the work for you.

So, the locomotive body would be the main parent (great great grandparent or such depending on how deep this goes because children can be parents too). Everything would be a child of that. Once you do this, all of those parts will be attached to the body and move with it although they will not be yet animated. Moving the piston rod is easy; because of the parent-child relationship, it's position is relative to the locomotive and it simply needs to move forwards and backwards at a calculated rate dependent on the locomotive's velocity. (You'll have to do some math there although you can probably "wing" some of the math and just do what looks right.) The first big problem is that the main rod doesn't just simply move back and forth, but rather one end travels in a circle.

I think the way I would solve this is to have the wheels actually disconnected from that and animate them separately. The wheels would be children of the locomotive body. And if you rotate them, they should be attached to the same spot on the body while rotating like wheel's should. You just have to figure out the circumference of the wheel and rotate the wheel 2pi (360 degrees) every time the locomotive moves that distance. All the wheels will turn at the same rate as long as they are the same diameter/circumference.

And here's the key: I would put the crankpins on the wheels as children of the wheel. That would give it an actual position relative to the wheel it is a child of. That's not so you can animate the crankpin or attach anything to it; this is just a simulation of reality. It's because you need a position to point at. And the solution is that the main rod's bone (a bone is a matrix basically) is centered at the crosshead. The main rod must have it's position at the crosshead for this to work right. So, when you talk about the main rod's position you are also talking about the position of the crosshead. That makes that long rod controlled there at the crosshead. Now, all you need to do is use a LookAt() function for the main rod's orientation/rotation and have it "look at" the main crankpin. As long as all the speeds are right, that should basically keep it attached to the main crankpin. And viola!

I think the primary problem left is the side rod; it needs to stay horizontal as it travels through it's circular path. There are probably several ways to handle this. You could have it as a child of the front crankpin and do a LookAt() to the back crankpin.

So, that's your main motion. If you get into the motions of the other rods, it should basically be more of the same.

 

Hope that helps!

 

 

 

Edited by BBeck

Share this post


Link to post
Share on other sites

All of this can be done via Maya or 3dStudio Max. You would need a center bone at 0 0 0 (root) and then add in bones from there for each of the different parts you want. Using constraints and set driven keyframing you can achieved what you want. Most of what you are doing is a simple rig due to the fact that it is all "solid" and should have either 1 or 0 weight applied to it. The hard part would be seperating out all of the parts you want animated and then weighting them to the bones, this will take time, but once complete will allow endless edits and simplistic modification.

I think you are over thinking this process + a lack of knowledge helps to make this a harder task than it is. This is not an insult just an obeservation of what is going on. Some things to think of:

 

1) You can rig this all day, but where you are going wrong is you are lacking CONTROLS that get applied to each of the bones. As you are not primarily a rigger/animator I understand why you might not have them, but in this case its horrible to attempt this without them.

2) Understanding the motion of an object is crucial before you even create the rig. If you want to avoid rework you need to know all the possible motions your object will need to make. If, in this case, you only want the spokes to control the wheels and you have the wheels moving in conjuntion this is a super simple rig that would take 5 minutes to finish. If you have other requirments such as pistons or bolts moving then we get into a bit trickier situation, all of which still depend upon number 1 (control rigs)

3) I know it was suggested, but I HIGHLY recommend you do not create this in Unreal or Unity or any other program. You will gain the most control for the first iterations as well as edits by doing it properly the first time. If you  want to learn about all of this  you need to do this from an approach that will help you to understand:

Youtube the following in order:

- Rigging

- Weighting

- Control Rig

- Set Driven Keys

4) If you are still confused, you could share the model with me, I will point out what you should do and even take some time to show you how to actually do it. If you dont care to learn I could just rig it up for ya in a few minutes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!