Camera

From Valve Developer Community
Revision as of 20:00, 13 October 2010 by Cluon (talk | contribs) (Created page with '== Camera Controls in the Source SDK == Camera controls are spread across multiple source files in the Source SDK, but is largely centralized under the CInput (or CSDKInput) cla…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Camera Controls in the Source SDK

Camera controls are spread across multiple source files in the Source SDK, but is largely centralized under the CInput (or CSDKInput) class. Most customizations to the camera control mechanisms can be accomplished either by editing methods in the CInput class directly, or by making your modifications to the CSDKInput stub provided. Keep in mind that if you modify the CInput class directly, it will make it harder to track updates to the Source SDK; on the flip side, if you decide to flesh out the CSDKInput class, you may need to extensively override or replace a large number of methods from the CInput class.

Basic Concepts

Before we get started, we should first review how the camera is represented to the rest of the engine. The camera position and direction are typically represented via a set of offset coordinates relative to the player. You can think of these offsets as a set of directions to tell how to position the camera starting from the player position:

  • First, turn around the vertical access by the offset vector's yaw component (this turns the camera left or right).
  • Next, turn around the horizontal access by the offset vector's pitch component (this points the camera up or down).
  • Finally, move in the direction your now facing backwards by the offset vector's distance component.