<?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/9548" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2013-11-15T12:10:21+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Moose]]></name></author>
		<updated>2013-11-15T12:10:21+00:00</updated>

		<published>2013-11-15T12:10:21+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32169#p32169</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32169#p32169"/>
		<title type="html"><![CDATA[btCompound and local vs world trafos]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32169#p32169"><![CDATA[
Hi all,<br><br>I am new to that forum. Currently developing a bullet integration for an abstracted physics engine interface into a commercial visualization application that sports a rather complex scene graph structure. Please excuse my lack of in-depth bullet knowledge as I am relatively new to this.<br><br>Basically, I have succeeded in integrating quite a few shapes and meshes, as well as several Constraints and now struggling with compound shapes.<br><br>The issue is, that they do not behave the way I expect them to.<br><br>Let me illustrate an example with a compound that contains only one shape. A sphere. It is not in the origin of the ocmpound but has a local translation. What I do is roughly following (I extract code but this is not a working example):<br><br><br>btSphereShape *sphere = new btSphereShape(100);<br><br>and a plane on the ground that is a static object and has no translation or mass or anything.<br><br>Then a compound:<br><br>btCompound *compound = new btCompound(true);<br>sb-&gt;addChildShape(btTransform( /*translation is 100, 10000, 0 */), sphere);<br><br>btTransform principal;<br>btVector3   inertia;<br>btScalar   *masses = new btScalar[1];<br>masses[0] = 1;<br>compound-&gt;createAabbTreeFromChildren();<br>compound-&gt;calculatePrincipalAxisTransform(masses, principal, inertia);<br>delete[] masses;<br><br>btVector3 inertia(0, 0, 0);<br>compound-&gt;calculateLocalInertia(1.0, inertia);<br>motionState = new btDefaultMotionState(btTransform( /*translation is 0, 0, 0 */));<br>btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass, motionState, compound, inertia);<br>btRigidBody *cb = new btRigidBody(rigidBodyCI);<br>cb-&gt;setActivationState(DISABLE_DEACTIVATION);<br><br>// all right. There might be errors as I free-typed that but I guess you see what I'm aiming at.<br><br>In my test program I start the simulation and output the compound's motion state transform and see if it collides with anything. I would expect the compound (the ball) to fall down onto the ground plane as it has a local transform to the center of mass (origin?) of the compound and then come to rest after falling 9950 (10000 - 50) or so units. Which would mean, it starts at 0.0 (the origin of the compound) and then descends to -9950. Instead I see this:<br><br>....start...<br>compound X and Y: 0 -8.175 collision with 0<br>compound X and Y: 0 -286.125 collision with 0<br>compound X and Y: 0 -885.625 collision with 0<br>compound X and Y: 0 -1915.68 collision with 0<br>compound X and Y: 0 -3338.13 collision with 0<br>compound X and Y: 0 -4986.75 collision with 0<br>compound X and Y: 0 -6965.1 collision with 0<br>compound X and Y: 0 -9499.35 collision with 0    // all good to here<br>compound X and Y: 20.1942 -10041.8 collision with 1 objects (ground)<br>compound X and Y: 47.4288 -10244.1 collision with 1 objects (ground)<br>compound X and Y: 74.9495 -10750.2 collision with 1 objects (ground)<br>compound X and Y: 102.315 -11589.3 collision with 1 objects (ground)<br>compound X and Y: 126.961 -12732.6 collision with 1 objects (ground)<br>compound X and Y: 152.895 -14129.2 collision with 1 objects (ground)<br>compound X and Y: 177.535 -15773.3 collision with 1 objects (ground)<br>compound X and Y: 204.799 -17830.2 collision with 1 objects (ground)<br>compound X and Y: 232.211 -20285.8 collision with 1 objects (ground)<br>compound X and Y: 259.406 -23039.4 collision with 1 objects (ground)<br>compound X and Y: 284.545 -26203 collision with 1 objects (ground)<br>compound X and Y: 308.853 -29700.6 collision with 1 objects (ground)<br>... snip... falls further into the abyss.<br><br>You see, I get a collision with the ground but the object continues to fall, which I don't get. Also, it appears to drift to the side after the collision which makes no sense either.<br><br>Please note that when I drop a compound with two objects, both roughly at the same position it seems to be OK. Can't know for sure though. Also, when I drop other stuff, like only the ball with no compound or a triangle mesh or anything else I have the simulation behaves nicely.<br><br>Can anyone shed some light on this? My suspicion is, that I use the local trafo in the compound wrong. Or misunderstand the entire motionstate thing. I already learned from an old post in that forum, that what bullet calls the center of mass is not actually the center of mass but the local transform of a child to the compound.<br><br>By experiment I found that when I use btCompound::calculatePrincipalAxisTransform() I can determine the actual center of mass for the compound but it comes in world trafo as it seems. Why is that?<br><br>I understand this function is supposed to help me integrating this into a scene graph based application that would typically have a group node for the compound. Can you give me any example of how this is done best?<br><br>All, right, that'll bit it for now.<br><br>Thanks a bunch for any response.<br><br>Moose<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=10538">Moose</a> — Fri Nov 15, 2013 12:10 pm</p><hr />
]]></content>
	</entry>
	</feed>
