Selecting/Getting nodes within a rectangular area

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
Voxel
Posts: 8
Joined: Wed Feb 23, 2011 9:04 am

Selecting/Getting nodes within a rectangular area

Post by Voxel »

Hello,

I have some objects (say cubes) of different size in my scene and I want to be able to determine objects within a rectangular area which should be defined by mouse.

I think this is a feature which is common in all editors - I don't know the name but let me name the feature "area selection". Because some of you have experience in writing an editor, I hope you can help my.

Please point me to the right direction how I can achieve this functionality. Maybe you have already some code snippets available which you can share with me?

Thanks in advance for your help,
Voxel
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Selecting/Getting nodes within a rectangular area

Post by CuteAlien »

On click you create a ray for your mouse with ISceneCollisionManager::getRayFromScreenCoordinates. Collide this ray against a plane which is at the height of your floor (plane3d has intersection routines to handle that). Save that point somewhere and do the same again when the user releases the mouse-button again and you have the rectangle. Now just go over all objects and check if their coordinates are within that rectangle.
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
Voxel
Posts: 8
Joined: Wed Feb 23, 2011 9:04 am

Re: Selecting/Getting nodes within a rectangular area

Post by Voxel »

Thank you for your answer, CuteAlien.

I'm aware of the way you described to solve my problem.
My hope was, that there are some libary methods which I don't know and which I could reuse.

Again, thanks for your reply!
Voxel
Post Reply