render/PushCustomClipPlane

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=PushCustomClipPlane |Parent=render |Description=Pushes a new clipping plane of the clip plane stack and sets it as active. |Realm=Client |IsClass=No }} {{Ar...")
 
(Added an example)
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=PushCustomClipPlane
 
|Parent=render
 
 
|Description=Pushes a new clipping plane of the clip plane stack and sets it as active.
 
|Description=Pushes a new clipping plane of the clip plane stack and sets it as active.
 
|Realm=Client
 
|Realm=Client
 
|IsClass=No
 
|IsClass=No
 +
|Name=PushCustomClipPlane
 +
|Parent=render
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 15: Line 15:
 
|name=distance
 
|name=distance
 
|desc=The distance of the plane.
 
|desc=The distance of the plane.
 +
}}
 +
{{Example
 +
|Description=Clips the lower half of your custom entity
 +
|Code=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
 +
 +
    render.EnableClipping( true )
 +
    render.PushCustomClipPlane( normal, position )
 +
 +
    self:DrawModel()
 +
 +
    render.PopCustomClipPlane()
 +
    render.EnableClipping(false)
 +
end
 
}}
 
}}

Revision as of 20:52, 27 April 2016

 render.PushCustomClipPlane( )

Contents

Description

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

Arguments

Vector normal

The normal of the clipping plane.

Arguments

number distance

The distance of the plane.

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

    render.EnableClipping( true )
    render.PushCustomClipPlane( normal, position )

    self:DrawModel()

    render.PopCustomClipPlane()
    render.EnableClipping(false)
end


Personal tools
Navigation