(self)
Handle interactive navigation in shaders.
Handle interactive navigation in shaders.
Handle interactive navigation in shaders .
def initialize_navigation(self):
        """Handle interactive navigation in shaders."""
        # dynamic navigation
        if not self.is_static:
            self.add_uniform("scale", vartype="float", ndim=2, data=(1., 1.))
            self.add_uniform("translation", vartype="float", ndim=2, data=(0., 0.))
            
            self.add_vertex_header("""
                // Transform a position according to a given scaling and translation.
                vec2 transform_position(vec2 position, vec2 scale, vec2 translation)
                {
                return scale * (position + translation);
                }
            """)
            
        if not self.is_static:            
            pos = "transform_position(%s.xy, scale, translation)" % self.position_attribute_name
        else:
            pos = "%s.xy" % self.position_attribute_name
        
        if self.is_position_3D:
            vs = """gl_Position = vec4(%s, %s.z, 1.);""" % (pos,
                self.position_attribute_name)
        else:
            vs = """gl_Position = vec4(%s, 0., 1.);""" % (pos)
        
        if self.depth is not None:
            vs += """gl_Position.z = %.4f;""" % self.depth
        
        self.add_vertex_main(vs, position='last', name='navigation')
def initialize_navigation ( self ) : # dynamic navigation if not self . is_static : self . add_uniform ( "scale" , vartype = "float" , ndim = 2 , data = ( 1. , 1. ) ) self . add_uniform ( "translation" , vartype = "float" , ndim = 2 , data = ( 0. , 0. ) ) self . add_vertex_header ( """
                // Transform a position according to a given scaling and translation.
                vec2 transform_position(vec2 position, vec2 scale, vec2 translation)
                {
                return scale * (position + translation);
                }
            """ ) if not self . is_static : pos = "transform_position(%s.xy, scale, translation)" % self . position_attribute_name else : pos = "%s.xy" % self . position_attribute_name if self . is_position_3D : vs = """gl_Position = vec4(%s, %s.z, 1.);""" % ( pos , self . position_attribute_name ) else : vs = """gl_Position = vec4(%s, 0., 1.);""" % ( pos ) if self . depth is not None : vs += """gl_Position.z = %.4f;""" % self . depth self . add_vertex_main ( vs , position = 'last' , name = 'navigation' )