Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Camera orientation #126749
04/27/07 02:12
04/27/07 02:12
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Hi, all.

I seem to have a problem getting the camera orientation correct. I've tried many different fixes, but none of them seem to work.

here's the my_plane action from my wdl:

Code:

ENTITY* plane;

action my_plane
{
plane= me;
my.fat= on;
my.narrow= on;
c_setminmax(plane);
while(1)
{
if(key_w== on)
{
plane.roll-= 4 * time_step;
}
if(key_s== on)
{
plane.roll+= 4 * time_step;
}
if(key_a== on)
{
plane.tilt+= 4 * time_step;
}
if(key_d== on)
{
plane.tilt-= 4 * time_step;
}
if(key_q== on)
{
plane.pan+= 4 * time_step;
}
if(key_e== on)
{
plane.pan-= 4 * time_step;
}
if(key_cuu== on)
{
c_move (plane,vector(0,50 * time_step,0),nullvector,glide);
}
else
{
c_move (plane,vector(0,20 * time_step,0),nullvector,glide);
}
if(key_r== on)
{
c_move (plane,vector(0,-10 * time_step,0),nullvector,glide);
}
camera.x= plane.x;
camera.y= plane.y;
camera.z= plane.z;
camera.pan= plane.pan;
camera.tilt= plane.tilt;
camera.roll= plane.roll;
wait(1);
}
}



For some reason, the camera looks off to the side of the plane model instead of looking forward. The plane moves forward correctly, so it can't be wrong MED orientation. I've tried the following to fix it:

Code:

camera.pan= plane.pan + 90;



That puts it at the right angle, but while the plane rolls, the camera tilts and vice-versa. The plane's pan works just fine with the camera re-orientation, it's just the tilt and roll that are the issue.

Code:

camera.pan= plane.pan + 90;
camera.tilt= plane.tilt - 90;
camera.roll= plane.roll - 90;



This just makes the camera go all freaky. the tilt of the plane equates to the pan of the camera and the... well, it's just wierd.

Can anyone help me? I'm kind of desperate, as I would like to do this kind of thing for other projects.


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Camera orientation [Re: MrCode] #126750
04/27/07 03:37
04/27/07 03:37
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
It is your MED orientation, I believe.
Rotate it by 90° in MED and save it. Then change the:
Code:

if(key_cuu== on)
{
c_move (plane,vector(0,50 * time_step,0),nullvector,glide);
}
else
{
c_move (plane,vector(0,20 * time_step,0),nullvector,glide);
}
if(key_r== on)
{
c_move (plane,vector(0,-10 * time_step,0),nullvector,glide);
}



to:

Code:


if(key_cuu== on)
{
c_move (plane,vector(50 * time_step,0,0),nullvector,glide);
}
else
{
c_move (plane,vector(20 * time_step,0,0),nullvector,glide);
}
if(key_r== on)
{
c_move (plane,vector(-10 * time_step,0,0),nullvector,glide);
}




See, the problem was: You had the plane oriented in a 90° angle in MED, but then moved it along it's y axis, and it looked right. instead, move it along it's x axis, cause that should be the one that faces forward. If you say camera.pan = ship.pan then the camera should be oriented along the ship's local x axis. (not to be confused with the Worlds x axis, the global x axis.)
Kinda complicated... but try it, and maybe you'll find out yourself.


~"I never let school interfere with my education"~
-Mark Twain
Re: Camera orientation [Re: Germanunkol] #126751
04/27/07 10:57
04/27/07 10:57
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
to rotate the plane You may use:
c_rotate function and add USE_AXISR mode if You want to.

to move camera try something like this:
var cam_dist[3] -100, 0, 10; (behind, straight, little up)

camera loop:
vec_set (temp, player.x)
vec_add (temp, camera_dist)
vec_set (camera.x, temp)
vec_set (temp, player.x)
vec_sub (temp, camera.x)
vec_to_angle (camera.pan, temp)


Never say never.
Re: Camera orientation [Re: tompo] #126752
04/27/07 22:53
04/27/07 22:53
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Er, Parameter unknown camera_dist.

Code?
Code:

var video_mode= 8;
var video_screen= 1;
var video_depth= 32;

var cam_dist[3] -100, 0, 10;

string cam_flight_wmb= <canyon_explorer.wmb>;

function main()
{
level_load (cam_flight_wmb);
}

ENTITY* plane;

action my_plane
{
plane= me;
my.fat= on;
my.narrow= on;
c_setminmax(plane);
while(1)
{
if(key_w== on)
{
plane.tilt-= 4 * time_step;
}
if(key_s== on)
{
plane.tilt+= 4 * time_step;
}
if(key_a== on)
{
plane.roll-= 4 * time_step;
}
if(key_d== on)
{
plane.roll+= 4 * time_step;
}
if(key_q== on)
{
plane.pan+= 4 * time_step;
}
if(key_e== on)
{
plane.pan-= 4 * time_step;
}
if(key_cuu== on)
{
c_move (plane,vector(50 * time_step,0,0),nullvector,glide);
}
else
{
c_move (plane,vector(20 * time_step,0,0),nullvector,glide);
}
if(key_r== on)
{
c_move (plane,vector(-10 * time_step,0,0),nullvector,glide);
}
camera.x= plane.x;
camera.y= plane.y;
camera.z= plane.z;
camera.pan= plane.pan;
camera.tilt= plane.tilt;
camera.roll= plane.roll;

vec_set (temp, player.x);
vec_add (temp, camera_dist);
vec_set (camera.x, temp);
vec_set (temp, player.x);
vec_sub (temp, camera.x);
vec_to_angle (camera.pan, temp);
wait(1);
}
}




Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Camera orientation [Re: MrCode] #126753
04/28/07 06:47
04/28/07 06:47
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
var cam_dist[3] = -100, 0, 10;
You have missed the "equal sign".


Re: Camera orientation [Re: vlau] #126754
04/28/07 09:51
04/28/07 09:51
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
My bad
Firs... I've missed "="
Second.. you used var cam_dist but in script is camera_dist, so change one of those to be the same.


Never say never.
Re: Camera orientation [Re: tompo] #126755
05/06/07 03:42
05/06/07 03:42
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I know this topic has gotten REALLY old, but I didn't want to double-post.

This camera isn't exactly what I wanted. I wanted the camera to follow the plane's position and its rotations.

are there any mods I can make to the current code, or do I have to completely re-write it?


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Camera orientation [Re: MrCode] #126756
05/06/07 06:26
05/06/07 06:26
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
An example about chase camera is printed on the manual
under ang_add/ang_rotate.

Re: Camera orientation [Re: vlau] #126757
05/06/07 09:26
05/06/07 09:26
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
try something like this
Code:
 
var cam_ang[3]; // direction angle of the camera to the target.
var speed = 0.4; // camera delay
var temp2[3];
var camera_dist[3] = -65,0,20;

action player_action
{
c_rotate (me, vector(mouse_pos.x ,mouse_pos.y , 0), USE_AXISR | use_box);
vec_set(temp,camera_dist);
vec_rotate(temp,camera.pan);
vec_add(temp,my.x);
vec_set(camera.pan,my.pan);
vec_set(temp2,temp);
vec_sub(temp2,camera.x);
vec_scale(temp2,speed *time_step);
vec_add(camera.x,temp2);
}




Never say never.
Re: Camera orientation [Re: tompo] #126758
05/06/07 19:28
05/06/07 19:28
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Which object should I put it on? I have the plane, and a dummy cube I thought I would use with vec_for_vertex to attach it to the plane.

here's the code:

Code:

var video_mode= 8;
var video_screen= 1;
var video_depth= 32;


string plane_wmb= <planemovetest.wmb>;

sound rumble_snd= <tm150.wav>;

var cam_ang[3]; // direction angle of the camera to the target.
var speed = 0.4; // camera delay
var temp2[3];
var camera_dist[3] = -65,0,20;

function main()
{
level_load (plane_wmb);
wait(3);
plane_rumble();
}

ENTITY* plane;
ENTITY* cam;

action my_plane
{
plane= me;
my.fat= on;
my.narrow= on;
c_setminmax(my);
while(1)
{
if(key_w== on)
{
my.tilt-= 4 * time_step;
}
if(key_s== on)
{
my.tilt+= 4 * time_step;
}
if(key_a== on)
{
my.roll-= 4 * time_step;
}
if(key_d== on)
{
my.roll+= 4 * time_step;
}
if(key_q== on)
{
my.pan+= 4 * time_step;
}
if(key_e== on)
{
my.pan-= 4 * time_step;
}
if(key_cuu== on)
{
c_move (my,vector(100 * time_step,0,0),nullvector,glide);
}
else
{
c_move (my,vector(50 * time_step,0,0),nullvector,glide);
}
if(key_r== on)
{
c_move (my,vector(-10 * time_step,0,0),nullvector,glide);
}
wait(1);
}
}

function plane_rumble()
{
ent_playloop (plane,rumble_snd,1000);
}

action attach_cam_to_plane
{
cam= me;
cam.fat= on;
cam.narrow= on;
c_setminmax(cam);
camera.x= cam.x;
camera.y= cam.y;
camera.z= cam.z;
cam.pan= camera.pan;
cam.tilt= camera.tilt;
cam.roll= camera.roll;
vec_for_vertex (temp, plane,241);
}


action player_action
{
c_rotate (me, vector(mouse_pos.x ,mouse_pos.y , 0), USE_AXISR | use_box);
vec_set(temp,camera_dist);
vec_rotate(temp,camera.pan);
vec_add(temp,my.x);
vec_set(camera.pan,my.pan);
vec_set(temp2,temp);
vec_sub(temp2,camera.x);
vec_scale(temp2,speed *time_step);
vec_add(camera.x,temp2);
}




Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}

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