# building 2-d stick figure model in Java w/inverse kin. and physics - Java-Games

This is a discussion on building 2-d stick figure model in Java w/inverse kin. and physics - Java-Games ; Hi, The subject says it all , but I'll try to be more specific. I'm trying to build a 2-d model of a simple (human) stick figure for a 2-d rock-climbing game I'm writing for fun in Java. I would ...

1. ## building 2-d stick figure model in Java w/inverse kin. and physics

Hi,

The subject says it all , but I'll try to be more specific. I'm
trying to build a 2-d model of a simple (human) stick figure for a 2-d
rock-climbing game I'm writing for fun in Java. I would like to do it
in a nice object-oriented way, but more importantly, I want to be able
to do the following: keeping 2 feet and 1 hand fixed in position, I
want to be able to grab the other hand and move it to an exact
location, and have the body follow. The main constraints are: the
limbs are not elastic, and the joints each have a range of motion that
cannot be exceeded.

I can see that when I move the right hand, often there will be an
infinite number of possible "solutions" or positions of the rest of
the body, so I will need additional constraints. Ideally, the other
hand and feet will support the weight of the figure, and I will
calculate the body position support the body and maximize efficiency
(ie. so the 'climber' doesn't get tired quickly)

I am not a mech. engineer, so I'm partly doing this as an exercise to
learn how to model a 2-d figure and add "realistic" features, such as
the inverse kinematics and also balance and various forces.

I'd like to start with something simple that I can understand, so if
anyone has simple examples that are similar, that would be helpful.
Also, online tutorials or even just suggestions for how to "model"
this figure would be useful. I'm pretty much a beginner, but
interested in learning. I realize there is already a 3-d climbing
game, and I also realize there is complex software to handle this
stuff, but I'm interested in this ground-up approach, since I really
want to learn as much as possible.

Here is the basic configuration of the stick figure (open to slight
modification):

O
_/|\_
^
/ \
| |

I.e. the "fixed points" are the hands and feet (except the one being
moved by the user/player), and the points to be automatically
positioned are the elbows, knees, "neck" (point where arms, head and
torso join) and "hips" (point where legs and torso join) I would like
to be able to pick any hand/foot and move it and have the rest of the
body follow based on 'balance' and 'strength'.

I think I am starting to understand that the position of each joint is
subject to "limb" length, and then I have to impose these other
constraints so that I end up minimizing/maximizing a function. I just
don't quite know how to set that up.

Pseudocode/general algorithm data-structure hints are very welcome
too.

Thanks for your patience and any help or guidance!
G

2. ## Re: building 2-d stick figure model in Java w/inverse kin. and physics

I don't know if this will be much help to you, but it seems related and is
fun anyway:
http://www.sodaplay.com/

Mitch Berkson

3. ## Re: building 2-d stick figure model in Java w/inverse kin. and physics

On Sat, 27 Dec 2003 02:15:43 -0500, "Mitch Berkson"
<mitch@bermita.com> wrote:

>I don't know if this will be much help to you, but it seems related and is
>fun anyway:
>http://www.sodaplay.com/
>
>Mitch Berkson
>

That's really cool.

4. ## Re: building 2-d stick figure model in Java w/inverse kin. and physics

bob <thanatos@coldmail.nu> brightened my day with his incisive wit when
in news:96eruvc83pn7jh0uod3t9smaj4fti2qntn@4ax.com he conjectured that:

> On Sat, 27 Dec 2003 02:15:43 -0500, "Mitch Berkson"
> <mitch@bermita.com> wrote:
>
>>I don't know if this will be much help to you, but it seems related
>>and is fun anyway:
>>http://www.sodaplay.com/
>>
>>Mitch Berkson
>>

> That's really cool.

Thats the understatement of the year. Brilliantly simple and effective UI.
Great modelling. Excellent!

5. ## Re: building 2-d stick figure model in Java w/inverse kin. and physics

Gazing across the alien landscape, mitty heard the tapocketa-tapocketa
of the the soda straw legs of the enigmatic alien creatures...

Walter Mitty <mitticus.remo.veme@yahoo.co.uk> wrote in message news:<Xns9460F56DA500waltermitty@127.0.0.1>...
> bob <thanatos@coldmail.nu> brightened my day with his incisive wit when
> in news:96eruvc83pn7jh0uod3t9smaj4fti2qntn@4ax.com he conjectured that:
>
> > On Sat, 27 Dec 2003 02:15:43 -0500, "Mitch Berkson"
> > <mitch@bermita.com> wrote:
> >
> >>I don't know if this will be much help to you, but it seems related
> >>and is fun anyway:
> >>http://www.sodaplay.com/
> >>
> >>Mitch Berkson
> >>

> > That's really cool.

>
> Thats the understatement of the year. Brilliantly simple and effective UI.
> Great modelling. Excellent!

6. ## Re: building 2-d stick figure model in Java w/inverse kin. and physics

but probably not useful for the original poster. Sodaplay is neat , and Im even
considering that cyclic waveform control for custonizing walking animations --
I did email the creator to add joints with 0 stretch/jiggle and or struts with no
enlongation so that you could create more rigid structures with tie points in their
middle (try making an armbone with muscles attached half way up ts length --
the part beyond the midpoint will wobble like a hinge even if you make the whole
bone an assembly of triangles for stability (real bones done bend much)

for the problem originally posted :
complication of pure 2d approach -- none of the body joints can be closer to the
cliff than the arch length of the child limb ( I seem to recall lots of pix with
rockclimbers with their cheeks up against the rock face...) Some kind
of pseudo 3d constraints will be needed eventually to allow realistic movements
(so it wont look like walking on knees/elboes up the wall)

maniacal_engineer wrote:

> Gazing across the alien landscape, mitty heard the tapocketa-tapocketa
> of the the soda straw legs of the enigmatic alien creatures...
>
> Walter Mitty <mitticus.remo.veme@yahoo.co.uk> wrote in message news:<Xns9460F56DA500waltermitty@127.0.0.1>...
> > bob <thanatos@coldmail.nu> brightened my day with his incisive wit when
> > in news:96eruvc83pn7jh0uod3t9smaj4fti2qntn@4ax.com he conjectured that:
> >
> > > On Sat, 27 Dec 2003 02:15:43 -0500, "Mitch Berkson"
> > > <mitch@bermita.com> wrote:
> > >
> > >>I don't know if this will be much help to you, but it seems related
> > >>and is fun anyway:
> > >>http://www.sodaplay.com/
> > >>
> > >>Mitch Berkson
> > >>
> > > That's really cool.

> >
> > Thats the understatement of the year. Brilliantly simple and effective UI.
> > Great modelling. Excellent!