normal attaching an image to the cursor

16 Mar 2016 18:18 #1

Hi all,

I'm working on a specific problem. Let me try to explain it:

I'm developing application where I have to reach between two points with a haptic device. Instead of 3d cursor I just want to use a 2d jpg image. I want to know whether it is possible to attach an image to a cursor, because my task is in 2D plane so I don't want to consider the depth.

would be great if some one can suggest me solution,


Please Log in or Create an account to join the conversation.

16 Mar 2016 21:23 #2

One approach would be to extend example 03-analytics which use 2D widgets to display information from the haptic device that are read inside the haptics thread. By looking at example 06-images you can see how a 2D image can be loaded, positionned, and displayed onto the screen. By using the position information from the haptic device (x,y,z) you could then easily control the position of your 2D image.

Since the position coming from the haptic device is expressed in meters [m], you will also need to define a scale factor that converts a position in meters into a position defined in pixels. Further more, if you want to center your bitmap cursor at the center of the screen, you may also want to take into account the width and height of the window. Also keep in mind that the reference axis for 2D widgets and 3D haptic devices are different, and therfore you would need to read axes y and z from the haptic device in order to control axes x and y of the 2D image cursor.

// read position of haptic device
cVector3d posHapticDevice;

// compute position of image
double scale = 1500;
double posImageX = scale * posHapticDevice.y() + 0.5 * windowW;
double posImageY = scale * posHapticDevice.z() + 0.5 * windowH;

// assign position to image
image->setLocalPos(posImageX , posImageY);

Please Log in or Create an account to join the conversation.

17 Mar 2016 13:29 #3

Thank you so much Francois!

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum