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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2019-04-04T16:13:59+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Dox]]></name></author>
		<updated>2019-04-04T16:13:59+00:00</updated>

		<published>2019-04-04T16:13:59+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41978#p41978</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41978#p41978"/>
		<title type="html"><![CDATA[Rotate a btConvexHullShape via btCompoundShape problem.]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41978#p41978"><![CDATA[
Hello,<br><br>Normally, I build a btConvexHullShape from an HACD generated model like this:<br><div class="codebox"><p>Code: </p><pre><code>     //...Retrieve a geometry list from OpenSceneGraph....   .....   .....   for(unsigned int i = 0; i &lt; l_GeometryList.size(); i++) {    osg::Vec3Array* l_GfxVertices = dynamic_cast&lt;osg::Vec3Array*&gt;(l_GeometryList[i]-&gt;getVertexArray());    if(!l_GfxVertices) {      continue;    }    btAlignedObjectArray&lt;btVector3&gt; l_PhyVertices;    //Calc centroid    btVector3 l_Centroid = btVector3(0,0,0);    for(unsigned int i = 0; i &lt; l_GfxVertices-&gt;size(); i++) {      btVector3 l_Vertex((*l_GfxVertices)[i].x(), (*l_GfxVertices)[i].y(), (*l_GfxVertices)[i].z());      l_Centroid += l_Vertex;    }    l_Centroid *= 1.f/(double(l_GfxVertices-&gt;size()));    //Shift vertices around centroid    for(unsigned int i = 0; i &lt; l_GfxVertices-&gt;size(); i++) {      btVector3 l_Vertex((*l_GfxVertices)[i].x(), (*l_GfxVertices)[i].y(), (*l_GfxVertices)[i].z());      l_Vertex -= l_Centroid;      l_PhyVertices.push_back(l_Vertex);    }    //Create the convex hull shape    btConvexHullShape* l_ConvexHullShape = new btConvexHullShape(&amp;(l_PhyVertices[0].getX()), l_PhyVertices.size());    l_ConvexHullShape-&gt;setMargin(0.001f);    btTransform l_PhyTransform;    l_PhyTransform.setIdentity();    l_PhyTransform.setOrigin(l_Centroid);        btCompoundShape* l_PhyCompoundShape = new btCompoundShape();    l_PhyCompoundShape-&gt;addChildShape(l_PhyTransform, l_ConvexHullShape);    }</code></pre></div>This code basically works and place the convex hull in the correct position. <br><br>Now I need a rotation, so I have simple added the rotation to the l_PhyTransform (for example, after the l_PhyTransform.setOrigin(l_Centroid) line):<br><div class="codebox"><p>Code: </p><pre><code>      PhyQuaternion l_quat;      l_quat.setEulerZYX(0, 0, M_PI_2);      l_PhyTransform.setRotation(l_quat);</code></pre></div>This code doesn't works as expected (for me): a simple convex shape rotation of 90° (on X). Instead, the rotation there is, but I can see a sort of "degenerated" mesh: some polygons are corrects, some others are like "deformed" and moved in weird position.<br><br>Can you tell me where is my silly error?<br><br>Many thanks!<br><br>Bye<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13055">Dox</a> — Thu Apr 04, 2019 4:13 pm</p><hr />
]]></content>
	</entry>
	</feed>
