Finding objects

Software: Away3D 4.x

Kirill, Newbie
Posted: 06 July 2012 04:18 PM   Total Posts: 3

Hell,
We have some problems with finding objects under mouse cursor.
I have nested container structure, and in certain conditions I want to listen mouse events of the deepest ones, which are transparent.
Actually, I want to get an array of elements under mouse cursor, including transparent ones.

1. Is it possible to find all objects including trasparent, located on the ray that started at camera point and directed by mouse?

2.Can i make child objects inside container to fire mouse events, if child object is not aligned to visible container plane?

3. Can i check collision with custom ray and object(passed by refference),even if it is transparent?

Answer to any question would by very helpful.
Thanks in advance.

   

Richard Olsson, Administrator
Posted: 06 July 2012 09:03 PM   Total Posts: 1192   [ # 1 ]

First of all, the picking system has recently undergone some major changes, and the new system (still in a bit of motion) is in the release branch, and slated to be included in the 4.0 stable release later this month.

With this new picking system, you have two clearly separated options. Using a shader to do per-pixel picking on the GPU (slow on some devices as it requires GPU readback) or using a raycasting approach on the CPU. In this case only the CPU approach would work, because the GPU approach can only ever find one object.

I’m actually not sure whether there is a way to find all the objects “under the mouse” using this system though. It definitely does it internally, but I don’t think it’s exposed anywhere. It only ever returns a single object, but you could of course hack that.

So:

1. Yes, possibly with some hacking required. Or you can file a feature request and maybe we can expose an API like this (since it’s already happening internally anyway.)

2. I’m not sure I understand what you mean by “aligned to visible container plane”, but yes you can listen for mouse events on objects that are inside containers.

3. Yes, transparency has no impact on the picking system.

Hope this helps!

 

   

Kirill, Newbie
Posted: 09 July 2012 04:35 PM   Total Posts: 3   [ # 2 ]

Thank you. Your answer helped us!

For anyone, looking for quick solution for finding all objects on the ray.

You can add a function getViewAllCollisions to the RaycastPicker class (in the release or picking_refactor branch) wich returns all found objects. It’s a copy and paste from the original getViewCollision function(

 

File Attachments
getViewAllCollisions.txt  (File Size: 2KB - Downloads: 403)
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X