Mouse picking on invisible mesh?

Software: Away3D 4.x

CyrilM, Newbie
Posted: 01 April 2013 01:43 PM   Total Posts: 15

Is it possible to use mouse picking on an invisible mesh?

I’m not talking about bounding space collision, I mean per poly mesh picking. It works when the mesh is visible, but when I set the .visible property to false it doesn’t work anymore. While that does make sense it means that I can’t hide the collision mesh, I need to put it inside or below other geometry. Problem is that this means the collision mesh isn’t where I want it to be.

For example, a collision mesh hidden bellow some terrain would place the character ever so slightly below the actual terrain geometry. Or what if I wanted a lower poly collision mesh on a character that was slightly larger than the characters actual shape.

   

CyrilM, Newbie
Posted: 08 May 2013 03:44 PM   Total Posts: 15   [ # 1 ]

Ok, so after wresting with this for a while (including mucking about in the Away3D source code) I couldn’t seem to get the code to work to do this. I have concluded that the solution is to set the collision mesh alpha value to 0 instead of setting it to invisible.

However, this has the unfortunate side effect of still rendering the collision mesh even though you can’t see it.

It works, but it’s not the proper way to do it.

Anyone know if this is supported in the newer versions of Away3D, or am I missing something?

   

SirGordon, Newbie
Posted: 13 April 2014 07:23 AM   Total Posts: 29   [ # 2 ]

+1, seeking a solution to this too

   

Avatar
theMightyAtom, Sr. Member
Posted: 13 April 2014 10:00 AM   Total Posts: 669   [ # 3 ]

hmm, seems logical to me that if you make something invisible, Away doesn’t render it, and therefore it will not receive mouse events. I would have suggested exactly the same solution as you found yourself, i.e make it completely see through (alpha 0) but still part of the scene graph when calculating mouse events. I think computing if an object is hit “if it had been part of the scene graph” would be just as expensive as having it there but invisible to the viewer. That is you would still have to perform the same operations on the mesh data in order to know if it is hit.

I believe your own solution is a good one, and probably the best one smile
(is it handled differently in other packages you know?)

Cheers!

   

SirGordon, Newbie
Posted: 13 April 2014 11:20 AM   Total Posts: 29   [ # 4 ]

As far as i have investigated, Entity (and Mesh) have the “bounds” property, which is probably taken into account when calculating mouse interactions, so if you want to modify the “hitbox” of a Mesh, you have to modify it’s bounds?

   

rdoi, Member
Posted: 14 April 2014 01:37 PM   Total Posts: 86   [ # 5 ]

Hi there,

Extend the class RaycastPicker, and copy/override the method getViewCollision(). Around line 93 from the original code (away 4.1.6), you can remove the isVisible requirement from the condition:

if (entity.isVisible && entity.isIntersectingRay(rayPositionrayDirection))
 
_entities[_numEntities++entity

Also take a look in the mouse picking tutorial to learn how to use a Picker class.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X