render/PushCustomClipPlane

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added an example)
(preserve old Enable Clipping state in the example)
Line 22: Line 22:
 
     local position = normal:Dot( self:GetPos() ) -- self:GetPos() is the origin of the clipping plane
 
     local position = normal:Dot( self:GetPos() ) -- self:GetPos() is the origin of the clipping plane
  
     render.EnableClipping( true )
+
     local oldEC = render.EnableClipping( true )
 
     render.PushCustomClipPlane( normal, position )
 
     render.PushCustomClipPlane( normal, position )
  
Line 28: Line 28:
  
 
     render.PopCustomClipPlane()
 
     render.PopCustomClipPlane()
     render.EnableClipping(false)
+
     render.EnableClipping( oldEC )
 
end
 
end
 
}}
 
}}

Revision as of 21:11, 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

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

    self:DrawModel()

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


Personal tools
Navigation