Transform: Mouse space to aspect2dp space?

Hi all!

I’m attempting to make a lasso-tool that will let me select a cluster of objects in aspect2dp using the “rectangular-lasso” interface motif provided by most file browsers. I’m having some trouble with the mapping from the mouse selection coordinates (given by the MouseWatcher, ranging from -1 to 1) and the aspect2dp coordinates (ranging from -1 to 1 in the vertical axis, but ranging from -n to n in the horizontal, n determined by the window’s aspect ratio). I’m thinking that I’ll create a scaling function based on the location of the aspect2dp “placeholder” nodes (a2dpTopCenter, a2dpLeftCenter, etc), since these appear to correctly change location when the window is resized.

Is this the “right and proper” way to do this sort of manipulation, or is there a better way?

Thanks!
-Mark

You should consider working in render2d space instead of aspect2d space, since render2d exactly matches the MouseWatcher coordinates: -1 to 1 in both axes. You can use Panda’s relative scene graph operations to easily get coordinate in render2d space (e.g. pos = button.getPos(render2d), or point = point * button.getMat(render2d)

David