render.PushCustomClipPlane

From Garry's Mod
Jump to: navigation, search
 render.PushCustomClipPlane( )

Contents

Description

Pushes a new clipping plane of the clip plane stack and sets it as active.

NOTE

A max of 2 clip planes are supported on Linux/POSIX, and 6 on Windows.

Arguments

Vector normal

The normal of the clipping plane.

Arguments

number distance

The distance of the plane from the world origin. You can use Vector:Dot between the normal and any point on the plane to find this, see Example 1.

Examples

Example

Clips the lower half of your custom entity

function ENT:Draw()
    local normal = self:GetUp() -- Everything "behind" this normal will be clipped
    local position = normal:Dot( self:GetPos() ) -- self:GetPos() is the origin of the clipping plane

    local oldEC = render.EnableClipping( true )
    render.PushCustomClipPlane( normal, position )

    self:DrawModel()

    render.PopCustomClipPlane()
    render.EnableClipping( oldEC )
end


Personal tools
Navigation