Crystal Space
Welcome, Guest. Please login or register.
September 21, 2014, 03:05:05 pm

Login with username, password and session length
Search:     Advanced search
9018 Posts in 2051 Topics by 8494 Members
Latest Member: Onapthanh
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  rotate the cmera with mouse
« previous next »
Pages: 1 [2] Print
Author Topic: rotate the cmera with mouse  (Read 6054 times)
kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« Reply #15 on: March 18, 2006, 02:29:15 am »

Ok, smooth movement is now "clear" to me. But what about moving like in real games? Is it legal to use both camera->Move (...) and camera->MoveWorld (...)? Well, I'm worried that collision detection and other things may not work if I use two different movements.

Thanks.
« Last Edit: March 18, 2006, 02:31:49 am by kornerr » Logged

kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« Reply #16 on: March 18, 2006, 01:39:30 pm »

I've written the following to make camera move parallel to the floor with no dependence of how it's turned.

simple.cpp

Code:
- - - -
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.
« Last Edit: March 18, 2006, 01:54:35 pm by kornerr » Logged

Pages: 1 [2] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.189 seconds with 16 queries.