Mouse coodinates from blob track TOP

Hi,

I am trying to create a system which selects a blob from the blob Track TOP based on mouse input (click). What I had in mind is to create a container window (to be displayed in perform mode), and display the blob track TOP result in it. Then I want to map a mouse in CHOP just to the blob track part of the container window. Once I have the coordinates, I check which u,v values recorded in the blob track info DAT are closest to the mouse click, and that would correspond to the selected blob.

I have been trying to work it out, but have been unable to get results. Is the approach above correct, or is there an easier method which I might be missing?

Thanks.

Hi @wiltabone,

you can use the data in the Info DAT attached to the Blob Track TOP to instance some rectangles in a 3D render. Now using a Render Pick CHOP, you can again retrieve the blob number from the instance data by relying on the row number’s correlation with the order of instancing.

So the 2 things to have a look at would be Instancing and Renderpicking.
Our curriculum at learn.derivative.ca has a section on instancing you might find helpful:

And for Renderpicking I would like to point you to the examples provided for the Render Pick CHOP and Render Pick DAT in the OPSnippets.

Thanks Markus!
I was not so familiar with Renderpicking - so this workflow was quite useful.

1 Like

Hi Markus,
As an additional feature, I wanted to make selection automatic via a mouse hover. The hovering behaviour on the slider CHOP which houses the renderPick works correctly and I am able to extract the local u, v coordinates. I tied a timer CHOP to it so that if the ‘inside’ condition lasts for 3 seconds, a mouse click is executed. I had gone through the forums and also the documentation and implemented the click method (sliderCOMP Class - Derivative), passing the u, v coordinates.
However the click() method never seems to actually result in a click when the timer is finished. I have tried other methods, such as interactMouse() to no avail.

Is there something essential I should look out for? Or is it more common to use an external package such as pynput in these cases?

Cheers.

Hi @wiltabone,

how are you checking for the click? Are you checking via a Panel Execute DAT or also via the Renderpick CHOP?

If the later, try using the Renderpick DAT instead. It allows for multiple select triggers - for example you could use the Panel COMP’s “inside” channel as well as the “select” channel to trigger renderpick events.

The Renderpick DAT expects a table input with columns for select, u, and v. I usually use a Panel CHOP, select the channels I like to trigger with and include the “rollu” and “rollv” channels. In order to eventually convert them to a DAT table, i need to Shuffle the channels, but also need to duplicate the rollu and rollv channels as they will be used for all select methods. This is a simple trick of the Select CHOP, where when naming the same channel multiple times, it creates copies of them.

Hope this gets you a bit further
cheers
Markus

Hey Markus,

Thanks for your reply. The click and selection behaviour is working as expected. What I am trying to do is use the click() method from the Slider COMP to execute a click programmatically if the pointer over an area for 3 seconds. This is because eventually the pointer will be moved around by sensors rather than an actual mouse with clicking capabilities.

So so far the timer is triggered when the ‘inside’ condition is a 1, but when the click() method is called nothing happens - ie. The region that the mouse is hovering over is not clicked. I checked around and didn’t find much resources on how to call clicks inside TD using the click() methods from the slider and panel COMPS except for using external os libraries like pynput.

Wondering what your take is on this or if again I missed something crucial.

Thanks

Hey @wiltabone,

i tried to rebuild your example with a simple renderpick setup and a timer having a .click() call on the parent panel in the Timer CHOP’s onDone callback. To verify that it is working I used a Panel Execute DAT.

Can you share a replicable example to see why it might not be working in your case?

cheers
Markus

Hey @snaut,

I attached a quick example.

Thanks

blob_click_sample.10.toe (13.1 KB)

EDIT: I have even implemented an external notebook that correctly executes mouse clicks using the pynput library. It works everywhere except for the ‘renderPick’ view window (maximised).

Hey @snaut,

Did the example I attached work for you, or does it replicate the same issues I faced?

Thanks

Hi @wiltabone,

yup, I can see the same thing but I think it’s architectural in nature.

You can use a regular Container COMP instead of a Slider COMP for the interaction. This at least prevents some general confusion. All Panel operators can deal with uv click points so there is no need to for a Slider.

There are also 2 callback operators currently running when the Timer CHOP is done. The right place is the onDone callback and the CHOP Execute DAT can be removed. Especially with the CHOP Execute running onValueChange the script will execute when the “done” channel switches from 0 to 1 but also when going back to 1.

For starting the Timer, you could probably just use the Panel CHOP’s “inside” channel and then in the onDone callback access the Container COMP’s mouse inside-uv directly via the panel values before sending the click method to it:

def onDone(timerOp, segment, interrupt):
	panelOp = op('renderPick2')
	u = panelOp.panel.insideu
	v = panelOp.panel.insidev
	panelOp.click(u, v)
	return

You might want to rethink the approach of starting the Timer CHOP via the “inside” panel value, the issue being that the timer can now only be restarted if the pointer leaves the panel and reenters. Since everything is based on triggering in a certain region, you could use a single Render Pick CHOP that constantly picks up what is below the pointer and with the help of a Speed CHOP make sure that any result is only passed on 3 seconds later.
The Render Pick CHOP comes with a “picked” channel which can be used to:

  • count up when it’s 1 by using it as an input to a Speed CHOP
  • reset the Speed CHOP when it’s going back to 0

As it only goes to 1 when the pointer is actually above a blob, also the counter only starts when you are rolled over a blob, stops when rolling off a blob and restarts when rolling onto a blob again.

Attached an example
Hope this helps
Markus
blob_click_sample.11.toe (11.4 KB)