hi all,
i was thinking about using gem for some gui stuff like slider, radio, number, playlist, bang etc. i think the hardest part is to integrate the mouse interaction (click-drag...)?
pat
Hi Patrick,
For unrotated rectangles its easy, for other shapes of GUI objects is not so easy.
Basically each abstraction figures out the upper-right and lower-left coords of the bounding box. This is based on the position/size of the object (using gemlist_list). Actually when I did this gemlist_info did not exist so I was doing crazy things to approximate the position of those corner points.
Then you just compare the position of the mouse to the position those corners:
Xlower <= Xmouse <= Xupper Ylower <= Ymouse <= Yupper
Then you can do things like trap a click when that state is true, measure the distance from the centre of the object and the mouse-pointer, and use that to translate the object so that it gets "grabbed" in the position you click...
Mind you I was making draggable boxes... not sliders, but its about the same problem...
I've posted a feature request for doing this kind of stuff so that it can be Gem that senses if a point in space is inside or outside of a gem object, no matter its shape or orientation. It should also be 3D so that you can do this with 3D cursors...
But actually gemlist_info makes this way easier than it used to be, still I have no idea how to test if a point is in the bounds of a sphere!
I can make a simple demo if your stuck...
.b.
patrick wrote:
hi all,
i was thinking about using gem for some gui stuff like slider, radio, number, playlist, bang etc. i think the hardest part is to integrate the mouse interaction (click-drag...)?
pat
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Maybe you can approximate the sphere with small adjacent squares, like integration?
~Kyle
On 8/28/06, B. Bogart ben@ekran.org wrote:
But actually gemlist_info makes this way easier than it used to be, still I have no idea how to test if a point is in the bounds of a sphere!
On Mon, 28 Aug 2006, B. Bogart wrote:
For unrotated rectangles its easy, for other shapes of GUI objects is not so easy.
For any linear transform (rotation, translation, reflection, scaling and shearing), if you can get the matrix that transformed the original rectangle, then you can separate the translation and non-translation parts of it and then inverse the latter using [mtx_inverse] from iemmatrix or [lti.MatrixInversion] from ltilib. This will allow to take points on the screen and undo the transform on them.
However, I think that the transforms all have to be 2-D, else recovering 3-D world positions from screen positions becomes much more difficult...
I think that OpenSG (OpenSceneGraph) makes it easy (or at least easier) to deal with the mouse than OpenGL/GEM. There's an OpenSG library for Pd in the works, by Mike Wozniewski (from Montréal).
(I hope to schedule a presentation on OpenSG soon, maybe at the next PureData Montréal Users Group meeting)
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada