<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/7826" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2012-01-31T19:19:48+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/7826</id>

		<entry>
		<author><name><![CDATA[wolverineun]]></name></author>
		<updated>2012-01-31T19:19:48+00:00</updated>

		<published>2012-01-31T19:19:48+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=26907#p26907</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=26907#p26907"/>
		<title type="html"><![CDATA[rotating bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=26907#p26907"><![CDATA[
I'm trying to simulate bodies that are stacked and has a 6d0f constraint that lets you rotate it <br>around the X axis. When i move the first one it makes the other boxes rotate, <br>but when they come to rest and i try to move then in the oposite direction it does not work.<br><br>this code create the bodies:<br><div class="codebox"><p>Code: </p><pre><code>btCollisionShape* boxShape = new btBoxShape(btVector3(halfW,halfH,halfD));   for (int i=0;i&lt;numBodies;i++){btTransform bodyTransform;bodyTransform.setIdentity();bodyTransform.setOrigin(btVector3(0,-27+i*halfH,0));        btScalar mass(10.);bool isDynamic = (mass != 0.f);btVector3 localInertia;if (isDynamic)boxShape-&gt;calculateLocalInertia(mass,localInertia);btDefaultMotionState* myMotionState = new btDefaultMotionState(bodyTransform);btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,boxShape,localInertia);        btRigidBody* boxBody=new btRigidBody(rbInfo);                boxBody-&gt;setActivationState(DISABLE_DEACTIVATION);        sBoxBodies.push_back(boxBody);        sDynamicsWorld-&gt;addRigidBody(boxBody);                btTransform frameInB;        frameInB = btTransform::getIdentity();        frameInB.setOrigin(btVector3(btScalar(0), btScalar(-halfH), btScalar(0.)));                        btGeneric6DofConstraint* pGen6DOF = new btGeneric6DofConstraint(*boxBody, frameInB, true);                pGen6DOF-&gt;setLimit(0, btScalar(0.), btScalar(0.));        pGen6DOF-&gt;setLimit(1, btScalar(0.), btScalar(0.));        pGen6DOF-&gt;setLimit(2, btScalar(0.), btScalar(0.));        pGen6DOF-&gt;setLimit(3, btScalar(0.), btScalar(SIMD_PI));        pGen6DOF-&gt;setLimit(4, btScalar(0.), btScalar(0.));        pGen6DOF-&gt;setLimit(5, btScalar(0.), btScalar(0.));                sDynamicsWorld-&gt;addConstraint(pGen6DOF);}</code></pre></div>and then when i make my object pickup <br>i have these code to rotate the selected body<br><div class="codebox"><p>Code: </p><pre><code>sDynamicsWorld-&gt;rayTest(CameraPosition, Ray, rayCallback);                if (rayCallback.hasHit())                {                                        btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);                    if (body)                    {                        body-&gt;setActivationState(DISABLE_DEACTIVATION);                                               if(oldy &gt; TouchScreen-&gt;LocationYTouchesMoved)                        {                                body-&gt;applyTorque(btVector3(25000,0,0));                        }                        else                        {                            body-&gt;applyTorque(btVector3(-25000,0,0));                        }                                            }                                                       }</code></pre></div>if these is not the way to go please tell me what should i do.<br>I appreciate any help<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=9005">wolverineun</a> — Tue Jan 31, 2012 7:19 pm</p><hr />
]]></content>
	</entry>
	</feed>
