本文整理汇总了Python中cube.Cube.gfx_init方法的典型用法代码示例。如果您正苦于以下问题:Python Cube.gfx_init方法的具体用法?Python Cube.gfx_init怎么用?Python Cube.gfx_init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cube.Cube
的用法示例。
在下文中一共展示了Cube.gfx_init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import gfx_init [as 别名]
class Scene :
def __init__( self , fovy , ratio , near , far , robot_files ) :
self.fovy = fovy
self.near = near
self.far = far
self.ratio = ratio
self.camera = None
self.jelly = JellyCube();
self.jctl = JellyControl( self.jelly , [1.5,1.5,1.5] )
self.jelly.set_borders( (-10,10,-10,10,-10,10) )
self.mode = 0
def mkpln( s , p , r , a , c ) :
p = Plane((s,s),np.dot(tr.translation_matrix(p),tr.rotation_matrix(r*m.pi/180.0,a)))
p.c = c
return p
self.borders = [
mkpln(20,(-10,0,0),-90,(0,0,1),(.4,1,0)) ,
mkpln(20,( 10,0,0), 90,(0,0,1),(.4,1,0)) ,
mkpln(20,(0,0,-10), 90,(1,0,0),(.4,1,0)) ,
mkpln(20,(0,0, 10),-90,(1,0,0),(.4,1,0)) ,
mkpln(20,(0,-10,0), 0,(1,0,0),(.4,1,0)) ,
mkpln(20,(0, 10,0),180,(1,0,0),(.4,1,0)) ]
self.cube = Cube( 100 )
# self.cube = Mesh( 'data/FROG.3DS.gk2' )
self.x = 0.0
self.last_time = timer()
self.plane_alpha = 65.0 / 180.0 * m.pi
self.lpos = [ 1 ,-1 , 0 ]
def gfx_init( self ) :
self.camera = Camera( ( 0 , 0 ,10 ) , ( 0 , 0 , 0 ) , ( 0 , 1 , 0 ) )
self.jelly.gfx_init()
self.jctl.gfx_init()
self.cube.gfx_init()
self._update_proj()
glEnable( GL_DEPTH_TEST )
glEnable( GL_NORMALIZE )
glEnable( GL_CULL_FACE )
glEnable( GL_COLOR_MATERIAL )
glColorMaterial( GL_FRONT , GL_AMBIENT_AND_DIFFUSE )
def draw( self ) :
self.time = timer()
dt = self.time - self.last_time
self._step( dt )
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
self.camera.look()
self.lpos = [ 3,2,1 ]
self._set_lights()
self._draw_scene()
self.x+=dt*.3
self.last_time = self.time
def _step( self , dt ) :
if self.mode == 0 :
self.jelly.wobble( dt , self.jctl.forces( dt ) )
else :
self.jelly.wobble( dt )
def _draw_scene( self ) :
glTranslatef( -1.5 , - 1.5 , -1.5 )
glCullFace( GL_BACK )
self.jelly.draw( self.cube )
self.jctl.draw()
glCullFace( GL_FRONT )
for b in self.borders :
glColor3f( *b.c )
b.draw()
def _update_proj( self ) :
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective( self.fovy , self.ratio , self.near , self.far )
glMatrixMode(GL_MODELVIEW)
def _set_lights( self ) :
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_AMBIENT, [ 0.2 , 0.2 , 0.2 ] );
#.........这里部分代码省略.........