LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3D Picture Control using Mouse Wheel

Hi,

I'd like to be able to zoom in and out using the mouse scroll wheel in 3D picture control but I don't see how to do this, right now you have to hold down shift and click the left mouse button for zooming. I understand one of the values in ModelViewMatrix represents the amount you have zoomed in/out but Im not sure how to acquire mouse wheel data properly to implement it.

I checked the acquire data VIs and for scroll wheel data it only seems to give discrete answers if you scroll really fast, like 120/240/360. I read some threads saying that it was possible but without really explaining how to do it, any assistance on this problem would be appreciated!

0 Kudos
Message 1 of 14
(5,808 Views)

*possible to get individual count rates for every scroll on the mouse wheel.

0 Kudos
Message 2 of 14
(5,802 Views)

I've attached an image on how the code for scrolling would work. It works somewhat, the main issue is that if you're viewing the object in 3D picture control from a certain angle, as soon as you move the scroll key up/down the image seems to rotate to a new position and if you try to use the scroll key again after this rotation it works fine. Don't understand why this is happening. There is also a minor issue of the Y coordinate changing ever so slightly (by 0.0001) when zooming using the scroll key.

I would have attached the original code but its very large and would do more harm than good for people trying to troubleshoot the problem.

0 Kudos
Message 3 of 14
(5,764 Views)

Just a quick explanation for the image attached. I'm reading the current (X,Y,Z) positions from ModelViewMatrix, then adding the Z value to the scroll value. The scroll value has been adjusted so one scroll is a change in value of 1 (instead of 120). Then feeding the XYZ information to setup camera.

0 Kudos
Message 4 of 14
(5,761 Views)

Hello Nik1,

 

My name is Laurence and I am an application engineer here at NIUK.

 

Am I right in thinking you have now solved the issue where scrolling was not producing the correct data, and that the problem now is that your picture rotates before the initial zoom, and a slight change in y?

 

I have had a look at your image and would like to help assist in this issue.

 

Would it be possible to upload the image as a VI which I can run on my machine? This would be a good initial test to see if the problem persists across computers, and allows me to have a closer look at your VI’s process.

 

Kind Regards,

Laurence C

Applications Engineer

National Instruments UK


Larry Colvin
Associate Principal Engineer
Dyson Technology Ltd.

0 Kudos
Message 5 of 14
(5,742 Views)

Hi Laurence,

Okay so I've uploaded the image as a VI, tweaked a few things from the image, nothing major. Using a cone as an example 3D object in this instance.

You are correct, scrolling is producing the correct data now. The picture rotates before the initial zoom, you'll notice at larger distances the Y value changes ever so slightly when zooming, and at short distances the object starts doing rotations when zooming in closer or further away.

Thanks for having a look.

0 Kudos
Message 6 of 14
(5,737 Views)

Hello Nik1,

 

I have been playing around with your VI you sent in to further understand the problem with zooming. I experienced being unable to zoom if I had not initially rotated the object slightly, and when the zooming was carried out it would randomly (or so it seemed) rotate the object/camera so the object wasn’t in the same plane.

 

I went online and researched about the ModelViewMatrix and found an interesting resource that explained to me what each element in the matrix would change about the picture.

 

I then rewrote your inside case structure to simplify the matrix operations. I decided to carry out no matrix inverse or multiplications and instead opted for calling particular parts of the matrix out. I would then operate a change on the element (4,3) which determined the z position and reassembled the matrix. This is then immediately written back into the ModelViewMatrix property node.

 

When testing I found I also had to change the multiplier control to be a double precision number rather than an integer, and the shift register which was initialised and added to the scroll wheel data I removed as it stopped the VI from recognising scroll direction (also not sure what it was originally for).

 

Now when you scroll in the picture when the VI is running it zooms in and out depending on the direction you scroll. You also do not require to rotate the object every time you scroll. I have attached my version of the VI and I hope it is what you want it to do. LabVIEW also has a very good example code which demonstrates various object controls which can be used to set up a scene, this can be found in the labVIEW examples under: building user interfaces > displaying data > pictures > solarsystem.vi

 

I hope this helps, if you have any further questions please do not hesitate to reply or post a new thread.

 

Kind Regards,

Laurence C

Applications Engineer

National Instruments UK


Larry Colvin
Associate Principal Engineer
Dyson Technology Ltd.

Message 7 of 14
(5,710 Views)

Hi Laurence, could you downsave your VI to the same LabVIEW release as Nik1's please? Yours is 2011.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 8 of 14
(5,706 Views)

Hi,

 

Thanks for pointing that out, I would have missed it otherwise.

 

I have re-saved the VI in 10.0 LabVIEW format and reattached it to this post.

 

I hope it works now.

 

Regards,

Laurence C

Applications Engineer

National Instruments UK


Larry Colvin
Associate Principal Engineer
Dyson Technology Ltd.

0 Kudos
Message 9 of 14
(5,703 Views)

Hey LarryC,

Yeah, the inverse and multiplications effectively did the same job as just extracting the proper values from the (4x4 Matrix).
But I have also tried your method before, which is changing the Z position then reassembling the matrix and writing it back into ModelViewMatrix property node.

The problem here is, as I foolishly forgot to mention earlier, I would like to retain the ability to rotate around the object (by having camera controller on spherical) what I noticed when you reassemble a matrix and write it back into ModelViewMatrix, the camera controller automatically switches to Oriented mode, and there seems to be no way of overriding it. Even if you program it on the block diagram and force the camera controller to be in spherical mode and stick up an indicator on the front panel, it will always say the camera controller mode is spherical even though it's quite clearly not (is actually oriented). This same thing is happening in the VI you wrote.

The shift register intialised for scroll wheel data was a remanant of an older piece of code, sorry.

Yes I have looked at the Solar systems example, it's a nice VI but it doesn't reveal much about how to assign a different key to zoom aside from the inbuilt one (ctrl + left mouse button) when in spherical camera controller mode. I was aiming to have an image which you could rotate around and zoom in/out using the scroll wheel instead of (ctrl + left mouse button).

I very much appreciate that you have spent quite a considerable time on this.

Regards,

Nik

0 Kudos
Message 10 of 14
(5,685 Views)