2018-11-05 18:26:53 +00:00
|
|
|
"""
|
|
|
|
3D Lines with Single Color
|
|
|
|
--------------------------
|
|
|
|
"""
|
|
|
|
import bpy
|
|
|
|
import gpu
|
|
|
|
from gpu_extras.batch import batch_for_shader
|
|
|
|
|
|
|
|
coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)]
|
|
|
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
2018-11-19 20:32:49 +00:00
|
|
|
batch = batch_for_shader(shader, 'LINES', {"pos": coords})
|
|
|
|
|
2018-11-05 18:26:53 +00:00
|
|
|
|
|
|
|
def draw():
|
|
|
|
shader.bind()
|
|
|
|
shader.uniform_float("color", (1, 1, 0, 1))
|
|
|
|
batch.draw(shader)
|
|
|
|
|
|
|
|
|
2018-11-19 20:32:49 +00:00
|
|
|
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
|