def test_key_frames_vec(): """ Test KeyFrames vec""" vector_keyframes = KeyFrames({ 0: vec(1, 0, 0), 3: vec(0, 1, 0), 6: vec(0, 0, 1) }) my_keyframes = KeyFrames({0: 1, 3: 7, 6: 20}) # should display numpy vector (0.5, 0.5, 0) print("Test KeyFrames vec for 1.5 : ", end="") print(vector_keyframes.value(1.5))
def test_transformation(): """ test transformation """ translate_keys = {0: vec(0, 0, 0), 2: vec(1, 1, 0), 4: vec(0, 0, 0)} rotate_keys = { 0: quaternion(), 2: quaternion_from_euler(180, 45, 90), 3: quaternion_from_euler(180, 0, 180), 4: quaternion() } scale_keys = {0: 1, 2: 0.5, 4: 1} keyframes = TransformKeyFrames(translate_keys, rotate_keys, scale_keys) print("Test for transformation keyframes : ", end="") print(keyframes.value(1.5))
def main(): """ create a window, add scene objects, then run rendering loop """ shaders_repertory = "../shaders/" vert_name = "lambert_vert.glsl" frag_name = "lambert_frag.glsl" viewer = ViewerLambert(shaders_repertory + vert_name, shaders_repertory + frag_name) rotator_node = RotationControlNode(glfw.KEY_LEFT, glfw.KEY_RIGHT, vec(0, 1, 0)) rotator_node.add(Suzanne(light_vector=(1, 1, 1))) viewer.add(rotator_node) viewer.run()
def launch_windows(): """ create a window, add scene objects, then run rendering loop """ glfw.init() shaders_repertory = "../shaders/" vert_name = "lambert_vert.glsl" frag_name = "lambert_frag.glsl" viewer = ViewerAnimation(shaders_repertory + vert_name, shaders_repertory + frag_name) translate_keys = {0: vec(0, 0, 0), 2: vec(1, 1, 0), 4: vec(0, 0, 0)} rotate_keys = { 0: quaternion(), 2: quaternion_from_euler(180, 45, 90), 3: quaternion_from_euler(180, 0, 180), 4: quaternion() } scale_keys = {0: 1, 2: 0.5, 4: 1} keynode = KeyFrameControlNode(translate_keys, rotate_keys, scale_keys) keynode.add(Cylinder()) viewer.add(keynode) viewer.run() glfw.terminate() # destroy all glfw windows and GL contexts
def main(): """ create a window, add scene objects, then run rendering loop """ viewer = ViewerRoboticArm() # construct our robot arm hierarchy for drawing in viewer cylinder = Cylinder() # re-use same cylinder instance base_node_y = 0.2 limb_shape = Node(transform=translate(0, base_node_y, 0) @ scale( 0.05, 1, 0.05)) # make a thin cylinder limb_shape.add(cylinder) arm_node = RotationControlNode(glfw.KEY_LEFT, glfw.KEY_RIGHT, vec(0, 1, 0)) arm_node.add(limb_shape) base_shape = Node(transform=scale(1.2, base_node_y, 1.2), children=[cylinder]) base_node = Node( transform=rotate(axis=(0, 1, 0), angle=90) @ scale(0.5, 0.5, 0.5), children=[base_shape]) base_node.add(arm_node) viewer.add(base_node) viewer.run()