示例#1
0
    def __init__(self, size=(256, 256), lbase=None, output=None):
        """ Prepares graphics context in which to render synthetic
        images."""

        if lbase is None:
            # Create the renderer
            window_type = "texture"
            self.lbase, self.output = gr.setup_renderer(window_type, size=size)
        else:
            # Use the supplied lbase instance
            self.lbase = lbase
            if output is None:
                # Default to last output in lbase.output_list
                self.output = self.lbase.output_list[-1]
        # Get the RTT target
        self.tex = self.output.getTexture()
        # Initialization
        self.models = {}
        self.bgs = {}
        # Make the scene and attach it to lbase's rootnode
        self.scene = pm.NodePath("scene")
        self.scene.reparentTo(self.lbase.rootnode)
        # Initialize local copies of all of the models and bgs
        self.init_models()
        self.init_bgs()
示例#2
0
文件: main.py 项目: acs1903/genthor
    def __init__(self, size=(256, 256), lbase=None, output=None):
        """ Prepares graphics context in which to render synthetic
        images."""

        if lbase is None:
            # Create the renderer
            window_type = "texture"
            self.lbase, self.output = gr.setup_renderer(window_type, size=size)
        else:
            # Use the supplied lbase instance
            self.lbase = lbase
            if output is None:
                # Default to last output in lbase.output_list
                self.output = self.lbase.output_list[-1]
        # Get the RTT target
        self.tex = self.output.getTexture()
        # Initialization
        self.models = {}
        self.bgs = {}
        # Make the scene and attach it to lbase's rootnode
        self.scene = pm.NodePath("scene")
        self.scene.reparentTo(self.lbase.rootnode)
        # Initialize local copies of all of the models and bgs
        self.init_models()
        self.init_bgs()
示例#3
0
文件: imager.py 项目: jiaxx/genthor
 def get_renderer(self, window_type, size, light_spec=None):
     """ Initializes a new renderer and adds it to the
     Imager.renderers dict."""
     # Create the LightBase instance/output
     lbase, output = self.renderers.get((window_type, size),
                                        gr.setup_renderer(window_type, size, 
                                            light_spec=light_spec))
     # Add to the Imager.renderers
     self.renderers[(window_type, size)] = lbase, output
     return lbase, output
示例#4
0
    def get_renderer(self, window_type, size, light_spec=None, cam_spec=None):
        """ Initializes a new renderer and adds it to the
        Imager.renderers dict."""
        # Create the LightBase instance/output

        import hashlib
        def get_id(l):
            return hashlib.sha1(repr(l)).hexdigest()
        ls_id = get_id(light_spec)
        cs_id = get_id(cam_spec)

        lbase, output = self.renderers.get((window_type, size, ls_id, cs_id),
                                           gr.setup_renderer(window_type, size,
                                               light_spec=light_spec,
                                               cam_spec=cam_spec))
        # Add to the Imager.renderers
        self.renderers[(window_type, size, ls_id, cs_id)] = lbase, output
        return lbase, output
示例#5
0
    def get_renderer(self, window_type, size, light_spec=None, cam_spec=None):
        """ Initializes a new renderer and adds it to the
        Imager.renderers dict."""
        # Create the LightBase instance/output

        import hashlib

        def get_id(l):
            return hashlib.sha1(repr(l)).hexdigest()

        ls_id = get_id(light_spec)
        cs_id = get_id(cam_spec)

        lbase, output = self.renderers.get(
            (window_type, size, ls_id, cs_id),
            gr.setup_renderer(window_type,
                              size,
                              light_spec=light_spec,
                              cam_spec=cam_spec))
        # Add to the Imager.renderers
        self.renderers[(window_type, size, ls_id, cs_id)] = lbase, output
        return lbase, output