Setting mouse position? - c++

Well I'm working on a small program and I'm trying to set the position of the window's mouse to it's center every time it moves. Thing is I have no idea how to make this work. I had the following code:
auto point = new Point(300.0, 200.0);
//auto ends up being Windows::Foundation::Point;
But I could still move the mouse freely all over the screen...
So then I searched the internet a bit and used:
Windows::UI::Input::PointerPoint point = Point(300.0, 200.0);//1
//and//
auto point = Windows::UI::Xaml::PointHelper::FromCoordinates(300.0, 200.0);//2
And example one wouldn't compile. Example 2 did compile but I could still move the mouse acrros the whole screen.
Don't know if it's important but I'm coding in C++, using DirectX for graphics and XAML for Text. (I'm also using the base class as C++/CX to work with XAML).

Try using SetCursorPos(), it should work on Windows.

Related

FTGL 3D Text issues

I am currently working on an engine that involves creating 3D objects such as boxes and spheres. My next task is to create 3D Text inside as an object. I am using Visual Studio 2012, OpenGL, Qt, FreeType2, and FTGL in C++ on a Windows 7 computer.
I have been able to import everything fine and get some things to render, but not the way I would like. If I create a box, the text jumps to the box I created. If I create another one, it jumps to that. If I move the camera, it jumps to the center of the scene. On top of that, all the letters in my string appear right on top of each other and I cannot position them.
What I want is for the text to be at whatever 3D location I tell it and for it to stay on the screen (so have multiple strings rendering) and for the letters to actually be able to make words. I have tried using glRasterPos3f as well to move it but it still stays latched onto whatever object it is. I have tried a lot to get a decent result but I keep running into the same thing. Please give me an idea of what the problem could be. Here is a sample of how I am rendering it to give an example:
glPushMatrix();
FTExtrudeFont* font = new FTExtrudeFont("Arial.ttf");
font->Depth(.5);
font->FaceSize(10);
glRasterPos3f(10,10,10);
font->Render("Text");
glPopMatrix();

How to move a mouse using the concept of object tracking in opencv?

I was looking online and how people created this virtual mouse application using different principles such as color detector, object tracking, convexity defects etc etc. I wrote this program which actually tracks a single object from a webcam and its actually working really well. Now, the idea is to use this moving object which is being tracked and i want to control my mouse using this application. I dont want the source code and i want to do it myself. But i dont have any clue how to start it. I just hope if you guys can give me some clue or some ideas which can help me to connect my mouse to my program? I want to be able to do left click, right click, double click . Thanks
If you are able to track an object in the screen then you will get the object co-ordinates & set that as your target co-ordinate. I assume you already did that.
Now set the mouse cursor to that target co-ordinate refer this thread.

VTKActor not visible after render but visible on camera->resetview()

I am working on a qt-vtk project. We have a line drawing function. where straight lines are created between two mouse click position. But once actor is created it is not visible. I was calling render function just after adding the actor. But it didn't work. But if i do camera->resetview() lines become visible , but entire perspective changes. Where am i doing wrong ?
thanks
Rwik
This may not be relevant to you, but I had this exact same problem (in ActiViz [managed VTK]) and wrangled with it for a week, so I hope this helps someone out there. It turned out to be a problem with the location of the lines we wanted to draw on the canvas; they were too far away from the camera (on the Z axis) to be visible.
For us, we were trying to draw a cross on the viewing area wherever the user clicked. The data points were there, as were the actors and whatnot, but they would only be visible in the scene if you called resetCamera() and thusly changed the camera's configuration.
Initially, I blamed the custom interactor that we had to add to cirvumvent the default interactor's swallowing of MouseUp events (intended behavior). Investigation revealed that this seemed unlikely.
After this I shifted the blame onto the camera under the suspicion that perhaps the reset call was making a call to some kind of update method which I wasn't aware of. I called resetCamera() and then reverted the camera values to what they were initially.
When this was successfully done, it eventuated that the crosses would appear when the camera zoomed out and then disappear again as soon as it was set back, and it was at this point I realized that it was something to do with the scene.
At this point, I checked the methods we were using to retrieve the mouse location in 3D and realized that the z value was enormous and it was placing the points too far away as a byproduct of VTK's methods to convert 2D locations on the control to 3D locations in the scene and vice versa.
So after all that, a very mundane and avoidable mistake that originated from the methods renderer.DisplayToWorld() and WorldToDisplay().
This might not be everyone's problem, but I hope I've spared someone a week of fiddling around with VTK.
I think that's a bit hard to help, without see the code, but have you tried using
ui->qvtkwidget->update();
, where ui is the instance of your class derived from QMainWindow?

how to keep a GUI on-screen without moving or resizing it according to camera movement

Hey i'm trying to make a GUI lib with SFML, and everything's done except one problem: Making the Interface stay still even when the camera moves or zooms in.
This would be easy to fix if zooming wasn't possible, but zooming out means scaling the contents of the Interface up, which causes it's text/images to become blurry.
Does anyone have a way to get around this issue? (preferably only using SFML, but if i must i can add OpenGL stuff....)
Stop using the same camera and perspective matrices for your GUI as you do for your scene.
In the case of SFML apply a different view, then restore the old one.

gui for mpi program

I have a problem about a simple mpi program.This program have some 3D points and these points are moving during the program. I created an simple code by implemented c++ and then I tried to add an simple gui. I used gnuplot library and I have a problem. When I call the gui function the gui is created and it is disappeared at the same time. I mean, point object have x,y,z coordinate and I have an array that includes point objects. I want to create them as gui. Can you help me about this problem?
Thanks for any help..
what about Qt? You could use the Qt Graphics View Framework to simulate the 3D-environment - it even supports coordinate transformation (ok, it was originally designed for 2d scope). It supports OpenGL and maybe you are able to simulate the 3D points by drawing dots and setting their positions using simple cosinus and tangens mathematics.
Don't get afraid of the many functions and classes Qt offers - it's very easy and fast to learn - just check out the simple tutorials and after that you right can start your gui!
...and if you are used to Qt, you'll never want to miss it :)
Could it be that the plot is up correctly but that then your program ends? Ie everything's correct, the window goes up, but the next thing that happens is that the program is done, and the window gets destroyed? Try putting in a couple lines that wait for a keypress right after you throw up the window. Then, the window will stay until you press a key (and then the program will end).