Setting Initial Camera Position

Hi,

I’d like to change a scene’s initial camera position.

I realise that in order to do this I need to disable the mouse. How do I do this?

Cheers,

Chris

Hi. In C++ it’s the other way around, default mouse camera control is turned off by default and if you wanted to turn it on you’d have to do:

window->setup_trackball();

So in your case you don’t have to do anything.

It’s part of the Hello World tutorial, btw (switch to C++): panda3d.org/manual/index.php/C … the_Camera

The problem is that I want to use the mouse as well. As soon as I call

window->setup_trackball();

the camera gets repositioned.

You have to get a pointer to the Trackball object, then you can call set_pos() on that object to reposition the camera where you want it. Use something like this:

window->setup_trackball();
NodePath tballnp = window->get_mouse().find("**/+Trackball");
PT(Trackball) trackball = DCAST(Trackball, tballnp.node());
trackball->set_pos(x, y, z);

Or even:

trackball->set_mat(camera.get_mat());

David

Ah sorry, I thought you didn’t want to use the trackball facility and just use mouse input to move the camera the “manual” way, in a task. Check the Mouse Support chapter when you need to change to that, it’s translated to C++.

Thanks, that’s fixed the problem.