Crystal Space
Welcome, Guest. Please login or register.
December 18, 2014, 09:26:13 pm

Login with username, password and session length
Search:     Advanced search
9032 Posts in 2046 Topics by 9288 Members
Latest Member: Lorrainewhite
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Absolute camera rotation problem
« previous next »
Pages: [1] Print
Author Topic: Absolute camera rotation problem  (Read 2210 times)
TheCommander
Newbie
*
Posts: 6



View Profile Email
« on: June 26, 2008, 04:14:14 pm »

Hi,

For the application I am developing I want to be able to move the camera to a specific point and orientation at a certain time (think similar to a cut-scene). I can find the locations and vectors by using blender2crystal but I don't understand how to actually cause the rotation to take place.

At the moment I can load and move the camera around but my attempts to change orientation are ignored (more likely I have forgotten some code). Here is the code I am currently using:

Code:
        csRef<iCamera> camera = view->GetCamera();
csVector3 camera_pos (0,0.367063,6.75359);
csRef<iCameraPositionList> camposlist = engine->GetCameraPositions ();
csRef<iCameraPosition> campos = camposlist->FindByName("MainCam");
campos->SetForwardVector(csVector3(-2.3441e-007,-0.445272,0.895396));
campos->SetUpwardVector(csVector3(-1.17205e-007,0.895396,0.445271));
campos->SetPosition(camera_pos);
campos->Load(camera,engine);

What happens is when this is triggered the camera moves to the position set but maintains the orientation it was on before it was moved, instead of moving back to point in the direction entered in code.
I also tried using the lookat() function like this:
Code:
        csOrthoTransform ot = camera->GetTransform();
ot.LookAt (csVector3(-2.3441e-007,-0.445272,0.895396), csVector3(-1.17205e-007,0.895396,0.445271));
ot.GetFront ().Set(csVector3(-2.3441,-0.445272,0.895396));
ot.GetUp ().Set (csVector3(-1.17205,0.895396,0.445271));
camera->SetTransform(ot);
but this has exactly the same effect, no rotation.

If it helps I am using CS 1.2 on Visual Studio 2008, running Windows Vista (not SP1), the version of winlibs that goes with 1.2 and a ATI x1600 video card.

Thanks in advance.
Logged

I am using CS 1.2 (stable), win32libs 1.2_002, windows vista business 64 and an ati radeon x1600 with latest drivers (7.14.0010.0618), along with CS 1.9 (latest) and win32libls 1.3_004
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: June 27, 2008, 01:24:54 pm »

The LookAt() line is how it should work. But remove the ot.GetFront().Set and ot.GetUp().Set lines. Only keep the LookAt(). LookAt() doesn't remember anything of the current state of the transform so it should work fine.

Greetings,
Logged
TheCommander
Newbie
*
Posts: 6



View Profile Email
« Reply #2 on: June 27, 2008, 04:57:19 pm »

Thanks, but oddly using this code:
Code:
csRef<iCamera> camera = view->GetCamera();
csOrthoTransform ot = camera->GetTransform();
ot.LookAt (csVector3(-2.3441e-007,-0.445272,0.895396), csVector3(-1.17205e-007,0.895396,0.445271));
camera->SetTransform(ot);
still doesn't do anything at all. I know that the program executes the code but it seems to ignore it. I would guess that I have missed a command that actually forces the change to be drawn to the screen. If it is any help the rest of the code is based on the Simple apps, and this routine is executed by pressing the control key, based on the OnKeyboard routine in Simple1. This is the whole of this camera move routine, there are no other commands to, for example, update the camera (I don't know if this is needed)

Thanks in advance.
Logged

I am using CS 1.2 (stable), win32libs 1.2_002, windows vista business 64 and an ati radeon x1600 with latest drivers (7.14.0010.0618), along with CS 1.9 (latest) and win32libls 1.3_004
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: June 27, 2008, 09:02:26 pm »

Then I see only two possibilities:

1. The code is actually working but not doing what you think it should do.

2. The code is working but the camera transform is later (by some other part of the code) set back to another state. If you simply modified simple1 or something then that could occur very easily as the camera transform is again manipulated in the frame event.

Other then that the code you show us is 100% correct and nothing more is needed for it to work.

Greetings,
Logged
TheCommander
Newbie
*
Posts: 6



View Profile Email
« Reply #4 on: June 28, 2008, 05:53:40 pm »

Thanks for the help, turns out it was the other camera rotation code, removing it solves the problem.
Logged

I am using CS 1.2 (stable), win32libs 1.2_002, windows vista business 64 and an ati radeon x1600 with latest drivers (7.14.0010.0618), along with CS 1.9 (latest) and win32libls 1.3_004
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 4.272 seconds with 15 queries.