On Mon, 1 Jun 2009 12:13:52 -0400
Jorge Rodriguez <[email protected]> wrote:

First of all, I really appreciate all your help. I'm starting to get
things the way I want them to function. I'm sure any experienced coder
would gasp if they ever saw how I have done things but no matter.

Next I want to fix the flashlight in 3rd person so the projected
texture is coming from the player instead of the screen. Do I need to
edit the vertex shader code to do this? BaseVSShader.cpp?

I suppose it would be sufficient to just attach the
env_projectedtexture to the muzzle of the player's gun perhaps.

> On Mon, Jun 1, 2009 at 1:16 AM, Chris Marshall <[email protected]>
> wrote:
> 
> > First of all, what is the difference between CAM_Think() and
> > CAM_ThirdThink()? I was looking to see which one to override in the
> > sdk files but it appears that CAMThirdThink() is never called.
> 
> 
> Again I don't know about the standard sources but mine are set up so
> that CAM_Think() is called all the time and CAM_ThirdPersonThink() is
> called only if the player is in third person.
> 
> Secondly, if I override CAM_Think, I don't see how I can control the
> > "location" of the camera except for distance away from the player. I
> > thought about how I could do some trig and set the pitch and yaw to
> > move the camera, but then I'd have to rotate the camera itself back
> > to look forward. I guess what I'm saying is that I don't see how I
> > can rotate the camera relative to itself instead of the player. Do
> > I _have_ to use the overrideview function? Can I use trig to set
> > the proper location of the camera in CAM_Think and then override
> > _only_ the view angles in OverrideView()?
> 
> 
> Thinking about it again I doubt what I said before. I'll just show
> you what my sources do and let you figure it out, I don't want to
> confuse you.
> 
> void CSDKInput::CAM_SetUpCamera( Vector& vecOffset, QAngle&
> angCamera ) {
>     VectorCopy( m_vecCamera, vecOffset );
>     VectorCopy( m_angCamera, angCamera );
> }
> 
> void ClientModeSDKNormal::OverrideView( CViewSetup *pSetup )
> {
>     QAngle camAngles;
> 
>     // Let the player override the view.
>     C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
>     if(!pPlayer)
>         return;
> 
>     pPlayer->OverrideView( pSetup );
> 
>     if( SDKInput()->CAM_IsThirdPerson() )
>     {
>         SDKInput()->CAM_SetUpCamera( pSetup->origin, pSetup->angles );
>     }
>     else if (::input->CAM_IsOrthographic())
>     {
>         pSetup->m_bOrtho = true;
>         float w, h;
>         ::input->CAM_OrthographicSize( w, h );
>         w *= 0.5f;
>         h *= 0.5f;
>         pSetup->m_OrthoLeft   = -w;
>         pSetup->m_OrthoTop    = -h;
>         pSetup->m_OrthoRight  = w;
>         pSetup->m_OrthoBottom = h;
>     }
> }
> 
> void CSDKInput::CAM_Think( void )
> {
>     VPROF("CSDKInput::CAM_Think");
> 
>     if(!C_BasePlayer::GetLocalPlayer())
>         return;
> 
>     C_SDKPlayer* pPlayer = C_SDKPlayer::GetLocalSDKPlayer();
> 
>     if (!pPlayer)
>         return;
> 
>     if (pPlayer->IsKnockedOut())
>         CAM_ToThirdPerson();
> 
>     if( !m_fCameraInThirdPerson )
>         return;
> 
>     Vector vecFollowCamera;
>     QAngle angFollowCamera;
>     Vector vecThirdCamera;
>     QAngle angThirdCamera;
> 
>     m_flCameraWeight = Approach(pPlayer->IsInFollowMode()?1:0,
> m_flCameraWeight, gpGlobals->frametime *
> (1/cam_switchtime.GetFloat()));
> 
>     if (m_flCameraWeight > 0.0f)
>     {
>         //if (pPlayer->IsInFollowMode() && !m_bWasInFollowMode)
>         //    CAM_ResetFollowModeVars();
> 
>         m_bWasInFollowMode = pPlayer->IsInFollowMode();
> 
>         CAM_FollowModeThink(vecFollowCamera, angFollowCamera);
>     }
> 
>     if (m_flCameraWeight < 1.0f)
>     {
>         CAM_ThirdPersonThink(vecThirdCamera, angThirdCamera);
>     }
> 
>     float flWeight = Gain(m_flCameraWeight, 0.8f);
> 
>     m_vecCamera = vecFollowCamera * flWeight + vecThirdCamera *
> (1-flWeight);
>     m_angCamera = angFollowCamera * flWeight + angThirdCamera *
> (1-flWeight);
> }
> 
> The weight is used in order to transfer from follow mode to regular
> third person mode smoothly, and you probably won't need it. Other
> than that if you set m_vecCamera and m_angCamera then it should work
> properly. The method of finding the proper values for those two
> involves just doing some math. Start with the player origin, add a
> little bit of height (vecCamera.z += 10 or whatever) and then do
> something like this:
> 
>     QAngle angEngine;
>     engine->GetViewAngles( angEngine );
>     Vector vecEngineForward, vecEngineRight, vecEngineUp;
>     AngleVectors(angEngine, &vecEngineForward, &vecEngineRight,
> &vecEngineUp);
> 
>     vecCamera -= vecEngineForward * 20;
>     vecCamera += vecEngineRight * 10;
> 
> That's probably the simplest over-the-shoulder camera you can get.
> Probably a good idea to set those numbers to cvars so that you can
> modify them ingame and see what looks best, but that's the general
> idea. As for the angles they are most of the time best set to
> whatever the player's view angles are. This way the camera is always
> behind and a little to the side of the player, and facing the same
> way the player is. Is that what you want?
> 
> As for the muzzle flashes, either your player character has
> contracted EUTS (Explosive Urinary Tract Syndrome) or you are trying
> to retrieve an attachment from the wrong model. You should either
> instruct your player character on the dangers of STDs or make sure
> you are calling GetAttachment() on the w model and not the v model or
> player model.
> 

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to