Exemplo n.º 1
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.º 2
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.º 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
    def __transitMotion(self):
        if self.currentState != self.nextState:

            if self.transitTime >= TRANSIT_TIME:
                self.currentState = self.nextState
                self.figure.connectAnimator(core.ANIMETION_SLOT_A0, STATE_MOTION[self.currentState])
                self.figure.connectAnimator(core.ANIMETION_SLOT_A1)
                return

            self.transitTime += core.getElapsedTime()
            if self.transitTime > TRANSIT_TIME:
                self.transitTime = TRANSIT_TIME
            self.figure.setBlendingWeight(core.ANIMETION_PART_A, self.transitTime / TRANSIT_TIME)
Exemplo n.º 5
0
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

    # update core
    core.update()

    # render the objects contained in showcase from the camera.
Exemplo n.º 6
0
    curY = 0
    press = 0
    touch = core.singleTouch()
    if touch != None:
        curX = touch['cur_x'] + w // 2
        curY = -touch['cur_y'] + h // 2
        press = touch['is_holded'] | touch['is_moved']
    impl.process_inputs()

    core.update()

    camera.shoot(showcase)
    if _particle is not None:
        _particle.shoot(camera.projectionMatrix,
                        vmath.inverse(camera.viewInverseMatrix),
                        core.getElapsedTime())

    imgui.new_frame()
    imgui.begin("Effekseer", True, imgui.WINDOW_ALWAYS_AUTO_RESIZE)

    changed, effect_current = imgui.combo("Effects", effect_current,
                                          effect_list)
    if changed is True:
        _particle.stop_all_effects()
        _handle = _particle.add(effect_list[effect_current],
                                loop=_loop_enabled)
        _particle.set_dynamic_input(_handle, _dynamic)
        _particle.set_location(_handle, _position[0], _position[1],
                               _position[2])
        _particle.set_scale(_handle, _scale[0], _scale[1], _scale[2])
Exemplo n.º 7
0
# open or resize window (This function is valid only on PC,Ignored in smartphone apps)
core.window(True, 480, 640)

cam = core.camera("maincam")
cam.orthographicProjection = True
cam.position = vmath.vec3(0.0, 0.0, 100.0)

showcase = core.showcase()

boxes = []

world = world(gravity=(0, -10), doSleep=True)
boxes.append(DynamicBox(world, showcase, (0, -100), (150, 20), 0, True))
boxes.append(DynamicBox(world, showcase, (10, 100), (10, 5), 15))

while True:
    core.update()
    touch = core.singleTouch()
    if touch is not None and touch['is_pressed']:
        boxes.append(
            DynamicBox(world, showcase, (touch['cur_x'], touch['cur_y']),
                       (10, 5), 15))

    world.Step(core.getElapsedTime(), 10, 10)
    for box in boxes:
        box.update()

    core.update()
    cam.shoot(showcase)
    core.swap()
Exemplo n.º 8
0
    curY = 0
    press = 0
    touch = core.singleTouch()
    if touch != None:
        curX = touch['cur_x'] + w // 2
        curY = -touch['cur_y'] + h // 2
        press = touch['is_holded'] | touch['is_moved']
    impl.process_inputs()

    core.update()

    camera.shoot(showcase)
    if _particle is not None:
        _particle.shoot(camera.projectionMatrix,
                        vmath.inverse(camera.viewInverseMatrix),
                        core.getElapsedTime(),
                        update=_update_enabled,
                        render=_render_enabled,
                        culling=_culling_enabled)

    imgui.new_frame()
    imgui.begin("Effekseer", True, imgui.WINDOW_ALWAYS_AUTO_RESIZE)

    changed, effect_current = imgui.combo("Effects", effect_current,
                                          effect_list)
    if changed is True:
        _particle.stop_all_effects()
        for seq in range(_particle_nb):
            _handle = _particle.add(effect_list[effect_current],
                                    loop=_loop_enabled)
            _particle.set_dynamic_input(_handle, _dynamic)