<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Maratis forum - Physics]]></title>
		<link>http://forum.maratis3d.com/viewtopic.php?id=451</link>
		<description><![CDATA[The most recent posts in Physics.]]></description>
		<lastBuildDate>Tue, 25 Sep 2012 16:55:42 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Physics]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=2692#p2692</link>
			<description><![CDATA[<div class="quotebox"><cite>anael wrote:</cite><blockquote><p>I think the y mouse needs to be inverted :<br />Your camera is not in ortho mode ?</p><div class="codebox"><pre><code>MVector3 cameraPos = camera-&gt;getTransformedPosition();
MVector3 mousePos3d = camera-&gt;getUnProjectedPoint(MVector3(x*width, height - y*height, 1));
    
MVector3 vec = (mousePos3d - cameraPos).getNormalized();
    
MVector3 rayO = pos + vec*camera-&gt;getClippingNear();
MVector3 rayD = pos + vec*camera-&gt;getClippingFar();</code></pre></div></blockquote></div><p>Perspective. Thanks for hint, i missed about y axis <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Mikey)]]></author>
			<pubDate>Tue, 25 Sep 2012 16:55:42 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=2692#p2692</guid>
		</item>
		<item>
			<title><![CDATA[Re: Physics]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=2691#p2691</link>
			<description><![CDATA[<p>I think the y mouse needs to be inverted :<br />Your camera is not in ortho mode ?</p><div class="codebox"><pre><code>MVector3 cameraPos = camera-&gt;getTransformedPosition();
MVector3 mousePos3d = camera-&gt;getUnProjectedPoint(MVector3(x*width, height - y*height, 1));
    
MVector3 vec = (mousePos3d - cameraPos).getNormalized();
    
MVector3 rayO = pos + vec*camera-&gt;getClippingNear();
MVector3 rayD = pos + vec*camera-&gt;getClippingFar();</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Tue, 25 Sep 2012 13:49:20 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=2691#p2691</guid>
		</item>
		<item>
			<title><![CDATA[Re: Physics]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=2690#p2690</link>
			<description><![CDATA[<p>Thanks for fast response, when i tried to pick objects (with function i wrote in my plugin) i faced the problem that after rotation the body is not rotated, so <br /></p><div class="quotebox"><blockquote><p>The rotation/scale etc transform the bodies yes.</p></blockquote></div><p>so, i think i have a problem with my function below <img src="http://forum.maratis3d.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /><br />can you look at this function and say whats wrong ? (I use only perspective projection)<br /></p><div class="codebox"><pre><code>int pickObject(void)
{
    MEngine * engine = MEngine::getInstance();
    MScriptContext * script = engine-&gt;getScriptContext();
    
    if (script-&gt;getArgsNumber() == 3)
    {
        MOCamera * camera = (MOCamera *)script-&gt;getPointer(0);
        float x = script-&gt;getFloat(1);
        float y = script-&gt;getFloat(2);

        MPhysicsContext * physics = engine-&gt;getPhysicsContext();
        
        unsigned int width, height;
        engine-&gt;getSystemContext()-&gt;getScreenSize(&amp;width, &amp;height);

        MVector3 rayO = camera-&gt;getTransformedPosition();
        MVector3 rayD = camera-&gt;getUnProjectedPoint(MVector3(x * float(width), y * float(height), 1));
        rayD = rayO + ((rayD - rayO).getNormalized() * (camera-&gt;getClippingFar() - camera-&gt;getClippingNear()));

        unsigned int objId;
        if (physics-&gt;isRayHit(rayO, rayD, &amp;objId))
        {
            MLevel * level = engine-&gt;getLevel();
            MScene * scene = level-&gt;getCurrentScene();
            unsigned int entCount = scene-&gt;getEntitiesNumber();
            for (unsigned int i = 0; i &lt; entCount; ++i)
            {
                MOEntity * entity = scene-&gt;getEntityByIndex(i);
                MPhysicsProperties * phyProps = entity-&gt;getPhysicsProperties();
                if (phyProps)
                {
                    if (phyProps-&gt;getCollisionObjectId() == objId)
                    {
                        script-&gt;pushPointer(entity);
                        return 1;
                    }
                }
            }
        }
    }
    
    return 0;
}</code></pre></div><p>sometimes if works wrong (don&#039;t detect collision)</p>]]></description>
			<author><![CDATA[dummy@example.com (Mikey)]]></author>
			<pubDate>Tue, 25 Sep 2012 12:14:51 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=2690#p2690</guid>
		</item>
		<item>
			<title><![CDATA[Re: Physics]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=2689#p2689</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>Is there a way to display physic bodies ?</p></blockquote></div><p>&gt; But we&#039;ll add that on the TODO list</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Tue, 25 Sep 2012 11:54:00 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=2689#p2689</guid>
		</item>
		<item>
			<title><![CDATA[Re: Physics]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=2688#p2688</link>
			<description><![CDATA[<p>There is no physics display in editor,<br />but you can use the box.mesh, cylinder.mesh, cone.mesh and sphere.mesh of &quot;Small Demos&quot; example<br />to build a collision body, set it invisible and then attach an object to it.</p><p>The rotation/scale etc transform the bodies yes.</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Tue, 25 Sep 2012 11:53:00 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=2688#p2688</guid>
		</item>
		<item>
			<title><![CDATA[Physics]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=2687#p2687</link>
			<description><![CDATA[<p>Is there a way to display physic bodies ?<br />Does fuctions set rotation and else transform bodies ?</p>]]></description>
			<author><![CDATA[dummy@example.com (Mikey)]]></author>
			<pubDate>Tue, 25 Sep 2012 11:23:22 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=2687#p2687</guid>
		</item>
	</channel>
</rss>
