Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Counter-Strike like rotation(limbs+keyframe animation)

Author
Message
SpaDeKo
17
Years of Service
User Offline
Joined: 6th Jul 2009
Location:
Posted: 2nd Sep 2010 16:24
Well.
I have this model with animated legs for the movement.
Only the legs are moving, as I want to make the upper body part move with the mouse.

How would I archive the upper body part, and the child limbs to rotate with the camera, and still let the hip and legs stay at their own position.?

--------------------------------------
NewBie - Coding? Damn..
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Sep 2010 16:57
ROTATE LIMB Obj,Limb,X,Y,Z

I would figure out which limb you want to rotate, maybe even work out better if you rotate 2 limbs. For example, if your character has 1 or more bones on the spine, rotating them might give better results, like a bone above the pelvis could be rotated, but then if theres a bone above that, then rotating that as well might be the best bet - maybe divide the angle by 2, and rotate the limbs by that - so the top-most limb would be rotating at twice the rate of the limb below that. As a body turns, the shoulders turn fully, but the spine might not - you might want to gradually go into the turn to keep the deformations to a minimum.

I suggest making a model viewer, so you can display the limb numbers and sketch out a skeleton with the limb numbers - makes life much simpler if you know what limb is what. I mean, in future you might want enemies to look around by rotating their neck and head, you might as well take a little time out to write a model viewer and get used to rotations.

The animation, limb rotation etc is just like using a keyframe animation package. You can animate the whole model, then rotating limbs is a non permanent thing - you can always rotate the limb back to 0,0,0 to cancel any effects. Child limbs are rotate just like in your animation package, rotating a spine will rotate anything connected to it - that's why I suggest rotating more than 1 limb, at least on Y. It's maybe a good idea to use a limited angle range, say 60 degrees on Y and 90 degrees on X, and if the rotation exceeds that, turn the character - but also turn the character naturally when they are moving. Like rotate the whole character left, while incrementing the aiming angle back to 0. That should help avoid the 'tank' look that a lot of character can end up with after being animated thru code.
You will have to tweak things a lot, but it should be doable, and it should look cool.

Health, Ammo, and bacon and eggs!
SpaDeKo
17
Years of Service
User Offline
Joined: 6th Jul 2009
Location:
Posted: 2nd Sep 2010 17:22
Thank you very much for your answer, that gave some other perspectives

I already got a model viewer that shows me the model structure and the limb names and assigned numbers

The problem is that its about 3 years since I did DBPro coding, and in the meantime, I've done music in FL Studio, and 3D in 3Ds Max, so I'm a bit rusty at this point.

Well. To start small, this is my code, wich rotates my model on the Y and X axis, of course.

yrotate object 2,object angle y(2)+mousemovex()/3.0
xrotate object 2,object angle x(2)+mousemovey()/3.0


I'm pretty sure the YRotate and XRotate wont work on limbs, as far as I know.

I'll take a look at it

--------------------------------------
NewBie - Coding? Damn..
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Sep 2010 17:30
Unfortunately not, and this has implications - because...

yrotate object 2,object angle y(2)+mousemovex()/3.0
xrotate object 2,object angle x(2)+mousemovey()/3.0

is not the same as...

Rotate Object 2,object angle x(2)+mousemovey()/3.0,object angle y(2)+mousemovex()/3.0,0

Your code would rotate the object nicely, the ROTATE OBJECT command will have issues with eular angles, and you face the same problem when you come to ROTATE LIMB, because you can only rotate on all axis at the same time.
I tend to try and only rotate on a single axis on a limb, which can help avoid eular angle problems - this usually means an extra bone or two, but it's worth it. For instance, if you had 2 bones at the lower back, you could rotate them on seperate axis, say lower bone rotate on Y and other bone rotate on X, then your results will be much more predictable.

Health, Ammo, and bacon and eggs!
SpaDeKo
17
Years of Service
User Offline
Joined: 6th Jul 2009
Location:
Posted: 2nd Sep 2010 17:53 Edited at: 2nd Sep 2010 17:55
Ahh. I see :S

Dude = Reference#


Lets asume the upper body part is linked to limb 5+6.

rotate limb 2,5,limb angle y(2)+mousemovex()/3.0
and
rotate limb 2,6,limb angle x(2)+mousemovey()/3.0

Would this be a right way to archive the (torso?) Upper body rotation?

--------------------------------------
NewBie - Coding? Damn..
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Sep 2010 19:05
Yeah, that's the way, although you will have to experiment a lot it should work pretty well.

Health, Ammo, and bacon and eggs!
SpaDeKo
17
Years of Service
User Offline
Joined: 6th Jul 2009
Location:
Posted: 2nd Sep 2010 19:34
Hmmm...
When trying to compile, I get this error:
Quote: "Parameter for 'ROTATE LIMB' do not match 'Object Number, Limb Number, XAngle, YAngle, ZAngle' at line 115."


Line 115 + 116:
rotate limb 2,3,limb angle y(2)+mousemovex()/3.0
rotate limb 2,3,limb angle x(2)+mousemovey()/3.0


--------------------------------------
NewBie - Coding? Damn..
SpaDeKo
17
Years of Service
User Offline
Joined: 6th Jul 2009
Location:
Posted: 2nd Sep 2010 19:48
Damn. Doesnt matter how I change the parametres, it still wont compile.

Would it be easier/better just to cut of the lower body part >
Then load the legs+hip > Then load the upper body part > Glue object to limb(Hip) > and rotate object?

--------------------------------------
NewBie - Coding? Damn..
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Sep 2010 20:44 Edited at: 2nd Sep 2010 20:44
Take a look at the error...
Quote: ""Parameter for 'ROTATE LIMB' do not match 'Object Number, Limb Number, XAngle, YAngle, ZAngle' at line 115.""

And your code...
Quote: "Rotate Limb 2, 3, ( Limb Angle Y(2) + MouseMoveX() / 3.0 )"


Now look again closely, and break it down into parts...

See what you're missing? You only specify one angle, whilst the error clearly states you need 3 angles to rotate a limb.

You need to change your command to this...

(Plus, you're limb angle Y command is also wrong. You need to give it an object, and a limb for it to return the angle.)

It's another case of read the help and look at your code!

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2026-07-22 17:50:56
Your offset time is: 2026-07-22 17:50:56