Mouse over. David please!!

Hi,

This message is for David.
I want to implement a method for showing the name of an object when the mouse pointer is over the object but without using rays (from camera to object) and collisions.
In an old message, you explained how that was implemented in ToonTown. You mentioned something about creating rectangle regions in aspect2d and something about a mouseWatcherRegion. I have look for the old post but I have not successed.
Furthermore, I have some doubts:

  • How can I know which objects are currently displayed in the screen?
  • What does the getBound() method return? A rectangle, a sphere, what?
  • Is there any way to map the bounds of a 3D object (in render space) to a rectangle in 2D (render2d, aspect2d)?
    Regards.
    Alberto

Yes, this is really the way we solved this problem in Toontown. You basically create a MouseWatcherRegion for each object that you want to be clickable. Since the MouseWatcherRegion defines a rectangular region on screen, that means you need to be able to determine a rectangular region that roughly corresponds to the object in question.

There are several ways to determine whether the object is onscreen. The easiest way is base.cam.isInView(point), where the point is a point within your object, converted to the coordinate space of base.cam.

Similarly, you can call base.camLens.project() to convert from a 3-d point (in the camera’s coordinate space) to a 2-d point onscreen. The return value of project() is false if the point is offscreen.

Neither of these tests will tell you if the object is behind a wall. We don’t even worry about that case in Toontown (it’s possible to click on someone through a wall, but this generally doesn’t bother anyone).

David

Hi,

Thank you very much for the help.
Alberto