Another Ragdoll problem

Blitz3D Forums/Blitz3D Programming/Another Ragdoll problem

Nexus6(Posted 2005) [#1]
I have managed to get a 3D Verlet Integrater and constraint system up and running OK, I can throw a chain of cubes around and they behave exactly how I would expect. I am now ready to move onto the next stage and construct a ragdoll, but this is were im stuck. To construct a ragdoll, I need to be able to place several particles/verlets on the one mesh ie a torso would require verlets placed at the shoulders, neck, top of the legs etc.
The current method im using is positionentity torso,x,y,z were x,y,z are the co-ordinates of the verlet, as you can see, using this method is OK if I only have to place the mesh at the position of one verlet, but I have to place the mesh at several positions simultaneously.

Im at work at the moment so haven't got the most uptodate code, but heres's a copy of what I have with me, it still shows the method that I am using.



I hope this Code box came out OK.
Any help appreciated.


Nexus6(Posted 2005) [#2]
I hate waiting, not getting any work done here, constantly refreshing the page to see if any replies have come in. I think I'll go for my lunch and see if any replies come in while im out of the office (hint, hint).


Stevie G(Posted 2005) [#3]
I think you need to make it clearer what you want. Are you going to make the ragdoll mesh within code or load a boned mesh?

If you're making it in code then it would be much easier to keep each constraint/limb as a separate entity.

Firstly create a temp mesh for your limb. Note that you need to offset the z axis, and make sure the depth of the mesh = 1 for this to work.

LIMB = createsphere()
positionmesh LIMB,0,0,1
scalemesh LIMB,1,1,.5

Add a new field into the contraint type so that you can store a copy of LIMB. Then in the update constraint phase simply position this limb at the head verlet. Pointentity the limb to the tail verlet. Then scaleentity on the z axis only based on the entitydistance between the two verlets.

You may want to store a thickness variable in the contraint type so that you can have a wider head etc.. Just apply this when your scaling the entity ..
e.g. scaleentity c\limb, c\thickness, c\thickness, entitydistance(... )


Nexus6(Posted 2005) [#4]
Thanks Stevie,
I will be modelling each limb as a seperate entity, but the problems im having is being able to place an entity (limb) at co-ordinates of multiple verlets simutaneously as in this picture




Stevie G(Posted 2005) [#5]
Like I said have a new limb for each constraint ... position it at one verlet , point it at the other and scale ... have you tried it?


Paolo(Posted 2005) [#6]
@Nexus6
I don't understand what you want to do exactly, but if
you are trying to code a ragdoll character then you will
have bigger problems to resolve in the future ... such
as limiting the knee joint angles or detecting collision
within all the elements connected ...

Your code above works pretty good for a chain, but
if you are looking for a more complicated structure then
I would suggest having a look at one of the physics
engines we have around... Toka or ODE ...

just a thought...


Nexus6(Posted 2005) [#7]
Stevie, take the torso for instance, it is one limb or to be precice, one body part, yet it has many verlets and constraints, if i was to create a primitive for this, say a cube, I would still need to position that cube at every verlet that the torso is constructed........

Hold on, i think I know what you mean. Are you saying,,, the torso is made of 5 verlets and 9 constraints, but dont try and position the cube at all 5 verlets, just choose one. Now theres an idea, I'll give it a go.
My first thought was to parent a pivot at each position on the limb and then place thsese at the co-ordinates of the verlets, but that had many flaws.

Anyway I'll give that a go, let me know if im way off track.

@Eurythmia, I know I will have several problems with contraints, I have looked into dot product and other constraint algorithms, and they seem quite complicated. This is a learning exercise for me and also I would like to code some physics without resorting to additional dll's and learning new commands etc.

Anyway wish me luck, its getting an obsession this.


Stevie G(Posted 2005) [#8]
Yeah, obviously arms, legs and head will work as I suggest. You're probably better just creating a new verlet between the two lowest torsoe verlets, adding a few more contraints to stabilise it. Then you can position the torsoe there and point it at the neck verlet.

Personally, I use a pivot to represent each verlet. There are next to no overheads and you don't need to store the current x,y,z positions as you can use entityx( v\pivot ) etc... The added bonus is that you can set up collisions for each pivot. This is the method I use for the demo I posted a few days ago in the showcase.