Guest DILDOMASTER666 Posted September 6, 2015 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. 0 Share this post Link to post
Arctangent Posted September 6, 2015 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. 0 Share this post Link to post
Guest DILDOMASTER666 Posted September 6, 2015 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. 0 Share this post Link to post
andrewj Posted September 6, 2015 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. 0 Share this post Link to post
RjY Posted September 6, 2015 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 ;) 0 Share this post Link to post
Wagi Posted September 6, 2015 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. 0 Share this post Link to post
Blastfrog Posted September 7, 2015 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. 0 Share this post Link to post
Jon Posted September 8, 2015 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. :? 0 Share this post Link to post
RjY Posted September 8, 2015 Jon said::? Sorry, I didn't see that. Edited to add spoiler tags but it's probably far too late. 0 Share this post Link to post