Elspin
04-05-2011 04:53:18
I've been trying for a while now to get springs working with very little luck. In an old thread I was pointed to the "RevoluteJoint" - and though I'm still not entire sure why I'm supposed to use a hinge as a spring, I've finally got it set up as a very simple hinge in my program thanks to some helpful old posts by betajaen and others. So that is my question - how can I set up two objects with a spring constraint between them? I don't want them to swing around or rotate - which I'm not sure how to disable while keeping the spring. Currently I have my system set up like this:
So basically - it's just a hinge on a slight angle with the boxes weighing 1kg each, the angle and axis of the hinge has gone through a few iterations just to see what would happen, but I can't get much of a reaction out of the spring part of the system. I'd really appreciate any help here
Critter::KinematicBody *mHolder = mRenderSystem->createKinematicBody( NxOgre::BoxDescription(1,1,1), NxOgre::Vec3( 0, 12, 0 ), "KCube.mesh", kbodyDescription);
Critter::Body *mBody = mRenderSystem->createBody(NxOgre::BoxDescription(1,1,1), NxOgre::Vec3(0,6,0), "Cube.mesh", bodyDescription);
NxOgre::RevoluteJointDescription jointDescript;
jointDescript.reset();
jointDescript.mLocalAnchor[0] = NxOgre::Vec3( -.5, 0.5, 0 );
jointDescript.mLocalAnchor[1] = NxOgre::Vec3( 0, 4, 0 );
jointDescript.mLocalAxis[0] = NxOgre::Vec3(0,0,1);
jointDescript.mLocalAxis[1] = NxOgre::Vec3(0,0,1);
NxOgre::RevoluteJoint* basicJoint = mScene->createRevoluteJoint( mHolder, mBody, jointDescript );
NxOgre::SpringDescription springDescript;
springDescript.mDamper = 0;
springDescript.mSpring = 1;
springDescript.mTargetValue = 0;
basicJoint->setSpring( springDescript );
So basically - it's just a hinge on a slight angle with the boxes weighing 1kg each, the angle and axis of the hinge has gone through a few iterations just to see what would happen, but I can't get much of a reaction out of the spring part of the system. I'd really appreciate any help here