File information

Last updated

Original upload

Created by

Ericson Willians

Uploaded by

ericsonwillians

Virus scan

Safe to use

Tags for this mod

About this mod

This mod adds an advanced third-person camera system to Quake 2 Rerelease, delivering a modern, cinematic perspective with smooth movement, robust collision detection, dedicated player avatar visualization, and enhanced aiming adjustments. Beta release.

Permissions and credits
Mirrors
Changelogs
Donations

Quake 2 Rerelease Third-Person Camera System – Detailed Overview



This mod implements an advanced third-person camera system for Quake 2 Rerelease that brings a modern, cinematic perspective to the classic game. It features smooth camera movement, robust collision detection, precise aiming adjustments, and a dedicated player avatar that mirrors your in-game actions in real time.

===========================================================


Video Overview




===========================================================


GitHub Links


Repository: https://github.com/EricsonWillians/quake2-modded-dll
Release v0.1.0: https://github.com/EricsonWillians/quake2-modded-dll/releases/tag/v0.1.0

===========================================================


Features


  • Smooth Camera Movement: The camera follows the player with configurable smoothing parameters including distance, height, and side offsets. Linear interpolation ensures fluid transitions.
  • Intelligent Collision Detection: Multi-layered collision handling prevents the camera from clipping through walls and exposing areas beyond the level boundaries.
  • Sky Box Detection: Ensures that the camera does not reveal views of the external environment.
  • Precise Aiming System: An enhanced targeting mechanism computes accurate aiming directions, keeping weapon fire aligned with the visual crosshair.
  • Player Avatar Visualization: A dedicated entity mirrors the player’s state and animations, ensuring continuous visual representation even when the main entity is hidden.
  • Customizable Settings: Easily adjust camera parameters in-game using CVARs.


===========================================================


Technical Implementation



1. Camera System:
The camera positioning algorithm calculates a desired position behind the player and adjusts it based on collision detection and smoothing:


vec3_t desiredPos = playerEyePos - (forward * effective_distance) + (right * effective_side);
desiredPos.z += effective_height;

// Collision handling
HandleCameraCollision(ent, playerEyePos, desiredPos, cameraPos);

// Smooth transitions
ent->client->ps.viewoffset = LerpVec(ent->client->ps.viewoffset, targetViewOffset, effective_smooth);


2. Player Avatar System:
A separate avatar entity is generated to represent the player visually in third-person view. This entity copies the player’s state and uses the designated player model:


// Copy entity state from player
avatar->s = ent->s;
avatar->s.modelindex = 255; // Player model index


3. Aiming System:
The mod projects a trace from the player's eye position to compute an accurate aim point. This ensures weapon fire remains precise even in third-person mode:


vec3_t dir = self->client->thirdperson_target - start;
float length = dir.length();
if (length > 0) {
aimdir = dir * (1.0f / length);
}


===========================================================


Configuration Variables


The following console variables (CVARs) control the behavior of the third-person camera:

  • sv_thirdperson: Enables (1) or disables (0) third-person view.
  • tp_distance: Sets the camera distance from the player (default: 64).
  • tp_height: Adjusts the vertical offset of the camera.
  • tp_side: Sets the horizontal side offset (positive values move the camera to the right).
  • tp_smooth: Determines the smoothing factor for camera movement (range: 0.0–1.0, default: 0.5).


===========================================================


Usage & Installation



Player Commands:
To toggle third-person view, bind a key (e.g., F3) to the command:

bind f3 "thirdperson"


Console Variables:
These settings can be entered in the console or added to your autoexec.cfg:

sv_thirdperson 1 // Enable third-person view
tp_distance 80 // Set camera distance to 80 units
tp_height 16// Raise camera by 16 units
tp_side 12 // Offset camera 12 units to the right
tp_smooth 0.7 // Set camera smoothing to 70%


Installation Instructions:
  • Compile the project to generate the new game_x64.dll.
  • Navigate to your Quake 2 Rerelease installation directory, then open the rerelease/baseq2 folder.
  • It is advisable to back up your original game_x64.dll (e.g., as game_x64_backup.dll).
  • Replace the existing game_x64.dll with the newly compiled version.


===========================================================


Integration & Engine Hooks


The mod integrates into the Quake 2 engine by hooking into essential functions:
  • ClientBeginServerFrame – Updates the third-person view each frame.
  • ClientThink – Processes player input and updates camera positioning.
  • Weapon Firing Functions – Adjusts the aiming direction for accurate targeting in third-person mode.


===========================================================


Collision Detection & Animation Handling



Collision Detection:
The system employs multi-layered collision detection:
  • Primary ray casting from the player to the desired camera position.
  • Proximity probes detect nearby walls and adjust the camera position accordingly.
  • Sky detection prevents the camera from showing areas outside the level.


Animation Handling:
The player avatar’s animations are managed by copying the player’s frame properties and adjusting view angles for natural movement:

// Copy entity state
avatar->s = ent->s;
avatar->s.modelindex = 255;

// Set proper rotation for third-person appearance
avatar->s.angles[YAW] = ent->client->v_angle[YAW];
avatar->s.angles[PITCH] = 0;
avatar->s.angles[ROLL] = 0;


===========================================================


Troubleshooting & Future Enhancements


  • If the camera clips through walls, try adjusting tp_distance or tp_side.
  • For jerky movement, consider increasing the tp_smooth value.
  • Animation glitches may occur as the state machine is still under development.
  • Future updates will improve crosshair alignment with the native crosshair and introduce additional camera modes.


===========================================================


Performance Considerations & Future Development


The system is optimized for efficiency:
  • The player avatar is created only when necessary.
  • Collision detection uses a limited number of ray casts to minimize performance impact.
  • Smooth interpolation ensures minimal effect on frame rates.


Future improvements include enhanced animation handling, new camera modes (e.g., over-shoulder, cinematic), and further refinements to the aiming system and crosshair integration.

Enjoy the enhanced third-person perspective in Quake 2 Rerelease and please share your feedback and suggestions for future improvements!