<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[GMan's Mods & Stuff — rotations dont always work correctly?]]></title>
		<link>https://gprogs.com/viewtopic.php?id=366</link>
		<atom:link href="https://gprogs.com/extern.php?action=feed&amp;tid=366&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in rotations dont always work correctly?.]]></description>
		<lastBuildDate>Thu, 12 Mar 2009 14:31:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: rotations dont always work correctly?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1404#p1404</link>
			<description><![CDATA[<p>thanks for the functions and the modules!</p><p>Ill try them out</p><p>EDIT<br />they work great thanks</p>]]></description>
			<author><![CDATA[null@example.com (Slenkar)]]></author>
			<pubDate>Thu, 12 Mar 2009 14:31:01 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1404#p1404</guid>
		</item>
		<item>
			<title><![CDATA[Re: rotations dont always work correctly?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1402#p1402</link>
			<description><![CDATA[<p>greetings <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" />&nbsp; try these:<br /></p><div class="codebox"><pre><code>Function NodeMove(node:ISceneNode,x:Float,y:Float,z:Float)    
    &#039; from: http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=4680            
    Local dest:Vector3df=Vector3df.createFromVals(x,y,z)
    node.getRelativeTransformation().transformVect(dest)
    node.setPosition(dest)
EndFunction

Function NodeTurn(node:ISceneNode,pitch:Float,yaw:Float,roll:Float)
    &#039; from: http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=4680
    Local m:Matrix4=Matrix4.Create()
    Local n:Matrix4=Matrix4.Create()
    Local t:Matrix4=Matrix4.Create()
    
    m.setRotationDegrees(node.GetRotation())
    
    n.setRotationDegrees(_VECTOR3DF(0,0,roll))
    t.setRotationDegrees(_VECTOR3DF(pitch,0,0))
    n.MultEq(t)
    t.setRotationDegrees(_VECTOR3DF(0,yaw,0))
    n.MultEq(t)
        
    m.MultEq(n)
    node.SetRotation(m.getRotationDegrees())
EndFunction

Function NodePointTo:Vector3df(node:ISceneNode, x:Float, y:Float, z:Float)
    Local direction:Vector3df = _VECTOR3DF(x,y,z).Minus(node.getPosition())
    node.SetRotation(direction.getHorizontalAngle())
EndFunction</code></pre></div><p>there will still be a rotation problem since its not using quaternions.&nbsp; i have not been able to have a good quaternion rotation routine.</p>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Wed, 11 Mar 2009 00:32:54 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1402#p1402</guid>
		</item>
		<item>
			<title><![CDATA[Re: rotations dont always work correctly?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1400#p1400</link>
			<description><![CDATA[<p>I tried to convert it to blitzmax but m.getrotationdegrees returns null<br /></p><div class="codebox"><pre><code>Function TurnEntity(node:iscenenode,vec:vector3df)
    Local m:matrix4=New matrix4
    m.setRotationDegrees(node.GetRotation())
    Local n:matrix4=New matrix4
    n.setRotationDegrees(vec);
    M.Mult(n )
    node.SetRotation( m.getRotationDegrees() )
    node.updateAbsolutePosition()
EndFunction</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Slenkar)]]></author>
			<pubDate>Tue, 10 Mar 2009 14:32:53 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1400#p1400</guid>
		</item>
		<item>
			<title><![CDATA[Re: rotations dont always work correctly?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1399#p1399</link>
			<description><![CDATA[<p>ok so I was using global rotation co-ords<br />I had&nbsp; alook through the irrlicht forums and found this:<br /></p><div class="codebox"><pre><code>void rotate(irr::scene::ISceneNode *node, irr::core::vector3df rot)
{
    irr::core::matrix4 m;
    m.setRotationDegrees(node-&gt;getRotation());
    irr::core::matrix4 n;
    n.setRotationDegrees(rot);
    m *= n;
    node-&gt;setRotation( m.getRotationDegrees() );
    node-&gt;updateAbsolutePosition();
}

//--- turn ship left or right ---
void turn(irr::scene::ISceneNode *node, irr::f32 rot)
{
    rotate(node, irr::core::vector3df(0.0f, rot, 0.0f) );
}

//--- pitch ship up or down ---
void pitch(irr::scene::ISceneNode *node, irr::f32 rot)
{
    rotate(node, irr::core::vector3df(rot, 0.0f, 0.0f) );
}

//--- roll ship left or right ---
void roll(irr::scene::ISceneNode *node, irr::f32 rot)
{
    rotate(node, irr::core::vector3df(0.0f, 0.0f, rot) );
}</code></pre></div><p>but in blitz you cannot use * to multiply vectors</p>]]></description>
			<author><![CDATA[null@example.com (Slenkar)]]></author>
			<pubDate>Tue, 10 Mar 2009 14:31:14 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1399#p1399</guid>
		</item>
		<item>
			<title><![CDATA[rotations dont always work correctly?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1394#p1394</link>
			<description><![CDATA[<p>Hi I am turning a mesh with the mouse:</p><div class="codebox"><pre><code>        If x&lt;640 And y&lt;480 
            Local v:vector3df=node.GetRotation()
            v.sety(v.gety()+(prev_mouse_x-x))
            v.setx(v.getx()+(prev_mouse_y-y))
            node.SetRotation(v)
            prev_mouse_x=x
            prev_mouse_y=y
            EndIf</code></pre></div><p>it works ok but if the mesh is facing upwards and i move the mouse to the side the mesh rotates on its local Z axis. (instead of Y axis)</p><p>adjusting the pitch of the mesh always works correctly though</p>]]></description>
			<author><![CDATA[null@example.com (Slenkar)]]></author>
			<pubDate>Mon, 09 Mar 2009 18:09:53 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1394#p1394</guid>
		</item>
	</channel>
</rss>
