Crystal Space
Welcome, Guest. Please login or register.
July 23, 2014, 09:06:22 am

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8220 Members
Latest Member: Igymatta
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  A question about camera rotation
« previous next »
Pages: [1] Print
Author Topic: A question about camera rotation  (Read 1801 times)
Alexin
Guest


Email
« on: July 29, 2005, 04:12:51 pm »

Hi all. I've just recently started messing around with Crystal Space. (0.98r004, in case that matters for this issue.) After finishing the "simple1.cpp" tutorial, I decided that I would try to change the camera movement style from a basic mimicry of a FPS into a bare-bones mimicry of the style found in games like Freespace. (I was aiming to start with the space button for foreward motion, and the arrow and page up-down keys for rotation of the camera along its X, Y, and Z axes.) Adding a 'rotZ' to the 'rotX' and 'rotY' variables used in "simple1.cpp" caused very wacky camera motion, likely because of some rule of matrix algebra that I have forgotten.

As such, I set out to see if I could find a replacement for the tutorial's messy handling of rotation. After a bit of digging through the documentation, I stumbled upon "CS_VEC_ROT_(direction)" and "CS_VEC_TILT_(direction)", which I figured would be what I was looking for. Upon trying these, however, I discovered that these functions didn't actually have any rotation components at all, but rather caused straffing motion, which didn't seem to make much sense. As such, I went to look at their code.

The following occurs in '/CS/include/iengine/camera.h':
Code:
#define CS_VEC_FORWARD   csVector3(0,0,1)
#define CS_VEC_BACKWARD  csVector3(0,0,-1)
#define CS_VEC_RIGHT     csVector3(1,0,0)
#define CS_VEC_LEFT      csVector3(-1,0,0)
#define CS_VEC_UP        csVector3(0,1,0)
#define CS_VEC_DOWN      csVector3(0,-1,0)

#define CS_VEC_ROT_RIGHT  csVector3(0,1,0)
#define CS_VEC_ROT_LEFT   csVector3(0,-1,0)
#define CS_VEC_TILT_RIGHT (-csVector3(0,0,1))
#define CS_VEC_TILT_LEFT  (-csVector3(0,0,-1))
#define CS_VEC_TILT_UP    (-csVector3(1,0,0))
#define CS_VEC_TILT_DOWN  (-csVector3(-1,0,0))

As you can clearly see, each function on the top has an identical twin on the bottom. I could find no differences in the rest of the .h file. I suppose I've been going on a bit too long without a clear question, so:

1. Are the CS_VEC_ROT and CS_VEC_TILT supposed to be used for camera rotation?
2. If so, are these functions broken, or am I not using them correctly?
3. If they are not meant to be used for camera rotation, what are they used for? Are they currently working for this purpose?
4. If these functions are not meant to be used for camera rotation, do there exist functions that do for rotation what CS_VEC_FORWARD does for spatial translation?

--Thanks for any help, and apologies for such a long-winded post for what should be a simple question. ^^
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: July 29, 2005, 07:39:16 pm »

Hi all. I've just recently started messing around with Crystal Space. (0.98r004, in case that matters for this issue.) After finishing the "simple1.cpp" tutorial, I decided that I would try to change the camera movement style from a basic mimicry of a FPS into a bare-bones mimicry of the style found in games like Freespace. (I was aiming to start with the space button for foreward motion, and the arrow and page up-down keys for rotation of the camera along its X, Y, and Z axes.) Adding a 'rotZ' to the 'rotX' and 'rotY' variables used in "simple1.cpp" caused very wacky camera motion, likely because of some rule of matrix algebra that I have forgotten.

As such, I set out to see if I could find a replacement for the tutorial's messy handling of rotation. After a bit of digging through the documentation, I stumbled upon "CS_VEC_ROT_(direction)" and "CS_VEC_TILT_(direction)", which I figured would be what I was looking for. Upon trying these, however, I discovered that these functions didn't actually have any rotation components at all, but rather caused straffing motion, which didn't seem to make much sense. As such, I went to look at their code.

The following occurs in '/CS/include/iengine/camera.h':
Code:
#define CS_VEC_FORWARD   csVector3(0,0,1)
#define CS_VEC_BACKWARD  csVector3(0,0,-1)
#define CS_VEC_RIGHT     csVector3(1,0,0)
#define CS_VEC_LEFT      csVector3(-1,0,0)
#define CS_VEC_UP        csVector3(0,1,0)
#define CS_VEC_DOWN      csVector3(0,-1,0)

#define CS_VEC_ROT_RIGHT  csVector3(0,1,0)
#define CS_VEC_ROT_LEFT   csVector3(0,-1,0)
#define CS_VEC_TILT_RIGHT (-csVector3(0,0,1))
#define CS_VEC_TILT_LEFT  (-csVector3(0,0,-1))
#define CS_VEC_TILT_UP    (-csVector3(1,0,0))
#define CS_VEC_TILT_DOWN  (-csVector3(-1,0,0))

As you can clearly see, each function on the top has an identical twin on the bottom. I could find no differences in the rest of the .h file. I suppose I've been going on a bit too long without a clear question, so:

1. Are the CS_VEC_ROT and CS_VEC_TILT supposed to be used for camera rotation?
2. If so, are these functions broken, or am I not using them correctly?
3. If they are not meant to be used for camera rotation, what are they used for? Are they currently working for this purpose?
4. If these functions are not meant to be used for camera rotation, do there exist functions that do for rotation what CS_VEC_FORWARD does for spatial translation?

--Thanks for any help, and apologies for such a long-winded post for what should be a simple question. ^^

Those are not functions. They are defines which declare constant vectors that you can use as parameters to other functions. For example, check in apps/walktest/keys.cpp where these constants are used as parameters to the RotateThis() function in order to rotate the camera.

Greetings,
Logged
Alexin
Guest


Email
« Reply #2 on: July 29, 2005, 09:19:08 pm »

Aha, that works perfectly! Thank you.
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 4.153 seconds with 13 queries.