Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#python
import k3d
k3d.check_node_environment(locals(), "MeshSourceScript")
# Perform required one-time setup to store geometric points in the mesh ...
points = Output.create_points()
point_selection = Output.create_point_selection()
# Perform required one-time setup to store bilinear patches in the mesh ...
patches = k3d.bilinear_patch.create(Output)
# Create an (optional) array to hold color values at the parametric
# corners of each patch ...
Cs = patches.parameter_attributes().create("Cs", "k3d::color")
# We will create two identical bilinear patches
for i in range(2):
patches.patch_selections().append(0)
patches.patch_materials().append(None)
#python
import k3d
k3d.check_node_environment(context, "MeshSourceScript")
# Create two triangles, arranged to form a square ...
vertices = [k3d.point3(-3, -3, 0), k3d.point3(3, -3, 0), k3d.point3(3, 3, 0), k3d.point3(-3, 3, 0)]
vertex_counts = [3, 3]
vertex_indices = [0, 1, 3, 1, 2, 3]
material = None
polyhedron = k3d.polyhedron.create(context.output, vertices, vertex_counts, vertex_indices, material)
#python
import k3d
k3d.check_node_environment(locals(), "RenderEngineScript")
graph = """
digraph G {
node [ shape="box" style="filled" color="black" fillcolor="white" ];
"""
for node in Document.nodes():
graph += str(node.__hash__())
graph += "[\n"
graph += "label=\"" + node.name + "\"\n"
graph += "URL=\"http://www.k-3d.org/wiki/" + node.factory().name + "\"\n"
graph += "]\n"
for node in Document.nodes():
#python
import k3d
k3d.check_node_environment(locals(), "MeshModifierScript")
from random import seed, randint
Output.copy(Input)
seed(123)
colors = [ k3d.color(1, 0, 0), k3d.color(1, 1, 0), k3d.color(0, 1, 0), k3d.color(0, 1, 1), k3d.color(0, 0, 1), k3d.color(1, 0, 1), k3d.color(1, 1, 1)]
for prim_idx, const_primitive in enumerate(Input.primitives()):
if const_primitive.attributes()["uniform"]:
Cs = Output.prmitives()[prim_idx].attributes()["uniform"].create_array("Cs", "k3d::color")
#todo: find out how to get the length for uniform data
#python
import k3d
k3d.check_node_environment(locals(), "MeshSourceScript")
positions = [(-5, -5, 0), (5, -5, 0), (5, 5, 0), (-5, 5, 0)]
points = Output.create_points()
point_selection = Output.create_point_selection()
for position in positions:
points.append(k3d.point3(position[0], position[1], position[2]))
point_selection.append(0.0)
nurbs_curve_groups = Output.create_nurbs_curve_groups()
first_curves = nurbs_curve_groups.create_first_curves()
first_curves.assign([0])
curve_counts = nurbs_curve_groups.create_curve_counts()
#python
import k3d
k3d.check_node_environment(context, "OpenGLPainterScript")
from OpenGL.GL import *
points = context.mesh.points()
if points:
glPushAttrib(GL_ALL_ATTRIB_BITS)
glDisable(GL_LIGHTING)
glEnable(GL_POINT_SMOOTH)
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST)
glEnable(GL_BLEND)
glBlendFunc(GL_ONE, GL_ONE)
glPointSize(3)
glColor3d(1, 1, 1)
#python
from math import radians
import k3d
k3d.check_node_environment(locals(), "MeshSourceScript")
# Construct a sphere mesh primitive ...
paraboloids = k3d.paraboloid.create(Output)
color = paraboloids.parameter_attributes().create("Cs", "k3d::color")
# Add two paraboloids ...
paraboloids.matrices().append(k3d.translate3(k3d.vector3(-5, 0, 0)))
paraboloids.materials().append(None)
paraboloids.radii().append(3)
paraboloids.z_min().append(0)
paraboloids.z_max().append(6)
paraboloids.sweep_angles().append(radians(360))
paraboloids.selections().append(0.0)
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 1, 0))
#python
import k3d
k3d.check_node_environment(context, "MeshSourceScript")
# Perform required one-time setup to store geometric points in the mesh ...
points = context.output.create_points()
point_selection = context.output.create_point_selection()
# Perform required one-time setup to store bezier triangle patches in the mesh ...
patches = k3d.bezier_triangle_patch.create(context.output)
# We will create two identical bezier triangle patches ...
for i in range(2):
patches.patch_first_points().append(len(points))
patches.patch_orders().append(4)
patches.patch_selections().append(0)
patches.patch_materials().append(None)
# from The Platonic Spheroids at http://www.cise.ufl.edu/research/SurfLab/pre99-papers/97.spheroids.ps.gz
#python
import k3d
k3d.check_node_environment(locals(), "MeshSourceScript")
from random import uniform
count = 100
size = 10
points = Output.create_points()
point_selection = Output.create_point_selection()
for i in range(count):
points.append(k3d.point3(uniform(-size, size), uniform(-size, size), uniform(-size, size)))
point_selection.append(0.0)
point_groups = Output.create_point_groups()
first_points = point_groups.create_first_points()