<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Maratis forum - Collision and camera in plugins question?]]></title>
		<link>http://forum.maratis3d.com/viewtopic.php?id=777</link>
		<description><![CDATA[The most recent posts in Collision and camera in plugins question?.]]></description>
		<lastBuildDate>Fri, 20 Sep 2013 20:38:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5039#p5039</link>
			<description><![CDATA[<p>I dont know much about c++ to be honest, but when I need that plugin for my game I will make it.</p>]]></description>
			<author><![CDATA[dummy@example.com (Pär)]]></author>
			<pubDate>Fri, 20 Sep 2013 20:38:23 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5039#p5039</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5038#p5038</link>
			<description><![CDATA[<p>You can inspire what is done in lua to do the same in c++,<br />follow what I said and remember to always use physCont-&gt;addCentralForce to move objects with physics</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Fri, 20 Sep 2013 19:39:57 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5038#p5038</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5036#p5036</link>
			<description><![CDATA[<p>So I can replicate what you did in Jules demo if I want to make it through lua?</p>]]></description>
			<author><![CDATA[dummy@example.com (Pär)]]></author>
			<pubDate>Fri, 20 Sep 2013 14:30:44 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5036#p5036</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5033#p5033</link>
			<description><![CDATA[<p>For a camera, you can replicate what is done in Jules demo in lua but in c++,<br />basically apply physics to an invisible box (with sphere collision shape) with very low mass (0.001 for example) that follow your player or else, and link the camera to this box so the camera will collide walls.</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Fri, 20 Sep 2013 10:12:44 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5033#p5033</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5031#p5031</link>
			<description><![CDATA[<p>I also thought about this, it would be great if my camera wouldn&#039;t go through objects or house-walls when I came near.</p>]]></description>
			<author><![CDATA[dummy@example.com (Pär)]]></author>
			<pubDate>Fri, 20 Sep 2013 00:05:38 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5031#p5031</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5028#p5028</link>
			<description><![CDATA[<p>I applied camera to object, but when i press &quot;W&quot; or &quot;S&quot; key camera moves independently from object. Why this is happening? Any sugestions, this is my code:</p><div class="codebox"><pre><code>void Test::move(float speed)
{
        MEngine * engine = MEngine::getInstance();
        MLevel * level = engine-&gt;getLevel();
        MScene * scene = level-&gt;getCurrentScene();
        MObject3d * parent = getParentObject();
        MOEntity * entity = (MOEntity *)parent;
        MOCamera *camera = scene-&gt;getCurrentCamera();
        MInputContext * input = engine-&gt;getInputContext();
        MPhysicsContext * physCont = engine-&gt;getPhysicsContext();
        MPhysicsProperties * phyProps = entity-&gt;getPhysicsProperties();

        MVector3 rot = entity-&gt;getTransformedRotation();

        camera-&gt;setPosition(parent-&gt;getTransformedPosition());
        
        if(input-&gt;isKeyPressed(&quot;W&quot;))
        {
            MVector3 dir;
            dir.x = sin(rot.y)*speed;
            dir.y = cos(rot.y)*speed;
            dir.z = sin(rot.y)*speed;
            
            
            physCont-&gt;addCentralForce(phyProps-&gt;getCollisionObjectId(), dir);

        }
        if(input-&gt;isKeyPressed(&quot;S&quot;))
        {
            MVector3 dir;
            dir.x = sin(rot.y)*(-speed);
            dir.y = cos(rot.y)*(-speed);
            dir.z = sin(rot.y)*(-speed);
            
            
            physCont-&gt;addCentralForce(phyProps-&gt;getCollisionObjectId(), dir);
        }
        
        if(input-&gt;isKeyPressed(&quot;A&quot;))
        {
            MVector3 dir,rotation;
            dir=parent-&gt;getEulerRotation();

            parent-&gt;setAxisAngleRotation(MVector3(0,0,1),dir.z+1);
        }

}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Skywriter)]]></author>
			<pubDate>Thu, 19 Sep 2013 16:49:35 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5028#p5028</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5025#p5025</link>
			<description><![CDATA[<p>Thanks Anael. Collision worked. I used box for collision shape, and sponza for level. I have modified function slightly. So far i have:<br /></p><div class="codebox"><pre><code>void Test::move(float speed)
{
        MEngine * engine = MEngine::getInstance();
        MLevel * level = engine-&gt;getLevel();
        MScene * scene = level-&gt;getCurrentScene();
        MObject3d * parent = getParentObject();
        MOEntity * entity = (MOEntity *)parent;
       
        MPhysicsContext * physCont = engine-&gt;getPhysicsContext();
        MVector3 rot = entity-&gt;getTransformedRotation();
        MPhysicsProperties * phyProps = entity-&gt;getPhysicsProperties(); // use parent physics prop if you want to move the parent

        MVector3 dir;
        dir.x = sin(rot.y)*speed;
        dir.y = cos(rot.y)*speed;
        dir.z = sin(rot.y)*speed;

        physCont-&gt;addCentralForce(phyProps-&gt;getCollisionObjectId(), dir);
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Skywriter)]]></author>
			<pubDate>Thu, 19 Sep 2013 10:02:35 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5025#p5025</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5024#p5024</link>
			<description><![CDATA[<p>if the physics of your entity and level is enabled in editor you don&#039;t need to enable it in code.</p><p>do you want to replicate something like the jules movement or sponza in c++ ? with gravity ?<br />if you want the entity to bounce/slide you don&#039;t need to stop the entity manually, let the physics handle it.</p><p>also, who do you want to move, &quot;parent&quot; or &quot;ent&quot; ?</p><p>first, enable physics in editor (be sure entity has a mass &gt; 0)<br />then move the entity with physCont-&gt;addCentralForce only :</p><div class="codebox"><pre><code>        MPhysicsContext * physCont = engine-&gt;getPhysicsContext();
        MVector3 rot = parent-&gt;getTransformedRotation();
        MPhysicsProperties * phyProps = parent-&gt;getPhysicsProperties(); // use parent physics prop if you want to move the parent

        MVector3 dir;
        dir.x = sin(rot.y)*speed;
        dir.y = cos(rot.y)*speed;
        dir.z = sin(rot.y)*speed;

        physCont-&gt;addCentralForce(phyProps-&gt;getCollisionObjectId(), dir);</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Thu, 19 Sep 2013 08:14:55 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5024#p5024</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5011#p5011</link>
			<description><![CDATA[<p>Hi, Anael. I have physics enabled in editor, but not in code. Actually have no idea how to do this in code, so if you have time for this, please post it for me. What i&#039;m trying to achieve is to stop entity from moving when it collides with something(anything in level like wall or other entity) and of course bactrack or slide when collision occurs. I tried <br /></p><div class="codebox"><pre><code>if (physCont-&gt;isObjectInCollision(phyProps-&gt;getCollisionObjectId()) == 0) // 0 collisions so move
{
    parent-&gt;setPosition(pos);
}</code></pre></div><p>but without sucess. Object still moves threw the wall. I tried to add<br /></p><div class="codebox"><pre><code>phyProps-&gt;setCollisionShape(M_COLLISION_SHAPE_BOX);</code></pre></div><p>but still nothing. What i&#039;m missing?</p>]]></description>
			<author><![CDATA[dummy@example.com (Skywriter)]]></author>
			<pubDate>Wed, 18 Sep 2013 20:32:38 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5011#p5011</guid>
		</item>
		<item>
			<title><![CDATA[Re: Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=5009#p5009</link>
			<description><![CDATA[<p>Hi,</p><p>you sure it&#039;s not :<br /></p><div class="codebox"><pre><code>if (physCont-&gt;isObjectInCollision(phyProps-&gt;getCollisionObjectId()) == 0) // 0 collisions so move
{
    parent-&gt;setPosition(pos);
}</code></pre></div><p>how is the collision shape of your entity, and is the physics enabled in the entity and in the level ?</p><p>Also let&#039;s say you are using the entity bounding box,<br />once you collide with the level and cannot move it means the entity will be stuck because it cannot move when in collision.</p><p>Also, when dealing with physics objects, it&#039;s better to move them with physCont-&gt;addCentralForce instead of setPosition.<br />isObjectInCollision returns the number of collision the entity is with.</p><p>Can you detail how exactly you want the entity to interact ?</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Wed, 18 Sep 2013 20:12:47 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=5009#p5009</guid>
		</item>
		<item>
			<title><![CDATA[Collision and camera in plugins question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=4998#p4998</link>
			<description><![CDATA[<p>Hi, im making a plugin in c++ and want entity to colide with level mesh and stop moving when it collided. What functions i should use? I&#039;m using isObjectInCollision, but it doesnt behave as i expected(just rotates with mouse movement). Actually i cant find description for this function, so i&#039;m not sure what it does. How to find that collision occured?&nbsp; Please help. Currently i have:<br /></p><div class="codebox"><pre><code>void Player::move(MObject3d * parent,MScene * scene,MEngine * engine,float speed)
{
        MVector3 pos=parent-&gt;getTransformedPosition();
        MVector3 rot=parent-&gt;getTransformedRotation();
        MOEntity* ent= scene-&gt;getEntityByName(&quot;Player&quot;);
        MPhysicsContext * physCont = engine-&gt;getPhysicsContext();
        MPhysicsProperties * phyProps = ent-&gt;getPhysicsProperties();

        pos.x += sin(rot.y)*speed;
        pos.y += cos(rot.y)*speed;
        pos.z += sin(rot.y)*speed;

        if (physCont-&gt;isObjectInCollision(phyProps-&gt;getCollisionObjectId())&gt;0)
        {
            parent-&gt;setPosition(pos);
        }
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Skywriter)]]></author>
			<pubDate>Wed, 18 Sep 2013 14:53:09 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=4998#p4998</guid>
		</item>
	</channel>
</rss>
