test_ri_texture = k3d.plugin.create("RenderManTextureMap", document)
test_ri_texture.name = "test_ri_texture"

test_node = k3d.plugin.create("Axes", document)
test_node.name = "test_node"

create_property(test_container, "k3d::bool_t", True)
create_property(test_container, "k3d::color", k3d.color(1, 2, 3))
create_property(test_container, "k3d::double_t", 3.1415)
create_property(test_container, "k3d::filesystem::path", k3d.filesystem.generic_path("/foo/bar/baz"))
create_property(test_container, "k3d::gl::imesh_painter*", test_gl_mesh_painter)
create_property(test_container, "k3d::imaterial*", test_material)
create_property(test_container, "k3d::inode*", test_node)
create_property(test_container, "k3d::int32_t", 19700827)
create_property(test_container, "k3d::matrix4", k3d.scale3(1, 2, 3))
create_property(test_container, "k3d::normal3", k3d.normal3(1, 2, 3))
create_property(test_container, "k3d::point3", k3d.point3(1, 2, 3))
create_property(test_container, "k3d::point4", k3d.point4(1, 2, 3, 4))
create_property(test_container, "k3d::ri::imesh_painter*", test_ri_mesh_painter)
create_property(test_container, "k3d::ri::itexture*", test_ri_texture)
create_property(test_container, "k3d::string_t", "K-3D Rocks!")
create_property(test_container, "k3d::vector3", k3d.vector3(1, 2, 3))

path = testing.binary_path() + "/document.serialization.properties.output.k3d"
document.save(path)

def test_property(value, expected_value):
	if value != expected_value:
		raise "property value doesn't match: ", value, expected_value
示例#2
0
    k3d.point3(1, 0, -1),
    k3d.point3(-1, 0, -1)
]

blobby.first_primitives().append(len(blobby.primitives()))
blobby.primitive_counts().append(len(ellipsoids) + 1)
blobby.first_operators().append(len(blobby.operators()))
blobby.operator_counts().append(1)
blobby.materials().append(Document.get_node("Material"))

for center in ellipsoids:
    blobby.primitives().append(k3d.blobby.primitive_type.ELLIPSOID)
    blobby.primitive_first_floats().append(len(blobby.floats()))
    blobby.primitive_float_counts().append(16)
    for i in (k3d.translate3(center[0], center[1], center[2]) *
              k3d.scale3(1)).column_major_list():
        blobby.floats().append(i)

# Add a segment to the blobby ...
blobby.primitives().append(k3d.blobby.primitive_type.SEGMENT)
blobby.primitive_first_floats().append(len(blobby.floats()))
blobby.primitive_float_counts().append(23)
blobby.floats().append(-1)
blobby.floats().append(0)
blobby.floats().append(0)
blobby.floats().append(1)
blobby.floats().append(0)
blobby.floats().append(0)
blobby.floats().append(1)
for i in k3d.identity3().column_major_list():
    blobby.floats().append(i)
示例#3
0
test_ri_texture.name = "test_ri_texture"

test_node = document.new_node("Axes")
test_node.name = "test_node"

create_property(test_container, "k3d::bool_t", True)
create_property(test_container, "k3d::color", k3d.color(1, 2, 3))
create_property(test_container, "k3d::double_t", 3.1415)
create_property(test_container, "k3d::filesystem::path",
                k3d.filesystem.generic_path("/foo/bar/baz"))
create_property(test_container, "k3d::gl::imesh_painter*",
                test_gl_mesh_painter)
create_property(test_container, "k3d::imaterial*", test_material)
create_property(test_container, "k3d::inode*", test_node)
create_property(test_container, "k3d::int32_t", 19700827)
create_property(test_container, "k3d::matrix4", k3d.scale3(1, 2, 3))
create_property(test_container, "k3d::normal3", k3d.normal3(1, 2, 3))
create_property(test_container, "k3d::point3", k3d.point3(1, 2, 3))
create_property(test_container, "k3d::point4", k3d.point4(1, 2, 3, 4))
create_property(test_container, "k3d::ri::imesh_painter*",
                test_ri_mesh_painter)
create_property(test_container, "k3d::ri::itexture*", test_ri_texture)
create_property(test_container, "k3d::string_t", "K-3D Rocks!")
create_property(test_container, "k3d::vector3", k3d.vector3(1, 2, 3))

path = testing.binary_path() + "/document.serialization.properties.output.k3d"
document.save(path)


def test_property(value, expected_value):
    if value != expected_value:
示例#4
0
Cs = blobby.parameter_attributes().create("Cs", "k3d::color")

# Add four ellipsoids to the blobby ...
ellipsoids = [k3d.point3(-1, 0, 1), k3d.point3(1, 0, 1), k3d.point3(1, 0, -1), k3d.point3(-1, 0, -1)]

blobby.first_primitives().append(len(blobby.primitives()))
blobby.primitive_counts().append(len(ellipsoids) + 1)
blobby.first_operators().append(len(blobby.operators()))
blobby.operator_counts().append(1)
blobby.materials().append(k3d.node.lookup_one(context.document, "Material"))

for center in ellipsoids:
	blobby.primitives().append(k3d.blobby.primitive_type.ELLIPSOID)
	blobby.primitive_first_floats().append(len(blobby.floats()))
	blobby.primitive_float_counts().append(16)
	for i in (k3d.translate3(center[0], center[1], center[2]) * k3d.scale3(1)).column_major_values():
		blobby.floats().append(i)

# Add a segment to the blobby ...
blobby.primitives().append(k3d.blobby.primitive_type.SEGMENT)
blobby.primitive_first_floats().append(len(blobby.floats()))
blobby.primitive_float_counts().append(23)
blobby.floats().append(-1)
blobby.floats().append(0)
blobby.floats().append(0)
blobby.floats().append(1)
blobby.floats().append(0)
blobby.floats().append(0)
blobby.floats().append(1)
for i in k3d.identity3().column_major_values():
	blobby.floats().append(i)
示例#5
0
	blobby = k3d.blobby.create(mesh)

	# Create a custom attribute array to assign color values to each blobby primitive ...
	Cs = blobby.vertex_attributes().create("Cs", "k3d::color")

	# Add four ellipsoid primitives to the blobby ...
	blobby.materials().append(None)
	blobby.first_primitives().append(len(blobby.primitives()))
	blobby.primitive_counts().append(4)

	ellipsoids = [(-1, 0, 1), (1, 0, 1), (1, 0, -1), (-1, 0, -1)]
	for center in ellipsoids:
		blobby.primitives().append(k3d.blobby.primitive_type.ELLIPSOID)
		blobby.primitive_first_floats().append(len(blobby.floats()))
		blobby.primitive_float_counts().append(16)
		for i in (k3d.translate3(center) * k3d.scale3(1.7, 1, 1.7)).column_major_values():
			blobby.floats().append(i)

	# Assign a color to each primitive ...
	Cs.assign([k3d.color(1, 0, 0), k3d.color(0, 1, 0), k3d.color(0, 0, 1), k3d.color(1, 1, 1)])

	# Add a single operator to the blobby to add all four primitives together ...
	blobby.first_operators().append(len(blobby.operators()))
	blobby.operator_counts().append(1)
	blobby.operators().append(k3d.blobby.operator_type.ADD)
	blobby.operator_first_operands().append(len(blobby.operands()))
	blobby.operator_operand_counts().append(5)
	blobby.operands().assign([5, 0, 1, 2, 3]) # Operand count, followed by the index of each primitive to add

	# Connect the FrozenMesh to a MeshInstance to place it in the scene ...
	mesh_instance = k3d.plugin.create("MeshInstance", context.document)
示例#6
0
文件: blobby.py 项目: yurivict/k3d
    k3d.point3(1, 0, -1),
    k3d.point3(-1, 0, -1)
]

blobby.first_primitives().append(len(blobby.primitives()))
blobby.primitive_counts().append(len(ellipsoids) + 1)
blobby.first_operators().append(len(blobby.operators()))
blobby.operator_counts().append(1)
blobby.materials().append(k3d.node.lookup_one(context.document, "Material"))

for center in ellipsoids:
    blobby.primitives().append(k3d.blobby.primitive_type.ELLIPSOID)
    blobby.primitive_first_floats().append(len(blobby.floats()))
    blobby.primitive_float_counts().append(16)
    for i in (k3d.translate3(center[0], center[1], center[2]) *
              k3d.scale3(1)).column_major_values():
        blobby.floats().append(i)

# Add a segment to the blobby ...
blobby.primitives().append(k3d.blobby.primitive_type.SEGMENT)
blobby.primitive_first_floats().append(len(blobby.floats()))
blobby.primitive_float_counts().append(23)
blobby.floats().append(-1)
blobby.floats().append(0)
blobby.floats().append(0)
blobby.floats().append(1)
blobby.floats().append(0)
blobby.floats().append(0)
blobby.floats().append(1)
for i in k3d.identity3().column_major_values():
    blobby.floats().append(i)
示例#7
0
	operator_operand_counts = blobbies.create_operator_operand_counts()
	operands = blobbies.create_operands()

	ellipsoids = [k3d.point3(-1, 0, 1), k3d.point3(1, 0, 1), k3d.point3(1, 0, -1), k3d.point3(-1, 0, -1)]

	first_primitives.append(len(primitives))
	primitive_counts.append(len(ellipsoids) + 1)
	first_operators.append(len(operators))
	operator_counts.append(1)
	materials.append(k3d.dynamic_cast(Document.get_node("Material"), "imaterial"))

	for center in ellipsoids:
		primitives.append(k3d.primitive_type.ellipsoid)
		primitive_first_floats.append(len(floats))
		primitive_float_counts.append(16)
		for i in (k3d.translate3(center) * k3d.scale3(1, 1, 1)).column_major_list():
			floats.append(i)

	primitives.append(k3d.primitive_type.segment)
	primitive_first_floats.append(len(floats))
	primitive_float_counts.append(23)
	floats.append(-1)
	floats.append(0)
	floats.append(0)
	floats.append(1)
	floats.append(0)
	floats.append(0)
	floats.append(1)
	for i in k3d.identity3().column_major_list():
		floats.append(i)