Artem Posted March 18, 2014 Share Posted March 18, 2014 Hello. Is it possible? I need to check if one cube touches a side (face) of another cube (it should be exactly its side/polygon, not just a single point). Off-topic:What's "isInFrustrum(frustumPlanes)"? Quote Link to comment Share on other sites More sharing options...
Artem Posted March 18, 2014 Author Share Posted March 18, 2014 Hm, it looks like I figured it out myself. I used "intersectsMinMax":player.getBoundingInfo().boundingBox.intersectsMinMax(box.getBoundingInfo().boundingBox.vectorsWorld[0], box.getBoundingInfo().boundingBox.vectorsWorld[6]) Quote Link to comment Share on other sites More sharing options...
gwenael Posted March 18, 2014 Share Posted March 18, 2014 BABYLON.BoundingBox.prototype.intersectsMinMax = function (min, max) { if (this.maximumWorld.x < min.x || this.minimumWorld.x > max.x) return false; if (this.maximumWorld.y < min.y || this.minimumWorld.y > max.y) return false; if (this.maximumWorld.z < min.z || this.minimumWorld.z > max.z) return false; return true;};// can also be written like this:BABYLON.BoundingBox.prototype.intersectsMinMax = function (min, max) { if (this.maximumWorld.x >= min.x && this.maximumWorld.y >= min.y && this.maximumWorld.z >= min.z && this.minimumWorld.x <= max.x && this.minimumWorld.y <= max.y && this.minimumWorld.z <= max.z) return true; return true;};intersectsMinMax allows you to check if there is an intersection (a common volume) between two bounding boxes, the one specified while calling intersectsMinMax and the one defined by min and max which are the parameters of the function. This intersection can be a single point... Vector3(max.x, max.y, max.z) = minimumWorld for example. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.