Mouse cursor

hello,

I am trying to get a mouse cursor working. From some forum research I found that I should be doing something like this :

#include "pandaFramework.h"
#include "pandaSystem.h" 
#include "MouseWatcher.h"
PandaFramework framework;
WindowFramework *window;

int main(int argc, char *argv[]) 
{
	framework.open_framework(argc, argv);

	WindowProperties prop; 
	framework.get_default_window_props(prop); 
	prop.set_title("Test mouse cursor");
	prop.set_cursor_hidden(true);

	window = framework.open_window(prop,0); 
	window->set_background_type(WindowFramework::BT_gray);
	window->setup_trackball();

	PT(FrameRateMeter) meter = new FrameRateMeter("fps"); 
	meter->setup_window(window->get_graphics_output());

	NodePath mouseBox = window->load_model(framework.get_models(), "models/box");
	mouseBox.show();

	PandaNode* pMouseNode = mouseBox.node();
	MouseWatcher* pMouseWatcher = (MouseWatcher*)window->get_mouse().node();
	pMouseWatcher->set_geometry(pMouseNode);

	framework.main_loop();

	framework.close_framework();  
	return (0);
}

but this doesn’t seem to work.
The cursor isn’t visible at all.

I should say that “box” is a simple test box.egg 3d model. I wasn’t sure if this needs to be a 2d texture or not.

Can anyone tell me if this is correct or if not how it can be fixed ?

chrys

That’s the right idea, but it does depend on your geometry. What MouseWatcher::set_geometry() does is vary the position of your model from (-1, 0, -1) to (1, 0, 1), depending on the position of the mouse onscreen.

However, it’s up to you to parent your model to render2d, which you haven’t done in this example, so you should do that. It’s also up to you to ensure that your model is visible and in the center of the screen when it is parented to render2d at (0, 0, 0).

David