Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
DILDOMASTER666

Adding a Chasecam to Choco?

Recommended Posts

Hey, I'm sorry if this isn't the correct forum; I'm not sure where else it would make sense in the Doom-related forums.

I recently got a hold of the Chocolate Doom source and I'm interested in developing on it, perhaps making a few silly hacks or features people might like and releasing it. One of the features I'd like to implement is a robust chasecam system, however, I'm not entirely sure where I should begin implementing this idea.

In other words, what I'm asking is thus:

Does anyone have any suggestions that can help? I do not want anyone in this thread to show me a single line of code unless it's absolutely necessary in demonstrating some specific point; I want to write it and implement it myself. I just want to have a general idea of where I should begin hacking at.

Share this post


Link to post

While I have no idea about the specifics, I feel like it would be handy to lay down some fundamentals to help you know if you're on the right track.

When converting a first person camera to a third person camera, you'll need to do the following:

  • Do not render HUD elemental that are strictly from the first person perspective. In Doom's case, this is only the weapon sprites, unless I'm forgetting something.
  • Actually render the player in the view point. Nearly all first person cameras do not bother rendering the graphics of the player from their own perspective, and those that do usually only do so in a limited manner. Without doing this, you'd not be able to see yourself.
  • Pull back the render point. Otherwise, you'll either not notice anything different or get a screen of Doom Guy's back. You're going to need to use trig for this, but getting the baseline working shouldn't be too much work, you should only need to use sine and cosine with the player's angle, which is already provided.
Some of the issues you'll going to need to deal with almost immediately is dealing with walls - as because you're not rendering from the player's current location but somewhere behind them, the camera would not be prevented from going through walls without you specifically handling that - and actually making sure this third person perspective isn't actually impairing. There's also potentially issues with how Doom's renderer works that could potentially be a pretty big obstacle, although I have no way of telling if that's the case or not.

Share this post


Link to post
Arctangent said:

There's also potentially issues with how Doom's renderer works that could potentially be a pretty big obstacle, although I have no way of telling if that's the case or not.


If I understand correctly (referencing Ling and Fraggle from the thread about linguortals), the renderer prefers traversing the BSP tree from the point of view of the local player and does not expect other objects to be able to be render viewpoints (?), or moreover, the concept of multiple render viewpoints is simply foreign to Doom's renderer. I don't know how difficult this will be to remedy if that's the case; I have yet to actually step through the rendering/BSP code to understand it.

Share this post


Link to post

No the engine can render from any point.

There are some global vars where to render from, called (I think) viewx, viewy, viewz, viewangle.

In the render setup, these variables are set from the main player. This is where you can modify it to move the view backwards (or whatever) for a chasecam.

Share this post


Link to post

To add to andrewj's post, this might be a place to start: a quick hack to move the camera behind the player while the use key is pressed.

Spoiler

diff --git a/src/doom/r_main.c b/src/doom/r_main.c
index 22278fe..8e11047 100644
--- a/src/doom/r_main.c
+++ b/src/doom/r_main.c
@@ -834,6 +834,12 @@ void R_SetupFrame (player_t* player)
     
     viewsin = finesine[viewangle>>ANGLETOFINESHIFT];
     viewcos = finecosine[viewangle>>ANGLETOFINESHIFT];
+
+    if (player->usedown)
+    {
+        viewx -= FixedMul(128*FRACUNIT, viewcos);
+        viewy -= FixedMul(128*FRACUNIT, viewsin);
+    }
 	
     sscount = 0;
 	
Patch is against chocolate-doom-2.2.0. Correcting imperfections, such as the weapon sprites still being visible, is left as an exercise ;)

Share this post


Link to post

The other thing you have to worry about is making sure the chase camera doesn't end up through a wall or under a floor. The best way to do it would be to trace a line backward (just like the way a bullet would be traced in the engine). If it hits something closer than 128 units away (or however far back you want the camera to be), show it at that point, otherwise just show it 128 units away.

Share this post


Link to post

I suggest having the camera somewhat above the player's head and y-sheared at a downward angle so that you have a nice view of what's in front without Doomguy's conspicuously well-chizzled ass getting in the way.

I also suggest tracing a line to where the player is currently aiming, and draw a crosshair on the HUD where it hits.

Share this post


Link to post
Fisk said:

I do not want anyone in this thread to show me a single line of code unless it's absolutely necessary in demonstrating some specific point; I want to write it and implement it myself. I just want to have a general idea of where I should begin hacking at.

RjY said:

To add to andrewj's post, this might be a place to start: a quick hack to move the camera behind the player while the use key is pressed.


:?

Share this post


Link to post
Jon said:

:?

Sorry, I didn't see that. Edited to add spoiler tags but it's probably far too late.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×