Пример #1
0
 def __init__(self,
              noise,
              parent,
              x0,
              y0,
              x1,
              y1,
              width,
              height,
              scale=1.0,
              coord=TexCoord.Cylindrical,
              face=0,
              border=1):
     HeightmapPatch.__init__(self, parent, x0, y0, x1, y1, width, height,
                             scale, coord, face, border)
     self.shader = None
     self.texture = None
     self.texture_peeker = None
     self.noise = noise
     self.tex_generator = None
     self.callback = None
     self.cloned = False
     self.texture_offset = LVector2()
     self.texture_scale = LVector2(1, 1)
     self.min_height = None
     self.max_height = None
     self.mean_height = None
Пример #2
0
 def __init__(self, name, width, height, height_scale, u_scale, v_scale,
              median, interpolator):
     Heightmap.__init__(self, name, width, height, height_scale, u_scale,
                        v_scale, median, interpolator)
     self.texture = None
     self.texture_offset = LVector2()
     self.texture_scale = LVector2(1, 1)
     self.tex_id = str(width) + ':' + str(height)
Пример #3
0
 def create_heightmap(self, patch, callback=None, cb_args=()):
     if not patch.str_id() in self.map_patch:
         #TODO: Should be done by inheritance
         if patch.coord == TexCoord.Cylindrical:
             x = patch.sector
             y = patch.ring
             face = -1
         elif patch.coord == TexCoord.Flat:
             x = patch.x
             y = patch.y
             face = -1
         else:
             x = patch.x
             y = patch.y
             face = patch.face
         #TODO: Should be done with a factory
         heightmap = self.patch_factory.create_patch(parent=self,
                                                     x=x,
                                                     y=y,
                                                     lod=patch.lod,
                                                     density=self.size,
                                                     coord=patch.coord,
                                                     face=face)
         self.map_patch[patch.str_id()] = heightmap
         #TODO: Should be linked properly
         heightmap.patch = patch
         if patch.lod > self.max_lod and patch.parent is not None:
             #print("CLONE", patch.str_id())
             parent_heightmap = self.map_patch[patch.parent.str_id()]
             heightmap.copy_from(parent_heightmap)
             delta = patch.lod - heightmap.lod
             scale = 1 << delta
             x_tex = int(x / scale) * scale
             y_tex = int(y / scale) * scale
             x_delta = float(x - x_tex) / scale
             y_delta = float(y - y_tex) / scale
             #Y orientation is the opposite of the texture v axis
             y_delta = 1.0 - y_delta - 1.0 / scale
             if y_delta == 1.0: y_delta = 0.0
             heightmap.texture_offset = LVector2(x_delta, y_delta)
             heightmap.texture_scale = LVector2(1.0 / scale, 1.0 / scale)
             #print(patch.str_id(), ':', parent_heightmap.lod, heightmap.texture_offset, heightmap.texture_scale)
             if callback is not None:
                 callback(heightmap, *cb_args)
         else:
             #print("GEN", patch.str_id())
             heightmap.generate(callback, cb_args)
     else:
         #print("CACHE", patch.str_id())
         heightmap = self.map_patch[patch.str_id()]
         if heightmap.is_ready() and callback is not None:
             callback(heightmap, *cb_args)
         else:
             pass  #print("PATCH NOT READY?", heightmap.heightmap_ready, callback)
Пример #4
0
 def __init__(self, name, width, height, height_scale, median, noise, offset, scale, coord = TexCoord.Cylindrical):
     Heightmap.__init__(self, name, width, height, height_scale, 1.0, 1.0, median)
     self.noise = noise
     self.offset = offset
     self.scale = scale
     self.coord = coord
     self.shader = None
     self.texture = None
     self.texture_offset = LVector2()
     self.texture_scale = LVector2(1, 1)
     self.tex_id = str(width) + ':' + str(height)
Пример #5
0
 def calc_sub_patch(self):
     self.copy_from(self.parent_heightmap)
     delta = self.patch.lod - self.lod
     scale = 1 << delta
     if self.patch.coord != TexCoord.Flat:
         x_tex = int(self.x / scale) * scale
         y_tex = int(self.y / scale) * scale
         x_delta = float(self.x - x_tex) / scale
         y_delta = float(self.y - y_tex) / scale
     else:
         x_tex = int(self.x * scale) / scale
         y_tex = int(self.y * scale) / scale
         x_delta = float(self.x - x_tex)
         y_delta = float(self.y - y_tex)
     self.texture_offset = LVector2(x_delta, y_delta)
     self.texture_scale = LVector2(1.0 / scale, 1.0 / scale)
Пример #6
0
 def __init__(self,
              parent,
              x0,
              y0,
              x1,
              y1,
              width,
              height,
              scale=1.0,
              coord=TexCoord.Cylindrical,
              face=-1,
              border=1):
     self.parent = parent
     self.x0 = x0
     self.y0 = y0
     self.x1 = x1
     self.y1 = y1
     self.scale = scale
     self.width = width
     self.height = height
     self.coord = coord
     self.face = face
     self.border = border
     self.r_width = self.width + self.border * 2
     self.r_height = self.height + self.border * 2
     self.r_x0 = self.x0 - float(
         self.border) / self.width * (self.x1 - self.x0)
     self.r_x1 = self.x1 + float(
         self.border) / self.width * (self.x1 - self.x0)
     self.r_y0 = self.y0 - float(
         self.border) / self.height * (self.y1 - self.y0)
     self.r_y1 = self.y1 + float(
         self.border) / self.height * (self.y1 - self.y0)
     self.dx = self.r_x1 - self.r_x0
     self.dy = self.r_y1 - self.r_y0
     self.lod = None
     self.patch = None
     self.heightmap_ready = False
     self.texture = None
     self.texture_peeker = None
     self.callback = None
     self.cloned = False
     self.texture_offset = LVector2()
     self.texture_scale = LVector2(1, 1)
     self.min_height = None
     self.max_height = None
     self.mean_height = None
Пример #7
0
 def __init__(self, font_family, font_size=14, owner=None):
     self.window = None
     self.layout = None
     self.last_pos = None
     self.font_size = font_size
     self.owner = owner
     self.scale = LVector2(*settings.ui_scale)
     self.text_scale = (self.scale[0] * self.font_size,
                        self.scale[1] * self.font_size)
     self.borders = (self.font_size, 0, self.font_size / 4.0,
                     self.font_size / 4.0)
     self.width = settings.default_window_width
     self.height = settings.default_window_height
Пример #8
0
    def convert_vector(self, vector):
        """
        Convert a OpenVR vector into a Panda3D vector. No coordinate system conversion is performed.
        """

        if len(vector.v) == 4:
            result = LVector4(vector.v[0], vector.v[1], vector.v[2],
                              vector.v[3])
        elif len(vector.v) == 3:
            result = LVector3(vector.v[0], vector.v[1], vector.v[2])
        elif len(vector.v) == 2:
            result = LVector2(vector.v[0], vector.v[1])
        return result
Пример #9
0
 def __init__(self, time, font_family, font_size=14, owner=None):
     self.time = time
     self.window = None
     self.layout = None
     self.last_pos = None
     self.font_size = font_size
     self.owner = owner
     self.scale = LVector2(*settings.ui_scale)
     self.text_scale = (self.scale[0] * self.font_size,
                        self.scale[1] * self.font_size)
     self.borders = (self.font_size, 0, self.font_size / 4.0,
                     self.font_size / 4.0)
     self.width = settings.default_window_width
     self.height = settings.default_window_height
     self.day_entry = None
     self.month_entry = None
     self.year_entry = None
     self.hour_entry = None
     self.min_entry = None
     self.sec_entry = None
Пример #10
0
    def __init__(self, pos):
        self.parts = ()
        self.firstRoomParts = ()
        self.secondRoomParts = ()
        self.thirdRoomParts = ()
        self.iceCubesSecondRoom = ()
        self.iceCubesThirdRoom = ()
        self.bigCube = 0
        self.white = LVector4(1, 1, 1, 1)
        self.innerwalltex = loader.loadTexture("caverock.jpg")
        self.snowTex = loader.loadTexture("ground.jpg")

        #Creates an array of ice cube velocities for the cube spinning that will be exhibited in room three.
        self.iceCubeVel = ()

        cube1Vel = LVector2(1, 0)
        self.iceCubeVel += (cube1Vel, )

        cube2Vel = LVector2(1, 0)
        self.iceCubeVel += (cube2Vel, )

        cube3Vel = LVector2(0, 1)
        self.iceCubeVel += (cube3Vel, )

        cube4Vel = LVector2(0, 1)
        self.iceCubeVel += (cube4Vel, )

        cube5Vel = LVector2(-1, 0)
        self.iceCubeVel += (cube5Vel, )

        cube6Vel = LVector2(0, -1)
        self.iceCubeVel += (cube6Vel, )

        cube7Vel = LVector2(0, -1)
        self.iceCubeVel += (cube7Vel, )

        cube8Vel = LVector2(-1, 0)
        self.iceCubeVel += (cube8Vel, )

        self.corn1 = 0
        self.corn2 = 0
        self.corn3 = 0
        self.corn4 = 0

        ########
        #
        #   ENTRANCE OF CAVE
        #
        ########
        self.entrance = Prism(pos, 200, 500, 50, self.white, self.snowTex,
                              'entrance')
        self.parts += (self.entrance, )

        self.setFirstRoom()
        '''
        Add all parts of the first room of the cave into the cave part queue
        '''
        for p in self.firstRoomParts:
            self.parts += (p, )
        '''
        Add all parts of the second room of the cave into the cave part queue
        '''
        for p in self.secondRoomParts:
            self.parts += (p, )
        '''
        Add all parts of the third room of the cave into the cave part queue
        '''
        for p in self.thirdRoomParts:
            self.parts += (p, )
        '''
        Add all ice cubes of second room to the cave part queue
        '''
        for p in self.iceCubesSecondRoom:
            self.parts += (p, )
        '''
        Add all ice cubes of third room to the cave part queue
        '''
        for p in self.iceCubesThirdRoom:
            self.parts += (p, )

        self.parts += (self.bigCube, )
Пример #11
0
 def calc_scale(self):
     screen_width = base.pipe.getDisplayWidth()
     screen_height = base.pipe.getDisplayHeight()
     self.scale = LVector2(1.0 / screen_width * 2.0,
                           1.0 / screen_height * 2.0)