cam.Start3D

From GMod Wiki

Jump to: navigation, search
Function
Syntax cam.Start3D( Vector position, Angle angle, Integer fov, Integer x, Integer y, Integer w, Integer , h )
Where is this used?
Description:
Positions the rendering camera three dimensionally.
Returns: nil
Part of Library: Cam
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Cam.Start3D]Cam.Start3D [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionRenders a box in front of and slightly up from the player's spawn position.
Used onNewerClient.png
Code
function OnPaint()
	local pos = LocalPlayer():GetPos();
	local ang = LocalPlayer():GetAngles();
 
	cam.Start3D( pos + ang:Forward() * 32 + ang:Up() * 8, LocalPlayer():EyeAngles() );
 
	draw.RoundedBox( 8, 50, 50, 100, 100, Color( 255, 255, 255 ) );
 
	cam.End3D();
end
 
hook.Add( "HUDPaint", "OnPaint", OnPaint );
OutputN/A


Additional Notes

FOV, x, y, w and h are optional.

This is not the player's view camera, this is a rendering camera. While it may be possible to affect the player's view with this, that is not its primary purpose.

In the first example given, it should be noted that because Draw functions are 2D rendering and that this is using 3D camera positioning, the rendered box does not have a proper z-index and will always render on top. Face the box and place your held weapon "over" it. You will find that the box is drawn on top of your weapon.

It should also be noted that the position and angle do not seem to update when this is hooked via HUDPaint.


The z-index issue may be solved by using a render target. Needs testing and example.

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox