コード例 #1
0
 def stop(self):
     location = self._window.get_location() # returns a tuple? So convert to array
     
     Settings.set('DisplaySettings','location', [location[0], location[1]] )
     
     self._shutdown()
     pyglet.app.exit()
コード例 #2
0
ファイル: frustum.py プロジェクト: freneticmonkey/Epsilon
    def __init__(self, width=None, 
                       height=None):
        NodeComponent.__init__(self)
        
        if width is None:
            width = Settings.get('DisplaySettings','resolution')[0]

        if height is None:
            height = Settings.get('DisplaySettings','resolution')[1]

        self._width = width
        self._height = height
        
        self._near_dist = 1.0
        self._near_width = 0.0
        self._near_height = 0.0
        self._far_dist = 1000.0
        self._far_width = 0.0
        self._far_height = 0.0
        
        self._aspect = self._width / float(self._height)
        #self._fov = 75.0
        self._fov = 60.0
        
        self._frustum_planes = []
        
        # Build Near/Far Planes
        self._calc_near_far()
        
        # Internal Stats
        self._num_inside = 0
        self._num_outside = 0
        self._num_intersect = 0
        
        # Debug
        self._update_frustum = True
        if Settings.has_option('RenderSettings','update_frustum'):
            self._update_frustum = Settings.get('RenderSettings','update_frustum')
        else:
            Settings.set('RenderSettings','update_frustum', self._update_frustum)
        
        self._top = None
        self._bottom = None
        self._left = None
        self._right = None

        self._verts = []

        self._gizmos = None

        self._projection_matrix = None
コード例 #3
0
    def __init__(self):
        WindowRenderer.__init__(self)
        self._meshes = []
        
        self._has_initialised = False
        self._camera = None
        self._scene_root = None
        self._print_font = None
        self._shader_manager = None
        self._ui_manager = None
        
        # Render Settings
        self._rendersettings = RenderSettings.get_instance()

        if not Settings.has_option('RenderSettings','wireframe'):
            Settings.set('RenderSettings','wireframe', False)

        if not Settings.has_option('RenderSettings','grid'):
            Settings.set('RenderSettings','grid', False)

        if not Settings.has_option('RenderSettings','draw_bounds'):
            Settings.set('RenderSettings','draw_bounds', False)
        
        # Render Listener to allow access to settings
        self._listener = RenderListener(self)
        
        # For FPS Calc
        self._last_time = 0.0
        
        self._fatal_error_displayed = False
        
        # Back Colour
        self._back_colour = Preset.lightgrey

        # Nodes queued for rendering.
        self._render_queue = []
コード例 #4
0
    def _load_configuration(self):
        if self._config_exists:
            # If read ok
            read_result = self._config.read(self._filepath)

            if len(read_result) > 0 and os.path.basename(read_result[0]) == self._filename:

                # Populate the classes with the appropriate values
                for section in self._config.sections():
                    #print "Reading Config Section: " + section
                    
                    for option in self._config.options(section):
                        
                        value_type = "str"

                        # If the section has been defined in the default settings
                        if Settings.has_section(section):
                            value_type = Settings.get(section, option).__class__.__name__
                        
                        # Else use a manual technique to figure this out.
                        else:
                            value = self._config.get(section, option)
                            value_type = self._check_type( value )
                            
                        if value_type == "str":
                            Settings.set(section, option, self._config.get(section, option) )

                        elif value_type == "int":
                            Settings.set(section, option, self._config.getint(section, option) )

                        elif value_type == "float":
                            Settings.set(section, option, self._config.getfloat(section, option) )

                        elif value_type == "bool":
                            Settings.set(section, option, self._config.getboolean(section, option) )

                        elif value_type == "list":
                            # If the item is a list get it as a string and process it as appropriate
                            # only lists containing homogeneous values are supported

                            list_value = self._config.get(section, option)

                            # If the section has already been defined in the default settings
                            if Settings.has_section(section):
                                #assuming that the list has more than one value...
                                list_type = Settings.get(section, option)[0].__class__.__name__

                            # Otherwise extract the type
                            else:
                                #Extract the first list element

                                # Default to a single element list
                                list_element = list_value[1:-1]

                                #Check for more and adjust as necessary
                                if list_value.find(',') > 0:
                                    list_element = list_value[1:list_value.find(',')]

                                # Get the element_type
                                list_type = self._check_type( list_element )

                            # In place of python's lack of a switch statement, defaulting to str if None
                            cast_func = { 'int' : int, 'float' : float, 'bool' : bool, 'str' : str, 'NoneType' : str }[list_type]

                            # Generate a list from the string
                            Settings.set(section, option, [cast_func(value) for value in list_value[1:-1].split(',')] )



                        value = self._config.get(section, option)
                        # print "Reading property class: %s name: %s value: %s" % ( section, option, str(value) )
                        # print "Class value class: %s name: %s value: %s valuetype: %s" % ( section, option, str(Settings.get(section, option)), Settings.get(section, option).__class__ )
        else:
            print "Can't find configuration file: %s " % self._filename
コード例 #5
0
ファイル: ui.py プロジェクト: freneticmonkey/Epsilon
 def update_frustum_action(self, checkbox):
     #RenderSettings.set_setting("update_frustum",checkbox.value)
     Settings.set('RenderSettings','update_frustum', checkbox.value)
コード例 #6
0
ファイル: ui.py プロジェクト: freneticmonkey/Epsilon
 def show_bounds_action(self, checkbox):
     #RenderSettings.set_setting("draw_bounds",checkbox.value)
     Settings.set('RenderSettings','draw_bounds', checkbox.value)
コード例 #7
0
ファイル: ui.py プロジェクト: freneticmonkey/Epsilon
 def show_grid_action(self, checkbox):
     #RenderSettings.set_setting("grid",checkbox.value)
     Settings.set('RenderSettings','grid', checkbox.value)
コード例 #8
0
ファイル: ui.py プロジェクト: freneticmonkey/Epsilon
 def show_wireframe_action(self, checkbox):
     #RenderSettings.set_setting("wireframe",checkbox.value)
     Settings.set('RenderSettings','wireframe', checkbox.value)