Crystal Space
Welcome, Guest. Please login or register.
October 24, 2014, 01:26:11 pm

Login with username, password and session length
Search:     Advanced search
9011 Posts in 2044 Topics by 8813 Members
Latest Member: Menymol
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Problem trying to move the camera
« previous next »
Pages: [1] Print
Author Topic: Problem trying to move the camera  (Read 2972 times)
eversor
Guest


Email
« on: July 03, 2005, 08:33:50 pm »

I want to use the 'camera->GetTransform ().LookAt ()' funtion for a 3rd view, but i don't know if i must use world or camera coordinates, because when i tried to use it (like in  4.9.5 Camera Movement) the position doesn't change. I have used the lookAt() function with imovable and it works ok
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: July 03, 2005, 09:06:07 pm »

I want to use the 'camera->GetTransform ().LookAt ()' funtion for a 3rd view, but i don't know if i must use world or camera coordinates, because when i tried to use it (like in  4.9.5 Camera Movement) the position doesn't change. I have used the lookAt() function with imovable and it works ok

LookAt() does not change the position. LookAt() only changes the orientation. To change the position you need to call SetOrigin().

Greetings,
Logged
eversor
Guest


Email
« Reply #2 on: July 03, 2005, 09:32:11 pm »

Once i change the position (I use MoveWorld(), not SetOrigin()), sometimes I need to change the orientation but when i use the lookAt() it doesn't change, so i want to know if i must call another function to upgrade the camera
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: July 04, 2005, 06:20:43 am »

Once i change the position (I use MoveWorld(), not SetOrigin()), sometimes I need to change the orientation but when i use the lookAt() it doesn't change, so i want to know if i must call another function to upgrade the camera

Can I see the exact code you are using? LookAt() should work fine.

Greetings,
Logged
eversor
Guest


Email
« Reply #4 on: July 04, 2005, 05:35:36 pm »

void Camara::desplazamiento(csVector3 vectorOrigen, csVector3 vectorDestino,
                            float velocidad){
  csVector3 destino(0,0,0);
  //Comprobamos la dirección (horizontal) hacia donde nos movemos
  if(vectorDestino[0] > vectorOrigen[0]){
    destino += (CS_VEC_RIGHT * velocidad);
  } else if(vectorDestino[0] < vectorOrigen[0]){
    destino += (CS_VEC_LEFT * velocidad);
  }
  //Comprobamos la dirección (vertical) hacia donde nos movemos
  if(vectorDestino[2] > vectorOrigen[2]){
    destino += csVector3 (0, 0, velocidad);
  } else if(vectorDestino[2] < vectorOrigen[2]){
    destino -= csVector3 (0, 0, velocidad);
  }
camara->GetTransform().LookAt(vectorDestino - vectorOrigen, csVector3(0,1,0));
  //Realizamos el movimiento
  camara->MoveWorld (destino);
}

This is the function I use to move the camera. The first and second parameters are used to find out in which way would the camera move (ie left-right and fordward-backward) Both are world coordinates, in fact they are the coordinates of the model i use. The camera movement is done ok, but the orientation doesn't work under no circumstances.

I also have tried this code, and doesn't work either

csOrthoTransform ot = camara-> GetTransform ();
  ot.LookAt (vectorDestino - vectorOrigen, csVector3(0,1,0));
   camara->SetTransform(ot);

Thanks
Logged
Administrator
Jr. Member
*****
Posts: 51


View Profile Email
« Reply #5 on: July 04, 2005, 06:41:54 pm »


camara->GetTransform().LookAt(vectorDestino - vectorOrigen, csVector3(0,1,0));
This is not valid

csOrthoTransform ot = camara-> GetTransform ();
  ot.LookAt (vectorDestino - vectorOrigen, csVector3(0,1,0));
   camara->SetTransform(ot);
This on the other hand should work.. I cannot really see why it does not.

-M
Logged
eversor
Guest


Email
« Reply #6 on: July 13, 2005, 08:17:42 pm »

I have found out what the problem is: after calling the lookAt() function, i need to rotate the camera (vertically) so i try to do it like in the Simple tutorial, but the problem is that if i rotate the camera, the lookAt() doesn't work, can you give any ideas for doing it??
Thanks
Logged
Pages: [1] 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 5.203 seconds with 15 queries.