//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
Need Explain camera vector
Re: Need Explain camera vector
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
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
Re: Need Explain camera vector
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);
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);
Re: Need Explain camera vector
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;
//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);