Constraint problem

Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

Constraint problem

Post by Tau »

Hi all,
I just implemented bullet into my game. Everything is working well but now i have problems with constraints.

Code: Select all

{
	dragging=ncakt;
	btVector3 pivA(0, 0, 0);
	btVector3 pivB(0, sT->polomer+2.3, 0);
	btVector3 axisa(0., 0., 1.);
	btVector3 axisb(0., 0., 1.);

	dragging->m_body->setAngularFactor(btVector3(0,0,0));
	dragging->m_body->clearForces();

	m_const = new btHingeConstraint(*m_body, *dragging->m_body, 
		pivA, pivB, axisa,  axisb);
	m_const->setLimit(-0.2,0.2);
						
	dynamicsWorld->addConstraint(m_const, true);
}
{
	dragginguwi=uwip;
	btVector3 pivA(0., 0., 0.);
	btVector3 pivB(0, sT->polomer+2.3, 0);
	btVector3 axisa(0., 0., 1.);
	btVector3 axisb(0., 0., 1.);

	dragginguwi->m_body->setAngularFactor(btVector3(0,0,0));
	dragginguwi->m_body->clearForces();

	m_const = new btHingeConstraint(*m_body, *dragginguwi->m_body, 
		pivA, pivB, axisa,  axisb);
	m_const->setLimit(-0.2,0.2);
						
	dynamicsWorld->addConstraint(m_const, true);
}
Destroyed dragged npc should be right beneath player but instead it is rotating around (click on the video) and item is also not under player but it appears to be somewhere at place (-2, 2, -0.5) by player (not in video). Constraint creation is basd on demo App_SliderConstraintDemo. I alredy tried
different constraint types but none of them worked correckt.

http://youtu.be/uaBgzVRmm0I

Could somebody please tell me what am i doing wrong?
Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

Re: Constraint problem

Post by Tau »

bump
I also tried btSliderConstraint

Code: Select all

{
	dragging=ncakt;
	btTransform frameInA, frameInB;
	frameInA = btTransform::getIdentity();
	frameInB = btTransform::getIdentity();
						
	frameInA.setOrigin(btVector3(0,0,0));
	frameInB.setOrigin(btVector3(0,sT->polomer+2.5,0));

	dragging->m_body->setAngularFactor(btVector3(0,0,0));
	dragging->m_body->clearForces();

	m_const = new btSliderConstraint(*m_body, *dragging->m_body, 
							frameInA, frameInB, true);
	m_const->setLowerLinLimit(0);
	m_const->setUpperLinLimit(0);

	dynamicsWorld->addConstraint(m_const);				
}
{
	dragginguwi=uwip;

	btTransform frameInA, frameInB;
	frameInA = btTransform::getIdentity();
	frameInB = btTransform::getIdentity();
						
	frameInA.setOrigin(btVector3(0,0,0));
	frameInB.setOrigin(btVector3(0,sT->polomer+2.5,0));

	dragginguwi->m_body->setAngularFactor(btVector3(0,0,0));
	dragginguwi->m_body->clearForces();

	m_const = new btSliderConstraint(*m_body, *dragginguwi->m_body, 
							frameInA, frameInB, true);
	m_const->setLowerLinLimit(0);
	m_const->setUpperLinLimit(0);
						
	dynamicsWorld->addConstraint(m_const);
}
Result was nearly the same
http://youtu.be/UqA-1ixaIg0