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
3 registered members (Joey, flink, AndrewAMD), 1,226 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
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 | 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