Sign in to follow this  
kyc

Game: ChronoDoll

Recommended Posts

Thanks for the responses, and yes it is my own engine. The only libraries I used are GLFW for cross-platform OpenGL, and tinyxml for parsing/saving map files.

Share this post


Link to post
Share on other sites
Yeah it really isn't much of a game, more a (final?) tech demo.

I started out using the article by Thomas Jakobsen, then lurked around many forums and searched for other verlet projects and absorbed and added my own interpretations.

The physics really isn't too hard, but it took the longest time figuring out how to do constraint-particle collisions. So far I think I am the only one to do it successfully, and the irony is that it is the simplest yet most unexpected "solution"; there's still some bugs (I have the solutions in my head), but the main thing is that EVERYTHING comes down to a capsule-capsule test.

Share this post


Link to post
Share on other sites
I'm doing the same stuff at the moment (verlet integration), but I haven't yet figured out any reliable method of doing angle constraints. What's yer secret? ;)

Can you also explain a bit the collision stuff, how did you do it for example :)

And how about the resting iterations, how many are you doing them per frame? It seems that it is impossible to get rid of that elasticity that is caused by the verlet integration method.

Share this post


Link to post
Share on other sites
miksan, sorry for not responding sooner.

I'm not doing any actual angle constraints, what exactly do you mean? Can you give me an example from the demo?

Collisions are based on swept circles, even against constraints.
What I do for constraints is to just give them a radius, add the highest of the endpoints' velocities, and detect it in exactly the same way as I do particles.

I am using 3 iterations. It works even with 0 iterations, except constraints are much more error prone (fluid-like is what I mean, collisions still work).

This is pretty much the entire engine, nothing special is needed to have resting. What do you mean by the elasticity that comes with verlet?

BTW, I'm working on a software renderer right now, so it'll take me awhile before I will get back to the physics (it's already taken half of my summer :P ).

Share this post


Link to post
Share on other sites
I already wondered where have you been to :P

With angle constraint I mean that you have three basic constraints, left, center and right. There's a stick between left and center, and a stick between center and right. Angle between those sticks is what I mean. It is like V-shape. Angle could be minimum or maximum angle. I thought that you used something like that in those ragdolls you have, because the head doesn't swing around freely etc. (like through legs). When I look closer, the effect might come from the collision system?

I tried to do it with minimum/maximum lenght stick constraints, but they where unusable when the angle was closer to 180. I also had a good advice from olii, but I couldn't get it working decently.

With elasticity I mean the delay the constraint satisfies itself. You can see it clearly when you do for example a rope of 200 stick constraints. It scretches a lot, like a rubber band! It doesn't matter how many resting iterations you do, there will always be some elasticity. There is more if you do the math using square roots, but if you use the approximation method, elasticity decreases slightly.

Share this post


Link to post
Share on other sites
pretty cool demo
can it handle boxes? i assume more iterations in your physics loop would reduce the bouncy-ness of everything (like: hitting a stack of objects really hard).....

reminds me alittle of the demo i just posted (except mine is in 3d and not even close to a game)
http://www.gamedev.net/community/forums/topic.asp?topic_id=265010

i was going to do a 2D only version of mine later on because 2D is cooler

================================================

as for angular constraints,
they can be done with a distance triggered line constraint
like a constraint between 2 points but it is only activated when the distance becomes above a 'certain value'

use MATH, to convert angle values into that "certain value"

i had to do this for my human body character joins like arms and legs

i guess i could explain it better

Share this post


Link to post
Share on other sites
To Miksan;

The way I've modeled angle constraints is to turn them into stick constraints using the law of cosines. If you have a left, center and right point as you suggest, and you know what the rest lengths should be between the center and the other two points, you can calculate what the length of the third imaginary stick must be at your critical angle, and if it's too long or too short (depending on how your constraint will work, whether it's supposed to keep the angle within a certain bound or outside of a certain minimum angle, respectively) you can just relax the third "stick" by pushing or pulling the left and right points in relation to each other. With a few relaxation iterations, it should stabilize, but I have no proof of that. It also might not precisely model an angle constraint perfectly, but if you're operating under the assumption that from frame to frame the system doesn't stray too far from a legal state, this should be fine, I think.

Just some thoughts.

Elijah

Share this post


Link to post
Share on other sites
etaylor27,

yes, I tried to model the angle constraint that way, but it had a major flaw. Imagine if the angle must be for example 170 degrees at maximum. The V-shape will be quite "open", and due to the "elasticity" of the verlet integration, a stick constraint (between the left and right basic constraint) will scretch so that the angle flips over. Especially with high velocities, doing an angle contraint like [0-10 minimum] or [170-180 maximum] is impossible. For example maximum angle of 180 degrees? How to maintain it?

Share this post


Link to post
Share on other sites
Miksan,

you bring up a good point, it could conceivably "flip over" if the angle is too large, or perhaps spin or do some other weird behavior, but I think that's a problem inherent to having these large angle constraints, not the method of solving for them. I could be wrong, but I don't think there will be another method that will stabilize your high-velocity situation with these extreme constraints. Again, the verlet method works somewhat under the assumption that from frame to frame, the configuration of the world hasn't changed much, and therefore shouldn't be too far from a "legal" state. So while your velocities may be high, hopefully your time step is small enough to compensate, and even if it's not quite small enough, I don't think from frame to frame the angle constraints would oscillate between two sides continuously, intuition would tell me that it would stabilize to one side.

Also, another thing to consider is this: is there a way to get rid of these angle constraints that are too extreme in the first place? Perhaps modeling your object in a different way could break it down to simpler constraints yet. And even if these new constraints aren't physically accurate, sometimes they could create a model that would look convincing enough and run with some stability, and hopefully that should be all you need anyway.

btw, did you actually model this situation or is this just conjecture? If you did run a simulation I would be interested in seeing any results. Feel free to e-mail me

Elijah

Share this post


Link to post
Share on other sites
Sign in to follow this