Forum

Problem with MouseOver / Outline Enable in First Person (where the mouse pointer is hidden)

05 April 2017 20:42
Hi everybody,

I would like to use the "outline enable" feature in First Person mode. However, in First-Person mode when the browser hides the mouse pointer image (which is desired) and the pointing position essentially becomes locked center-screen (where the crosshair is in shooter games), B4W still uses the position of the (now hidden) mouse pointer for outlining objects instead of center-screen. This makes it impossible for the user to "look at/point at" and get objects outlined properly in First-Person because the hidden mouse pointer could be anywhere whereas the pointing position is always center-screen.



You can check this with your own Jungle Outpost example if you set the bucket to "outline enable". In my example, the mouse pointer was in the lower left corner before the browser hid it. Indeed, B4W outlines the bucket at the (hidden) mouse pointer position instead of center-screen where the user would expect it in First-Person.
06 April 2017 10:58
Hi,

That's true about the mouse pointer. It is not possible to override the mouse position with Javascript.
But there is no need in this

Just use the pick_center method to get an object in the center of the screen.
Blend4Web developer
06 April 2017 19:19
Thanks, that did it! I added an event handler for mouse move which checks for objects with pick_center and plays (or ends) the outline effect accordingly. Works like a charm!

Even better than before because with my own handler I can check for the presence of one object but outline a different object. This is helpful when I have very small target objects that could be easily missed by the user. I can now put a large, invisible "detection mask" object around the small object to increase the hit detection area, so I check for detection on the mask object but still play the outline effect for the actual target object.



Great, thanks again!
08 April 2017 08:59
Sorry, but may I bother you with another question regarding outlining and "pick_center"?

I only want the outline to show if the object is visible to the camera, NOT when the line of sight is obscured by meshes of other objects, for obvious reasons - for example, I don't want objects in a room to show their outline through walls/floors/ceilings when I'm in another room.

Since "pick_center" reacts to SELECTABLE objects, I can achieve this by setting ALL objects, including walls etc., to "selectable". But is this the right way to do it? A large scene could have a massive number of objects… Or is there a way to test specifically if the object returned by "pick_center" is obscured?
08 April 2017 20:10
Since "pick_center" reacts to SELECTABLE objects, I can achieve this by setting ALL objects, including walls etc., to "selectable". But is this the right way to do it? A large scene could have a massive number of objects… Or is there a way to test specifically if the object returned by "pick_center" is obscured?
Actually, this is a correct approach. Basically, testing object's visibility means rendering other objects which might block this object. And this is why you need to make walls selectable as well. If the walls are static and have the same material, this won't seriously harm the performance. Hint: to set some property for selected object you can ALT-click it.

What I would recommend anyway, is to try to minimize the amount of pick_object()/pick_center() calls. If you can do this only on click, this will be a good optimization.

And if you need the best performance possible and at the same time you want the approach to be as generic as possible, then physics is your choice. This requires more efforts though. You can check how this is done in Petigor's Tale (sources available in the free SDK under apps_dev/petigors_tale). Find the start_menu.js module and check the intro_load_cb method.
Blend4Web developer
11 April 2017 18:28
OK, thanks. I may look into these options later on. For now, I'm satisfied with the performance.
 
Please register or log in to leave a reply.