Forum

Adding a spot on an object and "save" it

15 February 2017 14:17
Hello there,

On a previous post of mine , https://www.blend4web.com/en/forums/topic/3022/ , i was asking how i could take the real coordinates of a mouse click so i could add a spot on my obj. This happened thanks to Ray Test example!!! After this, i mean after adding some spots-flags on my obj i wanted to "save" them to stay on the object.

So , i thought after on_click on the container take those clientX, ClientY that mouse_cb function needs to run and store them in a database. I made a replica of mouse_cb function waiting for parameters (x,y) and i give those parameters after pulling them from the database. I repeat call mouse_cb for all my spots-flags in the database. This works fine but another problem appears.

The problem is that ClientX, ClientY depends on the client's screen, the current zoom, and the camera's position. So if i run the app from another pc (with different screen dimensions or differnet zoom) the spots appears in different position or not at all.

So, which is the most proper way to achieve that? I hope i explained it well. Ask me for anything you didnt understand.

Thank you
20 February 2017 16:50
Hi,

Yes, the 2D mouse coordinates cannot be linked to. You have to convert them into 3D coordinates of a scene. In fact, they are already converted and stored in the "hit_pos" variable in that Ray Test example.
The Founder | Twitter
 
Please register or log in to leave a reply.