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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2013-08-25T22:46:42+00:00</updated>

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

		<entry>
		<author><name><![CDATA[konri100]]></name></author>
		<updated>2013-08-25T22:46:42+00:00</updated>

		<published>2013-08-25T22:46:42+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31610#p31610</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31610#p31610"/>
		<title type="html"><![CDATA[Ogre + Bullet rotation]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31610#p31610"><![CDATA[
I'm trying to make a character controlller and i've got problem with rotation. If i do it this way:<div class="codebox"><p>Code: </p><pre><code>for(list&lt;btRigidBody*&gt;::iterator It = Objects.begin(); It != Objects.end(); ++It){        Ogre::SceneNode* node = static_cast&lt;Ogre::SceneNode*&gt;((*It)-&gt;getUserPointer());        btVector3 Point = (*It)-&gt;getCenterOfMassPosition();        node-&gt;setPosition(Ogre::Vector3((float)Point[0], (float)Point[1], (float)Point[2]));        btQuaternion btq = (*It)-&gt;getOrientation();        Ogre::Quaternion quart = Ogre::Quaternion(btq.w(),btq.x(),btq.y(),btq.z());        node-&gt;setOrientation(quart);}</code></pre></div>then it looks like rotation of the mesh is kinda inverted, i mean forward is forward, backward is backward, but left is right and right is left.<br><br>If i do it this way:<br><div class="codebox"><p>Code: </p><pre><code>if(left || right){        xform.setRotation(btQuaternion(btVector3(0.0, 1.0, 0.0), turnAngle));        Ogre::SceneNode* node = static_cast&lt;Ogre::SceneNode*&gt;(body-&gt;getUserPointer());        node-&gt;setOrientation(Ogre::Quaternion(-(Ogre::Radian)turnAngle, Ogre::Vector3(0.0, 1.0, 0.0)));}</code></pre></div>then it works, but i'm not sure if it's supposed to be like this<br><br>some more code if it is necessery:<div class="codebox"><p>Code: </p><pre><code>void KinematicCharacterControl::playerStep(btScalar delta, bool forward, bool backward, bool left, bool right, bool jump){    preStep();btTransform xform;xform = body-&gt;getWorldTransform();    body-&gt;activate(true);/* Handle turning */if(left)    {std::cout &lt;&lt; "left" &lt;&lt; std::endl;turnAngle += delta * turnVelocity;    }if(right)    {std::cout &lt;&lt; "right" &lt;&lt; std::endl;turnAngle -= delta * turnVelocity;    }    if(left || right)    {        xform.setRotation(btQuaternion(btVector3(0.0, 1.0, 0.0), turnAngle));        Ogre::SceneNode* node = static_cast&lt;Ogre::SceneNode*&gt;(body-&gt;getUserPointer());        node-&gt;setOrientation(Ogre::Quaternion(-(Ogre::Radian)turnAngle, Ogre::Vector3(0.0, 1.0, 0.0)));    }    body-&gt;setWorldTransform(xform);body-&gt;setCenterOfMassTransform(xform);btVector3 linearVelocity = body-&gt;getLinearVelocity();btScalar speed = body-&gt;getLinearVelocity().length();btVector3 forwardDir = xform.getBasis()[2];forwardDir.normalize();btVector3 walkDirection = btVector3(0.0, 0.0, 0.0);btScalar walkSpeed = walkVelocity * delta;if(forward)    {walkDirection += forwardDir;    }if(backward)    {walkDirection -= forwardDir;    }    if(jump)    {this-&gt;jump();    }if(!forward &amp;&amp; !backward &amp;&amp; onGround()){linearVelocity *= btScalar(0.2);body-&gt;setLinearVelocity(linearVelocity);}else{if(speed &lt; maxLinearVelocity){btVector3 velocity = linearVelocity + walkDirection * walkSpeed;body-&gt;applyCentralImpulse(velocity*10);}}}//update:Character-&gt;playerStep(DeltaTime* 0.001, forward, backward, left, right, jump);    btTransform xform;characterBody-&gt;getMotionState()-&gt;getWorldTransform(xform);    btVector3 pos = xform.getOrigin();    btQuaternion btq = xform.getRotation();//first way    characterNode-&gt;setOrientation(btq.w(),btq.x(),btq.y(),btq.z());    characterNode-&gt;setPosition(Ogre::Vector3(pos[0], pos[1], pos[2]));</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=10416">konri100</a> — Sun Aug 25, 2013 10:46 pm</p><hr />
]]></content>
	</entry>
	</feed>
