• Advertisement
Sign in to follow this  

Disable rotation of a body ODE

This topic is 1857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there,

I want to constraint the rotation of a cube so that it can only translate. I've tried using an aMotor with the following code:

	this->aMotor=dJointCreateAMotor(this->system->getGame()->worldID,this->system->jointGroup);
	dJointAttach(this->aMotor,0,this->bodyID);
	dJointSetAMotorMode(this->aMotor,dAMotorUser);
	dJointSetAMotorNumAxes(this->aMotor,3);
	dJointSetAMotorAxis(this->aMotor,0,0,1,0,0);
	dJointSetAMotorAxis(this->aMotor,1,0,0,1,0);
	dJointSetAMotorAxis(this->aMotor,2,0,0,0,1);
	dJointSetAMotorParam(this->aMotor, dParamVel1, 0);
	dJointSetAMotorParam(this->aMotor, dParamVel2, 0);
	dJointSetAMotorParam(this->aMotor, dParamVel3, 0);
	dJointSetAMotorParam(this->aMotor, dParamFMax1, dInfinity);
	dJointSetAMotorParam(this->aMotor, dParamFMax2, dInfinity);
	dJointSetAMotorParam(this->aMotor, dParamFMax3, dInfinity);

If i'm not mistaken, that code creates an AMotor joint, attaches it to the body and the world, and sets the target velocity of each axis of the motor to be 0 and the FMax to be dInfinity. I thought that would disable the body's rotation, but it does nothing. Is there anything wrong with my code? Do you know any other way to constrain the rotation?

Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement

Nevermind, I'm surprised that such a simple mistake has given me so much trouble haha. I didn't know that I could pass 0 as the joint group parameter jor dJointCreate to allocate the joint "normally" and I thought I had to pass a joint group, so I used the only one I have, the contact joint group, which is emptied each frame. That's why it did nothing.

 

But now I have another problem: I want the box to slide in a plane, and it does so correctly if the plane has no friction, but as soon as I put a bit of friction into it, the movement starts being a bit jerky, like it moves bit by bit at first and suddenly it gains speed and starts moving smoothly and very fast. Do you know how I can keep the smooth movement while constraining rotation?

 

P.S: Sorry if I make any grammar mistake, English is not my native language

Share this post


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

  • Advertisement