Jump to content

  • Log In with Google      Sign In   
  • Create Account


Disable rotation of a body ODE


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Aitorman   Members   -  Reputation: 126

Like
0Likes
Like

Posted 23 March 2013 - 11:06 AM

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



Sponsor:

#2 Aitorman   Members   -  Reputation: 126

Like
0Likes
Like

Posted 23 March 2013 - 04:54 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS