This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-03-27 07:14:23

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Help with joints system.

Im trying to develop a jointed body engine, but I've ran into some trouble when doing the legs, I'm doing them in three parts, the top of the leg, the bottom of the leg and the foot, the foot doesn't matter at the moment, once I'v gotten the bottom part of the leg to work, I should be able to adapt it so that it works for the foot.
So my problem is, I cant get them to look jointed, and emulate walking properly. Iv tried Trig (Im not very good at it, since I've not done it in school yet) I've tried adapting the scripting for the arms, still nothing works. Do you have any idea how to do it? Ill credit you if you help.
The project is: http://scratch.mit.edu/projects/markyparky56/952673


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#2 2010-03-27 14:02:24

AddZero
Scratcher
Registered: 2007-08-11
Posts: 100+

Re: Help with joints system.

Wow, this is an ambitious project, nice!

So you're trying to make a "forward kinematics" FK animation system.
Have you seen this? http://scratch.mit.edu/projects/erbie/377828
or this? http://scratch.mit.edu/projects/camieac/127252

So, you have three joints in the leg:
For the thigh, you can put the pivot point (on the costume) at the top, then the lower leg, you can put the pivot point at the knee, then on the foot, on the ankle.

if you rotate the thigh, the lower leg and foot also rotate.  If you rotate the lower leg, the foot also rotates, and if you rotate the foot, only the foot rotates.
In animation systems this is called a parent child relationship. 

So the foot has to know where the lower leg is positioned and rotated...
The lower leg has to know the same about the thigh, and the thigh needs to know the same about the hip.

You'll be using sin and cos to translate, there's a good simple example of this somewhere...  perhaps the above projects will help.



After you get that working, animating a walk cycle with FK is not very easy if you want it to look right.  you have to rotate every joint for every frame in the cycle and play back that animation, (from a list probably)  So that the foot does not go through the floor when it's supposed to be planted on the ground. 

http://www.idleworm.com/how/pic/a0002/wlk01.gif

http://www.idleworm.com/how/anm/02w/walk1.shtml

It's easier to animate walk cycles with IK "inverse kinematics" because you would only have to position the foot, and the other leg parts position and rotate appropriately.  but that's more difficult to program.  (and perhaps not a very fast algorithm in scratch. http://scratch.mit.edu/projects/Suzu/854771 )

Last edited by AddZero (2010-03-27 14:21:46)


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#3 2010-03-27 16:52:06

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Help with joints system.

AddZero wrote:

Wow, this is an ambitious project, nice!

So you're trying to make a "forward kinematics" FK animation system.
Have you seen this? http://scratch.mit.edu/projects/erbie/377828
or this? http://scratch.mit.edu/projects/camieac/127252

So, you have three joints in the leg:
For the thigh, you can put the pivot point (on the costume) at the top, then the lower leg, you can put the pivot point at the knee, then on the foot, on the ankle.

if you rotate the thigh, the lower leg and foot also rotate.  If you rotate the lower leg, the foot also rotates, and if you rotate the foot, only the foot rotates.
In animation systems this is called a parent child relationship. 

So the foot has to know where the lower leg is positioned and rotated...
The lower leg has to know the same about the thigh, and the thigh needs to know the same about the hip.

You'll be using sin and cos to translate, there's a good simple example of this somewhere...  perhaps the above projects will help.



After you get that working, animating a walk cycle with FK is not very easy if you want it to look right.  you have to rotate every joint for every frame in the cycle and play back that animation, (from a list probably)  So that the foot does not go through the floor when it's supposed to be planted on the ground. 

http://www.idleworm.com/how/pic/a0002/wlk01.gif

http://www.idleworm.com/how/anm/02w/walk1.shtml

It's easier to animate walk cycles with IK "inverse kinematics" because you would only have to position the foot, and the other leg parts position and rotate appropriately.  but that's more difficult to program.  (and perhaps not a very fast algorithm in scratch. http://scratch.mit.edu/projects/Suzu/854771 )

Ok... those 2 projects you posted at the begining aren't that helpful... the crane one was the closet to what im trying to achive, the skeleton one is just like an animation going through a series of ready set instructions. But i geuss its a start. 
Iv been thinking if I should do it a bit like that, but how would i do it so that it can do it anywhere across the stage?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#4 2010-03-27 22:53:38

AddZero
Scratcher
Registered: 2007-08-11
Posts: 100+

Re: Help with joints system.

The first two projects showed the use of forward kinematics; so that when you rotate the upper leg and the lower leg moves and rotates as though it's connected.

But like I said to make a good walk cycle in FK, you'll have to set the rotations on each leg section for each frame anyway. ( so that the foot stays where you want it, planted on the ground.)

So here's a another idea, don't use fk and trig.
Instead you could hand animate the rotation and position for each part of the leg and save those positions in a list.  you'll probably need to make an editor script for positioning the parts and saving positions for each frame in a list.
But this idea is not easy either.  it will take a lot of work to make parts look connected and the animation smooth.  (FK is nice because those rotating joints make smooth arcs with less work. But FK is better for arms than legs.  IK is preferred for jointed limbs when they touch something, like feet touching the ground.  But not practical in scratch, that I know of.)

Or you could make this much simpler and have stiff one part legs.  But that's the easy (and not pretty) way out.

I do not know an easy way to have three part legs (upper, lower, feet) do all the complicated rotations and moves that are in a walk cycle animation.  But I've tried to explain how real animation programs work.  (that are used by animators to make your movies, cartoons and games.)

This is a very challenging problem.  Congrats for trying!

I may be able to help later next week if you like.

Last edited by AddZero (2010-03-27 23:07:14)


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#5 2010-03-28 11:19:45

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Help with joints system.

AddZero wrote:

The first two projects showed the use of forward kinematics; so that when you rotate the upper leg and the lower leg moves and rotates as though it's connected.

But like I said to make a good walk cycle in FK, you'll have to set the rotations on each leg section for each frame anyway. ( so that the foot stays where you want it, planted on the ground.)

So here's a another idea, don't use fk and trig.
Instead you could hand animate the rotation and position for each part of the leg and save those positions in a list.  you'll probably need to make an editor script for positioning the parts and saving positions for each frame in a list.
But this idea is not easy either.  it will take a lot of work to make parts look connected and the animation smooth.  (FK is nice because those rotating joints make smooth arcs with less work. But FK is better for arms than legs.  IK is preferred for jointed limbs when they touch something, like feet touching the ground.  But not practical in scratch, that I know of.)

Or you could make this much simpler and have stiff one part legs.  But that's the easy (and not pretty) way out.

I do not know an easy way to have three part legs (upper, lower, feet) do all the complicated rotations and moves that are in a walk cycle animation.  But I've tried to explain how real animation programs work.  (that are used by animators to make your movies, cartoons and games.)

This is a very challenging problem.  Congrats for trying!

I may be able to help later next week if you like.

Ok thanks, ill give it ago, i have an idea which might work.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#6 2010-03-29 13:43:50

AddZero
Scratcher
Registered: 2007-08-11
Posts: 100+

Re: Help with joints system.

Here's another idea... it's still kind of complicated, but may allow for more automatic movement, instead of prerecorded.
It might be a faster IK solver idea:

Have a hidden knee object.
the upper leg's rotation axis is still at the hip, and is constantly positioned where the hip is. but it looks in the direction of the knee.
the lower leg's rotation axis is at the ankle, and it's also constantly looking in the direction of the knee and is positioned at the foot location.
the knee's y position is half way between the distance between the hip and the foot, but has more x position as the two points are closer.  some type of formula to position where the knee should be... approximately at least.

Now you can position the feet and the legs respond accordingly, perhaps you have make some system to pickup and plant the feet as the character walks and jumps... hmm... this is still complicated. 
but IK like this, would give more dynamic results, not prerecored animation, and mix animation like crouch and walk slowly...

Last edited by AddZero (2010-03-29 22:47:08)


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#7 2010-03-30 08:30:52

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Help with joints system.

AddZero wrote:

Here's another idea... it's still kind of complicated, but may allow for more automatic movement, instead of prerecorded.
It might be a faster IK solver idea:

Have a hidden knee object.
the upper leg's rotation axis is still at the hip, and is constantly positioned where the hip is. but it looks in the direction of the knee.
the lower leg's rotation axis is at the ankle, and it's also constantly looking in the direction of the knee and is positioned at the foot location.
the knee's y position is half way between the distance between the hip and the foot, but has more x position as the two points are closer.  some type of formula to position where the knee should be... approximately at least.

Now you can position the feet and the legs respond accordingly, perhaps you have make some system to pickup and plant the feet as the character walks and jumps... hmm... this is still complicated. 
but IK like this, would give more dynamic results, not prerecored animation, and mix animation like crouch and walk slowly...

Uhhhh... would you try putting that into a project or diagram, because thats a bit too confusing for me...


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#8 2010-03-30 15:28:44

AddZero
Scratcher
Registered: 2007-08-11
Posts: 100+

Re: Help with joints system.

You picked a very difficult problem.
I spent a good chunk of time trying to explain it well. 
(does someone else have an easier solution?)

I think I've explained 4 possible solutions to the problem now.
None of them are easy.  This is advanced stuff. (again, congrats for trying!)

What method did you want to use?
What part of what I wrote is confusing? 
I'll try to explain it clearer.

(With the last method, I left some holes.  I don't know how to figure out the best knee position yet.  Probably place the knee at the midpoint between the hip and ankle, (imagine a line between the hip and ankle) and move it perpendicular to that line forward a certain number, there may be some formula for this.  You can try searching on google, but most deal with multi-joint IK ( like for mechanical snakes), I bet there's a simple solution to 1 joint IK (just a knee) somewhere...  edit:  ooh, look at it like a triangle?)

You want to me to make an example? 
Hey, that is a ton of work!
I can with a "please", perhaps.   smile

Or perhaps someone else has a better/easier solution to this problem?

Last edited by AddZero (2010-03-30 16:44:11)


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#9 2010-03-30 17:03:06

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Help with joints system.

Well, I don't know about animating the whole thing so it walks realistically, but here's a cool non-trig way to deal with joints...

http://scratch.mit.edu/projects/taddl/956154

It takes a few more sprites though so might have lag issues at higher sprite counts.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#10 2010-03-30 17:40:54

AddZero
Scratcher
Registered: 2007-08-11
Posts: 100+

Re: Help with joints system.

Paddle2See wrote:

Well, I don't know about animating the whole thing so it walks realistically, but here's a cool non-trig way to deal with joints...

http://scratch.mit.edu/projects/taddl/956154

It takes a few more sprites though so might have lag issues at higher sprite counts.

Cool Thanks!  That's a good way to do the FK method, good for swinging arms.

That could be part of the puzzle.
The next part is to figure out the angles so that the foot is planted on the ground.  That's what IK does.


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#11 2010-03-31 05:58:17

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Help with joints system.

Ok... that helped... Ill give that a go, thanks for showing me tha paddle2see.  smile


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#12 2010-03-31 17:41:50

taddl
Scratcher
Registered: 2009-03-08
Posts: 100+

Re: Help with joints system.

what about this?:
http://scratch.mit.edu/projects/taddl/960712


http://blocks.scratchr.org/API.php?action=projects&type=newest&return=image&user=taddl
http://blocks.scratchr.org/API.php?user=taddl&action=projects&type=newest&return=text&num=1

Offline

 

#13 2010-03-31 18:34:54

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Help with joints system.

It looks okay when he's walking to the right... but when he starts walking left....


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#14 2010-04-01 05:59:15

taddl
Scratcher
Registered: 2009-03-08
Posts: 100+

Re: Help with joints system.

What aboute this?:
http://scratch.mit.edu/projects/taddl/962019


http://blocks.scratchr.org/API.php?action=projects&type=newest&return=image&user=taddl
http://blocks.scratchr.org/API.php?user=taddl&action=projects&type=newest&return=text&num=1

Offline

 

#15 2010-04-01 06:12:30

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Help with joints system.

just use BYOB by Jens. there's a link on the Panther page and that version of Scratch has hot a sprite nesting feature. that means that sprites can be attatched to a decided part of another sprite and stay there no matter how the sprite swings or moves. it's great stuff and there's an example project included that demostrates the use of the nested sprites with a frog.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#16 2010-04-01 12:46:42

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Help with joints system.

sparks wrote:

just use BYOB by Jens. there's a link on the Panther page and that version of Scratch has hot a sprite nesting feature. that means that sprites can be attatched to a decided part of another sprite and stay there no matter how the sprite swings or moves. it's great stuff and there's an example project included that demostrates the use of the nested sprites with a frog.

This is for scratchers to use as a base, not byob.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#17 2010-04-09 17:10:02

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Help with joints system.

Try embedding the parts onto each other.

Offline

 

#18 2010-04-13 19:26:53

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Help with joints system.

RAWR http://scratch.mit.edu/projects/NXTGeek/216865

Try this!

It seems useful !


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#19 2010-05-13 22:01:27

mrak
Scratcher
Registered: 2009-11-22
Posts: 30

Re: Help with joints system.

taddl wrote:

what about this?:
http://scratch.mit.edu/projects/taddl/960712

great  smile

Offline

 

Board footer