X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=examples%2Fopengl%2Frokuro.py;h=e6b4c5366ba330df1d962731f72c4481293618fb;hb=909e9ce1deb21d4f1697ec18b4520e5e122dce92;hp=fd9eaffc33a055f17c0b3d000dc20c9dec629dad;hpb=a2aac66072e1037a90172a366f43beb5886cf245;p=meshio%2Fpymeshio.git diff --git a/examples/opengl/rokuro.py b/examples/opengl/rokuro.py index fd9eaff..e6b4c53 100644 --- a/examples/opengl/rokuro.py +++ b/examples/opengl/rokuro.py @@ -1,25 +1,31 @@ #!/usr/bin/python # coding: utf-8 +import math from OpenGL.GL import * from OpenGL.GLU import * from . import baseview class RokuroView(baseview.BaseView): - def __init__(self, distance): + def __init__(self): super(RokuroView, self).__init__() self.w=1 self.h=1 self.head=0 self.pitch=0 - self.distance=distance + self.SHIFT_FACTOR=0.001 + self.distance=100 self.shiftX=0 self.shiftY=0 self.aspect=1 self.n=1 self.f=10000 + def __str__(self): + return '' % ( + self.shiftX, self.shiftY, self.distance) + def onResize(self, w=None, h=None): super(RokuroView, self).onResize(w, h) self.aspect=float(self.w)/float(self.h) @@ -31,8 +37,8 @@ class RokuroView(baseview.BaseView): self.distance*=0.9 def shift(self, dx, dy): - self.shiftX+=dx - self.shiftY+=dy + self.shiftX+=dx * self.distance * self.SHIFT_FACTOR + self.shiftY+=dy * self.distance * self.SHIFT_FACTOR def rotate(self, head, pitch): self.head+=head @@ -66,3 +72,17 @@ class RokuroView(baseview.BaseView): self.dolly(d) return True + def look_bb(self, min_v, max_v): + w=max_v[0]-min_v[0] + h=max_v[1]-min_v[1] + long_side=max(w, h) + def deglee_to_radian(deglee): + return math.pi*deglee/180.0 + d=long_side/math.tan(deglee_to_radian(30)) * 1.5 + self.distance=min_v[2]+d + cx=min_v[0]+max_v[0] + cy=min_v[1]+max_v[1] + self.shiftX=-cx/2.0 + self.shiftY=-cy/2.0 + print(self) +