Raydium 3D Game Engine

New Camera Behavior- won't spin out of control when car does
Page 1 of 1

Author:  cspotcode [ Wed Jun 06, 2007 6:33 pm ]
Post subject:  New Camera Behavior- won't spin out of control when car does

I messed around in the source and added a new camera mode that, in my opinion, is much better than the current one.

Rather than trying to stare at the back bumper of the car, it simply tries to follow the car. This means that when the car spins out of control, the camera doesn't. Also, when driving backwards, you can see where you're going.

I added it as a checkbox in the options screen.

Is there any way I could get this included in the official code? I'm really new to Raydium and I don't know how things work around here. Sorry if this is an ignorant question.

Here's my modified mania_drive.c.
Here's the diff file for the changes I made. (I used the mania_drive.c from the ManiaDrive 1.2 source download)
> dReal cam_pos[3]={0,0,0};
> signed char camera_alternate;
> camera_alternate=raydium_gui_read_name("menu","chkCameraAlternate",str);
> str[0]=(camera_alternate?'y':'n');
> raydium_parser_db_set("ManiaDrive-CameraAlternateActive",str);
> str[1]=0;
> raydium_gui_check_create("chkCameraAlternate",handle,10,77," Alternate camera behavior",camera_alternate);
> raydium_gui_widget_sizes(4,4,18);
>    dReal dist_vector[3];
>    dReal car_to_cam_distance;
>    // calculate the alternate camera position
>    dist_vector[0] = cam_pos[0]-pos[0];
>    dist_vector[1] = cam_pos[1]-pos[1];
>    dist_vector[2] = cam_pos[2]-pos[2];
>    // find the distance from car to camera
>    car_to_cam_distance = sqrt(dist_vector[0]*dist_vector[0] + dist_vector[1]*dist_vector[1] + dist_vector[2]*dist_vector[2]);
>    // determine new camera position by scaling down the distance vector to be exactly 1 unit long,
>    // and then using that vector as an offset from the car's position
>    cam_pos[0] = pos[0] + (dist_vector[0]/car_to_cam_distance);
>    cam_pos[1] = pos[1] + (dist_vector[1]/car_to_cam_distance);
>    cam_pos[2] = pos[2] + (dist_vector[2]/car_to_cam_distance);
>    if(camera_alternate) {
>       cam[0] = cam_pos[0];
>       cam[1] = cam_pos[1];
>       cam[2] = cam_pos[2] + 0.4;
>    }
> char altCamActive[RAYDIUM_MAX_NAME_LEN];
> raydium_parser_db_get("ManiaDrive-CameraAlternateActive",altCamActive,"y");
> camera_alternate=(altCamActive[0]=='y'?1:0);

Author:  vicentecarro [ Thu Jun 07, 2007 10:20 am ]
Post subject: 

great, i like it !
And this is the first time i have seen the face of the driver ;)

Author:  cspotcode [ Thu Jun 07, 2007 3:15 pm ]
Post subject: 

Thanks, I'm glad to hear that.

Is there any way I can get this into the official source? Should I PM Xfennec?

EDIT: Nevermind, I read about SVN in the wiki and I'll requested an SVN login in the devel forum.

Author:  Arkane [ Sat Jun 09, 2007 10:22 am ]
Post subject: 

Great view!


Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group