Model rotating but staying attached

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
eejin
Posts: 97
Joined: Sun Jul 24, 2011 11:50 am

Model rotating but staying attached

Post by eejin »

Hello, I've ran into a bit of trouble with the players character.

The problem is that the character rotates toward the mouse en that works but now when the mouse is in one of the four parts of the screen (see image for reference) the leg animation will be different.
Image
Example: When the mouse is in part 1 and the D button is pressed the character will walk to the right and will face the cursor. Now it would walk sideways so a sideways animation would be shown. But when the mouse is not exactly in the middle of the image (width wise) in part 1 it would look a little bit odd. Now the legs should move 45 degrees everytime so they should be seperated from the body. now if the body is rotated 44 degrees then the cursor would be in part 1 and the body would face 0 degrees (straight up) then you would see that the torso isn't connected to the legs. So my question is how do I fix this problem?

A thing that I think could be done is that a row of vertices would be connected to the legs and body but this should be done in Irrlicht itself I think.

Thanks in advance.
eagletree
Posts: 28
Joined: Mon Jul 26, 2010 11:55 pm

Re: Model rotating but staying attached

Post by eagletree »

I'm not able to understand your question clearly and there may be something about RTS games that is beyond me. But, it sounds like you are trying to use multiple discrete meshes (perhaps linked as children?) where one might be more appropriate. If the object is a Player model, it could be made one mesh in loading, so there are no holes to see through, then perform rotations via it's rigging. It would fall to you to create the model such that it can't be manipulated in such a way that the parts can appear separated, unless for some reason, they should be separated at some point in the scenario. If this is done for breakage (say in an explosion), a solution would be to have different models pre and post explosion.

Forgive me if I've missed your question.
eejin
Posts: 97
Joined: Sun Jul 24, 2011 11:50 am

Re: Model rotating but staying attached

Post by eejin »

Well the thing is The upper body faces the mouse and the legs rotate in 45 degrees pieces so they could look seperated. I use bones maybe there is a use with that?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Model rotating but staying attached

Post by CuteAlien »

I usually do fake (sorry, it's a thing game-coders sometimes do, don't tell anyone...). Which means - I have animations like walk-forward-look-left, walk-forward-look-straight, walk-forward-look-right, etc.
So my avatars do not look exactly at the target, but only approximately in the right direction. But it also means I just need a single animation for that and it's fixed and not dynamic which is a lot easier. One day I'll do better..
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
eejin
Posts: 97
Joined: Sun Jul 24, 2011 11:50 am

Re: Model rotating but staying attached

Post by eejin »

Yea the easy way is not always the best way. Is it that hard that I wont get it to work?
Do you maybe have a video showing the way you described?
The way I want it is identical to this: www.deadfrontier.com (main page video).
blAaarg
Posts: 94
Joined: Tue Mar 02, 2010 9:11 pm
Location: SoCal

Re: Model rotating but staying attached

Post by blAaarg »

To me, in that link, it looked like the programmers were basically doing almost exactly what CuteAlien was describing (that is, have an animation of the character backing up and shooting forward). The only difference was that they were pointing the character's upper body at the target and letting the legs "slip" on the floor when he wasn't backing straight up. Then, when the difference between the direction he was running and the direction he was shooting was large enough, they would swap in a different animation (of him, say, shooting left while running forward) and swivel his gun exactly towards the target even if his (mostly hidden) legs were running (and slipping) in a (slightly) different direction.

Improving on that would be complicated, I think. You could have completely independent animated nodes for upper and lower body and rely upon the points where they link up (at the belt, for instance) being obscured by the fact that the upper body is larger and above the legs. That would avoid having to figure out a way to weld the vertices of 2 different, independent animations (which doesn't sound fun or effecient). Also, your character's feet would still slip on the floor if he isn't running a constant speed matched to the animation.

Using rigged meshes with bones might theoretically address those problems but that seems at least as complicated to me. :|
"Computers don't make mistakes! What they do they do on purpose!!"

-Dale Gribble
eejin
Posts: 97
Joined: Sun Jul 24, 2011 11:50 am

Re: Model rotating but staying attached

Post by eejin »

So what you are saying is that I need the upper body and the legs as seperate models each with animations and don't have connected vertices between these two to keep it simple?
Then the noticable gap between the legs and the upper body is almost too small to be noticable from the character that takes up only about 1/10 of the screen?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Model rotating but staying attached

Post by mongoose7 »

You'd push the upper body slightly down onto the legs so there would be no gap. Assumes upper body is a bit wider, but why not?
eejin
Posts: 97
Joined: Sun Jul 24, 2011 11:50 am

Re: Model rotating but staying attached

Post by eejin »

Ok thanks for the help. Lets see if I can get it to work.
Post Reply