示例#1
0
    def rotation_z(self, theta=0):
        """
        Rotate model.

        :param theta:
        :return:
        """
        self._model = _tr.matmul([_tr.rotation_z(theta), self._model])
示例#2
0
    def uniform_scale(self, s=1):
        """
        Uniform scale model.

        :param s:
        :return:
        """
        self._model = _tr.matmul([_tr.uniform_scale(s), self._model])
示例#3
0
    def apply_temporal_transform(self, t):
        """
        Apply temporal transform to model until drawing.

        :param t:
        :return:
        """
        self._modelPrev = self._model
        self._model = _tr.matmul([t, self._model])
示例#4
0
    def rotation_a(self, theta, axis):
        """
        Rotate model.

        :param theta:
        :param axis:
        :return:
        """
        self._model = _tr.matmul([_tr.rotation_a(theta, axis), self._model])
示例#5
0
    def scale(self, sx=1, sy=1, sz=1):
        """
        Scale model.

        :param sx:
        :param sy:
        :param sz:
        :return:
        """
        self._model = _tr.matmul([_tr.scale(sx, sy, sz), self._model])
示例#6
0
    def translate(self, tx=0, ty=0, tz=0):
        """
        Translate model.

        :param tx:
        :param ty:
        :param tz:
        :return:
        """
        self._model = _tr.matmul([_tr.translate(tx, ty, tz), self._model])
示例#7
0
    def shearing(self, xy=0, yx=0, xz=0, zx=0, yz=0, zy=0):
        """
        Apply shear to model.

        :param xy:
        :param yx:
        :param xz:
        :param zx:
        :param yz:
        :param zy:
        :return:
        """
        self._model = _tr.matmul([_tr.shearing(xy, yx, xz, zx, yz, zy), self._model])
示例#8
0
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

        # Clearing the screen in both, color and depth
        glClear(GL_COLOR_BUFFER_BIT)

        theta = glfw.get_time()
        tx = 0.7 * np.sin(0.5 * theta)
        ty = 0.2 * np.sin(5 * theta)

        # Derivative of tx give us the direction
        dtx = 0.7 * 0.5 * np.cos(0.5 * theta)
        if dtx > 0:
            reflex = tr.scale(-1, 1, 1)
        else:
            reflex = tr.identity()

        # Create booObj transformation
        booT = tr.matmul(
            [tr.translate(tx, ty, 0),
             tr.scale(0.5, 0.5, 1.0), reflex])
        obj_boo.apply_temporal_transform(booT)

        # Draw shapes
        obj_boo.draw()
        obj_question.draw()

        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)

    glfw.terminate()