当前位置: 首页>>代码示例>>Python>>正文


Python Camera.renderRotateCamera方法代码示例

本文整理汇总了Python中Camera.Camera.renderRotateCamera方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.renderRotateCamera方法的具体用法?Python Camera.renderRotateCamera怎么用?Python Camera.renderRotateCamera使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Camera.Camera的用法示例。


在下文中一共展示了Camera.renderRotateCamera方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import renderRotateCamera [as 别名]
class TestRender:
    '''This is the class that renders maze.
    Camera angles are handled by Camera.py.
    '''
    WINDOW_WIDTH = 700
    WINDOW_HEIGHT = 700
    SCALE = .5
    MAP_SIZE =100
    X_FACTOR = 1
    Y_FACTOR = 1
    Z_FACTOR = 1
    MAP_SIZE = 100
    SEA_LEVEL = 4

    def __init__(self):
        self.set_up_graphics()
        self.load_object()
	self.set_up_glut()
        self.camera = Camera(0,60,0)
	self.camera.rotate(-75,-150,0)
	self.poly_view = False	
        self.start_loop()


    def set_up_glut(self):
        glutIdleFunc(self.display)
        glutDisplayFunc(self.display)

        glutIgnoreKeyRepeat(GLUT_KEY_REPEAT_OFF)
        glutKeyboardFunc(self.keyPressed)
        glutKeyboardUpFunc(self.keyUp)

        glutSetCursor(GLUT_CURSOR_NONE)
        glutPassiveMotionFunc(self.mouseMove)
	
	#glGenLists(50)
	#glNewList(1, GL_COMPILE)
	#glNewList(1, GL_COMPILE)
    
    def start_loop(self):	
	glutMainLoop()

    def set_up_graphics(self):
        glutInit()
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
        glutInitWindowSize(self.WINDOW_WIDTH, self.WINDOW_HEIGHT)
        glutCreateWindow('Terrains!')

        glMatrixMode(GL_PROJECTION)

        gluPerspective(45,1,.1,500)
        glMatrixMode(GL_MODELVIEW)

        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glEnable (GL_BLEND)
        
        
        glClearColor(.529,.8078,.980,0)
        glEnable(GL_NORMALIZE)

        glEnable (GL_DEPTH_TEST)

        #glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
    
    def load_object(self):
        self.load = Structure()
        self.structure = self.load.create_structure()

    def load_object2(self):
        self.load = Grass()
        self.structure = self.load.create_grass_list()

    def display(self, x=0, y=0):

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()
        #Put camera and light in the correct position
        self.camera.move()
	self.camera.renderRotateCamera()
        self.camera.renderTranslateCamera()
        glCallList(self.structure)
	
        
        glDisable(GL_TEXTURE_2D)
        glutSwapBuffers()
       
    def mouseMove(self, x, y):
        '''Called when the mouse is moved.'''
        factor = 2
        
        tmp_x = (self.camera.mouse_x - x)/factor
        tmp_y = (self.camera.mouse_y - y)/factor
        if tmp_x > self.camera.ROTATE:
            tmp_x = self.camera.ROTATE
        self.camera.rotate(tmp_y, tmp_x, 0)
        x = self.WINDOW_WIDTH/2
        y = self.WINDOW_HEIGHT/2
        glutWarpPointer(x, y)
        self.camera.mouse_x = x
        self.camera.mouse_y = y
#.........这里部分代码省略.........
开发者ID:aapope,项目名称:TerrainGeneration,代码行数:103,代码来源:TestRender.py

示例2: __init__

# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import renderRotateCamera [as 别名]

#.........这里部分代码省略.........
        self.convert = Convert((1, 1, 1), (self.QUALITY, 1, self.QUALITY), (1*self.SCALE, self.HEIGHT_SCALE*self.SCALE, 1*self.SCALE), self.MAP_SIZE)
        

    def load_map(self, heightmap_filename):
        self.load = LoadTerrain(heightmap_filename, self.convert, self.tex_holder)
        self.heights = self.load.load()
        self.map_index = self.load.createRenderList(self.heights)

    def load_skybox(self):
        #self.skybox = Skybox((len(self.heights[0])*self.X_FACTOR, self.Y_FACTOR, len(self.heights)*self.Z_FACTOR))
        scale = (self.convert.gl_x+self.convert.gl_z)*self.SKYBOX_SIZE
        self.skybox = Skybox(self.tex_holder, (scale,scale,scale))
        self.sky_index = self.skybox.createCallList(1, 3)

    def create_building(self, x, y, z):
        self.load = Structure(self.tex_holder)
        self.building_index_list.append([self.load.create_structure(), (x,y,z)])
        print self.building_index_list

    def display(self, x=0, y=0):
        '''Called for every refresh; redraws the floor and objects
        based on the camera angle. Calls collision detection, handles
        the appropriate objects for keys, doors, etc.'''
        #print "loopdy loop"
        # print self.curr_time - time.time()
        f_rate = 1.0/60
        if self.last_time+f_rate <= time.time():
            self.last_time = time.time()

            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

            glLoadIdentity()        
            glDisable(GL_LIGHTING)
            self.camera.renderRotateCamera()
            glTranslate(-self.skybox.x/2, -1-self.camera.pos_Y, -self.skybox.z/2)
            glCallList(self.sky_index)

            if abs(self.curr_time - time.time()) >= 1:
                print "FPS:", self.count
                print time.time()
                self.count = 0
                self.curr_time = time.time()
            else:
                self.count+=1
        
            if self.need_lists:
                self.create_render_newlist()

            #self.lock.acquire()
                

            glLoadIdentity()
        #Put camera and light in the correct position
            self.camera.move()
            self.camera.renderRotateCamera()
            self.camera.renderTranslateCamera()

            glEnable(GL_LIGHTING)
            glEnable(GL_LIGHT0)
            glEnable(GL_LIGHT1)
            self.renderLightSource()
            
            for index in self.land_index_list:
            #print "INDEX:", index
                glCallList(index)
开发者ID:aapope,项目名称:TerrainGeneration,代码行数:69,代码来源:RenderWorld.py


注:本文中的Camera.Camera.renderRotateCamera方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。