Need Explain camera vector

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
feelthat
Posts: 194
Joined: Sat Feb 02, 2013 5:27 am

Need Explain camera vector

Post by feelthat »

//outer code setting
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100.0f, .02f, 0, 0, 0, true, 1.0f);
camera->setPosition(core::vector3df(0,0,20));
camera->setTarget(core::vector3df(0,0,21));

//irrlicht kernel
//in CSceneNodeAnimatorCameraFPS::animateNode
.
.
target.set(0, 0, core::max_(1.f, pos.getLength()));
.
.
mat.transformVect(target);
.
.
target += pos;
camera->setTarget(target);
.
.
.

My queestion is I already set camera target outer code
why animateNode get camera position length in target z then add pos to be a target???
//target.set(0, 0, core::max_(1.f, pos.getLength())); this
//target += pos; and this
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Need Explain camera vector

Post by thanhle »

Hi,
Because you are using FPS camera instead of normal camera.
With FPS camera, the target is updated as you press the keyboard keys.

Regards
Thanh
feelthat
Posts: 194
Joined: Sat Feb 02, 2013 5:27 am

Re: Need Explain camera vector

Post by feelthat »

1.
I can understand do the rotation
mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0));
mat.transformVect(target);

2.
but why use pos.getLength() setting target z then add pos
reason why?

if pos(0,0,20) then target=(0,0,20); add pos, target=(0,0,40);

if pos(0,0,40) then target=(0,0,40); add pos, target=(0,0,80);
feelthat
Posts: 194
Joined: Sat Feb 02, 2013 5:27 am

Re: Need Explain camera vector

Post by feelthat »

Finally I got answer~~~

//here get target HorizontalAngle
core::vector3df relativeRotation = target.getHorizontalAngle();

//set target length = pos length
target.set(0, 0, core::max_(1.f, pos.getLength()));

//rotation target length to HorizontalAngle
mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0));
mat.transformVect(target);

//add pos to do the compare target-z with camera pos length, after add
//target-z + => positive mean forward,
//target-z - => negtive or zero mean backward
target += pos;



feelthat wrote:1.
I can understand do the rotation
mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0));
mat.transformVect(target);

2.
but why use pos.getLength() setting target z then add pos
reason why?

if pos(0,0,20) then target=(0,0,20); add pos, target=(0,0,40);

if pos(0,0,40) then target=(0,0,40); add pos, target=(0,0,80);
Post Reply