I am wondering if I hard code the up vector as 0,1,0
and position is behind the characters.
And I will cross produce a right vector
With all these vectors, how do I build a Camera out of them in Ogre3D?
I understand that it uses position and lookat and fov etc
how do I "convert" the various vectors into pos, lookat and fov?
Thanks
Jack
How do you call cameras following the player from behind?
-
- Gremlin
- Posts: 156
- Joined: Tue Sep 18, 2012 3:43 am
-
- Gremlin
- Posts: 156
- Joined: Tue Sep 18, 2012 3:43 am
Re: How do you call cameras following the player from behind
humm, this is no good
It's looking at the opposite direction.
tried to exchange the order of subtraction.... no good..
I even negate the lookAt vector to no avail
Any quick fix for me please?
Jack
update:
Whoops.. lookAt target is the position itself not a directional vector.
But I am getting serious object occlusion....
Update2:
How can I make the Camera watch the agents back automatically?
Thanks
Jack
Code: Select all
Ogre::Vector3 newCamPos = WorkerPos + Ogre::Vector3(0.0f, 5.0f, 5.0f);
lookAt = WorkerPos-newCamPos;
mCamera->setPosition(newCamPos);
mCamera->lookAt(lookAt);
tried to exchange the order of subtraction.... no good..
I even negate the lookAt vector to no avail
Any quick fix for me please?
Jack
update:
Whoops.. lookAt target is the position itself not a directional vector.
But I am getting serious object occlusion....
Update2:
How can I make the Camera watch the agents back automatically?
Code: Select all
#include "DollyCam.h"
#include <Ogre.h>
DollyCamera::DollyCamera(Ogre::SceneManager *sceneMgr,
Ogre::Viewport* viewport, Ogre::RenderWindow* rw,
OgreBites::SdkCameraMan* cammgr) :
mSceneMgr(sceneMgr), mViewport(viewport), mWindow(rw),
mCameraMan(cammgr)
{
}
void DollyCamera::Create(Ogre::String name) {
mCamera = mSceneMgr->createCamera(name.c_str());
}
void DollyCamera::update(float dt, Ogre::Vector3 newPos) {
Ogre::Vector3 newCamPos = newPos + Ogre::Vector3(0.0f, 5.0f, 5.0f);
mCamera->setPosition(newCamPos);
mCamera->lookAt(newPos);
mWindow->removeViewport(0);
Ogre::Radian R = Ogre::Math::ATan(Ogre::Math::Tan(Ogre::Degree((float)45/2))/mCamera->getAspectRatio())*2;
mCamera->setFOVy(R);
mViewport = mWindow->addViewport( mCamera );
if (mCameraMan) {
delete mCameraMan;
mCameraMan = NULL;
}
mCameraMan = new OgreBites::SdkCameraMan(mCamera);
}
Jack
-
- Halfling
- Posts: 87
- Joined: Wed Aug 14, 2013 6:55 am
- Location: Norway
- x 13
Re: How do you call cameras following the player from behind
I think what you are looking for is the third person camera