My default camera won't move

Hello!

Im trying to move some objects around, i can set_pos of my meshes (NodePath) successfully, but the default camera wont move… this is what i have:

NodePath static0 = window->load_model(framework.get_models(), "test.obj");
static0.reparent_to(window->get_render());
static0.set_pos(LVector3::zero);  //this works fine

Camera* cam = window->get_camera(0);
cam->get_transform()->set_pos(LVector3(3000.f, 50.f, 0.f)); //this not

This should move the camera far away but it keeps fixed on place looking the model…

What is the correct way to manipulate the camera position & rotation?
Thanks.

Did you accidentally enable default management?

window->setup_trackball();

https://docs.panda3d.org/1.10/cpp/introduction/tutorial/controlling-the-camera

Thanks for answering…
I tried the window->setup_trackball(); it allows me to use mouse to manipulate the camera, as i don`t want that, i removed that line from my code, so my program is not running with it…

Update:
From the link you submit, i noticed there is no Camera* pointer as used type, the example is using NodePath for camera, and get the camera as follows:

camera = window->get_camera_group();

So this line :
camera = window->get_camera(0);

does not returns me a manipulable camera… isn`t ? This means i need to understand the concept of a Camera object and NodePath…

I think this will help you understand.
https://docs.panda3d.org/1.10/python/more-resources/cheat-sheets

1 Like

Thanks, it is an useful content…

get_camera_group() practically is the NodePath that contains the main camera…
get_camera(0) is just a PandaNode isn´t ?

get_camera_group() https://www.panda3d.org/reference/cxx/classWindowFramework.html#ac9f860c3bb6c471f0e0184d3ef06c588
get_camera()
https://www.panda3d.org/reference/cxx/classWindowFramework.html#aae58a4cf88c776a0c53bf61751b30f6e
Specifically, each method can be found in the API. :slightly_smiling_face:

In short:
get_camera_group() - This is the node for all cameras.
get_camera(0) - A specific node at index 0.

OK you explained well…
What I really do not understand is, why do I need to access a node that contains multiples cameras rather than choosing only the camera I want to manipulate…

Moving window->get_camera(0) has a lot o more sense than moving window->get_camera_group() to translate the camera 0…

Moving the group of cameras makes me feel than I’m moving all my camera…

I fully agree with you, please note that the approach used in the official manual is not always correct. It is better to give examples for a tutorial with a newly created camera than to refer to the basic one. This will only confuse.

1 Like

i guess got success creating a new camera by doing this:

Camera* cam = new Camera("My_Camera");
NodePath ncam = window->make_camera().attach_new_node(cam);
ncam.set_pos(LVector3(0.f, 50.f, 50.f));

Only think i need to do is to set it as current camera, switch from default to this newly created because i still see rendering the default one…

I think this path involves the creation of another display region. However, it is better to use

get_camera_group ()

In Panda, it often happens that methods or classes are not well named.

1 Like

I was thinking about it and you were right…

CameraGroup (a NodePath: this should be the parent of the followings nodes)
Camera (a PandaNode : child of CameraGroup NodePath)
SomeAudioNode (a PandaNode : chile of CameraGroup NodePath)

The group in this case is CameraGroup, maybe the name get_camera_group means that i’m accessing the Nodepath for the default camera group, not a group of all cameras!..

Don’t make it more sense ?

I have previously published the PandaNode classes schema.

As for NodePath, think of it as a handle for classes.

https://docs.panda3d.org/1.10/python/reference/panda3d.core.NodePath

Perfect!..
This is getting more and more sense…
Thanks !

I completely forgot about PandaNode and the nodes described here.
https://docs.panda3d.org/1.10/cpp/programming/scene-graph/index

1 Like