Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, degenerate_762, ozgur), 1,311 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Camera Movement with the mouse [Re: Knuckles] #139431
07/23/07 19:31
07/23/07 19:31
Joined: Aug 2003
Posts: 169
Tennessee, US
Ahriman Offline
Member
Ahriman  Offline
Member

Joined: Aug 2003
Posts: 169
Tennessee, US
Code:
var Cam_Rotate;
var Cam_Tilt;
var Cam_Dist;


camera.x = player.x + (cos(Cam_Rotate) * cos(Cam_Tilt)) * Cam_Dist;
camera.y = player.y + (sin(Cam_Rotate) * cos(Cam_Tilt)) * Cam_Dist;
camera.z = player.z + sin(Cam_Tilt) * Cam_Dist;
if(mouse_middle)
{
Cam_Rotate -= mouse_force.x / time_step * 2;
Cam_Tilt += mouse_force.y / time_step * 2;
}



That should work for what you need...Cam_Dist is the Camera distance away from the player

Re: Camera Movement with the mouse [Re: Ahriman] #139432
07/24/07 16:01
07/24/07 16:01
Joined: Jul 2006
Posts: 91
Florida, USA
Knuckles Offline OP
Junior Member
Knuckles  Offline OP
Junior Member

Joined: Jul 2006
Posts: 91
Florida, USA
What is the difference between Camera_Distance and Camera.pan?

Re: Camera Movement with the mouse [Re: Knuckles] #139433
07/24/07 17:00
07/24/07 17:00
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
The variable Cam_Dist is used to determ the distance between the potential view which is the predefined view 'camera' in this code snippet and the entity (player). Camera.pan lets you rotate the view around a specific angle, more detailed:

Quote:


pan is the horizontal angle (0..360) about the upright Z axis





Next to pan, you have tilt and roll, those 3 can be described like this:

Quote:


The entities' Euler angles that describe rotations about the Z, Y, and X axis (in degrees, 0..360).





Here's a picture that shows it:


In overall, Cam_Dist is used for a sertain distance and pan is used for rotating

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Camera Movement with the mouse [Re: Knuckles] #139434
07/25/07 04:37
07/25/07 04:37
Joined: Aug 2003
Posts: 169
Tennessee, US
Ahriman Offline
Member
Ahriman  Offline
Member

Joined: Aug 2003
Posts: 169
Tennessee, US
Yeah Im sorry I forgot to add the actual camera.pan and camera.tilt code in there... add this code below what I posted so that the camera always looks at the player.

Code:
vec_set(temp,player.x); 
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp);



Page 2 of 2 1 2

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