Пример #1
0
    def test_array(self):

        p = SuperPoint(3.0, 4.0)
        arr = ObjArray(p)
        arr.append(p)
        arr.append(p)
        p = SuperPoint(7.0, 9.0)
        arr.append(p)

        code = """
index = 2
temp = arr[index]
p1 = temp.x
temp.y = 12.34
        """
        arg = ArrayArg('arr', arr)
        arg1 = FloatArg('p1', 4.4)
        shader = Shader(code=code, args=[arg, arg1])
        shader.compile()
        shader.prepare([Runtime()])
        shader.execute()
        val = shader.get_value('p1')
        self.assertAlmostEqual(val, 7.0)
        obj = arr[2]
        self.assertAlmostEqual(obj.y, 12.34, 6)
Пример #2
0
    def test_array(self):

        p = SuperPoint(3.0, 4.0)
        arr = ObjArray(p)
        arr.append(p)
        arr.append(p)
        p = SuperPoint(7.0, 9.0)
        arr.append(p)

        code = """
index = 2
temp = arr[index]
p1 = temp.x
temp.y = 12.34
        """
        arg = ArrayArg('arr', arr)
        arg1 = FloatArg('p1', 4.4)
        shader = Shader(code=code, args=[arg, arg1])
        shader.compile()
        shader.prepare([Runtime()])
        shader.execute()
        val = shader.get_value('p1')
        self.assertAlmostEqual(val, 7.0)
        obj = arr[2]
        self.assertAlmostEqual(obj.y, 12.34, 6)
Пример #3
0
    def add(self, name, shape):
        if name in self._names_shapes:
            raise ValueError("Shape %s allready exist" % name)

        if shape in self._shape_addr:
            raise ValueError("Shape allready exist", shape)

        self._names_shapes[name] = shape
        self._shapes_names[shape] = name
        if type(shape) not in self._shape_arrays:
            darr = ObjArray(shape)
            self._shape_arrays[type(shape)] = darr
            idx = 0
        else:
            darr = self._shape_arrays[type(shape)]
            idx = len(darr)

        darr.append(shape)
        self._shape_addr[shape] = idx
        self._update_bbox(shape)
Пример #4
0
    def add(self, name, shape):
        if name in self._names_shapes:
            raise ValueError("Shape %s allready exist" % name)

        if shape in self._shape_addr:
            raise ValueError("Shape allready exist", shape)

        self._names_shapes[name] = shape
        self._shapes_names[shape] = name
        if type(shape) not in self._shape_arrays:
            darr = ObjArray(shape)
            self._shape_arrays[type(shape)] = darr
            idx = 0
        else:
            darr = self._shape_arrays[type(shape)]
            idx = len(darr)

        darr.append(shape)
        self._shape_addr[shape] = idx
        self._update_bbox(shape)
Пример #5
0
    def load(self, shader_name, color_mgr):

        text = self._loader.load(shader_name, 'props.txt')
        args = []
        if text is not None:
            args = parse_args(text)
        code = self._loader.load(shader_name, 'code.py')
        if code is None:
            raise ValueError("Integrator %s code is missing!" % shader_name)

        #array of shadepoints for debuging purpose
        sp = ShadePoint.factory(color_mgr.zero())
        arr = ObjArray(sp)
        for i in range(10):
            arr.append(sp)
        arg = ArrayArg('path_array', arr)
        args.append(arg)

        hdr_buffer = StructArg('hdr_buffer', ImagePRGBA(1, 1))
        args.append(hdr_buffer)
        self.shader = Shader(code=code, args=args)
        self._color_mgr = color_mgr
Пример #6
0
    def load(self, shader_name, color_mgr):

        text = self._loader.load(shader_name, 'props.txt')
        args = []
        if text is not None:
            args = parse_args(text)
        code = self._loader.load(shader_name, 'code.py')
        if code is None:
            raise ValueError("Integrator %s code is missing!" % shader_name)

        #array of shadepoints for debuging purpose
        sp = ShadePoint.factory(color_mgr.zero())
        arr = ObjArray(sp)
        for i in range(10):
            arr.append(sp)
        arg = ArrayArg('path_array', arr)
        args.append(arg)

        hdr_buffer = StructArg('hdr_buffer', ImagePRGBA(1, 1))
        args.append(hdr_buffer)
        self.shader = Shader(code=code, args=args)
        self._color_mgr = color_mgr