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
25 def onResize(self, w=None, h=None):
\r
26 super(RokuroView, self).onResize(w, h)
\r
27 self.aspect=float(self.w)/float(self.h)
\r
35 def shift(self, dx, dy):
\r
36 self.shiftX+=dx * self.distance * self.SHIFT_FACTOR
\r
37 self.shiftY+=dy * self.distance * self.SHIFT_FACTOR
\r
39 def rotate(self, head, pitch):
\r
43 def updateProjection(self):
\r
44 gluPerspective(30, self.aspect, self.n, self.f)
\r
46 def updateView(self):
\r
47 glTranslate(self.shiftX, self.shiftY, -self.distance)
\r
48 glRotate(self.head, 0, 1, 0)
\r
49 glRotate(self.pitch, 1, 0, 0)
\r
51 def onMotion(self, x, y):
\r
54 self.dolly(y-self.y)
\r
56 if self.isMiddelDown:
\r
57 self.shift(x-self.x, self.y-y)
\r
59 if self.isRightDown:
\r
60 self.rotate(x-self.x, y-self.y)
\r
66 def onWheel(self, d):
\r
71 def look_bb(self, min_v, max_v):
\r
75 def deglee_to_radian(deglee):
\r
76 return math.pi*deglee/180.0
\r
77 d=long_side/math.tan(deglee_to_radian(30)) * 1.5
\r
78 self.distance=min_v[2]+d
\r
79 cx=min_v[0]+max_v[0]
\r
80 cy=min_v[1]+max_v[1]
\r