Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/williamvenner/gmod-3d2d-clipping

✂️ Simple library for efficient and cross-platform clipping of 3D2D GUI in Garry's Mod
https://github.com/williamvenner/gmod-3d2d-clipping

3d2d clip clipping gmod lua scissor scissoring stencil stencils

Last synced: 3 months ago
JSON representation

✂️ Simple library for efficient and cross-platform clipping of 3D2D GUI in Garry's Mod

Awesome Lists containing this project

README

        

## 3d2d-clipping

✂️ Simple library for efficient and cross-platform clipping of 3D2D GUI in Garry's Mod

## Example


Example



Left: No clipping


Right: 2D clipped

## Usage

### Loading the Library
```lua
my_addon.clip = include("lib/clip.lua")
```

### Clipping 2D Rectangles
```lua
local width, height = 200, 400
cam.Start3D2D(pos, ang, scale)
my_addon.clip:Scissor2D(width, height)
-- Draw 2D clipped stuff here!
my_addon.clip()
cam.End3D2D()
```

### Clipping 3D Bounding Boxes

```lua
local mins, maxs = ent:OBBMins(), ent:OBBMaxs()
-- or
local mins, maxs = ent:GetModelBounds()

my_addon.clip:Scissor3D(pos, ang, mins, maxs)
cam.Start3D2D(pos, ang, scale)
-- Draw 3D clipped stuff here!
cam.End3D2D()
my_addon.clip()
```


In most cases, this is not recommended because stencils are fundamentally 2D, leading to depth issues like this:


Depth Problems Example