Fake plane rotation

Posted By: 3run

Fake plane rotation - 09/08/11 16:39

I have top down camera (tilt -90) and I want to move camera's position and angles, so it will looks like plane is rotating.
I've archived that effect in X cord. by moving camera in X coordinates and changing it's tilt parameters, it looks good.
Now I want to make same on the Y coordinates, but ROLL doesn't work to realize that, how can I archive this?

Posted By: 3run

Re: Fake plane rotation - 09/08/11 19:49

If my explanation isn't good enough, please let me know, but don't keep silence!
Posted By: Superku

Re: Fake plane rotation - 09/08/11 20:02

var camera_roll = 0; // or call it "_pan"
...
vec_set(camera.pan,vector(0,-90,0));
ang_rotate(camera.pan,vector(camera_roll,0,0));

Should work!
Posted By: 3run

Re: Fake plane rotation - 09/08/11 21:01

It doesn't work as it should. Probably I'm doing something wrong. I'll upload a small demo tomorow.
Posted By: 3run

Re: Fake plane rotation - 09/09/11 13:13

Here is the example, I've made it in X coordinates and I want to make the same for Y coordinates:
Download link
I can already move camera at Y coordinates, I just need camera to rotate properly, ROLL doesn't help me.
Posted By: Superku

Re: Fake plane rotation - 09/09/11 13:20

It works, you've just left out the vec_set(...):

Click to reveal..
Code:
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
VECTOR dist;
VECTOR offset;
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
var cam_height = 400;
var cam_roll = 0;
var cam_tilt = 0;
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
function set_camera() 
{
	camera.arc = 80;
	// UP and DOWN:
	cam_tilt -= 0.5 * mickey.y * time_step;
	cam_tilt = clamp(cam_tilt, -110, -70);
	// LEFT and RIGHT:
	cam_roll += 0.5 * mickey.x * time_step;
	cam_roll = clamp(cam_roll, -20, 40);
	vec_set(camera.pan,vector(0,cam_tilt,0));
	ang_rotate(camera.pan, vector(cam_roll, 0, 0));
	vec_set(camera.x,vector(my.x,my.y,my.z + cam_height));
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
action camera_pos()
{
	VECTOR temp;
	player = my;
	set(my, INVISIBLE | PASSABLE);
	camera.tilt = -90;
	while(1)
	{
		// DEBUG FPS:
		var fps;
		fps = (1 / time_frame) * 16;
		DEBUG_VAR(fps, 10);		
		// UP and DOWN:
		my.x = -(cam_tilt+90)*10;		
		// LEFT and RIGHT:
		my.y = -cam_roll*10;		
		set_camera();
		wait(1);
	}
}
///////////////////////////////////// ///////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
function main()
{
	fps_max = 60;
	video_set(800, 600, 32, 0);
	freeze_mode = 1;
	level_load("level.wmb");
	wait(3);
	freeze_mode = 0;
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////


I've made some small changes in camera_pos, too.
Posted By: 3run

Re: Fake plane rotation - 09/09/11 17:18

Thanks, will give it a shot!

Edit: thanks a lot bro. Rotation works perfectly, didn't really like movement in camera_pos, but rotations are awesome laugh
© 2024 lite-C Forums