def __init__(_, ratio=1, cameratype='FREE'): super(Camera, _).__init__() _.ratio = ratio # window proportionnal aspect _.position = [0, 0, 0] # for target mode _.lookAt = [0, 0, -1] _.up = [0, 1, 0] # for ortho mode _.near_clip = 0.1 _.far_clip = 2000 _.fov = 45 _.roll = 0 _.matrix = _m.identity() _.rotation = _q.quaternion() _.speed = 0.5 _.V = _m.identity() # kept for PV inner computation ''' need a state switcher over dict CameraType = Enum('CameraType','FREE TARGET ORTHOGRAPHIC') cameraState = State(['camera_type']) cameraState.states('camera_type',CameraType) ''' _.types = { 'FREE': _.camera_free, 'ORTHOGRAPHIC': _.camera_ortho, 'TARGET': _.camera_target } _.setMode(cameratype)
def __init__(_, mesh, tex_coords, name=''): _.mesh = mesh _.tex_coords = tex_coords _.name = name # todo _.matrix = _m.identity() _.rotation = _q.quaternion() _.position = 0, 0, 0 _.createBuffers()
glUniform1i(locations[b"texturing"], texturing) if texturing: animate_texture() elif c == b's': screen_shot() elif c == b'q': sys.exit(0) glutPostRedisplay() rotating = False scaling = False rotation = q.quaternion() scale = 1. def screen2space(x, y): width, height = glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT) radius = min(width, height) * scale return (2. * x - width) / radius, -(2. * y - height) / radius def mouse(button, state, x, y): global rotating, scaling, x0, y0 if button == GLUT_LEFT_BUTTON: rotating = (state == GLUT_DOWN) elif button == GLUT_RIGHT_BUTTON: scaling = (state == GLUT_DOWN)