Thanks.
I guess my question would then be how do I convert from x,y,z to a,b,c
using maths instead of glTranslatef/glRotatef?
Cheers
Astan
Zack Schilling wrote:
> You cannot modify the matrix between glBegin and glEnd calls, so no
> translation or rotation between plotting of vertices is allowed.
>
> If I understand what you want, you're trying to draw a line from the
> "camera" to an object. Depending on how your frustum is set up, this
> may be a bad idea. In any case, it'll look strange and glitchy at
> best. But if you insist, here's what you need to do.
>
> Maintain the position of the camera with (x,y,z) and between loading
> the identity and doing any drawing, perform a glTranslatef(-x,-y,-z)
> as well as any other "camera" rotations you want. Once that's done,
> plot a line from (x,y,z) to (x1,y1,z1), where (x1,y1,z1) are the
> coordinates to the object you're drawing the line to.
>
> glBegin(GL_LINES)
> glVertex3f(x,y,z)
> glVertex3f(x1,y1,z1)
> glEnd()
>
> You cannot and should not try to adjust the matrix while plotting
> points.
>
> -Zack
>
> On Jul 2, 2009, at 10:51 PM, Astan Chee wrote:
>
>
>> Hi,
>> I'm trying to draw a line between two points (x0,y0,z0 and x1,y1,z1)
>> like this:
>>
>> glPushMatrix()
>>
>> glEnable(GL_BLEND)
>>
>> glTranslatef(x,y,z)
>>
>> glRotatef(-angle[0],0,1,0)
>> glRotatef(angle[1],1,0,0)
>>
>> glColor4f( 1, 0.0, 0.0, .8 )
>>
>> glBegin(GL_LINES)
>> glVertex3f(x0,y0,z0)
>>
>> glTranslatef(-x,-y,-z)
>>
>> glRotatef(angle[0],0,1,0)
>> glRotatef(-angle[1],1,0,0)
>>
>> glVertex3f(x1,y1,z1)
>> glEnd()
>>
>> glDisable(GL_BLEND)
>> glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
>> glPopMatrix()
>>
>> Where x0,y0,z0 is the point near or in front of the "camera" and the
>> point x1,y1,z1 is the point in "real world coordinates".
>> This doesn't seem to work. How should I be doing this assuming I don't
>> know how to calculate either point in terms of the other?
>> Thanks
>> Astan
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> PyOpenGL Homepage
>> http://pyopengl.sourceforge.net
>> _______________________________________________
>> PyOpenGL-Users mailing list
>> PyO...@li...
>> https://lists.sourceforge.net/lists/listinfo/pyopengl-users
>>
>
>
>
|