Rotate camera itself , How?¿

Previous topic - Next topic

mentalthink

HI there,
how I can rotate the camera itself?¿, I don´t want say rotate around object, else rotate in example the camera in the Z-Axis, and look all objects rotated.

I try whit camera Up, but don´t works, and if can´t in future version can be added this command?¿.

Thanks in advance,
Iván J.

MrTAToad

You would use :

X_MOVEMENT
X_CAMERA
X_ROTATE angle,0,0,1

Slydog

#2
I think with the camera you always need a 'look at' point.
So, to rotate the camera in a 360° circle, you need to set this 'look at' point to a point a certain distance from the camera, and rotate that point.

Something like this:
Code (glbasic) Select
LOCAL rotate# = 0.0
LOCAL look_x#, look_y#=0.0, look_z#
LOCAL camera_pos_x#=0.0, camera_pos_y#=0.0, camera_pos_z#=0.0,

WHILE 1=1
  INC rotate, 1.0
  IF rotate >= 360.0 THEN DEC rotate, 360.0
  look_x = COS(rotate)
  look_z = SIN(rotate)

  X_MAKE3D 0, 100, 75.0
  X_CAMERA camera_pos_x, camera_pos_y, camera_pos_z, look_x, look_y, look_z
  SHOWSCREEN
WEND


[Edit] Maybe I'm not sure what you're asking.  The above code rotates the camera around the 'y' axis, like you are turning.  To look up or down is different, and to rotate around the z-axis (roll?) I think you use 'CAMERA_UP'.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

MrTAToad

Yes, you would normally look at the centre of your world (or even an object)

mentalthink

#4
HI coleagues, I thing I write wrong, or I´m expressed too bad...

I want told rotate the camera not arond a object, I put a image.

You can see how the camera it´s rotate some degress .

@MrTatoad, I think you want say whit your code, modify the next geometries after Rotate
@Slydog, Your code works fine (only have 2 error, a coma in the last point when you declare the camera local variables), and another Error, this it´s in the camera Near_Clip_Plane, you can´t use a 0 values, so you don´t look nothing, or perhaps, something strange occurs in devices mobiles, I make this probe a couple of times.

Thanks, for your help


PS: In the images A told the Z axis, it´s well becuase it´s this whit Local Corrdinates, the viewport it´s in Global Coordinates.

[attachment deleted by admin]

matchy

#5
Like a first person airplane/chopper pilot perspective?

The camera can not be rotated.


It is expressed as pitch, yaw and roll (search for these words) which require tricky conversions calculations.
http://www.glbasic.com/forum/index.php?topic=3737

Wishlist: X_CAMERA_AXIS pitch#, yaw#, roll#

mentalthink

Thanks matchy, all say always rotate because in 3d software, I think the people say in this manner.

I found  a very complex code of a DOF 6 camera, but, it´s too much for me  ,

thanks again for clear me.

Kinds regards,
Iván J.

kanonet

There are at least 2 camera libs in the forum:

http://www.glbasic.com/forum/index.php?topic=3851.0
http://www.glbasic.com/forum/index.php?topic=3591.0
(i didnt try them)
and of cause the entitysystem can do what you need.
For myself i copied/stole the math from the ES and created a kind of a "ES light". You can find this in the attachment, of cause its a bit more than you need and still work in progress (and its optimised for my personal needs!), but maybe its useful for you and you get the idea.

[attachment deleted by admin]
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

mentalthink

HI Kanonet thanks for your code, I solved whit only use X_cameraUP, I remenber sometime ago I made somthing like I want, but I don´t rebember I have to use cos and sin in the Camera Up command.

Now it´s ok...

Thanks in advance for your code, I take a look more carefully.

Kinds regards,
Iván J.