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.
-
dudMaN
- Posts: 111
- Joined: Fri Mar 02, 2007 6:37 pm
Post
by dudMaN »
Hi everyone.
i'm trying to move my camera forward.
i just use
Code: Select all
cam->setPosition(cam->getTarget());
and it works, but its REALLY slow, so i tried:
Code: Select all
vector3df pos = cam->getPosition();
vector3df movedir = cam->getTarget();
movedir.Y = 0.0f;
movedir.normalize();
pos += movedir * 0.0000001f; // speed
// Mv Forward
cam->setPosition(pos);
and it just moves to the right.. i guess it works because no matter how i turn it always moves to the right.. -_- but i need it to move forward

:(:(
Plz help!
-dudMan
-
jreuschel1
- Posts: 25
- Joined: Sun Nov 12, 2006 7:51 pm
-
Contact:
Post
by jreuschel1 »
try moving based on the difference of the two positions
maybe something like this:
Code: Select all
vector3df varCPos,varTPos,varNPos;
float moveFactor=0.0001f;
varCPos=cam->getPosition();
varTPos=cam->getTarget();
varNPos=(varTPos-varCPos);
varNPos.normalize();
varNPos=varNPos*moveFactor;
cam->setPosition(varCPos+varNPos);
Directory of E:\RI-1
00/00/0000 12:00 AM <DIR> .
00/00/0000 12:00 AM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) All bytes free
E:\RI-1>_
-
dudMaN
- Posts: 111
- Joined: Fri Mar 02, 2007 6:37 pm
Post
by dudMaN »
hm.. it doesnt work..
and i kinda suck at math, havent taken a math or algebra class in a LOONG time..
o yea and im only 12 so i havent even been to college yet
-dudMan
-
Panos
- Posts: 14
- Joined: Wed Jan 17, 2007 6:00 pm
Post
by Panos »
Perhaps you could use an animator assigned to the camera...

Java rules!!!
-
vi-wer
- Posts: 93
- Joined: Sun May 20, 2007 7:15 pm
- Location: Germany
-
Contact:
Post
by vi-wer »
Hi dudMaN,
Your code is the right way. It only needs a few changes. And here they are:
Code: Select all
vector3df pos = cam->getPosition();
vector3df target = cam->getTarget();
vector3df movedir = target - pos;
movedir.normalize();
pos += movedir * 0.0000001f; // speed
target += movedir * 0.0000001f; // speed
// Mv Forward
cam->setPosition(pos);
cam->setTarget(target);
As far I know the target position will not change if you set a new cam position. That's why you should also set a new target.