def __init__(self, color: Vector, strength: float, position: Point3D,
              direction: Point3D, fov: float, isCircular: bool):
     Light.__init__(self, color, strength)
     self.position = position
     self.direction = direction
     self.fov = fov
     self.isCircular = isCircular
Beispiel #2
0
class Scene:
    def __init__(self):
        self.ground = Ground()
        self.chimney = ChimneyFactory().createRandomChimney()
        self.light = Light()
        self.camera = Camera()

    def generate_scene(self):
        self.ground.draw()
        self.chimney.draw()
        self.light.draw()

    def color_all(self):
        mat = MaterialFactory().create_random_color()
        chimney = self.chimney.get_object()
        mat.add_to_object(chimney)

    def prepare_camera(self):
        self.camera.place()
        self.camera.update()
        self.camera.setup_format()

    def render(self, filePath):
        self.camera.prepare_render(filePath)
        self.camera.render()

    def clear(self):
        bpy.ops.object.select_all(action="SELECT")
        bpy.ops.object.delete(use_global=False)
        for block in bpy.data.meshes:
            if block.users == 0:
                bpy.data.meshes.remove(block)

        for block in bpy.data.materials:
            if block.users == 0:
                bpy.data.materials.remove(block)

        for block in bpy.data.textures:
            if block.users == 0:
                bpy.data.textures.remove(block)

        for block in bpy.data.images:
            if block.users == 0:
                bpy.data.images.remove(block)

        for block in bpy.data.cameras:
            if block.users == 0:
                bpy.data.cameras.remove(block)

    def get_annotation_chimney(self):
        scene = bpy.context.scene
        camera = bpy.data.objects["Camera"]
        box = self.chimney.get_box()
        result = get_annot_chimney(scene, camera, box)
        return result

    def annotate(self):
        points_cheminee = self.get_annotation_chimney()
        return ({"points": points_cheminee, "label": "cheminee", "difficult": 0},)
Beispiel #3
0
 def __init__(self):
     """ Creates a new point light. Remember to set a position
     and a radius """
     Light.__init__(self)
     DebugObject.__init__(self, "PointLight")
     self.spacing = 0.5
     self.bufferRadius = 0.0
     self.typeName = "PointLight"
Beispiel #4
0
 def __init__(self):
     """ Creates a new point light. Remember to set a position
     and a radius """
     Light.__init__(self)
     DebugObject.__init__(self, "PointLight")
     self.spacing = 0.5
     self.bufferRadius = 0.0
     self.typeName = "PointLight"
    def __init__(self):
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")

        self._spacing = 0.6
        self.radius = 99999999999.0
        self.position = Vec3(0)
        self.bounds = OmniBoundingVolume()
    def __init__(self):
        """ Constructs a new directional light. You have to set a
        direction for this light to work properly"""
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
Beispiel #7
0
    def __init__(self, lightName, lightNum, 
                    ambient = Light.ambientDefault,
                    diffuse = Light.diffuseDefault, 
                    specular = Light.specularDefault,
                    direction = directionDefault):
        
        Light.__init__(self, lightName, lightNum, ambient, diffuse, specular)

        self.__direction = Vec3d(direction[0], direction[1], direction[2], 0.0)
Beispiel #8
0
 def __init__(self):
     """ Constructs a new directional light. You have to set a
     direction for this light to work properly"""
     Light.__init__(self)
     DebugObject.__init__(self, "GIHelperLight")
     self.typeName = "GIHelperLight"
     self.targetLight = None
     self.filmSize = 50
     self.bounds = OmniBoundingVolume()
Beispiel #9
0
 def loadColorsAndLight(self):
     self.rot = sm(np.array([200, 0, 0]), self.reflection)
     self.gruen = sm(np.array([0, 200, 0]), self.reflection)
     self.blau = sm(np.array([0, 0, 200]), self.reflection)
     self.gelb = sm(np.array([200, 200, 0]))
     self.grey2 = sm(np.array([100, 100, 100]), self.reflection)
     self.grey = cm(np.array([200, 200, 200]), np.array([0, 0, 0]))
     self.background_color = np.array([0, 0, 0])
     self.licht = Light(np.array([-30, 30, 10]), np.array([255, 255, 255]))
Beispiel #10
0
class HardwareAPI(Thread):
    isRunning = True

    powerLight = Light(3, 'Power')
    wifiLight = Light(5, 'Wifi')
    networkLight = Light(7, 'Network')

    resetButton = Button(11, 'Reset')
    volumeButton = Button(13, 'Volume')
    alarmButton = Button(15, 'Alarm')
    intercomButton = Button(19, 'Intercom')

    threads.append(powerLight)
    threads.append(wifiLight)
    threads.append(networkLight)
    threads.append(resetButton)
    threads.append(volumeButton)
    threads.append(alarmButton)
    threads.append(intercomButton)

    def __init__(self):
        Thread.__init__(self)

        # Start lights
        self.powerLight.start()
        self.wifiLight.start()
        self.networkLight.start()

        # Start buttons
        self.resetButton.start()
        self.volumeButton.start()
        self.alarmButton.start()
        self.intercomButton.start()

        print('Hardware API Initialized!')

    def kill(self):
        self.isRunning = False
        self.powerLight.kill()
        self.wifiLight.kill()
        self.networkLight.kill()
        self.resetButton.kill()
        self.volumeButton.kill()
        self.alarmButton.kill()
        self.intercomButton.kill()

    def run(self):
        try:
            while self.isRunning:
                None
        finally:
            print('Hardware API - Waiting for threads to finish')
            for i, t in enumerate(threads):
                t.join()
                print('Hardware API - Thread {} Stopped'.format(i))
            GPIO.cleanup()
            print('Hardware API Finished')
Beispiel #11
0
    def reflection2(self, surface=Surface(), light_in=Light()):
        # second way to get reflection

        # first to get meeting point
        mp_t0 = self.get_mp_and_t0(surface, light_in)

        # set the source and time
        light_r = Light()
        light_r.set_s(np.array([mp_t0[0], mp_t0[1], mp_t0[2]]))
        light_r.set_t(np.arange(0, mp_t0[3] + mp_t0[3] / 10, mp_t0[3] / 10))

        # get n vector , v_i
        n = surface.get_n()
        v_i = light_in.get_v()

        # get v_i shadow on n vector
        v_is = np.dot(-v_i, n) / sqrt(np.dot(n, n))
        # get sin vector p
        p = v_is + v_i
        # get v_r
        v_r = 2 * p - v_i

        # set light_r._v
        light_r.set_v(v_r)
        return light_r
Beispiel #12
0
    def __init__(self):
        self.screen_size = (800, 800)
        self.ballObject = Ball(400, 400, 0, 200)  # x, y, z, r
        self.ballObject.setMaterialToMetal()
        self.LightObject = Light(400, 400, 400, 83)  # x, y, z, power
        self.Ia = 87
        self.Ka = 0.39
        self.fatt = 0.63

        super().__init__()

        if (len(sys.argv) > 1 and sys.argv[1] == "--debug"):
            nSlider = QSlider(Qt.Horizontal, self)
            nSlider.setGeometry(10, 10, 100, 10)
            nSlider.valueChanged[int].connect(self.changeN)
            self.labelN = QLabel("N=" + str(self.ballObject.n), self)
            self.labelN.setGeometry(110, 10, 50, 10)

            ksSlider = QSlider(Qt.Horizontal, self)
            ksSlider.setGeometry(10, 20, 100, 10)
            ksSlider.valueChanged[int].connect(self.changeKs)
            self.labelKs = QLabel("Ks=" + str(self.ballObject.Ks), self)
            self.labelKs.setGeometry(110, 20, 50, 10)

            kdSlider = QSlider(Qt.Horizontal, self)
            kdSlider.setGeometry(10, 30, 100, 10)
            kdSlider.valueChanged[int].connect(self.changeKd)
            self.labelKd = QLabel("Kd=" + str(self.ballObject.Kd), self)
            self.labelKd.setGeometry(110, 30, 50, 10)

            iaSlider = QSlider(Qt.Horizontal, self)
            iaSlider.setGeometry(10, 160, 100, 10)
            iaSlider.valueChanged[int].connect(self.changeIa)
            self.labelIa = QLabel("Ia=" + str(self.Ia), self)
            self.labelIa.setGeometry(110, 160, 50, 10)

            kaSlider = QSlider(Qt.Horizontal, self)
            kaSlider.setGeometry(10, 170, 100, 10)
            kaSlider.valueChanged[int].connect(self.changeKa)
            self.labelKa = QLabel("Ka=" + str(self.Ka), self)
            self.labelKa.setGeometry(110, 170, 50, 10)

            ipSlider = QSlider(Qt.Horizontal, self)
            ipSlider.setGeometry(10, 180, 100, 10)
            ipSlider.valueChanged[int].connect(self.changeIp)
            self.labelIp = QLabel("Ip=" + str(self.LightObject.power), self)
            self.labelIp.setGeometry(110, 180, 50, 10)

            fattSlider = QSlider(Qt.Horizontal, self)
            fattSlider.setGeometry(10, 190, 100, 10)
            fattSlider.valueChanged[int].connect(self.changeFatt)
            self.labelFatt = QLabel("fatt=" + str(self.fatt), self)
            self.labelFatt.setGeometry(110, 190, 50, 10)
Beispiel #13
0
    def transmisson2(self,
                     surface=Surface(),
                     light_in=Light(),
                     n1=1,
                     n2=1.3330):
        # teacher's way
        # in parameter will get error, when set n1, n2 to n_air and n_water, so directly use value
        # return the transmisson light

        # get n vector , v_i
        n = surface.get_n()
        v_i = light_in.get_v()

        # set n1,n2 must judge the light way with n
        if np.dot(n, v_i) < 0:
            n1 = surface.get_n1()
            n2 = surface.get_n2()
        else:
            n2 = surface.get_n1()
            n1 = surface.get_n2()
            n = -n

        # get meeting point and time
        mp_t0 = self.get_mp_and_t0(surface, light_in)

        # set the source and time
        light_t = Light()
        light_t.set_s(np.array([mp_t0[0], mp_t0[1], mp_t0[2]]))
        light_t.set_t(np.arange(0, mp_t0[3] + mp_t0[3] / 10, mp_t0[3] / 10))

        # sin(theta1),sin(theta2),cos(theta1),cos(theta2)
        cos1 = np.dot(-v_i, n) / sqrt(np.dot(v_i, v_i) * np.dot(n, n))
        sin1 = sqrt(1 - cos1**2)
        sin2 = n1 * sin1 / n2
        cos2 = sqrt(1 - sin2**2)

        # calculate brust angle
        sin2_b = 1
        sin1_b = n2 * sin2_b / n1

        # check special case, n vector is equal with -v_i, directly trans
        if (np.cross(n, -v_i) == [0, 0, 0]).all():
            v_t = v_i
        else:
            # check brust case
            if (n1 >= n2) & (sin1 >= sin1_b):
                v_t = np.array([0, 0, 0])

            # normal case
            else:
                v_tx = np.cross(np.cross(n, v_i), n) * n1 / n2
                v_ty = -sqrt(np.dot(v_i, v_i) - np.dot(v_tx, v_tx)) * n

                v_t = v_tx + v_ty
        light_t.set_v(np.array([v_t[0], v_t[1], v_t[2]]))
        return light_t
    def handle(self):
        data = self.request.recv(1024).decode("UTF-8").strip('\r\n') # Get the data from the client and immediatly strip off \r\n chars and make a String out of it!

        if(len(data) > 1):
            try:
                lightName = Light(data.rsplit('get light ')[1])
                self.request.send(bytes(lightName.getStatus().encode("UTF-8")))

                logging.append("request for " + data + " from client " + self.client_address[0])
            except ValueError:
                logging.append("ERROR! light " + data.rsplit('get light ')[1] + " doesn't exist!")
                self.request.send(b"false")
        else :
            self.request.send(b"false")
    def __init__(self):
        """ Constructs a new directional light. You have to set a
        direction for this light to work properly"""
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"
        self.splitCount = 4
        self.pssmTargetCam = None
        self.pssmTargetLens = None
        self.pssmFarPlane = 100.0
        self.pssmSplitPow = 2.0
        self.updateIndex = 0

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
Beispiel #16
0
    def run_plot(self,
                 list_surface=[Surface()],
                 light_in=Light(),
                 i=1,
                 size=2):
        # i is the times to t and r, size is the large of surface
        list_tree_surface = self.lightrun(list_surface, light_in, i)
        tree_light = list_tree_surface[0]
        list_surface = list_tree_surface[1]

        fig = plt.Figure()
        ax = plt.axes(projection='3d')
        # get all light to plot
        list_light = tree_light.level_queue(tree_light.root)
        # plot light and surface
        for light in list_light:
            light.plot(fig, ax)
        for surface in list_surface:
            x_p = surface.get_p()[0]
            y_p = surface.get_p()[1]
            surface.plot(fig,
                         ax,
                         x=np.arange(-size + x_p, size + x_p, size / 5),
                         y=np.arange(-size + y_p, size + y_p, size / 5))

        plt.show()
Beispiel #17
0
def test():
    w = Window(2)
    d = Door(2.0)
    l = Light(95)
    r = Rad(3000)
    r = Room("Living room", 12, 15, 10, 10.5, r, d, l, w)
    print(r.get_length())
    print(r.get_width())
    print(r.get_height())
    print(r.getSqrFt())
    print(r.get_area())

    r.set_length(9)
    r.set_width(15)
    r.set_height(12)

    print(r.get_length())
    print(r.get_width())
    print(r.get_height())
    print(r.getSqrFt())
    print(r.get_area())

    r.change_temp(-1)
    print(r.get_temp())

    print(r)
Beispiel #18
0
 def popup_dismissed(self, _id, hexcolor, rgbcolor, buttoninstance):
     buttoninstance.background_color = rgbcolor
     xy = self.convert_hex_to_xy(hexcolor)
     x = round(xy[0], 4)
     y = round(xy[1], 4)
     xy = [x, y]
     Light.ChangeColor(self, _id, xy)
Beispiel #19
0
    def get_mp_and_t0(self, surface=Surface(), light=Light()):
        # mp is meetingpoint , t0 is the meeting time
        mp_t0 = np.array([0, 0, 0, 0])

        # get n,v_i,s
        n = surface.get_n()
        v_i = light.get_v()
        s = light.get_s()
        # for the case light and surface parallel, n*v' =0, and source is on surface, (s-p)*n'=0
        # let the point and time be 100
        if np.dot(n, v_i) == 0:
            t0 = 0
            mp_t0 = [0, 0, 0, 0]
        # source on surface
        else:
            if np.dot((s - surface.get_p()), n) == 0:
                mp_t0 = [s[0], s[1], s[2], 0]
            else:
                x, y, z, t0 = symbols('x y z t0')
                light_in_t0 = light.get_light_in_t0(t0)
                # get surface eqn for 1
                eq1 = surface.get_eqn(x, y, z)
                # eqn2 for x
                eq2 = Eq(x, light_in_t0[0])
                eq3 = Eq(y, light_in_t0[1])
                eq4 = Eq(z, light_in_t0[2])
                sol = linsolve([eq1, eq2, eq3, eq4], [x, y, z, t0])
                mp_t0 = next(iter(sol))
        return mp_t0
Beispiel #20
0
def test4():
    ''' Normal case, one time reflection and one time transmisson , light in air through the air.
        data : light source [-1 0 1], light vector [1 0 -1], surface is xoy,n1=1 n2=1
        esay to hand calculate 
               light_r.s = [0,0,0] light_r.vector = [1,0,1]
               light_t.s = [0,0,0] lgiht_t.vector = [1,0,-1]
    '''
    light_i = Light(np.array([-1, 0, 1]), np.array([1, 0, -1]))
    surface = Surface()
    list_surface = [surface]
    phy = Physical()

    list_tree_surface = phy.lightrun(list_surface, light_i, 1)
    tree_light = list_tree_surface[0]
    list_surface = list_tree_surface[1]
    list_light = tree_light.level_queue(tree_light.root)

    light_r = list_light[2]
    light_t = list_light[1]

    b1 = (light_r.get_s() == np.array([0, 0, 0])).all()
    b2 = (light_r.get_v() == np.array([1, 0, 1])).all()
    b3 = (light_t.get_s() == np.array([0, 0, 0])).all()
    b4 = (light_t.get_v() == np.array([1, 0, -1])).all()
    assert b1 & b2 & b3 & b4
Beispiel #21
0
 def loadScripts(self, dir):
     import sys
     sys.path.insert(0, "./scripts")
     from Script import Script
     s = Script(self, "test")
     from loading import Loading
     l = Loading(self.segments[0])
     self.scripts.append(l)
     from TheaterChase import TheaterChase
     t = TheaterChase(self.segments[0])
     self.scripts.append(t)
     from rainbow import Rainbow
     r = Rainbow(self.segments[0])
     self.scripts.append(r)
     from LeftToRightRandom import LeftToRightRandom
     lr = LeftToRightRandom(self.segments[0])
     self.scripts.append(lr)
     from RandomLed import RandomLed
     r = RandomLed(self.segments[0])
     self.scripts.append(r)
     from Light import Light
     self.scripts.append(Light(self.segments[0]))
     from Test import Test
     self.scripts.append(Test(self.segments[0]))
     from Cycle import Cycle
     self.scripts.append(Cycle(self.segments[0]))
     from SingleColor import SingleColor
     self.scripts.append(SingleColor(self.segments[0]))
Beispiel #22
0
    def __init__(self, lightName, lightNum, 
                    ambient = Light.ambientDefault,
                    diffuse = Light.diffuseDefault, 
                    specular = Light.specularDefault,
                    position = positionDefault,
                    atConstant = constantAttenuationDefault,
                    atLinear = linearAttenuationDefault,
                    atQuadratic = quadraticAttnuationDefault):

        Light.__init__(self, lightName, lightNum, ambient, diffuse, specular)

        self.__position = Vec3d(position[0], position[1], position[2], 1)

        self.__atConstant = atConstant
        self.__atLinear = atLinear
        self.__atQuadratic = atQuadratic
Beispiel #23
0
 def get_lights(self):
     lights = []
     response = requests.get(self.url + '/lights')
     if (self.success(response)):
         for num, info in response.json().items():
             state = info['state']
             light = Light(num, state)
             lights.append(light)
     return lights
Beispiel #24
0
def run5():
    surface = Surface(np.array([0, 1, 0]), np.array([0, 0, 1]),
                      Surface().get_n_air(),
                      Surface().get_n_water())
    list_surface = [surface]
    # light
    light_i = Light(np.array([0, 1, 0]), np.array([0, 0, 0]))
    # run
    Physical().run_plot(list_surface, light_i, 1, 10)
Beispiel #25
0
    def handle(self):
        data = self.request.recv(1024).decode("UTF-8").strip(
            '\r\n'
        )  # Get the data from the client and immediatly strip off \r\n chars and make a String out of it!

        if (len(data) > 1):
            try:
                lightName = Light(data.rsplit('get light ')[1])
                self.request.send(bytes(lightName.getStatus().encode("UTF-8")))

                logging.append("request for " + data + " from client " +
                               self.client_address[0])
            except ValueError:
                logging.append("ERROR! light " + data.rsplit('get light ')[1] +
                               " doesn't exist!")
                self.request.send(b"false")
        else:
            self.request.send(b"false")
Beispiel #26
0
def run8():
    surface1 = Surface(np.array([0, 0, 0]), np.array([1, 0, 0]))
    surface2 = Surface(np.array([0, 0, 0]), np.array([0, 0, 1]))
    surface3 = Surface(np.array([3, 0, 0]), np.array([1, 0, 0]))

    list_surface = [surface1, surface2, surface3]

    light_i = Light(np.array([0, 0, 1]), np.array([1, 0, -1]))

    Physical().run_plot(list_surface, light_i, 3, 6)
Beispiel #27
0
def run7():
    surface1 = Surface(np.array([0, 0, 0]), np.array([0, 0, 1]),
                       Surface().get_n_air(),
                       Surface().get_n_water())

    list_surface = [surface1]

    light_i = Light(np.array([0, 0, 1]), np.array([0.1, 0.1, -1]))

    Physical().run_plot(list_surface, light_i)
Beispiel #28
0
def run1():
    # light
    light_i = Light(np.array([-3, 5, 3]), np.array([1, 0, 0]))
    # surface
    surface = Surface(np.array([0, 1, 0]), np.array([0, 0, 1]),
                      Surface().get_n_air(),
                      Surface().get_n_water())
    list_surface = [surface]
    # run
    Physical().run_plot(list_surface, light_i, 1, 5)
Beispiel #29
0
    def __init__(self):
        """ Creates a new spot light. """
        Light.__init__(self)
        DebugObject.__init__(self, "SpotLight")
        self.typeName = "SpotLight"

        self.nearPlane = 0.5
        self.radius = 30.0
        self.spotSize = Vec2(30, 30)

        # Used to compute the MVP
        self.ghostCamera = Camera("PointLight")
        self.ghostCamera.setActive(False)
        self.ghostLens = PerspectiveLens()
        self.ghostLens.setFov(130)
        self.ghostCamera.setLens(self.ghostLens)
        self.ghostCameraNode = NodePath(self.ghostCamera)
        self.ghostCameraNode.reparentTo(Globals.render)
        self.ghostCameraNode.hide()
Beispiel #30
0
    def lightrun(self, list_surface=[Surface()], light_in=Light(), i_t=1):
        # i_t is reflection times and trans times
        # this function will simulate the ray, and return a tree and list_surface
        tree_light = Tree()
        tree_light.add(light_in)
        # this will be a for command for i_t
        for i in range(i_t):
            # calcute for list_surface
            # get myQueue length
            q_length = len(tree_light.myQueue)
            # run over myQueue,to add new light in tree, but we build a new list, queue is dynamic
            # select light
            list_light_temp = []
            for index in range(q_length):
                light_temp = tree_light.myQueue[index].elem
                list_light_temp.append(light_temp)

            for light_temp in list_light_temp:
                if light_temp == None:
                    # no light to reflect
                    tree_light.add(None)
                    tree_light.add(None)
                else:
                    # get p,t,surface
                    list_mpts = self.get_mp_t0_and_surface(
                        list_surface, light_temp)
                    mp_t0 = list_mpts[0]
                    surface_m = list_mpts[1]
                    # judge if surface is None
                    if surface_m == None:
                        # no reflect and transmisson
                        tree_light.add(None)
                        tree_light.add(None)
                    else:
                        # set the current light_in time
                        # find light_temp index in tree, through it's dynamic, bud no influence, cause if light_temp is finish , we dont need that
                        for i in range(len(tree_light.myQueue)):
                            if tree_light.myQueue[i].elem == light_temp:
                                index = i

                        tree_light.myQueue[index].elem.set_t(
                            np.arange(0, mp_t0[3] + mp_t0[3] / 10,
                                      mp_t0[3] / 10))
                        # set the point in surface is meeting point to save the value to plot
                        list_surface_index = list_surface.index(surface_m)
                        # mp = [mp_t0[0], mp_t0[1], mp_t0[2]]
                        # list_surface[list_surface_index].set_p(np.array(mp))

                        # calcute trans and ref
                        light_t_temp = self.transmisson2(surface_m, light_temp)
                        light_r_temp = self.reflection(surface_m, light_temp)
                        # add to tree
                        tree_light.add(light_t_temp)
                        tree_light.add(light_r_temp)
        return [tree_light, list_surface]
Beispiel #31
0
    def __init__(self, file_name):
        global active_camera
        self.models = None
        self.cameras = None
        self.lights = None
        self.active_camera = active_camera

        # shared resources
        self.textures = {}  # name -> tex lookup
        self.shaders = {}  # name -> tex lookup
        self.meshes = {}  # name -> tex lookup

        with open(file_name, "r") as fp:
            data = json.load(fp)

        # models
        self.models = {name: Model(m) for (name, m) in data["models"].items()}
        for model in self.models.values():
            vert_file = model.io['shader']['vert']
            frag_file = model.io['shader']['frag']
            shader_name = vert_file.split('.')[0]
            shader = ResourceManager.get_shader(shader_name)
            if not shader:
                shader = Shader(vert_file, frag_file)
                ResourceManager.add_shader(shader_name, shader)
            model.shader = shader

            mesh_name = model.io['mesh']  # contains relative path string
            mesh = ResourceManager.get_mesh(mesh_name)
            if not mesh:
                mesh = Mesh(mesh_name)
                ResourceManager.add_mesh(mesh_name, mesh)
            model.mesh = mesh

            tex_files = model.io['textures']
            for (layer, tex_file) in tex_files.items():
                tex = ResourceManager.get_texture(tex_file)
                if not tex:
                    tex = Texture(tex_file)
                    ResourceManager.add_texture(tex_file, tex)
                model.textures[layer] = tex

        # cameras, set first camera to active
        self.cameras = {
            name: Camera(c)
            for (name, c) in data["cameras"].items()
        }
        if len(self.cameras) > 0:
            # get first items value
            active_camera = next(iter(self.cameras.items()))[1]
        logging.warn('camera needs to set shader uniforms')

        # lights
        self.lights = {name: Light(l) for (name, l) in data["lights"].items()}
        logging.warn('light needs to set shader uniforms')
Beispiel #32
0
    def __init__(self):
        """ Constructs a new directional light. """
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"

        # If you change the split count, change DIRECTIONAL_LIGHT_SPLIT_COUNTS
        # in Shader/Includes/Configuration.include aswell! This is hardcoded
        # to improve performance
        self.splitCount = 6

        self.pssmTargetCam = Globals.base.cam
        self.pssmTargetLens = Globals.base.camLens
        self.pssmFarPlane = 150
        self.pssmSplitPow = 2.0
        self.sunDistance = 7000
        self.updateIndex = 0

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
    def __init__(self):
        """ Constructs a new directional light. You have to set a
        direction for this light to work properly"""
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"

        # If you change the split count, change DIRECTIONAL_LIGHT_SPLIT_COUNTS
        # in Shader/Includes/Configuration.include aswell! This is hardcoded
        # to improve performance
        self.splitCount = 5

        self.pssmTargetCam = Globals.base.cam
        self.pssmTargetLens = Globals.base.camLens
        self.pssmFarPlane = 150.0
        self.pssmSplitPow = 2.0
        self.updateIndex = 0

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
Beispiel #34
0
    def __init__(self) :

        # Create a controller for leap
        self.controller = Leap.Controller()

        # From classes
        self.model = Model3D()
        self.camera = Camera()
        self.light = Light()

        # Common variables
        self.rotate = 0.0
 def update(self, lightName, status):
     light = Light(lightName)
     light.set_status(status)
     return "Het gaat om lamp " + lightName + " en zijn nieuwe status is " + status
Beispiel #36
0
from Input import Input
from Light import Light

light = Light(4)
light.status()
light.turnOn()
light.turnOff()
 def setPos(self, pos):
     """ Sets the position of the spotlight """
     self.ghostCameraNode.setPos(pos)
     Light.setPos(self, pos)
 def cleanup(self):
     """ Internal method which gets called when the light got deleted """
     self.ghostCameraNode.removeNode()
     Light.cleanup(self)
 def index(self, lightname, status):
     light = Light(lightname)
     light.set_status(status)