Exemplo n.º 1
0
    def step(self, moveVector):

        l = vmath.length(moveVector)
        if l > 20.0:
            self.gorlDir = vmath.normalize(moveVector)
            self.__changeStatus(STATUS_RUN)
        elif l > 5.0:
            self.gorlDir = vmath.normalize(moveVector)
            self.__changeStatus(STATUS_WALK)
        else:
            self.__changeStatus(STATUS_STAY)

        r = vmath.dot(self.currentDir, self.gorlDir)
        if r < 0.99:
            n = vmath.cross(self.currentDir, self.gorlDir)
            ROT = vmath.mat_rotationY((1.0-r)*n.y*0.5, 3)
            self.currentDir = vmath.normalize(ROT * self.currentDir)

        if self.currentState == STATUS_RUN:
            self.currentPosition += self.currentDir * 2.0 * core.getElapsedTime()
        elif self.currentState == STATUS_WALK:
            self.currentPosition += self.currentDir * 1.0 * core.getElapsedTime()

        self.__transitMotion()

        self.figure.rotation = vmath.normalize(vmath.quat_rotation((0, 0, 1), self.currentDir))
        self.figure.position = self.currentPosition
        self.figure.step()
Exemplo n.º 2
0
    def draw_contents(self):
        if USE_IGE_CORE:
            core.update()
            d = self.goal - self.pos
            dist = vmath.length(d)
            d = vmath.normalize(d)
            r = vmath.dot(d, self.dir)
            if r < 0.98:
                n = vmath.cross(d, self.dir)
                if n > 0:
                    rot = vmath.mat_rotation(-5.0 * core.getElapsedTime(), 2)
                else:
                    rot = vmath.mat_rotation(5.0 * core.getElapsedTime(), 2)
                self.dir = rot * self.dir

            if dist > 5.0:
                self.pos = self.pos + self.dir * (core.getElapsedTime() *
                                                  100.0)

            self.ship.rotation = vmath.normalize(
                vmath.quat_rotation((0, 1), self.dir))
            self.ship.position = self.pos
            self.camera.shoot(self.showcase)

        else:
            super(TestApp, self).draw_contents()
Exemplo n.º 3
0
    def step(self, moveVector):

        currentDir = vmath.mat33(self.figure.rotation).getCol(2)

        l = vmath.length(moveVector)
        if l > 10.0:
            gorlDir = vmath.normalize(moveVector)
            self.body.linearVelocity = gorlDir * 100.0 * core.getElapsedTime()
        else:
            gorlDir = currentDir
            self.body.linearVelocity = (0, 0, 0)

        self.body.angularVelocity = (0, 0, 0)
        r = vmath.dot(currentDir, gorlDir)
        if r < 0.99:
            n = vmath.cross(currentDir, gorlDir)
            self.body.angularVelocity = (0, n.y * 10.0, 0)

        self.figure.rotation = self.body.rotation
        self.figure.position = self.body.position

        self.figure.setVertexElements('cape', core.ATTRIBUTE_ID_POSITION,
                                      self.soft.meshPositions())
        self.figure.setVertexElements('cape', core.ATTRIBUTE_ID_NORMAL,
                                      self.soft.meshNormals())
Exemplo n.º 4
0
goal = vmath.vec2(0, 0)
pos = vmath.vec2(0, 0)
dir = vmath.vec2(0, 1)

loop = True
while loop:
    core.update()
    touch = core.singleTouch()
    if touch is not None:
        goal = vmath.vec2(touch['cur_x'], touch['cur_y'])

    d = goal - pos
    dist = vmath.length(d)
    d = vmath.normalize(d)
    r = vmath.dot(d, dir)
    if r < 0.98:
        n = vmath.cross(d, dir)
        if n > 0:
            rot = vmath.mat_rotation(-5.0 * core.getElapsedTime(), 2)
        else:
            rot = vmath.mat_rotation(5.0 * core.getElapsedTime(), 2)
        dir = rot * dir

    if dist > 5.0:
        pos = pos + dir * (core.getElapsedTime() * 100.0)

    # update the direction and position of the ship object
    ship.rotation = vmath.normalize(vmath.quat_rotation((0, 1), dir))
    ship.position = pos