3rd person camera help[solved]

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
trollger
Posts: 84
Joined: Tue Jun 01, 2010 2:17 am
Location: At my computer

3rd person camera help[solved]

Post by trollger »

OK,I'm creating a 3rd person camera for my game.
I,m using OpenGL and the gcc compiler.
I'm also using code::blocks.
I have in my main loop:

Code: Select all

cam->setTarget(mainChar->getPosition() + vector3df(0,-.1,0));
cam->setPosition(mainChar->getPosition() + vector3df(50,20,20));
but when he rotates my camera doesn't rotate around him.
How do I rotate around my model?
Last edited by trollger on Fri Jul 23, 2010 5:30 pm, edited 1 time in total.
terier
Posts: 34
Joined: Sun Oct 05, 2008 4:46 pm

Post by terier »

Code: Select all

cam->setPosition(mainChar->getPosition() + vector3df(50,20,20));
You certainly can't, if you set camera's absolute position each frame :)
short question - short answer
trollger
Posts: 84
Joined: Tue Jun 01, 2010 2:17 am
Location: At my computer

Post by trollger »

what do you mean?
I asked how to revolve around my model.
to do that I need to rotate around certain point.
nathanf534
Posts: 199
Joined: Tue Dec 09, 2008 2:55 am

Post by nathanf534 »

instead of

Code: Select all

cam->setPosition(mainChar->getPosition() + vector3df(50,20,20));
try

Code: Select all

matrix4 mat;
mat.setRotationDegrees(mainChar->getRotation());
vector3df offset = vector3df(50,20,20);
mat.rotateVector(offset);
cam->setPosition(mainChar->getPosition() +offset);
while(signatureEmpty){cout<<wittyComment();}
trollger
Posts: 84
Joined: Tue Jun 01, 2010 2:17 am
Location: At my computer

Post by trollger »

thanks. it worked.
Post Reply