[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] converting "object position" to "view position" in (py)opengl



Thanks for that, but it doesn't seem to work. Well, it gives coordinates of x,y(,z) but when the camera changes angle (but not position), the coordinates don't change. What else do I need to be doing in this?
Anyway, I also forgot to mention this is how I make the text images:
def __init__(self):
        pygame.font.init()
        self.font = pygame.font.Font(FONT,18)
        self.char = []
        for c in range(256):
            self.char.append(self.CreateCharacter(chr(c)))
        self.char = tuple(self.char)

    def CreateCharacter(self,s):
        try:
            letter_render = self.font.render(s,1,(255,255,255), (0,0,0))
            letter = pygame.image.tostring(letter_render,'RGBA',1)
            letter_w,letter_h = letter_render.get_size()
        except:
            letter = None
            letter_w = letter_h= 0
        return (letter,letter_w,letter_h)
Since I make the text this way, I'm thinking of just doing it billboard but I'm not sure how to implement half of this.
Thanks again for any help.
Cheers
Astan


Ian Mallett wrote:
Er, the last three arguments return the data in C.  In Python, the syntax is different:

C: gluProject(objx,objy,objz,model,proj,view,winx,winy,winz)
Python: winx,winy,winz = gluProject(objx,objy,objz,model,proj)

And yes, it returns a z-coord, which should take into account the near clipping plane.  As long as the plane is ~0, (x,y) should be fairly accurate.

Keep in mind that the (x,y) coordinates are *real* coordinates, (i.e., the y is not flipped).  (0,0) is the bottom left.  If you rasterize the font as you were, it shouldn't be a problem.

Ian