Hi,

I'm trying to setup some game elements that move but have an unscaled,
2d appearence. I'm deriving from PythonCoordSyst to do this and it's
working OK. However in the render() method I'm having to translate all
the coordinates back and forth between the camera and the coordsyst,
which is tedious. Example:

def render(self):
        global camera
        
        pos = self.parent.position() 
        x, y, z = pos.x, pos.y, pos.z
        
        glDisable(GL_TEXTURE_2D)
        glDisable(GL_LIGHTING)
                         
        glBegin(GL_LINE_LOOP)
        glColor4f(1.0, 0.0, 0.0, 1.0)
        
        ref = self.parent

        pos.x, pos.y, pos.z = x, y + selector_size_y, z
        true_pos = pos % ref
        glVertex3f( true_pos.x, true_pos.y, true_pos.z )

        pos.x, pos.y, pos.z = x - selector_size_x, y, z
        true_pos = pos % ref
        glVertex3f( true_pos.x, true_pos.y, true_pos.z )
        
        pos.x, pos.y, pos.z = x, y - selector_size_y, z
        true_pos = pos % ref
        glVertex3f( true_pos.x, true_pos.y, true_pos.z )

        pos.x, pos.y, pos.z = x + selector_size_x, y, z
        true_pos = pos % ref
        glVertex3f( true_pos.x, true_pos.y, true_pos.z )
        
        glEnd()
        glEnable(GL_LIGHTING)
        glEnable(GL_TEXTURE_2D)

This is basically rendering a selection diamond around an object. Is
there a better way (i.e. using relative coordinates but translated into
screen space)?

Thanks
Nikos



_______________________________________________
Soya-user mailing list
Soya-user@gna.org
https://mail.gna.org/listinfo/soya-user

Reply via email to