Page 1 of 1

Click inside a bounding box's radius

Posted: Fri Aug 26, 2016 9:52 am
by tdkr80
(C#, IrrlichtLime)

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;
            }
 
Image

Image

Re: Click inside a bounding box's radius

Posted: Fri Aug 26, 2016 10:28 am
by CuteAlien
Your sphere *does* show the radius of the bounding-box. As you can see by how the sphere touches the corners of the bounding-box. Or did you want a bounding-box now around the sphere? That one is larger :-) (one uses the diagonal of the box other put's a cross inside - the lines of the cross are shorter than the diagonal).

Re: Click inside a bounding box's radius

Posted: Fri Aug 26, 2016 10:41 am
by tdkr80
Okay so... if the radius is the size of sphere, why can't I click the mesh?

Re: Click inside a bounding box's radius

Posted: Sat Aug 27, 2016 6:26 pm
by CuteAlien
Don't know ... what is that GetCursorPosition3D doing? Not an Irrlicht function to my knowledge. Usually your camera doesn't have a position but a line in 3D so I guess that function does some stuff?