<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[GMan's Mods & Stuff — rotations dont always work correctly?]]></title>
	<link rel="self" href="https://gprogs.com/extern.php?action=feed&amp;tid=366&amp;type=atom" />
	<updated>2009-03-12T14:31:01Z</updated>
	<generator>PunBB</generator>
	<id>https://gprogs.com/viewtopic.php?id=366</id>
		<entry>
			<title type="html"><![CDATA[Re: rotations dont always work correctly?]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=1404#p1404" />
			<content type="html"><![CDATA[<p>thanks for the functions and the modules!</p><p>Ill try them out</p><p>EDIT<br />they work great thanks</p>]]></content>
			<author>
				<name><![CDATA[Slenkar]]></name>
				<uri>https://gprogs.com/profile.php?id=40</uri>
			</author>
			<updated>2009-03-12T14:31:01Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=1404#p1404</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: rotations dont always work correctly?]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=1402#p1402" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[gman]]></name>
				<uri>https://gprogs.com/profile.php?id=2</uri>
			</author>
			<updated>2009-03-11T00:32:54Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=1402#p1402</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: rotations dont always work correctly?]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=1400#p1400" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Slenkar]]></name>
				<uri>https://gprogs.com/profile.php?id=40</uri>
			</author>
			<updated>2009-03-10T14:32:53Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=1400#p1400</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: rotations dont always work correctly?]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=1399#p1399" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Slenkar]]></name>
				<uri>https://gprogs.com/profile.php?id=40</uri>
			</author>
			<updated>2009-03-10T14:31:14Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=1399#p1399</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[rotations dont always work correctly?]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=1394#p1394" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Slenkar]]></name>
				<uri>https://gprogs.com/profile.php?id=40</uri>
			</author>
			<updated>2009-03-09T18:09:53Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=1394#p1394</id>
		</entry>
</feed>
