How to use the k3d.node.lookup_one function in k3d

To help you get started, we’ve selected a few k3d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github K-3D / k3d / tests / testing.py View on Github external
def displacement_shader_test(render_engine_name, shader_name):
	class result_object:
		def render(self):
			self.render_engine.render_camera_frame(self.camera, self.output, False)

	result = result_object
	result.document = k3d.open_document(k3d.filesystem.generic_path(source_path() + "/shaders/displacement_shader_test.k3d"))
	result.camera = k3d.node.lookup_one(result.document, "Camera")
	result.render_engine = k3d.node.lookup_one(result.document, "RenderMan Engine")
	result.material = k3d.node.lookup_one(result.document, "RenderManMaterial")
	result.shader = k3d.node.lookup_one(result.document, "RenderManDisplacementShader")

	result.shader.shader_path = k3d.share_path() / k3d.filesystem.generic_path("shaders/displacement/" + shader_name + ".sl")
	result.output = k3d.filesystem.generic_path(binary_path() + "/shaders/displacement/" + shader_name + "." + render_engine_name + ".tiff")
	result.render_engine.render_engine = k3d.node.lookup_one(result.document, render_engine_name)

	result.render_engine.render_camera_frame(result.camera, result.output, False)

	return result
github K-3D / k3d / tests / testing.py View on Github external
def displacement_shader_test(render_engine_name, shader_name):
	class result_object:
		def render(self):
			self.render_engine.render_camera_frame(self.camera, self.output, False)

	result = result_object
	result.document = k3d.open_document(k3d.filesystem.generic_path(source_path() + "/shaders/displacement_shader_test.k3d"))
	result.camera = k3d.node.lookup_one(result.document, "Camera")
	result.render_engine = k3d.node.lookup_one(result.document, "RenderMan Engine")
	result.material = k3d.node.lookup_one(result.document, "RenderManMaterial")
	result.shader = k3d.node.lookup_one(result.document, "RenderManDisplacementShader")

	result.shader.shader_path = k3d.share_path() / k3d.filesystem.generic_path("shaders/displacement/" + shader_name + ".sl")
	result.output = k3d.filesystem.generic_path(binary_path() + "/shaders/displacement/" + shader_name + "." + render_engine_name + ".tiff")
	result.render_engine.render_engine = k3d.node.lookup_one(result.document, render_engine_name)

	result.render_engine.render_camera_frame(result.camera, result.output, False)

	return result
github K-3D / k3d / tests / testing.py View on Github external
def volume_shader_test(render_engine_name, shader_name):
	class result_object:
		def render(self):
			self.render_engine.render_camera_frame(self.camera, self.output, False)

	result = result_object
	result.document = k3d.open_document(k3d.filesystem.generic_path(source_path() + "/shaders/volume_shader_test.k3d"))
	result.camera = k3d.node.lookup_one(result.document, "Camera")
	result.render_engine = k3d.node.lookup_one(result.document, "RenderMan Engine")
	result.material = k3d.node.lookup_one(result.document, "RenderManMaterial")
	result.shader = k3d.node.lookup_one(result.document, "RenderManVolumeShader")

	result.shader.shader_path = k3d.share_path() / k3d.filesystem.generic_path("shaders/volume/" + shader_name + ".sl")
	result.output = k3d.filesystem.generic_path(binary_path() + "/shaders/volume/" + shader_name + "." + render_engine_name + ".tiff")
	result.render_engine.render_engine = k3d.node.lookup_one(result.document, render_engine_name)

	result.render_engine.render_camera_frame(result.camera, result.output, False)

	return result
github K-3D / k3d / tests / ngui / MoveTool.py View on Github external
#python
import k3d
import testing

#Create a polycube
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler(0).panel(0).filler(0).filler(0).page_tab_list(0).page_tab("Create").filler(0).filler(0).push_button(0).click()

# Switch to point selection mode
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler("vbox").panel("content").filler("vbox").filler("toolbox").filler("main_toolbar").filler("row1").toggle_button("Select Nodes").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler("vbox").panel("content").filler("vbox").filler("toolbox").filler("main_toolbar").filler("row1").toggle_button("Select Points").click()

doc = k3d.documents()[0]
cube_instance = k3d.node.lookup_one(doc, "PolyCube Instance")

# set the selection on the PolyCube instance
selection = k3d.geometry.selection.create(0)
point_selection = k3d.geometry.point_selection.create(selection)
k3d.geometry.point_selection.append(point_selection, 0, 4, 1)
cube_instance.mesh_selection = selection

# Switch to move tool
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler("vbox").panel("content").filler("vbox").filler("toolbox").filler("main_toolbar").filler("row0").toggle_button("selection_tool").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler("vbox").panel("content").filler("vbox").filler("toolbox").filler("main_toolbar").filler("row0").toggle_button("move_tool").click()

# Activate the move tool properties and change the parameters
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUINodePropertiesPanel").filler("vbox").filler("decorations").combo_box("panel_type").menu(0).menu_item("NGUIToolPropertiesPanel").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUIToolPropertiesPanel").filler("vbox").panel("content").filler(0).filler("vbox").scroll_pane(0).viewport(0).filler("move_tool").panel("Builtin Properties").panel(0).panel("move_control").panel(2).push_button("up").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUIToolPropertiesPanel").filler("vbox").panel("content").filler(0).filler("vbox").scroll_pane(0).viewport(0).filler("move_tool").panel("Builtin Properties").panel(0).panel("move_control").panel(2).push_button("up").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUIToolPropertiesPanel").filler("vbox").panel("content").filler(0).filler("vbox").scroll_pane(0).viewport(0).filler("move_tool").panel("Builtin Properties").panel(0).panel("move_control").panel(2).push_button("up").click()
github K-3D / k3d / share / scripts / create_bicubic_patch.py View on Github external
# Add a single patch to the primitive ...
	patches.patch_selections().append(0)
	patches.patch_materials().append(None)
	for i in range(16):
		patches.patch_points().append(len(patches.patch_points()))

	# Add some colors to the patch corners ...
	Cs.append(k3d.color(1, 0, 0))
	Cs.append(k3d.color(0, 1, 0))
	Cs.append(k3d.color(0, 0, 1))
	Cs.append(k3d.color(1, 1, 1))

	# Connect the FrozenMesh to a MeshInstance to place it in the scene ...
	mesh_instance = k3d.plugin.create("MeshInstance", context.document)
	mesh_instance.name = "Bicubic Patch Instance"
	mesh_instance.gl_painter = k3d.node.lookup_one(context.document, "GL Default Painter")
	mesh_instance.ri_painter = k3d.node.lookup_one(context.document, "RenderMan Default Painter")

	context.document.set_dependency(mesh_instance.get_property("input_mesh"), frozen_mesh.get_property("output_mesh"))

	# Make the MeshInstance visible to render engines ...
	k3d.node.show(context.document, mesh_instance)

	context.document.finish_change_set("Create Bicubic Patch")

except:
	context.document.cancel_change_set()
	raise
github K-3D / k3d / share / scripts / shell / batch_render.py View on Github external
# create animated effects.
#
# To run the script, do the following at the shell:
#
# $ k3d --ui=none --script-file=/path/to/batch_render.py --batch --exit
#
# The 

import k3d
import os

# Load our "template" document.  We assume that the document already contains  materials / lighting / render options to suit.
document = k3d.open_document(k3d.share_path() / k3d.filesystem.generic_path("scripts/shell/batch_render.k3d"))

# Load an external OBJ file into the document.
obj_reader = k3d.node.lookup_one(document, "OBJMeshReader")
obj_reader.filepath = k3d.share_path() / k3d.filesystem.generic_path("geometry/knot.obj")

# Figure-out where to put the rendered results.
output = k3d.filesystem.native_path(os.getcwd()) / k3d.filesystem.generic_path("batch_render.tiff")
print output

# Render the document to the current directory.
camera = k3d.node.lookup_one(document, "Camera")
render_engine = k3d.node.lookup_one(document, "RenderMan Engine")
render_engine.render_camera_frame(camera, output, False)
github K-3D / k3d / share / scripts / create_particles.py View on Github external
# Add particles to the primitive ...
	particles.material().append(None)
	for i in range(particle_count):
		particles.points().append(i)
	
	constantwidth.append(0.5)

	# Assign a random color to each particle ...
	for i in range(particle_count):
		Cs.append(k3d.color(uniform(0, 1), uniform(0, 1), uniform(0, 1)))

	# Connect the FrozenMesh to a MeshInstance to place it in the scene ...
	mesh_instance = k3d.plugin.create("MeshInstance", context.document)
	mesh_instance.name = "Particle Instance"
	mesh_instance.gl_painter = k3d.node.lookup_one(context.document, "GL Default Painter")
	mesh_instance.ri_painter = k3d.node.lookup_one(context.document, "RenderMan Default Painter")

	context.document.set_dependency(mesh_instance.get_property("input_mesh"), frozen_mesh.get_property("output_mesh"))

	# Make the MeshInstance visible to render engines ...
	k3d.node.show(context.document, mesh_instance)

	context.document.finish_change_set("Create Point Group")

except:
	context.document.cancel_change_set()
	raise
github K-3D / k3d / share / scripts / create_polyhedron.py View on Github external
polyhedron.vertex_selections().append(0.0)
	polyhedron.vertex_selections().append(0.0)
	polyhedron.vertex_selections().append(0.0)
	polyhedron.vertex_selections().append(0.0)
	
	# Assign colors to the face vertices ...
	Cs.append(k3d.color(1, 0, 0))
	Cs.append(k3d.color(0, 1, 0))
	Cs.append(k3d.color(0, 0, 1))
	Cs.append(k3d.color(1, 1, 1))

	# Connect the FrozenMesh to a MeshInstance to place it in the scene ...
	mesh_instance = k3d.plugin.create("MeshInstance", context.document)
	mesh_instance.name = "Square Instance"
	mesh_instance.gl_painter = k3d.node.lookup_one(context.document, "GL Default Painter")
	mesh_instance.ri_painter = k3d.node.lookup_one(context.document, "RenderMan Default Painter")
	k3d.property.connect(context.document, frozen_mesh.get_property("output_mesh"), mesh_instance.get_property("input_mesh"))

	# Make the MeshInstance visible to render engines ...
	k3d.node.show(context.document, mesh_instance)

	context.document.finish_change_set("Create Square")

except:
	context.document.cancel_change_set()
	raise
github K-3D / k3d / share / scripts / pygtk_plot_function.py View on Github external
# Create a particle primitive ...
			particles = k3d.particle.create(mesh)

			# Create a custom attribute array to control the widths of particles ...
			constantwidth = particles.constant_attributes().create("constantwidth", "k3d::double_t")

			particles.material().append(None)
			constantwidth.append(0.2)

			for i in range(len(points)):
				particles.points().append(i)

			# Connect the FrozenMesh to a MeshInstance to place it in the scene ...
			mesh_instance = k3d.plugin.create("MeshInstance", context.document)
			mesh_instance.name = function + " Instance"
			mesh_instance.gl_painter = k3d.node.lookup_one(context.document, "GL Default Painter")
			mesh_instance.ri_painter = k3d.node.lookup_one(context.document, "RenderMan Default Painter")
			k3d.property.connect(context.document, frozen_mesh.get_property("output_mesh"), mesh_instance.get_property("input_mesh"))

			# Make the MeshInstance visible to render engines ...
			k3d.node.show(context.document, mesh_instance)

			context.document.finish_change_set("Plot " + function)
		except:
			context.document.cancel_change_set()
			raise
github K-3D / k3d / share / scripts / create_bilinear_patch.py View on Github external
# Add a single patch to the primitive ...
	patches.patch_selections().append(0)
	patches.patch_materials().append(None)
	for i in range(4):
		patches.patch_points().append(len(patches.patch_points()))

	# Add some colors to the patch corners ...
	Cs.append(k3d.color(1, 0, 0))
	Cs.append(k3d.color(0, 1, 0))
	Cs.append(k3d.color(0, 0, 1))
	Cs.append(k3d.color(1, 1, 1))

	# Connect the FrozenMesh to a MeshInstance to place it in the scene ...
	mesh_instance = k3d.plugin.create("MeshInstance", context.document)
	mesh_instance.name = "Bilinear Patch Instance"
	mesh_instance.gl_painter = k3d.node.lookup_one(context.document, "GL Default Painter")
	mesh_instance.ri_painter = k3d.node.lookup_one(context.document, "RenderMan Default Painter")

	context.document.set_dependency(mesh_instance.get_property("input_mesh"), frozen_mesh.get_property("output_mesh"))

	# Make the MeshInstance visible to render engines ...
	k3d.node.show(context.document, mesh_instance)

	context.document.finish_change_set("Create Bilinear Patch")

except:
	context.document.cancel_change_set()
	raise