[SOLVED] Wierd Camera View~

Rscorpiox

19-07-2009 15:52:24

I got a wierd camera view when I update the Newton world by calling update myself.

Here's my code:


/*Update the Newton world*/
m_World->update(evt.timeSinceLastFrame);

/*Setting the camera's position and direction*/
Vector3 pos;
Ogre::Quaternion ori;
body->getPositionOrientation(pos,ori);

camPos.x = pos.x + radius*cos(...
camPos.z = pos.z + radius*cos(...
camPos.y = pos.y + radius*sin(...

mCamNode ->setPosition(camPos);
Cam->lookAt(Vector3(pos.x,pos.y+2,pos.z));

/*Setting the body has the same direction with camera*/
Ogre::Quaternion dir = Cam->getOrientation();
dir.x=0;
dir.z=0;
body->setPositionOrientation(pos,dir);




I made the camera move around the body , and the character's body face the same way as camera.

Just like the usual 3rd person view game.

It's normal when camera stay just behind the body , rotating is all works just fine.

But when my camera on the top of my body , the wierd view shows up.

When camera at the back-upside of the body , and rotating to some direction.

The view just deformed like the video here:

http://www.chu.edu.tw/~b09402209/OgreNewt.avi

I've checked the position of camera , the body and camera's distance is the same as the camera behind body.

Don't know if this cause by OgreNewt.

But the status shows up after I update Newton world myself.

Hope somebody can give me some advice , or help.

Thanks for the reading .

Rscorpiox

19-07-2009 16:06:29

Oh , the camera can worked just fine when I update the newton world after setting camera's position like this:


/*Setting the camera's position and direction*/
Vector3 pos;
Ogre::Quaternion ori;
body->getPositionOrientation(pos,ori);

camPos.x = pos.x + radius*cos(...
camPos.z = pos.z + radius*cos(...
camPos.y = pos.y + radius*sin(...

mCamNode ->setPosition(camPos);
Cam->lookAt(Vector3(pos.x,pos.y+2,pos.z));

/*Update the Newton world*/
m_World->update(evt.timeSinceLastFrame);

/*Setting the body has the same direction with camera*/
Ogre::Quaternion dir = Cam->getOrientation();
dir.x=0;
dir.z=0;
body->setPositionOrientation(pos,dir);

/*Setting the camera's position and direction second times*/
Vector3 pos;
Ogre::Quaternion ori;
body->getPositionOrientation(pos,ori);

camPos.x = pos.x + radius*cos(...
camPos.z = pos.z + radius*cos(...
camPos.y = pos.y + radius*sin(...

mCamNode ->setPosition(camPos);
Cam->lookAt(Vector3(pos.x,pos.y+2,pos.z));



Set twice for the camera's position to avoid the body shiver cause by the camera.

But in this case , when I rotate my character speedy .

The body just can't rotate as soon as camera.

So.. still can't fix this... :oops:

Any advice are welcome.

Thanks for the reading.

Rscorpiox

30-07-2009 19:17:30

Anyone? :roll:

Maybe it's my problem not clearly enough.

Any question or advice?

Rscorpiox

09-08-2009 07:50:28

Solved!!

The Qri should normalized before set for the body.

The camera's view worked perfect now!