Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,758 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
camera rotate #285913
08/21/09 14:50
08/21/09 14:50
Joined: Jan 2009
Posts: 57
Slovakia
wolodo87 Offline OP
Junior Member
wolodo87  Offline OP
Junior Member

Joined: Jan 2009
Posts: 57
Slovakia
Hello,
I wrote script for rotating camera around certain point with certain radius while camera is still looking at that point, which can be an entity:
Code:
long radius;
	long posx=-800;
	long posy=0;
        var up=1;
	var speed=20*time_step;

vec_to_angle(camera.pan,vec_diff(NULL,some_entity.x,camera.x));
if(key_cul)
		{
			
			if(up==1)
		{
			if(posx<=radius)
			{
				posx+=speed;
				posy=sqrt((radius*radius)-(posx*posx));
			}
			
			if(posx>=radius)
			{
				up=0;
			}
			
		}
		if(up==0)
		{
			if(posx>=-radius)
			{
				posx-=speed;
				posy=-sqrt((radius*radius)-(posx*posx));
			}
			
			if(posx<=-radius)
			{
				up=1;
			}	
		}



It works, however the rotation speed is not linear (because sqrt function is not linear). The questin is, how could I achieve linear rotation speed? Or is there any function (lite-c) to achieve such rotation of camera?
It should work similary as 3D RPG camera with free rotation mode
(eg Sacred 2, Dungeon Siege...etc)

Re: camera rotate [Re: wolodo87] #285963
08/21/09 18:52
08/21/09 18:52
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Get the vector vertical to the direction from camera to object, and multiply it with mouse_force.y or whatever you use to move it:

if(mouse_force.y)
{
vec_set(temp, camera.pan);//get the angle of the camera
temp.pan += 90;//turn it
vec_for_angle(temp, temp);//get the direction of the angle which points aside the camera
vec_add(camera.x, vec_scale(temp, mouse_force_y.));//move the camera depending the mouse_force aside
}

The code isn't tested, maybe, I missed something.


Gamestudio download | 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