How to use the k3d.vector3 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 / mesh / mesh.serialization.py View on Github external
#python

import k3d
import sys
import testing

setup = testing.setup_mesh_writer_test(["FrozenMesh", "K3DMeshWriter"], "K3DMeshReader", "mesh.serialization.k3d")

mesh = setup.source.create_mesh()
primitive = mesh.primitives().create("test")

array_types = [ "k3d::bool_t", "k3d::color", "k3d::double_t", "k3d::imaterial*", "k3d::inode*", "k3d::int16_t", "k3d::int32_t", "k3d::int64_t", "k3d::int8_t", "k3d::matrix4", "k3d::normal3", "k3d::point2", "k3d::point3", "k3d::point4", "k3d::string_t", "k3d::texture3", "k3d::uint16_t", "k3d::uint32_t", "k3d::uint64_t", "k3d::uint8_t", "k3d::vector2", "k3d::vector3", "k3d::uint_t" ]
array_values = [ True, k3d.color(1, 2, 3), 1.0, None, None, 1, 2, 3, 4, k3d.identity3(), k3d.normal3(1, 2, 3), k3d.point2(1, 2), k3d.point3(1, 2, 3), k3d.point4(1, 2, 3, 4), "A String", k3d.texture3(1, 2, 3), 1, 2, 3, 4, k3d.vector2(1, 2), k3d.vector3(1, 2, 3), 7 ]

structure = primitive.structure().create("generic")
attributes = primitive.attributes().create("generic")

for i in range(len(array_types)):
	type = array_types[i]
	value = array_values[i]

	structure_array = structure.create(type, type)
	structure_array.append(value)
	structure_array.append(value)
	structure_array.append(value)

	attribute_array = attributes.create(type, type)
	attribute_array.append(value)
	attribute_array.append(value)
github K-3D / k3d / tests / mesh / mesh.modifier.TransformPoints.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("PolyCube", "TransformPoints")

selection = k3d.geometry.selection.create(0)
selection.points = k3d.geometry.point_selection.create(selection, 1)

setup.modifier.mesh_selection = selection
setup.modifier.input_matrix = k3d.translate3(k3d.vector3(0, 0, 1))


testing.require_valid_mesh(setup.document, setup.modifier.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.modifier.get_property("output_mesh"), "mesh.modifier.TransformPoints", 1)
github K-3D / k3d / tests / mesh / mesh.source.CUDAPolyGridAndTransformPoints.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_source_test("CUDAPolyGridAndTransformPoints")

setup.source.input_matrix = k3d.translate3(k3d.vector3(0, 0, 1))


testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.PolyGridAndTransformPoints", 1)
github K-3D / k3d / tests / mesh.modifier.CUDATransformPointsAsynchronous.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("PolyCube", "CUDATransformPointsAsynchronous")

selection = k3d.geometry.selection.create(0)
selection.points = k3d.geometry.point_selection.create(selection, 1)

setup.modifier.mesh_selection = selection
setup.modifier.input_matrix = k3d.translate3(k3d.vector3(0, 0, 1))


testing.require_valid_mesh(setup.document, setup.modifier.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.modifier.get_property("output_mesh"), "mesh.modifier.TransformPoints", 1)
github K-3D / k3d / tests / testing.py View on Github external
def create_camera(document):
	camera_view = k3d.plugin.create("ViewMatrix", document)
	camera_view.position = k3d.translate3(k3d.vector3(-10, -15, 10))
	camera_view.look = k3d.identity3()
	camera_view.up = k3d.translate3(k3d.vector3(0, 0, 20))
	
	camera = k3d.plugin.create("Camera", document)
	k3d.property.connect(document, camera_view.get_property("output_matrix"), camera.get_property("input_matrix"))

	return camera
github K-3D / k3d / tests / other / document.serialization.properties.py View on Github external
test_property(test_container2.get_property("k3d::bool_t").internal_value(), True)
test_property(test_container2.get_property("k3d::color").internal_value(), k3d.color(1, 2, 3))
test_property(test_container2.get_property("k3d::double_t").internal_value(), 3.1415)
test_property(test_container2.get_property("k3d::filesystem::path").internal_value(), k3d.filesystem.generic_path("/foo/bar/baz"))
test_property(test_container2.get_property("k3d::gl::imesh_painter*").internal_value().name, "test_gl_mesh_painter")
test_property(test_container2.get_property("k3d::imaterial*").internal_value().name, "test_material")
test_property(test_container2.get_property("k3d::inode*").internal_value().name, "test_node")
test_property(test_container2.get_property("k3d::int32_t").internal_value(), 19700827)
test_property(test_container2.get_property("k3d::matrix4").internal_value(), k3d.scale3(1, 2, 3))
test_property(test_container2.get_property("k3d::normal3").internal_value(), k3d.normal3(1, 2, 3))
test_property(test_container2.get_property("k3d::point3").internal_value(), k3d.point3(1, 2, 3))
test_property(test_container2.get_property("k3d::point4").internal_value(), k3d.point4(1, 2, 3, 4))
test_property(test_container2.get_property("k3d::ri::imesh_painter*").internal_value().name, "test_ri_mesh_painter")
test_property(test_container2.get_property("k3d::ri::itexture*").internal_value().name, "test_ri_texture")
test_property(test_container2.get_property("k3d::string_t").internal_value(), "K-3D Rocks!")
test_property(test_container2.get_property("k3d::vector3").internal_value(), k3d.vector3(1, 2, 3))
github K-3D / k3d / share / scripts / MeshSourceScript / spheres.py View on Github external
#python

from math import radians

import k3d
k3d.check_node_environment(locals(), "MeshSourceScript")

# Construct a sphere mesh primitive ...
sphere = k3d.sphere.create(Output)
color = sphere.parameter_attributes().create("Cs", "k3d::color")

# Add two spheres ...
sphere.matrices().append(k3d.translate3(k3d.vector3(-3, 0, 0)))
sphere.materials().append(None)
sphere.radii().append(2)
sphere.z_min().append(-1)
sphere.z_max().append(1)
sphere.sweep_angles().append(radians(360))
sphere.selections().append(0)
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 1, 0))
color.append(k3d.color(1, 1, 0))

sphere.matrices().append(k3d.translate3(k3d.vector3(3, 0, 0)))
sphere.materials().append(None)
sphere.radii().append(2)
sphere.z_min().append(-1)
sphere.z_max().append(1)
github K-3D / k3d / share / scripts / MeshSourceScript / tori.py View on Github external
# Add two tori ...
torus.matrices().append(k3d.translate3(k3d.vector3(-5, 0, 0)))
torus.materials().append(None)
torus.major_radii().append(3)
torus.minor_radii().append(2)
torus.phi_min().append(0)
torus.phi_max().append(radians(360))
torus.sweep_angles().append(radians(360))
torus.selections().append(0)
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 1, 0))
color.append(k3d.color(1, 1, 0))

torus.matrices().append(k3d.translate3(k3d.vector3(5, 0, 0)))
torus.materials().append(None)
torus.major_radii().append(3)
torus.minor_radii().append(2)
torus.phi_min().append(0)
torus.phi_max().append(radians(360))
torus.sweep_angles().append(radians(360))
torus.selections().append(0)
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(0, 0, 1))
color.append(k3d.color(0, 0, 1))
github K-3D / k3d / share / scripts / MeshSourceScript / spheres.py View on Github external
color = sphere.parameter_attributes().create("Cs", "k3d::color")

# Add two spheres ...
sphere.matrices().append(k3d.translate3(k3d.vector3(-3, 0, 0)))
sphere.materials().append(None)
sphere.radii().append(2)
sphere.z_min().append(-1)
sphere.z_max().append(1)
sphere.sweep_angles().append(radians(360))
sphere.selections().append(0)
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 1, 0))
color.append(k3d.color(1, 1, 0))

sphere.matrices().append(k3d.translate3(k3d.vector3(3, 0, 0)))
sphere.materials().append(None)
sphere.radii().append(2)
sphere.z_min().append(-1)
sphere.z_max().append(1)
sphere.sweep_angles().append(radians(360))
sphere.selections().append(0)
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(1, 0, 0))
color.append(k3d.color(0, 0, 1))
color.append(k3d.color(0, 0, 1))