I've written the following to make camera move parallel to the floor with no dependence of how it's turned.
simple.cpp- - - -
void Simple::TurnCamera (float x_rot, float y_rot) {
iCamera *camera = view->GetCamera ();
csMatrix3 rot = csXRotMatrix3 (x_rot) * csYRotMatrix3 (y_rot);
csOrthoTransform ot (rot, camera->GetTransform ().GetOrigin ());
camera->SetTransform (ot);
}
- - - -
void Simple::ProcessFrame () {
- - - -
if (kbd->GetKeyState (CSKEY_RIGHT))
camera->Move (CS_VEC_RIGHT * speed);
if (kbd->GetKeyState (CSKEY_LEFT))
camera->Move (CS_VEC_LEFT * speed);
if (kbd->GetKeyState (CSKEY_UP)) {
TurnCamera (0.0, y_rot);
camera->Move (CS_VEC_FORWARD * speed);
TurnCamera (x_rot, y_rot);
}
if (kbd->GetKeyState (CSKEY_DOWN)) {
TurnCamera (0.0, y_rot);
camera->Move (CS_VEC_BACKWARD * speed);
TurnCamera (x_rot, y_rot);
}
- - - -
}
- - - -
And about smooth movement. We (OSRPG team) will make it, but not now.
For now pending tasks are:
1) Collision detection;
2) Loading static models.