Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (ozgur, Ayumi, VHX, monarch), 1,161 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to rotate camera around a point? #274056
06/25/09 14:03
06/25/09 14:03
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hi, I want to use the left and right key to rotate the camera two dimensionally around a point. If anybody could explain the solution mathematically as well I would be more than thankful!

Re: How to rotate camera around a point? [Re: PadMalcom] #274057
06/25/09 14:07
06/25/09 14:07
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Check the calculation at vec_for_angle.


Click and join the 3dgs irc community!
Room: #3dgs
Re: How to rotate camera around a point? [Re: Joozey] #274062
06/25/09 14:20
06/25/09 14:20
Joined: Oct 2007
Posts: 11
J
JM89 Offline
Newbie
JM89  Offline
Newbie
J

Joined: Oct 2007
Posts: 11
What for a view (isometric, first person, ...) do you have?
I have solved this problem for a camera with a tilt of -35° some days ago. But my code is not the best, I believe...


JM

Last edited by JM89; 06/25/09 14:21.
Re: How to rotate camera around a point? [Re: JM89] #274437
06/26/09 19:26
06/26/09 19:26
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Okay, I found the solution smile The 768 is the radius!

VECTOR* temp_vec;
var cam_angle = 0;

function move_camera() {
temp_vec = vector(0,0,0);
while(1) {
if (key_cul) {
cam_angle +=1;
camera.x = cos(cam_angle) * 768;
camera.y = sin(cam_angle) * 768;
vec_diff(temp_vec.x,vector(0,0,0),camera.x);
vec_to_angle(camera.pan,temp_vec);
wait(1);
}
if (key_cur) {
cam_angle -=1;
camera.x = cos(cam_angle) * 768;
camera.y = sin(cam_angle) * 768;
vec_diff(temp_vec.x,vector(0,0,0),camera.x);
vec_to_angle(camera.pan,temp_vec);
wait(1);
}
wait(1);
}
}

Whoever wants a detailled explanation can read about it in my blog: http://www.jofre.de/?p=301 (German only)

Last edited by PadMalcom; 06/26/09 19:27.
Re: How to rotate camera around a point? [Re: PadMalcom] #274753
06/28/09 10:18
06/28/09 10:18
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
just use the if statement once rather for left then right

if(key_cul || key_cur){
cam_angle += key_cul - key_cur; //or (key_cul - key_cur) * 1;
...


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1