math & physics
agpx at November 13th, 2005 19:50 — #1
I have tried to implement a pendulum with the Novodex 2.2 SDK, but I have a strange instability problem.
I have picked the Lesson 301 (the Rope) and made the following modification:
1) The top piece of the rope is made kinematic (so that the rope don't falldown anymore).
2) I have increased the density of the last piece of the rope (to avoid to append other objects, for the moment, keeping the modification minimal).
3) I have increased the force strength.
The result is strange: every joint extend itself (like if it was a spring). I have replace the CreateRopeSphericalJoint with the simpler CreateSphericalJoint, but nothing change.
Moreover, when you try to apply the force the simulation become totally unstable. All the joints become crazy with no reason. If you sensibly decrease the density of the last piece of rope (making it much more light), the situation become better, but the program still don't be stable.
The rope, initially, stretch itself as if it are elastic. But there no spring at all.
I have tried to setup the joint projection. This make the stretching less evident, but the simulation still doesn't work.
The Novodex come with a demo "Breakable Joints" that show 3 pendulums. Whatever force you apply to the pendulum don't make the simulation unstable like mine. There are no source for this demo, so I don't understant what kinda of joints are used and how they are setup.
I don't understand this problem. How I can get rid of this instability? Why the rope exposes this "spring" behaviour? :sad:
It seems like that the spherical joint is stretched. Please help me. Thanks in advance.
P.S.: I have uploaded the modified version at the following address:
http://rocjoe.freefronthost.com/Lesson301.zip (about 32 Kb).
It actually contains only the Lesson301.exe and require the Novodex engine installed (yes, with no virus, trojan, spyware, adware, ecc...).
Take a look of this strange behaviour.
moe at November 14th, 2005 05:14 — #2
Normally Novodex is quite stable and instability lies within your implementation. Sorry that's not very helpful...
Have you tried to ask the same question in the Novodex forum? They are usually helpful only you might have to wait a little until you get a reply since they are also very busy working on their SDK. But I suggest giving it a try.
cobralionz at November 14th, 2005 14:27 — #3
OK you got a lot of nerve asking for help and not even showing the source code and instead ask us to download a shady executable file. If you think your source code is so great that none of us could ever write on our own, then you are obviously great enough to figure out your own problem yourself.
reedbeta at November 14th, 2005 15:36 — #4
Chill out, CobraLionz. There's no need to get upset. If you're worried about his executable then just don't download it.
cobralionz at November 15th, 2005 00:05 — #5
sorry, its a monday.. guess i let it get the best of me
agpx at November 16th, 2005 07:23 — #6
I haven't posted the source code because I don't want to bother you. Instead, the executable show a behaviour that could be happened to somebody.
However, the source code is the Lesson 301 provided with the SDK. With the following modification:
void CreateRope(const NxVec3& pos, const NxReal segHeight, const NxReal segRadius, const int nbSegments, const NxReal density)
ropeSegs = new NxActor*[nbSegments];
ropeLinks = new NxSphericalJoint*[nbSegments-1];
for (i = 0; i < nbSegments; i++)
ropeSegs[i] = CreateCapsule(pos + NxVec3(0,i*(2*segRadius+segHeight),0), segHeight, segRadius, (i > 0 ? density : (20.0f * density))); // Modified
for (i = 0; i < nbSegments - 1; i++)
ropeLinks[i] = CreateSphericalJoint(ropeSegs[i], ropeSegs[i+1], pos + NxVec3(0,(i+1)*(2*segRadius+segHeight),0), NxVec3(0,1,0));
ropeSegs[nbSegments - 1]->raiseBodyFlag(NX_BF_KINEMATIC); // Added
Basically, I made the last segment kinematic, in order to prevent the rope to falldown.
Lastly, I assign a greater density to the bottommost piece of the rope to emulate a weight. No other modifications.
I see that the library (just like others one), have some difficulty to maintain the constraints (the sequence of spherical joints that link the rope's pieces), when a modest force are applied (the weight). Actually I'm waiting for the account on the Novodex's forum, but I believe that a similar problem could be happened easily to other peoples, so I have tried to post my problem here.
agpx at November 18th, 2005 08:29 — #7
I think that the problem is that the engine can't easily maintain the constraints. There's a way to make the constraints more "hard"?
monjardin at November 18th, 2005 09:11 — #8
Why don't you try your question in the Novodex forum?
Would a hinge joint with a rod not suit your needs instead of a series of jointed spheres? You wouldn't run into these joint constraint problems in that case.
Also, a rigid pendulum is not hard to model without a full blown physics engine like Novodex. This is especially true if you keep the angle small (since you can approximate the sine of the angle as the angle).