model-converter-python/d3/camera.py

28 lines
794 B
Python
Raw Normal View History

2016-11-25 13:56:37 +00:00
from .geometry import Vector
2016-11-25 10:53:35 +00:00
2017-01-18 13:01:17 +00:00
import OpenGL.GLU as glu
2016-11-25 10:53:35 +00:00
class Camera:
2017-01-18 13:01:17 +00:00
"""Simple 3D camera
"""
def __init__(self, position = Vector(1.0,0.0,0.0), target = Vector(), up = Vector(0.0,1.0,0.0)):
"""Creates a simple camera
:param position: center of the camera
:param target: point where the camera is looking
:param up: up vector of the camera
"""
self.position = position
self.target = target
self.up = up
2016-11-25 10:53:35 +00:00
def look(self):
2017-01-18 13:01:17 +00:00
"""Sets the model view matrix of OpenGL
Simply calls the gluLookAt function
"""
glu.gluLookAt(
2016-11-25 10:53:35 +00:00
self.position.x, self.position.y, self.position.z,
self.target.x, self.target.y, self.target.z,
self.up.x, self.up.y, self.up.z)