Garry's Mod Wiki

cam

This directs all drawing to be done to a certain 2D or 3D plane or position, until the corresponding "End" function is called.

The matrix functions exist, but are mostly unusable unless you're familiar with the source engine's layout for each aspect.

Methods

cam.ApplyShake( Vector pos, Angle angles, number factor )
Shakes the screen at a certain position.
cam.End()
Switches the renderer back to the previous drawing mode from a 3D context. This function is an alias of cam. End3D.
cam.End2D()
Switches the renderer back to the previous drawing mode from a 2D context.
cam.End3D()
Switches the renderer back to the previous drawing mode from a 3D context.
cam.End3D2D()
Switches the renderer back to the previous drawing mode from a 3D2D context.
Switches the renderer back to the previous drawing mode from a 3D orthographic rendering context.
Returns a copy of the model matrix that is at the top of the stack. Editing the matrix will not edit the current view. To do so, you will have to push it. This function essentially returns the copy of the last pushed model matrix.
cam.IgnoreZ( boolean ignoreZ )
Tells the renderer to ignore the depth buffer and draw any upcoming operation "ontop" of everything that was drawn yet. This is identical to calling render. DepthRange( 0, 0. 01 ) for true and render. DepthRange( 0, 1 ) for false. See render. DepthRange.
Pops the current active rendering matrix from the stack and reinstates the previous one.
cam.PushModelMatrix( VMatrix matrix, boolean multiply = false )
Pushes the specified matrix onto the render matrix stack. Unlike opengl, this will replace the current model matrix. This does not work with cam. Start3D2D if multiply is false. When used in the Paint function of a panel, if you want to rely on the top-left position of the panel, you must use VMatrix:Translate with the (0, 0) position of the panel relative to the screen.
cam.Start( table dataTbl )
Sets up a new rendering context. This is an extended version of cam. Start3D and cam. Start2D. Must be finished by cam. End3D or cam. End2D. This will not update current view properties for 3D contexts. Issue Tracker: 2682
cam.Start2D()
Sets up a new 2D rendering context. Must be finished by cam. End2D. This is almost always used with a render target from the render. To set its position use render. SetViewPort with a target already stored. This will put an identity matrix at the top of the model matrix stack. If you are trying to use cam. PushModelMatrix, call it after this function and not before. This is a rendering hook which provides a 2d rendering context.
cam.Start3D( Vector pos = EyePos(), Angle angles = EyeAngles(), number fov = nil, number x = 0, number y = 0, number w = ScrW(), number h = ScrH(), number zNear = nil, number zFar = nil )
Sets up a new 3D rendering context. Must be finished by cam. End3D. For more advanced settings such as an orthographic view, use cam. Start instead. This is a rendering hook which provides a 3d rendering context. Negative x/y values won't work. Issue Tracker: 1995This will not update current view properties. Issue Tracker: 2682
cam.Start3D2D( Vector pos, Angle angles, number scale )
Sets up a new 2D rendering context. Must be finished by cam. End3D2D. This function pushes a new matrix onto the stack. (cam. PushModelMatrix) Matrix formula: local m = Matrix() m:SetAngles(angles) m:SetTranslation(pos) m:SetScale(Vector(scale, -scale, 1))This is a rendering hook which provides a 2d rendering context. This is a rendering hook which provides a 3d rendering context. This should be closed by cam. End3D2D otherwise the game crashes
cam.StartOrthoView( number leftOffset, number topOffset, number rightOffset, number bottomOffset )
Sets up a new 3d context using orthographic projection.