Posted by: Yates
Date posted: Mar 23 2005 User Rating: 3 out of 5.0 | Number of views: 7500 Number of comments: 7 | Description: This is an update to chrono's snippet. |
Thank you for your post Chrono, however I found a few problems with it that I figured I would post the fix to.
1) The alpha number is based on tr.fraction which is how close the camera is to the surface. This is incorrect. If the camera is, say 256 units away, and the user moves the mouse so that the camera is up against the wall, then the player would become translucent even though the camera is still far away - it's just up against a wall. Instead, we want to make the player translucent based on how close the camera actually is to the player. You can do that with the following:
Under #define CAM_HULL_OFFSET, add:
| | |
#define START_TRANS_DIST 128.0 #define TRANS_DELTA 1.9921875
|
Replace
| | | if( tr.fraction < 1.0 ) { adjDist = dist * tr.fraction; localPlayer->SetRenderMode( kRenderTransColor ); localPlayer->SetRenderColorA( (byte)(255 * tr.fraction) ); } else { adjDist = dist; }
|
with
| | | if( tr.fraction < 1.0 ) adjDist = dist * tr.fraction; else adjDist = dist;
if ( adjDist < START_TRANS_DIST ) { localPlayer->SetRenderMode( kRenderTransColor ); localPlayer->SetRenderColorA( (byte)(adjDist * TRANS_DELTA) ); }
|
2) You are using MoveToward which seems to be an unfinished utility function that really is just for floats that represent degrees, thus wrapping at 360. Since distance is just a linear floating point, do the following when you want to use a CAM_MAX_DIST greater than 360:
Replace
| | | camAngles[ 2 ] = MoveToward( camAngles[ 2 ], adjDist, CAM_ANGLE_SPEED );
|
with
| | | camAngles[ 2 ] = adjDist;
|
3) This one is actually just a feature I added, nothing wrong with Chrono's snippet. I set mwheelup to +camin and mweeldown to +camout so that the user can zoom in/out on the fly. I added the following code so that it would automatically enter first person when they zoomed in all the way, and automatically enter third person when they press +camout:
In order for the compiler to know which overloaded ConVar::SetValue() to use, change the following:
| | | #define CAM_MIN_DIST 16.0
|
to:
| | | #define CAM_MIN_DIST 16.0f
|
Just above:
| | | if( !m_fCameraInThirdPerson ) return;
|
add
| | | if( !m_fCameraInThirdPerson && input->KeyState( &cam_out ) ) { cam_idealdist.SetValue( CAM_MIN_DIST ); CAM_ToThirdPerson(); }
|
and right after:
| | | if( input->KeyState( &cam_in ) ) { dist -= CAM_DIST_DELTA; if( dist < CAM_MIN_DIST ) { camAngles[ PITCH ] = 0; camAngles[ YAW ] = 0; dist = CAM_MIN_DIST;
|
put:
Alternatively, if you want to keep the mousewheel handling weapon menus, you can bind MOUSE3 to +camdistance and then set convars c_maxdistance and c_mindistance to match CAM_MIN_DIST and CAM_MAX_DIST. You'll have to change the code that automatically enters/leaves thirdperson though to use m_fCameraDistanceMove instead of input->KeyState( &cam_in ). This way you hold down mouse3, and then move the mouse up/down to zoom in/out. I'll leave this exercise to someone else.
Hope this helps somebody out there! - Yates |
|
User Comments
Showing comments 1-7
|
Loving it. do you know how i can increase the ammount by which the camera moves in an out its rather slow... |
|
|
If you are using +camin and +camout then increase CAM_DIST_DELTA, if you are using +camdistance then increase CAM_ANGLE_MOVE. |
|
|
now I know I already asked, but does anyone know how to do a simple add of a new model without having to change the player.mdl? Also, when in third person, to get the model to show, you have to turn the flashlight on then off. Is there a way around this? |
|
|
When I go into third person, I have a side on view on a slightly see through player. I have compiled a debug version, with developer set to 1, does this make any difference? |
|
|
See the comments in the other post nisan |
|
|
There's a quick fix for the right-side only view... I'm pretty sure it has something to do with idealyaw in in_camera.h on the clientside. I wish I had it, but I can't seem to find it all now.. |
|
I added this to my HL2MP mod. There are two, probably related, problems that I'm getting. First, the hands from the first person view are visible and second, on some weapons, a long black line originating on the weapon and ending somewhere offscreen shows up. How do I make the hands invisible in the third person view (or either view for that matter)?
Also note that I haven't done the hl2mp content fix yet (http://articles.thewavelength.net/703/).Edited by DieparBaby on Apr 20 2006, 08:25:46
|
|
You must register to post a comment. If you have already registered, you must login.
|
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (12 guests)
|
|