Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
Box3d Collision

codemastermike
Registered User
Quote
2011-11-03 10:45:00

Im having a problem where isPointInside and intersectsWithBox functions keeps returning true (or what the functions are returning) eventhough the objects arent colliding.

The documentation states that the function "returns" if there is a collision, so Im assuming the code below should be correct to
do a proper BoxvsBox/Point collision check.


var Box1 = scene.getSceneNodeFromName("Box1");
var Box2 = scene.getSceneNodeFromName("Box2");

if(!Box1 || !Box2)
return;

Box1.updateAbsolutePosition();
Box2.updateAbsolutePosition();

var BBox1 = Box1.getBoundingBox();
var BBox2 = Box2.getBoundingBox();

var Center = BBox1.getCenter();

if(BBox2.isPointInside(Center) != null)
alert('isPointInside collision');

if(BBox1.intersectsWithBox(BBox2) != null)
alert('intersectsWithBox collision');


Am I doing this wrong, or isnt the box3d collision fully functional?


niko
Moderator
Quote
2011-11-03 12:39:55

You are testing the local bounding boxes, that's why they collide. What you want is the transformed bounding boxes. Instead of getBoundingBox(), use getTransformedBoundingBox().


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internation?l" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact