Author Topic: Need Help Coding Chase in-eyes View  (Read 1571 times)

Offline QwazyWabbit

  • Carpal Tunnel Member
  • ******
  • Posts: 1241
    • View Profile
  • Rated:
Need Help Coding Chase in-eyes View
« on: March 13, 2011, 09:52:21 PM »
OK, it looks like no-one has ever solved the problem of player clipping in the in-eyes view mode. The original Q2 code had chasecam from behind the chased player. Setting in-eyes would seem to be just a matter of copying the target player's look-angle into the chasing view but this renders the chaser's POV inside the head of the target player with all the nice artifacts dancing in the view. I've got semi-working chasecam code but I get lost in the vector functions and can't tell when to use gi.trace, VectorMA, VectorNormalize, etc.

Maybe we can put our collective heads together and figure this one out.

Here's what I have so far:

void ChaseCamUpdate(edict_t *ent)
{
   vec3_t o, ownerv, goal;
   edict_t *targ;
   vec3_t forward;
   trace_t trace;
   vec3_t angles;

   assert(ent != NULL);
   targ = ent->client->chase_target;

   VectorCopy(targ->s.origin, ownerv);

   if (ent->client->chase_mode == CHASE_EYES)
   {
      VectorCopy (targ->s.origin, goal);
      goal[2] += targ->viewheight + 6;
   }
   
   if (ent->client->chase_mode == CHASE_THIRDPERSON)
   {
      ownerv[2] += targ->viewheight;

      VectorCopy(targ->client->v_angle, angles);
      if (angles[PITCH] > ent->lclient->cam_maxpitch)
         angles[PITCH] = ent->lclient->cam_maxpitch;
      AngleVectors (angles, forward, NULL, NULL);
      VectorNormalize(forward);
      VectorMA(ownerv, -ent->lclient->cam_distance, forward, o);

      if (o[2] < targ->s.origin[2] + ent->lclient->cam_height)
         o[2] = targ->s.origin[2] + ent->lclient->cam_height;

      // jump animation lifts
      if (!targ->groundentity)
         o[2] += ent->lclient->cam_jump;

      trace = gi.trace(ownerv, vec3_origin, vec3_origin, o, targ, MASK_SOLID);
      VectorCopy(trace.endpos, goal);
      VectorMA(goal, 2, forward, goal);

      // pad for floors and ceilings
      VectorCopy(goal, o);
      o[2] += 6;
      trace = gi.trace(goal, vec3_origin, vec3_origin, o, targ, MASK_SOLID);
      if (trace.fraction < 1)
      {
         VectorCopy(trace.endpos, goal);
         goal[2] -= 6;
      }

      VectorCopy(goal, o);
      o[2] -= 6;
      trace = gi.trace(goal, vec3_origin, vec3_origin, o, targ, MASK_SOLID);
      if (trace.fraction < 1)
      {
         VectorCopy(trace.endpos, goal);
         goal[2] += 6;
      }
   }

   //common to all chase modes
 VectorCopy(goal, ent->s.origin);

   if(!ent->lclient->cam_freelook)
   {
      int i;
      ent->client->ps.pmove.pm_type = PM_FREEZE;
      for(i = 0; i < 3; i++)
         ent->client->ps.pmove.delta_angles = ANGLE2SHORT(targ->client->v_angle - ent->client->resp.cmd_angles);

      VectorCopy(targ->client->v_angle, ent->client->ps.viewangles);
      VectorCopy(targ->client->v_angle, ent->client->v_angle);
   }
   else
      ent->client->ps.pmove.pm_type = PM_NORMAL;

   ent->viewheight = 0;
   ent->client->ps.pmove.pm_flags |= PMF_NO_PREDICTION;
   gi.linkentity(ent);
}

I've highlighted the relevant block in yellow, this produces a in-head view, slightly elevated by 6 units, just to make it a little less annoying. I think the solution would be to push the camera POV forward of the targ->s.origin but I don't know how to do that at the moment.

Another solution might be to ID the chased player and then not render him in the chasing client.

Ideas anyone?
« Last Edit: March 13, 2011, 09:54:21 PM by QwazyWabbit »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline skuller

  • Newbie
  • *
  • Posts: 13
    • View Profile
  • Rated:
Re: Need Help Coding Chase in-eyes View
« Reply #1 on: March 15, 2011, 05:32:40 AM »
Quote
Another solution might be to ID the chased player and then not render him in the chasing client.

This is how it works in OpenTDM/OpenFFA mods. It requires cooperation from the server to hide player entity from the specified client. Both R1Q2 and Q2PRO servers support this. Game API has been extended so that a new shared field ‘clientNum’ has been added to the beginning of gclient_s struct:
Code: [Select]
struct gclient_s
{
    player_state_t  ps;     // communicated by server to clients
    int             ping;

    // the game dll can add anything it wants after
    // this point in the structure
    int             clientNum;
};

A compatible game mod fills this field with current client POV number: it is equal to client slot number for normal players, and changes for spectators that are chasing other players. Server looks at this field and hides player entity from client frame if necessary. A question remains is how the server would know that game mod is ‘clientNum’ aware and actually fills it with meaningful information, and how the game mod would know if it can safely use ‘clientNum’ for in-eyes chasecam. This is implemented though game/server features cvars. On startup, R1Q2 and Q2PRO servers set a read-only cvar ‘sv_features’ to a bitmask of supported features, among them is GMF_CLIENTNUM feature:
Code: [Select]
#define GMF_CLIENTNUM   1
#define GMF_PROPERINUSE 2
#define GMF_MVDSPEC     4
#define GMF_WANT_ALL_DISCONNECTS 8

In turn, game mod sets a read-only cvar ‘g_features’, exporting a bitmask of features it supports. Server then looks if ‘g_features’ has GMF_CLIENTNUM bit set, and if so, it respects ‘clientNum’ field. Game mod looks if ‘sv_features’ has GMF_CLIENTNUM bit set, and if so, it implements ‘proper’ in-eyes chasecam view by simply copying the playerstate of chased player to spectator playerstate (changing pm_type to PM_FREEZE and setting PMF_NO_PREDICTION bit of course). This is an example of how it can be done:

Code: [Select]
static void UpdateChaseCam( gclient_t *client ) {
    edict_t *ent = client->edict;
    edict_t *targ = client->chase_target;

    client->clientNum = ( targ - g_edicts ) - 1;
    client->ps = targ->client->ps;
    client->ps.fov = client->pers.fov;
    client->ps.pmove.pm_flags |= PMF_NO_PREDICTION;
    client->ps.pmove.pm_type = PM_FREEZE;

    VectorCopy( client->ps.viewangles, ent->s.angles );
    VectorCopy( client->ps.viewangles, ent->client->v_angle );
    VectorScale( client->ps.pmove.origin, 0.125f, ent->s.origin );
    ent->viewheight = targ->viewheight;
}
« Last Edit: March 15, 2011, 05:35:28 AM by skuller »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline fdrjk

  • Brobdingnagian Member
  • ***
  • Posts: 4996
  • gotta be above it
    • View Profile
  • Rated:
Re: Need Help Coding Chase in-eyes View
« Reply #2 on: March 15, 2011, 12:00:28 PM »
Yeah. Speccing players over their shoulder in FFA is pretty boring/ hard to watch. It also doesn't help when trying to pick out cheaters.

::)
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline QwazyWabbit

  • Carpal Tunnel Member
  • ******
  • Posts: 1241
    • View Profile
  • Rated:
Re: Need Help Coding Chase in-eyes View
« Reply #3 on: March 15, 2011, 03:40:39 PM »
Anyone running a server today should be using r1q2 or equivalent simply for the security improvements if for no other reason. I'd like to come up with a generic solution that doesn't need to depend on a particular engine feature if it can be done "generically".

I'm thinking that copying the player origin, then offsetting the spectator position with VectorAdd() ought to be workable. The principle is just to put the spectator POV on the tip of the chasee's unit vector and keep it there so the chasee is behind the spectator and out of view. What this would do in the presence of lag is another story.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline Whirlingdervish

  • Super ShortBus Extravaganza
  • Illimitable Sesquipedalian Member
  • *
  • Posts: 6383
    • View Profile
    • The Dervish Depository
  • Rated:
Re: Need Help Coding Chase in-eyes View
« Reply #4 on: March 15, 2011, 05:31:23 PM »
you'd just have to add about slightly more than half a bbox worth of units to get the spec position and that should work.

it won't be _exact_ but it will be much closer to what the player is seeing than the 3rd person or over the shoulder cam.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline peewee_RotA

  • Brobdingnagian Member
  • ***
  • Posts: 4147
  • Hi, I'm from the gov'ment and I'm here to help you
    • View Profile
  • Rated:
Re: Need Help Coding Chase in-eyes View
« Reply #5 on: March 15, 2011, 07:10:27 PM »
I'd convert the viewangles into a direction (or verctorma and use the forward), normalize, scale by 10, then add to that to s.origin[2] + 20.. That would put you in front of the model and right about eye level.

Personally i like mods that put the camera inside the head. I think that it looks interesting to see the w_weap move around while playing.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
GOTO ROTAMODS (rocketgib)
GOTO ROTAMAPS (fireworks)
HappyFriar- q2server.fuzzylogicinc.com
 Tune in to the Tastycast!!!!  http://dna.zeliepa.net

 

El Box de Shoutamente

Last 10 Shouts:

 

quadz

September 15, 2019, 01:18:02 PM
fun retrospective (nightmare)

https://www.youtube.com/watch?v=whizTpYtWxA

Uberphawx

September 15, 2019, 05:33:58 AM
Yeah, prophylactics are always an option, specially when you are doing it with something you think it has something "stormy" inside...
Stay safe folks...
 

ImperiusDamian

September 14, 2019, 02:09:14 PM
Well, obviously one has to use protection when fucking any kind of tropical weather system.
 

|iR|Focalor

September 14, 2019, 09:56:57 AM
If a hurricane blows your house down, call STD Contractors.

Uberphawx

September 14, 2019, 04:29:27 AM
You should use a condom first...
If it has hepatitis or gonorrhea or some kind of tropical STD then you may want to be safe first...
 

ImperiusDamian

September 13, 2019, 05:08:30 PM
fuck hurricanes up the ass. >:(

Uberphawx

September 13, 2019, 10:39:21 AM

https://www.youtube.com/watch?v=SgF42jlEEIs
Best video in the internet...
Don't pay attention to the title and take a listen..

RyU

September 12, 2019, 02:34:48 AM
pm me

playboy

September 11, 2019, 06:44:00 PM
mr. eastcoast up in this bitch

Unh0ly-rwz-

September 11, 2019, 04:30:46 PM
UPDATE! EVERYTHING WORKS NOW CLICK VVVV DOWN? THERE FOR LINK

http://forum.tastyspleen.net/quake/index.php?topic=22977.msg225448;topicseen#new

Show 50 latest
Welcome, Guest. Please login or register.
September 19, 2019, 09:49:10 AM

Login with username, password and session length