1 simple question about camera position

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
charles88
Posts: 29
Joined: Tue Nov 04, 2008 10:02 am

1 simple question about camera position

Post 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.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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?
Image Image Image
jontan6
Posts: 278
Joined: Fri Jun 13, 2008 5:29 pm

Post by jontan6 »

maybe u have collision detection on camera...
skumar
Posts: 201
Joined: Thu Feb 14, 2008 6:24 pm
Location: kerala state india
Contact:

Post 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?
skumar
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post 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 !!! ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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. ;)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
charles88
Posts: 29
Joined: Tue Nov 04, 2008 10:02 am

Post 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

Code: Select all

smgr->drawAll();
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. :P

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?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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! :lol:
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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).
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
charles88
Posts: 29
Joined: Tue Nov 04, 2008 10:02 am

Post by charles88 »

@JP: Yeah, that's a typo :oops: 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...
jontan6
Posts: 278
Joined: Fri Jun 13, 2008 5:29 pm

Post by jontan6 »

can you post your whole code? maybe there's something in it that causes the prob
Post Reply