comparison src/parpg/bGrease/renderer/camera.py @ 66:96af64cf3b81

Renamed grease to bGrease (Basic Grease) to get rid of conflicts with an already installed grease.
author KarstenBock@gmx.net
date Mon, 05 Sep 2011 15:00:34 +0200
parents src/parpg/grease/renderer/camera.py@09b581087d68
children
comparison
equal deleted inserted replaced
65:765cb0c16f20 66:96af64cf3b81
1 import pyglet
2
3 class Camera(object):
4 """Sets the point of view for further renderers by altering the
5 model/view matrix when it is drawn. It does not actually perform
6 any drawing itself.
7
8 :param position: The position vector for the camera. Sets the center of the view.
9 :type position: Vec2d
10 :param angle: Camera rotation in degrees about the z-axis.
11 :type angle: float
12 :param zoom: Scaling vector for the coordinate axis.
13 :type zoom: Vec2d
14 :param relative: Flag to indicate if the camera settings are relative
15 to the previous view state. If ``False`` the view state is reset before
16 setting the camera view by loading the identity model/view matrix.
17
18 At runtime the camera may be manipulated via attributes with the
19 same names and functions as the parameters above.
20 """
21
22 def __init__(self, position=None, angle=None, zoom=None, relative=False):
23 self.position = position
24 self.angle = angle
25 self.zoom = zoom
26 self.relative = relative
27
28 def draw(self, gl=pyglet.gl):
29 if not self.relative:
30 gl.glLoadIdentity()
31 if self.position is not None:
32 px, py = self.position
33 gl.glTranslatef(px, py, 0)
34 if self.angle is not None:
35 gl.glRotatef(self.angle, 0, 0, 1)
36 if self.zoom is not None:
37 sx, sy = self.zoom
38 gl.glScalef(sx, sy ,0)
39