Hello,
I have little program that render text in a 3d scene
I want to positionate an image with several buttons to control the
scene, in 2D at bottom left corner of the sceen(allways fix in one
position).
The problem is that this menu rotate and zoom in 3d scene. I want to
separate the 3D scene of 2D control.
What can I do?
Thanks for advance
xavi

import pyglet
from pyglet import window,image
from pyglet.gl import *
from pyglet import font
from pyglet.font import GlyphString

class Scene():
        x,y,z=0,0,500
        rx,ry,rz=0,0,0
        w,h=0,0
        fov=50

        win=''
        courier=''
        menu_img =''


        def __init__(self):

                self.opengl_init()

                self.win = window.Window(resizable=True)
                self.win.maximize()
                self.win.on_resize=self.view
                self.win.on_mouse_drag=self.drag

                self.courier = font.load('Courier 10 Pitch', 10, dpi=96)
                self.menu_img = image.load('menu.png').texture


                @self.win.event
                def on_draw():
                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
                        self.apply()
                        self.render_scene3d()
                        self.positionate_menu_2d()


        def positionate_menu_2d(self): #I want to positionate in bottom, left
corner of the screen
                self.menu_img.blit(0,0)

        def render_scene3d(self):
                glEnable(GL_TEXTURE_2D)
                glColor4f(1,1,1,1)
                text="Fast text on 3d scene!"
                glyphs = self.courier.get_glyphs(text)
                glyph_string = GlyphString(text, glyphs,x=0,y=0)
                glyph_string.draw()
                glDisable(GL_TEXTURE_2D)



        def opengl_init(self):
                glEnable(GL_BLEND)
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
                glDepthFunc(GL_LEQUAL)


        def view(self,width,height):
                self.w,self.h=width,height
                glViewport(0,0, width, height)
                self.prespectiva()


        def drag(self, x, y, dx, dy, button, modifiers):
                if button==1:
                        self.x-=dx*10
                        self.y-=dy*10
                elif button==2:
                        self.x-=dx*2
                        self.z-=dy*2
                elif button==4:
                        self.ry+=dx/4.
                        self.rx-=dy/4.

        def prespectiva(self):
                glMatrixMode(GL_PROJECTION)
                glLoadIdentity()
                gluPerspective(self.fov, float(self.w)/self.h, 0.1,0)
                glMatrixMode(GL_MODELVIEW)

        def apply(self):
                glLoadIdentity()
                glTranslatef(-self.x,-self.y,-self.z)
                glRotatef(self.rx,1,0,0)
                glRotatef(self.ry,0,1,0)
                glRotatef(self.rz,0,0,1)

scn=Scene()
pyglet.app.run()

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to