Page 1 of 1

ICameraSceneNode->setVisible(0) disables setPosition()

Posted: Sun Dec 21, 2008 5:07 am
by wyrmmage
Hello :)

I've discovered a rather curious bug with the camera class (it certainly took me awhile to track it down XD): when you call setVisible(0) on the node, all setPosition() calls afterward are completely ignored. This is very easy to test:

Code: Select all

ICameraSceneNode* nodeCamera = sceneManager->addCameraSceneNode(NULL, vector3df(0.0, 0.0, 0.0), vector3df(0, 0, 5));
nodeCamera->setVisible(0);
nodeCamera->setPosition(vector3df(0.0, 0.0, 1000.0));
nodeCamera->setTarget(vector3df(0, 100, 0));
Note that setTarget is unaffected.

Is this a feature, or a bug? If it's a feature, it'd be nice if it were mentioned somewhere in the documentation; if it's a bug, I'll try to look into it :)
-wyrmmage

Posted: Sun Dec 21, 2008 7:27 am
by Katsankat
I noticed the same thing, which happened because the cam was parented to an invisible node. Someone will suggest to make it visible, move it, and hide it.

Posted: Sun Dec 21, 2008 12:57 pm
by vitek
What exactly do you mean when you say that setPosition() calls are ignored? Are you saying that nodeCamera->getPosition() is not returning core::vector3df(0.f, 0.f, 1000.f)? Does the view not update to the new position if the camera is not visible? Is there some other problem?

AFAICT, getPosition() should work as expected (the position will be updated), so I doubt that is the problem.

So I'm guessing that the issue is that when the scene managers active camera is not visible, the view doesn't respond to camera state changes. To be honest, I don't know what I'd expect if the active camera is not visible. I'd expect consistent behavior from all camera types and all methods, but I'm not sure what the behavior should be exactly. If you wanted to discuss your point further, you'd have to explain what you think it means for the active camera to be not visible, and maybe explain why you want to make your camera not visible.

Travis

Posted: Mon Dec 22, 2008 3:20 am
by wyrmmage
Katsankat: My node is parented to nothing (just the SceneManager, since I specified NULL as the parent, I believe). Now that you mention it, I think this has been discussed before several times :(

Vitek: I'm sorry, I should have been more specific; what I meant was that the view does not update if the camera is invisible. getPosition() returns the expected values (0.0f, 0.0f, 1000.0f)

As soon as one makes the camera visible again, the view is updated; in other words, you can do this:

Code: Select all

cameraNode->setVisible(0);
cameraNode->setPosition(0, 0, 1000);
cameraNode->setVisible(1);
and it'll set the position and update the view :)

I'm not sure what it should mean for the camera to be invisible, but the reason that I did it was so that the camera would not participate in collision detection and response :)
-wyrmmage

Posted: Mon Dec 22, 2008 3:58 am
by Katsankat
You could perhaps change the camera affector.

Posted: Mon Dec 22, 2008 4:30 am
by vitek
How are you doing your collision? If you are using the collision manager and the collisoin response animator, just don't create a selector for the camera. If you are trying to avoid the node being picked with the collision manager methods like getSceneNodeFrom...BB(), just set the id of the camera to 0.

Travis

Posted: Thu Dec 25, 2008 10:31 pm
by wyrmmage
Good to know, thanks :)

I guess the current behavior for the invisible camera does make sense (although it didn't use to do this in 1.4); if the ISceneNode is invisible, it's just treated as if it isn't part of the scene graph, but the camera's setTarget method isn't inherited from ISceneNode, so it's not going to pay attention that particular method.

It would be nice if the docs were updated to provide a bit more info on this, though, IMHO :)
-wyrmmage

Posted: Fri Dec 26, 2008 1:50 am
by vitek
Agreed, documented and tested behavior is always a plus.