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

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



I'm rendering text right now like this given the string s and position (x,y) on the window:
        w = self.Screen[0]
        h = self.Screen[1]
        glViewport(0,0,w,h)
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glOrtho(0.0, w - 1.0, 0.0, h - 1.0, -1.0, 1.0)
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        s = str(s)
        i = 0
        lx = 0
        length = len(s)
        self.textView()
        glPushMatrix()
        while i < length:
            glRasterPos2i(x + lx, y)
            ch = self.char[ ord( s[i] ) ]
            glDrawPixels(ch[1], ch[2], GL_RGBA, GL_UNSIGNED_BYTE, ch[0])
            lx += ch[1]
            i += 1
        glPopMatrix() 
Thats why text on a billboard will require writing another function to render text on objects and have it dynamic (which I don't know how).
Also, I've had a look at gluProjection but I'm rather confused how to use it. Is there a python example somewhere that does this?
Cheers
Astan

Forrest Voight wrote:
You can have dynamic text on a billboard ... just update the texture
when you need to. How are you currently rendering text?

Why not use GLU? It's almost sure to be there if GL is. GLUT isn't on
the other hand ...
You could reimplement the glProject function in Python, but
billboarding would be easiest.

On Wed, Jul 1, 2009 at 1:19 AM, Astan Chee<astan.chee@xxxxxxxxx> wrote:
  
Also, I'm trying not to use glu or glut functions.

Forrest Voight wrote:

Why does the cross-section matter?

Just display it at the object's center...

On Wed, Jul 1, 2009 at 1:01 AM, Astan Chee<astan.chee@xxxxxxxxx> wrote:


Yes, this is what I'm trying to do but how do I calculate cross-section of
the object at a given distance?
Thanks again

Tyler Laing wrote:

Hmm, I'm not 100% familiar with 3d programming, but wouldn't the best way be
to find the cross-section of the object at some distance from the camera,
which would be a 2d shape, and then you can center the text on that shape?

On Tue, Jun 30, 2009 at 9:26 PM, Astan Chee <astan.chee@xxxxxxxxx> wrote:


Hi,
Im relatively new to opengl and I'm not familiat with its jargon but what
I have is objects in a 3D world in various positions and a camera that can
"move" around. What I'm trying to do is if the distance between object and
camera is close enough, display some information on the screen on the
object.
I know how to calculate distance and I know how to print/display text in
opengl (I'm using glOrtho and glRasterPos2i to map out the characters one at
a time).
Anyway, what I'm having problems with is how do I calculate where to
display these information on the screen so that it overlaps the object
(assuming I know the distance and the angle of the camera and the object
relative to the camera). Does this make sense? I've attached an image that I
photoshopped to look like what I'm trying to do.
Thanks for any help
Astan


--
Visit my blog at http://oddco.ca/zeroth/zblog