5 from OpenGL.GL import *
\r
6 from OpenGL.GLU import *
\r
8 from . import baseview
\r
10 class RokuroView(baseview.BaseView):
\r
12 super(RokuroView, self).__init__()
\r
17 self.SHIFT_FACTOR=0.001
\r
26 return '<RokuroView shiftX: %f, shiftY: %f, distance: %f>' % (
\r
27 self.shiftX, self.shiftY, self.distance)
\r
29 def onResize(self, w=None, h=None):
\r
30 super(RokuroView, self).onResize(w, h)
\r
31 self.aspect=float(self.w)/float(self.h)
\r
39 def shift(self, dx, dy):
\r
40 self.shiftX+=dx * self.distance * self.SHIFT_FACTOR
\r
41 self.shiftY+=dy * self.distance * self.SHIFT_FACTOR
\r
43 def rotate(self, head, pitch):
\r
47 def updateProjection(self):
\r
48 gluPerspective(30, self.aspect, self.n, self.f)
\r
50 def updateView(self):
\r
51 glTranslate(self.shiftX, self.shiftY, -self.distance)
\r
52 glRotate(self.head, 0, 1, 0)
\r
53 glRotate(self.pitch, 1, 0, 0)
\r
55 def onMotion(self, x, y):
\r
58 self.dolly(y-self.y)
\r
60 if self.isMiddelDown:
\r
61 self.shift(x-self.x, self.y-y)
\r
63 if self.isRightDown:
\r
64 self.rotate(x-self.x, y-self.y)
\r
70 def onWheel(self, d):
\r
75 def look_bb(self, min_v, max_v):
\r
79 def deglee_to_radian(deglee):
\r
80 return math.pi*deglee/180.0
\r
81 d=long_side/math.tan(deglee_to_radian(30)) * 1.5
\r
82 self.distance=min_v[2]+d
\r
83 cx=min_v[0]+max_v[0]
\r
84 cy=min_v[1]+max_v[1]
\r