Exemple #1
0
   def __init__(self, sky_renderer, new_layer, new_texture_manager):
       '''
       Constructor
       '''
       RendererObjectManager.__init__(self, new_layer, new_texture_manager)
       
       self.label_maker = None
       self.labels = []
       self.sky_region_map = SkyRegionMap() 
 
       # These are intermediate variables set in beginDrawing() and used in
       # draw() to make the transformations more efficient
       self.label_offset = Vector3(0, 0, 0)
       self.dot_product_threshold = None
 
       self.texture_ref = None
       
       # A quad with size 1 on each size, so we just need to multiply
       # by the label's width and height to get it to the right size for each
       # label.
       vertices = [-0.5, -0.5,   # lower left
                   -0.5,  0.5,   # upper left
                   0.5, -0.5,    # lower right
                   0.5,  0.5]    # upper right
       # make the vertices fixed point? byte buffer?
       self.quad_buffer = np.array(vertices, dtype=np.float32)     
       # We want to initialize the labels of a sky region to an empty list.
       def construct_method():
           return []
       
       self.sky_region_map.region_data_factory = \
           SkyRegionMap.RegionDataFactory(construct_method)
           
           
Exemple #2
0
 def __init__(self, new_layer, new_texture_manager):
     '''
     Constructor
     '''
     RendererObjectManager.__init__(self, new_layer, new_texture_manager)
     self.vertex_buffer = VertexBuffer(True)
     self.color_buffer = NightVisionBuffer(True)
     self.text_coord_buffer = TextCoordBuffer(True)
     self.index_buffer = IndexBuffer(True)
     self.texture_ref = None
     self.opaque = True
 def __init__(self, new_layer, new_texture_manager):
     '''
     Constructor
     '''
     RendererObjectManager.__init__(self, new_layer, new_texture_manager)
     self.vertex_buffer = VertexBuffer(True)
     self.color_buffer = NightVisionBuffer(True)
     self.text_coord_buffer = TextCoordBuffer(True)
     self.index_buffer = IndexBuffer(True)
     self.texture_ref = None
     self.opaque = True
Exemple #4
0
    def __init__(self, new_layer, new_texture_manager):
        '''
        Constructor
        '''
        RendererObjectManager.__init__(self, new_layer, new_texture_manager)

        self.vertex_buffer = VertexBuffer()
        self.text_coord_buffer = TextCoordBuffer()
        self.images = []
        self.textures = []
        self.red_textures = []

        self.updates = set()
Exemple #5
0
 def __init__(self, new_layer, new_texture_manager):
     '''
     constructor
     TODO: change inputs to not be default
     '''
     def construct_method():
         return PointObjectManager.RegionData()
     
     RendererObjectManager.__init__(self, new_layer, new_texture_manager)
     self.sky_regions = SkyRegionMap()
     self.sky_regions.region_data_factory = \
         self.sky_regions.RegionDataFactory(construct_method)
     self.num_points = 0
     
Exemple #6
0
 def __init__(self, new_layer, new_texture_manager):
     '''
     Constructor
     '''
     RendererObjectManager.__init__(self, new_layer, new_texture_manager)
     
     self.vertex_buffer = VertexBuffer()
     self.text_coord_buffer = TextCoordBuffer()
     self.images = []
     self.textures = []
     self.red_textures = []
     
     self.updates = set()
     
Exemple #7
0
 def __init__(self, layer_id, new_texture_manager):
     '''
     Constructor
     '''
     RendererObjectManager.__init__(self, layer_id, new_texture_manager)
     self.width = 2
     self.height = 2
     self.geo_to_viewer_transform = create_identity()
     self.look_dir = Vector3(0, 0, 0)
     self.up_dir = Vector3(0, 1, 0)
     self.transformed_look_dir = Vector3(0, 0, 0)
     self.transformed_up_dir = Vector3(0, 1, 0)
     
     #search_helper = SearchHelper()
     self.dark_quad = None
     #self.search_arrow = SearchArrow()
     #crosshair = CrosshairOverlay()
     
     
Exemple #8
0
    def __init__(self, sky_renderer, new_layer, new_texture_manager):
        '''
        Constructor
        '''
        RendererObjectManager.__init__(self, new_layer, new_texture_manager)

        self.label_maker = None
        self.labels = []
        self.sky_region_map = SkyRegionMap()

        # These are intermediate variables set in beginDrawing() and used in
        # draw() to make the transformations more efficient
        self.label_offset = Vector3(0, 0, 0)
        self.dot_product_threshold = None

        self.texture_ref = None

        # A quad with size 1 on each size, so we just need to multiply
        # by the label's width and height to get it to the right size for each
        # label.
        vertices = [
            -0.5,
            -0.5,  # lower left
            -0.5,
            0.5,  # upper left
            0.5,
            -0.5,  # lower right
            0.5,
            0.5
        ]  # upper right
        # make the vertices fixed point? byte buffer?
        self.quad_buffer = np.array(vertices, dtype=np.float32)

        # We want to initialize the labels of a sky region to an empty list.
        def construct_method():
            return []

        self.sky_region_map.region_data_factory = \
            SkyRegionMap.RegionDataFactory(construct_method)
Exemple #9
0
 def __init__(self, layer_id, texture_manager):
     '''
     Constructor
     '''
     RendererObjectManager.__init__(self, layer_id, texture_manager)
     
     self.vertex_buffer = VertexBuffer(0, True)
     self.color_buffer = ColorBuffer(0, True)
     self.index_buffer = IndexBuffer(0, True)
     self.sun_pos = GeocentricCoordinates(0, 1, 0)
     
     num_vertices = self.NUM_VERTEX_BANDS * self.NUM_STEPS_IN_BAND
     num_indices = (self.NUM_VERTEX_BANDS-1) * self.NUM_STEPS_IN_BAND * 6
     self.vertex_buffer.reset(num_vertices)
     self.color_buffer.reset(num_vertices)
     self.index_buffer.reset(num_indices)
     
     sin_angles = [0.0] * self.NUM_STEPS_IN_BAND
     cos_angles = [0.0] * self.NUM_STEPS_IN_BAND
     
     angle_in_band = 0
     d_angle = 2* math.pi / float(self.NUM_STEPS_IN_BAND - 1)
     for i in range(0, self.NUM_STEPS_IN_BAND):
         sin_angles[i] = math.sin(angle_in_band)
         cos_angles[i] = math.cos(angle_in_band)
         angle_in_band += d_angle
         
     band_step = 2.0 / float((self.NUM_VERTEX_BANDS-1) + self.EPSILON)
     
     vb = self.vertex_buffer
     cb = self.color_buffer
     band_pos = 1
     for band in range(0, self.NUM_VERTEX_BANDS):
         a, r, g, b = 0, 0, 0, 0
         
         if band_pos > 0:
             intensity = long(band_pos * 20 + 50) & 0xFFFFFFFF
             a = 0xFF
             r = (intensity << 16) & 0x00FF0000
             g = (intensity << 16) & 0x0000FF00
             b = (intensity << 16) & 0x000000FF
         else:
             intensity = long(band_pos * 40 + 40) & 0xFFFFFFFF
             color = (intensity << 16) | (intensity << 8) | (intensity)
             a = 0xFF
             r = color & 0x00FF0000
             g = color & 0x0000FF00
             b = color & 0x000000FF
         
         band_pos -= band_step
     
         sin_phi = math.sqrt(1 - band_pos*band_pos) if band_pos > -1 else 0
         for i in range(0, self.NUM_STEPS_IN_BAND):
             vb.add_point(Vector3(cos_angles[i] * sin_phi, band_pos, sin_angles[i] * sin_phi))
             cb.add_color(a, r, g, b)
     
     ib = self.index_buffer
     
     # Set the indices for the first band.
     top_band_start = 0
     bottom_band_start = self.NUM_STEPS_IN_BAND
     for triangle_band in range(0, self.NUM_VERTEX_BANDS-1):
         for offset_from_start in range(0, self.NUM_STEPS_IN_BAND-1):
             # Draw one quad as two triangles.
             top_left = (top_band_start + offset_from_start)
             top_right = (top_left + 1)
             
             bottom_left = (bottom_band_start + offset_from_start)
             bottom_right = (bottom_left + 1)
             
             # First triangle
             ib.add_index(top_left)
             ib.add_index(bottom_right)
             ib.add_index(bottom_left)
             
             # Second triangle
             ib.add_index(top_right)
             ib.add_index(bottom_right)
             ib.add_index(top_left)
             
         # Last quad: connect the end with the beginning.
             
         # Top left, bottom right, bottom left
         ib.add_index((top_band_start + self.NUM_STEPS_IN_BAND - 1))
         ib.add_index(bottom_band_start)
         ib.add_index((bottom_band_start + self.NUM_STEPS_IN_BAND - 1))
         
         # Top right, bottom right, top left
         ib.add_index(top_band_start)
         ib.add_index(bottom_band_start)
         ib.add_index((top_band_start + self.NUM_STEPS_IN_BAND - 1))
         
         
         top_band_start += self.NUM_STEPS_IN_BAND
         bottom_band_start += self.NUM_STEPS_IN_BAND
         
         
Exemple #10
0
    def __init__(self, layer_id, texture_manager):
        '''
        Constructor
        '''
        RendererObjectManager.__init__(self, layer_id, texture_manager)

        self.vertex_buffer = VertexBuffer(0, True)
        self.color_buffer = ColorBuffer(0, True)
        self.index_buffer = IndexBuffer(0, True)
        self.sun_pos = GeocentricCoordinates(0, 1, 0)

        num_vertices = self.NUM_VERTEX_BANDS * self.NUM_STEPS_IN_BAND
        num_indices = (self.NUM_VERTEX_BANDS - 1) * self.NUM_STEPS_IN_BAND * 6
        self.vertex_buffer.reset(num_vertices)
        self.color_buffer.reset(num_vertices)
        self.index_buffer.reset(num_indices)

        sin_angles = [0.0] * self.NUM_STEPS_IN_BAND
        cos_angles = [0.0] * self.NUM_STEPS_IN_BAND

        angle_in_band = 0
        d_angle = 2 * math.pi / float(self.NUM_STEPS_IN_BAND - 1)
        for i in range(0, self.NUM_STEPS_IN_BAND):
            sin_angles[i] = math.sin(angle_in_band)
            cos_angles[i] = math.cos(angle_in_band)
            angle_in_band += d_angle

        band_step = 2.0 / float((self.NUM_VERTEX_BANDS - 1) + self.EPSILON)

        vb = self.vertex_buffer
        cb = self.color_buffer
        band_pos = 1
        for band in range(0, self.NUM_VERTEX_BANDS):
            a, r, g, b = 0, 0, 0, 0

            if band_pos > 0:
                intensity = long(band_pos * 20 + 50) & 0xFFFFFFFF
                a = 0xFF
                r = (intensity << 16) & 0x00FF0000
                g = (intensity << 16) & 0x0000FF00
                b = (intensity << 16) & 0x000000FF
            else:
                intensity = long(band_pos * 40 + 40) & 0xFFFFFFFF
                color = (intensity << 16) | (intensity << 8) | (intensity)
                a = 0xFF
                r = color & 0x00FF0000
                g = color & 0x0000FF00
                b = color & 0x000000FF

            band_pos -= band_step

            sin_phi = math.sqrt(1 -
                                band_pos * band_pos) if band_pos > -1 else 0
            for i in range(0, self.NUM_STEPS_IN_BAND):
                vb.add_point(
                    Vector3(cos_angles[i] * sin_phi, band_pos,
                            sin_angles[i] * sin_phi))
                cb.add_color(a, r, g, b)

        ib = self.index_buffer

        # Set the indices for the first band.
        top_band_start = 0
        bottom_band_start = self.NUM_STEPS_IN_BAND
        for triangle_band in range(0, self.NUM_VERTEX_BANDS - 1):
            for offset_from_start in range(0, self.NUM_STEPS_IN_BAND - 1):
                # Draw one quad as two triangles.
                top_left = (top_band_start + offset_from_start)
                top_right = (top_left + 1)

                bottom_left = (bottom_band_start + offset_from_start)
                bottom_right = (bottom_left + 1)

                # First triangle
                ib.add_index(top_left)
                ib.add_index(bottom_right)
                ib.add_index(bottom_left)

                # Second triangle
                ib.add_index(top_right)
                ib.add_index(bottom_right)
                ib.add_index(top_left)

            # Last quad: connect the end with the beginning.

            # Top left, bottom right, bottom left
            ib.add_index((top_band_start + self.NUM_STEPS_IN_BAND - 1))
            ib.add_index(bottom_band_start)
            ib.add_index((bottom_band_start + self.NUM_STEPS_IN_BAND - 1))

            # Top right, bottom right, top left
            ib.add_index(top_band_start)
            ib.add_index(bottom_band_start)
            ib.add_index((top_band_start + self.NUM_STEPS_IN_BAND - 1))

            top_band_start += self.NUM_STEPS_IN_BAND
            bottom_band_start += self.NUM_STEPS_IN_BAND