示例#1
0
def import_boxbv(box, hitcheck_name, corrector):
	mat = import_collision_matrix(box.rotation, corrector)
	y, x, z = unpack_swizzle((box.extent.x / 2, box.extent.y / 2, box.extent.z / 2))
	b_obj, b_me = box_from_extents(hitcheck_name, -x, x, -y, y, -z, z)
	mat.translation = unpack_swizzle((box.center.x, box.center.y, box.center.z))
	b_obj.matrix_local = mat
	set_b_collider(b_obj, (x+y+z)/3)
	return b_obj
示例#2
0
def import_meshbv(coll, hitcheck_name, corrector):
	# print(coll)
	b_obj, b_me = mesh_from_data(hitcheck_name, [unpack_swizzle(v) for v in coll.vertices], list(coll.triangles))
	mat = import_collision_matrix(coll.rotation, corrector)
	mat.translation = unpack_swizzle((coll.offset.x, coll.offset.y, coll.offset.z))
	b_obj.matrix_local = mat
	set_b_collider(b_obj, 1, bounds_type="MESH", display_type="MESH")
	return b_obj
示例#3
0
def center_origin_to_matrix(n_center, n_dir):
	"""Helper for capsules to transform nif data into a local matrix """
	# get the rotation that makes (1,0,0) match m_dir
	n_dir = unpack_swizzle((n_dir.x, n_dir.y, n_dir.z))
	n_center = unpack_swizzle((n_center.x, n_center.y, n_center.z))
	m_dir = mathutils.Vector(n_dir).normalized()
	rot = m_dir.to_track_quat("Z", "Y").to_matrix().to_4x4()
	rot.translation = n_center
	return rot
示例#4
0
def import_spherebv(sphere, hitcheck_name):
    r = sphere.radius
    b_obj, b_me = box_from_extents(hitcheck_name, -r, r, -r, r, -r, r)
    b_obj.location = unpack_swizzle(
        (sphere.center.x, sphere.center.y, sphere.center.z))
    set_b_collider(b_obj, r, bounds_type="SPHERE", display_type="SPHERE")
    return b_obj