Click inside a bounding box's radius

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
tdkr80
Posts: 18
Joined: Thu Aug 18, 2016 10:15 am

Click inside a bounding box's radius

Post 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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Click inside a bounding box's radius

Post 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).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
tdkr80
Posts: 18
Joined: Thu Aug 18, 2016 10:15 am

Re: Click inside a bounding box's radius

Post by tdkr80 »

Okay so... if the radius is the size of sphere, why can't I click the mesh?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Click inside a bounding box's radius

Post 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?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply