Page 1 of 1
1 simple question about camera position
Posted: Thu Nov 20, 2008 8:15 am
by charles88
Hi, can someone please tell me whether the setPosition() is working with camera? because currently I try to set the camera position and move it with my node, but only the setTarget is working.
Code: Select all
cam->setPosition(node->getPosition+vector3df(0,20,-50));
cam->setTarget(node->getAbsolutePosition());
Thanks.
Posted: Thu Nov 20, 2008 11:04 am
by JP
How is it not working? The camera doesn't move at all?
Do you have the node parents to the camera, or vice versa?
Posted: Thu Nov 20, 2008 1:21 pm
by jontan6
maybe u have collision detection on camera...
Posted: Thu Nov 20, 2008 2:29 pm
by skumar
i also had same problem with set position , when collision detection is enabled...why that happens...
What if i want to set the cam to a specific point?
Posted: Thu Nov 20, 2008 2:54 pm
by Acki
skumar wrote:i also had same problem with set position , when collision detection is enabled...why that happens...
well, I assume you're trying to move the node through an obstacle, but that doesn't work because of the collision detection...
with collision detection you cant move through obstacles !!!
Posted: Thu Nov 20, 2008 11:49 pm
by rogerborg
We've
discussed this before.
Crib notes: you can work around it on the SVN trunk, but on 1.4.X, you have to remove the collision animator and create and attach a brand new one each time you move the camera manually. Bummer, eh?
If you feel like raising a bug against it in the tracker, maybe one of those lazy Irrlicht devs might add some new functionality to 1.4.3 / 1.5 to solve this problem.
Posted: Fri Nov 21, 2008 9:22 am
by charles88
@JP:
Yeah, the camera doesn't move (which suppose to move), but the target is on the node (which is correct). And I want to update the camera position without parenting it to the node. Is there any way for that? I've put
Code: Select all
cam->setPosition(node->getPosition+vector3df(0,20,-50));
cam->setTarget(node->getAbsolutePosition());
before
But still doesn't work.
@jonta6:
No, there is no collision detection. I don't add one anyway, I just want to simply make my camera follow my node when I move the node without parenting.
@rogerborg:
I think that thread and mine are different.
Thanks guys for your response.
But what I really want to know is that, does the setPosition() work on camera? Because for me it is not working "correctly".
I doesn't mean that the setPosition() is not working completely, but just that when I change my node and according to the code above the position of the camera should change to right?
Posted: Fri Nov 21, 2008 9:59 am
by JP
Your code should work fine, so long as your lack of () on node->getPosition is a typo rather than something you've left out in your code. I'm assuming it's a typo because any compiler shouldn't allow that but if you're using some crappy compiler that's allowed it that could be your problem and if so i'd suggest using a better compiler!
Posted: Fri Nov 21, 2008 1:39 pm
by rogerborg
charles88 wrote:
Code: Select all
cam->setPosition(node->getPosition+vector3df(0,20,-50));
cam->setTarget(node->getAbsolutePosition());
On the offchance that your node's
relative position isn't changing, I'd do:
Code: Select all
const core::vector3df nodePosition = node->getAbsolutePosition();
cam->setPosition(nodePosition + vector3df(0,20,-50));
cam->setTarget(nodePosition);
You may want to slap updateAbsolutePosition() around willy nilly (if doing anything willy nilly is legal in your jurisdiction).
Posted: Sun Nov 23, 2008 2:03 pm
by charles88
@JP: Yeah, that's a typo
I'm using the default compiler.
@rogerborg: thanks rogerborg, but still didn't work for me.
I think nvm, in that case I just attach my camera to my node. sigh...
Posted: Sun Nov 23, 2008 2:18 pm
by jontan6
can you post your whole code? maybe there's something in it that causes the prob