Hello, I'm trying to click a mesh by checking the position of a cursor in 3D, and seeing if it's position is less than the radius of the nodes bounding box. At first I thought there was some math involved. But then I did a bit of debugging. Below you'll find two screenshots.
The first screenshot just shows a mesh with it's bounding box enabled.
The second screenshot shows a sphere scene node with it's size set to the nodes bounding box radius, positioned at the center of the node's bounding box.
So, in theory the sphere scene node should show you the radius of the bounding box, right? If I'm wrong, please correct me.
Anyways, I still cannot click the mesh within the radius, and can only click it further within the radius.
Here's the screenshots and code:
Code: Select all
if (node.Position.GetDistanceFrom(camera.GetCursorPosition3D()) < node.BoundingBoxTransformed.Radius)
{
SceneNode n = game.GetSceneManager().AddSphereSceneNode(node.BoundingBoxTransformed.Radius);
n.Position = node.BoundingBoxTransformed.Center;
n.SetMaterialType(MaterialType.TransparentAddColor);
return true;
}