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)
#python import k3d import sys import testing document = k3d.new_document() source = document.new_node("FrozenMesh") mesh = 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 ] attributes = primitive.attributes().create("uniform") for i in range(len(array_types)): type = array_types[i] value = array_values[i] named_array = primitive.structure().create(type, type) named_array.append(value) named_array.append(value) attribute_array = attributes.create(type, type) attribute_array.append(value) attribute_array.append(value) attribute_array.append(value) print repr(mesh) sys.stdout.flush()
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
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 document2 = k3d.open_document(k3d.filesystem.native_path(path)) test_container2 = k3d.node.lookup_one(document, "test_container")
#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) attribute_array.append(value)