def makeHandActor(self, f=1):
     a1, a2, a3, c = (10 * f, 0, 0), (0, 7 * f, 0), (0, 0, 3 * f), (.7, 0.3,
                                                                    0.3)
     palm = Ellipsoid(pos=(0, -3, 0),
                      axis1=a1,
                      axis2=a2,
                      axis3=a3,
                      alpha=0.6,
                      c=c)
     wrist = Box(pos=(0, -9, 0),
                 length=6 * f,
                 width=5,
                 height=2,
                 alpha=0.4,
                 c=c)
     arm = Assembly([palm, wrist])
     self.vp.actors.append(arm)  # add actor to internal list
     f1 = self.vp.add(
         Cylinder((-2, 1.5, 0), axis=(0, 1, 0), height=5, r=.8 * f, c=c))
     f2 = self.vp.add(
         Cylinder((-1, 3, 0), axis=(0, 1, 0), height=6, r=.7 * f, c=c))
     f3 = self.vp.add(
         Cylinder((0, 4, 0), axis=(0, 1, 0), height=6.2, r=.75 * f, c=c))
     f4 = self.vp.add(
         Cylinder((1, 3.5, 0), axis=(0, 1, 0), height=6.1, r=.7 * f, c=c))
     f5 = self.vp.add(
         Cylinder((2, 2, 0), axis=(0, 1, 0), height=5, r=.6 * f, c=c))
     return [arm, f1, f2, f3, f4, f5]
Beispiel #2
0
    def box(self, scale=1):
        """Return the bounding box as a new ``Mesh``.

        :param float scale: box size can be scaled by a factor

        .. hint:: |latex.py|_
        """
        b = self.GetBounds()
        from vtkplotter.shapes import Box
        pos = (b[0] + b[1]) / 2, (b[3] + b[2]) / 2, (b[5] + b[4]) / 2
        length, width, height = b[1] - b[0], b[3] - b[2], b[5] - b[4]
        oa = Box(pos, length * scale, width * scale, height * scale, c='gray')
        if isinstance(self.GetProperty(), vtk.vtkProperty):
            pr = vtk.vtkProperty()
            pr.DeepCopy(self.GetProperty())
            oa.SetProperty(pr)
            oa.wireframe()
        return oa
    def build_keyboard(self):

        if self.verbose: print('Building Keyboard..')
        nts = ("C", "D", "E", "F", "G", "A", "B")
        tol = 0.12
        keybsize = 16.5  # in cm, span of one octave
        wb = keybsize / 7
        nr_octaves = 7
        span = nr_octaves * wb * 7

        self.vp = Plotter(title='PianoPlayer ' + __version__,
                          axes=0,
                          size=(700, 1400),
                          bg='lb',
                          verbose=0)

        #wooden top and base
        self.vp.add(
            Box(pos=(span / 2 + keybsize, 6, 1),
                length=span + 1,
                height=3,
                width=5).texture('wood5'))  #top
        self.vp.add(
            Box(pos=(span / 2 + keybsize, 0, -1),
                length=span + 1,
                height=1,
                width=17).texture('wood5'))
        self.vp.add(
            Text('PianoPlayer ' + __version__,
                 pos=(18, 5.5, 2),
                 depth=.7,
                 c='w'))
        self.vp.add(
            Text('https://github.com/marcomusy/pianoplayer',
                 pos=(105, 4.8, 2),
                 depth=.7,
                 c='w',
                 s=.8))
        leggio = self.vp.add(
            Box(pos=(span / 1.55, 8, 10),
                length=span / 2,
                height=span / 8,
                width=0.08,
                c=(1, 1, 0.9)))
        leggio.rotateX(-20)
        self.vp.add(
            Text('Playing\n\n' + self.songname, pos=[0, 0, 0], s=1.2,
                 c='k').rotateX(70).pos([49, 7, 9]))

        for ioct in range(nr_octaves):
            for ik in range(7):  #white keys
                x = ik * wb + (ioct + 1) * keybsize + wb / 2
                tb = self.vp.add(
                    Box(pos=(x, -2, 0),
                        length=wb - tol,
                        height=1,
                        width=12,
                        c='white'))
                self.KB.update({nts[ik] + str(ioct + 1): tb})
                if not nts[ik] in ("E", "B"):  #black keys
                    tn = self.vp.add(
                        Box(pos=(x + wb / 2, 0, 1),
                            length=wb * .6,
                            height=1,
                            width=8,
                            c='black'))
                    self.KB.update({nts[ik] + "#" + str(ioct + 1): tn})
        self.vp.show(interactive=0)
        self.vp.camera.Azimuth(4)
        self.vp.camera.Elevation(-30)