Cleaned camera
This commit is contained in:
parent
d99ade3f7b
commit
29ec3e1a3d
26
d3/camera.py
26
d3/camera.py
|
@ -1,17 +1,27 @@
|
||||||
from .geometry import Vector
|
from .geometry import Vector
|
||||||
|
|
||||||
from OpenGL.GL import *
|
import OpenGL.GLU as glu
|
||||||
from OpenGL.GLU import *
|
|
||||||
|
|
||||||
|
|
||||||
class Camera:
|
class Camera:
|
||||||
def __init__(self, position = None, target = None, up = None):
|
"""Simple 3D camera
|
||||||
self.position = Vector() if position is None else position
|
"""
|
||||||
self.target = Vector() if target is None else target
|
def __init__(self, position = Vector(1.0,0.0,0.0), target = Vector(), up = Vector(0.0,1.0,0.0)):
|
||||||
self.up = Vector(0.0,1.0,0.0) if up is None else target
|
"""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
|
||||||
|
|
||||||
def look(self):
|
def look(self):
|
||||||
gluLookAt(
|
"""Sets the model view matrix of OpenGL
|
||||||
|
|
||||||
|
Simply calls the gluLookAt function
|
||||||
|
"""
|
||||||
|
glu.gluLookAt(
|
||||||
self.position.x, self.position.y, self.position.z,
|
self.position.x, self.position.y, self.position.z,
|
||||||
self.target.x, self.target.y, self.target.z,
|
self.target.x, self.target.y, self.target.z,
|
||||||
self.up.x, self.up.y, self.up.z)
|
self.up.x, self.up.y, self.up.z)
|
||||||
|
|
Loading…
Reference in New Issue