360 degree chase camera

Developer discussion of experimental fixes, changes, and improvements.

Moderators: Nexuiz Moderators, Moderators

360 degree chase camera

Postby Spaceman » Wed Dec 31, 2008 2:16 am

Sorry, it's not a patch. Simply copy the code and paste the code below in to your client/View.qc and compile.

Use chase_active 70 to enable, or any value >1.

You can also try 'set a 50', 'set b 50' or 'set c 50' in the console to fine tune your playermodels position.

chase_active 1 is still handled by Darkplaces.

http://paste.debian.net/24822/

Code: Select all
// Assign Standard Viewflags
   // Draw the World (and sky)
   R_SetView(VF_DRAWWORLD, 1);

   R_SetView(VF_FOV, GetCurrentFov(fov));

// ------------- add the following to client/View.qc at about line 283

// start with chase_active 70
// use 'set a 50', 'set b 50' or 'set c 50' to fine tune your playermodels position
// chase_active 1 uses the traditional Darkplaces chase camera

if (cvar("chase_active") > 1)
{
   vector temp1;
   vector temp2;
   vector temp3;

   temp1 = input_angles;

//    temp1_x += cvar("x");
//    temp1_y += cvar("y");
//    temp1_z += cvar("z");

   temp2 = pmove_org;

   temp2_x += cvar("a") + cvar("chase_active") * cos(input_angles_x * DEG2RAD);
   temp2_y += cvar("b") + cvar("chase_active") * cos(input_angles_x * DEG2RAD);
   temp2_z += cvar("c") + cvar("chase_active") * sin(input_angles_x * DEG2RAD);

   temp3_x = cvar("chase_active");
   temp3_y = cvar("chase_active");
   temp3_z = cvar("chase_active");

   temp3 = vectoangles(temp3);

   temp1_y += 180 + temp3_y - input_angles_y;

   R_SetView(VF_ANGLES, temp1);
   R_SetView(VF_ORIGIN, temp2);
}

// -------------


   // Draw the Crosshair
   float scoreboard_active;
   scoreboard_active = Sbar_WouldDrawScoreboard();



// I have the following key binds in my autoexec.cfg

// bind / "toggle chase_active 0 50 75 100"

// bind c "toggle a -180 -165 -150 -135 -120 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 120 135 150 165 180 ; echo a $a"
// bind v "toggle a 180 165 150 135 120 105 90 75 60 45 30 15 0 -15 -30 -45 -60 -75 -90 -105 -120 -135 -150 -165 -180 ; echo a $a"

// bind d "toggle b -180 -165 -150 -135 -120 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 120 135 150 165 180 ; echo b $b"
// bind f "toggle b 180 165 150 135 120 105 90 75 60 45 30 15 0 -15 -30 -45 -60 -75 -90 -105 -120 -135 -150 -165 -180 ; echo b $b"

// bind e "toggle c -180 -165 -150 -135 -120 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 120 135 150 165 180 ; echo c $c"
// bind r "toggle c 180 165 150 135 120 105 90 75 60 45 30 15 0 -15 -30 -45 -60 -75 -90 -105 -120 -135 -150 -165 -180 ; echo c $c"
Spaceman
Alien trapper
 
Posts: 264
Joined: Tue Aug 28, 2007 10:53 am

Postby [-z-] » Wed Dec 31, 2008 4:43 am

This is awesome :D

bind kp_1 "toggle a -180 -165 -150 -135 -120 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 120 135 150 165 180 ; echo a $a"
bind kp_2 "toggle a 180 165 150 135 120 105 90 75 60 45 30 15 0 -15 -30 -45 -60 -75 -90 -105 -120 -135 -150 -165 -180 ; echo a $a"
bind kp_3 "toggle b -180 -165 -150 -135 -120 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 120 135 150 165 180 ; echo b $b"
bind kp_4 "toggle b 180 165 150 135 120 105 90 75 60 45 30 15 0 -15 -30 -45 -60 -75 -90 -105 -120 -135 -150 -165 -180 ; echo b $b"
bind kp_5 "toggle c -180 -165 -150 -135 -120 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 120 135 150 165 180 ; echo c $c"
bind kp_6 "toggle c 180 165 150 135 120 105 90 75 60 45 30 15 0 -15 -30 -45 -60 -75 -90 -105 -120 -135 -150 -165 -180 ; echo c $c"


doesn't seem to be working for me.

http://pics.nexuizninjaz.com/viewer.php ... 0wecdi.jpg
[-z-]
Site Admin and Nexuiz Ninja
 
Posts: 1794
Joined: Mon Nov 13, 2006 12:20 am
Location: Florida

Postby Spaceman » Wed Dec 31, 2008 12:15 pm

Either type 'set a 0', 'set b 0' and 'set c 0' in the console or add them to your autoexec.cfg
Code: Select all
set a 0
set b 0
set c 0

This will create the cvars a, b and c. Once these cvars have been created the keybinds should work.
Spaceman
Alien trapper
 
Posts: 264
Joined: Tue Aug 28, 2007 10:53 am

Postby mand1nga » Wed Dec 31, 2008 6:01 pm

Nice work victim. I've cleaned up a bit your code and made a patch with it.

I think this brings us a little more camera control, specially for demo recording. However we need more work on this, because this way the camera is looking always to the same direction. It would be nice if you find a way for rotating the camera. Also it would be great to have mouse support for controlling the camera, so we can make smoother movements while recording demos.

I've changed the source so we can use more descriptive variable names. This is the config for it:

Code: Select all
set camera_steps_increase "-180 -165 -150 -135 -120 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 120 135 150 165 180"
set camera_steps_decrease "180 165 150 135 120 105 90 75 60 45 30 15 0 -15 -30 -45 -60 -75 -90 -105 -120 -135 -150 -165 -180"

alias camera_move_right "toggle chase_active_angle_y $camera_steps_increase"
alias camera_move_left "toggle chase_active_angle_y $camera_steps_decrease"

alias camera_move_up   "toggle chase_active_angle_z $camera_steps_increase"
alias camera_move_down "toggle chase_active_angle_z $camera_steps_decrease"

alias camera_move_backward "toggle chase_active_angle_x $camera_steps_increase"
alias camera_move_forward "toggle chase_active_angle_x $camera_steps_decrease"

alias camera_reset "set chase_active_angle_x 0; set chase_active_angle_y 0 ; set chase_active_angle_z 0; "

camera_reset

bind u camera_move_left
bind i camera_move_right
bind j camera_move_down
bind k camera_move_up
bind n camera_move_backward
bind m camera_move_forward


I would like to see more improvements in this direction, just imagine the amazing videos we would make if we get more control of the camera.
mand1nga
Alien trapper
 
Posts: 321
Joined: Mon May 12, 2008 12:19 am

Postby mand1nga » Tue Jan 06, 2009 12:41 am

This is what I want to have regarding camera control while watching demos

1) Being able to put the camera anywhere and roll it using key binds
2) Control the angle of view with the mouse
3) Optionally chase the player while it moves
4) Enable this only when watching demos, so you can't use it like the mordor eye on servers with anti-wallhack disabled.
5) Provide support for scripting the camera, someday

We are still trying stuff with victim[v], here you can see some non-smooth achievements :)

Ideas and comments are welcome
mand1nga
Alien trapper
 
Posts: 321
Joined: Mon May 12, 2008 12:19 am

Postby GreEn`mArine » Tue Jan 06, 2009 10:07 am

awesome, looks good.
To achieve that, so far I've always been using GL Intercept. But this had several disadvantages, and also required me to press buttons while cl_capturevideo was active (not scriptable).

Doing the scripting will be the most challenging work I guess. Not only will you have to find out how to save it in a proper format, you'll also have to think about how to create the path, visualize it, influence interpolation and the timing.

Once you are at this step, I would recommend that you have a look how other camera systems do their work, like:
- Quake 3: http://q3defrag.org/files/defrag/
- UT99, 2003/4, 3: http://rypelcam.net/
IRC quote:
[kojn] I've been coming a bit more recently
[kojn] she took it the dirty way
GreEn`mArine
Forum addon
 
Posts: 1509
Joined: Tue Feb 28, 2006 9:33 pm
Location: Germany

Postby mand1nga » Tue Jan 06, 2009 2:13 pm

Thanks for the feedback GM, I'll take a look at these links later.

I think it would be nice to have better demo playback control before thinking about scripting the camera. Like being able to forward the demo up to a given time, grep the demos (like the div0 perl script does). I guess making a demo play backwards would be nearly impossible, however I don't have a clue about that.
mand1nga
Alien trapper
 
Posts: 321
Joined: Mon May 12, 2008 12:19 am

Postby Spaceman » Wed Jan 07, 2009 1:25 am

mand1nga wrote:1) Being able to put the camera anywhere and roll it using key binds
2) Control the angle of view with the mouse
3) Optionally chase the player while it moves
4) Enable this only when watching demos, so you can't use it like the mordor eye on servers with anti-wallhack disabled.
5) Provide support for scripting the camera, someday


This is still a work in progress, hence all the cvar_set's.

Some lines for your autoexec.cfg http://paste.debian.net/25421/

The code http://paste.debian.net/25422/

The code satisfies 1, 2, & 5 of mand1nga's specifications. Item 3 only needs a cvar check and add add 'p_move' to 'camera_position'.

Enable with chase_camera 2

You can use the following aliases to move the camera in a straight line along an axis
Code: Select all
// move the camera along the X axis
bind v "+move_x+"
bind c "+move_x-"

// move the camera along the Y axis
bind f "+move_y+"
bind d "+move_y-"

// moves the camera along the Z axis
bind r "+move_z+"
bind e "+move_z-"


You can use the following aliases to move the camera, relative to the cameras point of view, but only along the x, y axis. They don't move the camera up or down.
Code: Select all
// move the camera forwards, relative to the direction it is pointing
bind j "+move_forward"

// move the camera backwards, relative to the direction it is pointing
bind m "+move_back"

// move the camera left, relative to the direction it is pointing
bind b "+move_left"

// move the camera right, relative to the direction it is pointing
bind n "+move_right"


You can use the following aliases to rotate the map around an axis
Code: Select all
// rotate the camera around the +X axis
bind x "+rotate_x+"

// rotate the camera around the -X axis
bind z "+rotate_x-"

// rotate the camera around the +Y axis
bind s "+rotate_y+"

// rotate the camera around the -Y axis
bind a "+rotate_y-"

// rotate the camera around the +Z axis
bind w "+rotate_z+"

// rotate the camera around the -Z axis
bind q "+rotate_z-"


These 2 cvar's adjust the speed the camera moves
Code: Select all
// the speed the camera rotates at
rotate_speed 2

// the speed the camera moves at
move_speed 2


Still to do:
    move_forward_xyz - move the camera using three dimensions
    add a cvar for 3) Optionally chase the player while it moves
    remove the cvar_set's
    move_degree 'x y z' - move the camera in the direction 'x y z'

A script:
Code: Select all
bind H "camera_angle_move_z 10 ; camera_angle_move_y 6; defer 2 "camera_angle_move_z -5 " ; defer 5 "camera_angle_move_z 0; camera_angle_move_y 0""

Rotates the camera around Z at speed 10 and around Y at speed 6,
after 2 seconds rotate around -Z at speed 5 (or Z at speed -5),
after 3 seconds (5 in total) stop.


Note: Where I have used X, Y and Z, I don't actually know if they are the correct axis labels.
Spaceman
Alien trapper
 
Posts: 264
Joined: Tue Aug 28, 2007 10:53 am

Postby Spaceman » Wed Jan 07, 2009 1:29 am

If want to use the above as a chase camera and you want to stop your player moving around when you move your mouse. Change the mouse sensitivity to 0.
Code: Select all
sensitivity  0

Obviously you will need to change it back, mine is 6.
Spaceman
Alien trapper
 
Posts: 264
Joined: Tue Aug 28, 2007 10:53 am

Postby mand1nga » Wed Jan 07, 2009 2:19 pm

victim wrote:Still to do:
move_forward_xyz - move the camera using three dimensions
add a cvar for 3) Optionally chase the player while it moves
remove the cvar_set's
move_degree 'x y z' - move the camera in the direction 'x y z'


I wonder if we really don't need these cvar_sets, maybe they become useful for scripting the camera.

I'll test your code this night. Please if you can post it in patch form, so we can get more feedback.

This is the approach I've taken, still a work in progress. It allows switching between the chasing and free camera modes. The chasing mode starts like in the center of the player model, it should be improved.Here the config for it.

I like this extreme programming approach :)
mand1nga
Alien trapper
 
Posts: 321
Joined: Mon May 12, 2008 12:19 am

Next

Return to Nexuiz - Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron