Beispiel #1
0
global mode
global canvas

#Variables are defined here
#Aiqu modes, EYE, RADIO, WEATHER, SLEEP, DEEP
mode = "EYE"

#sleepTimer = 0
sleeping = False

state = eye.NEUTRAL
oldState = state

detectTimer = 0

LOGGER = pi3d.Log(level='DEBUG', file='aiqu.log')


def wakeup():
    LOGGER.info('WAKE UP!')
    state = eye.NEUTRAL
    mode = "EYE"
    sleeping = False
    sleepTimer = time.time()


def tex_load(DISPLAY, fname):
    ''' return a slide object'''
    slide = Slide()
    if not os.path.isfile(fname):
        return None
Beispiel #2
0
method to make models conform (aproximately) to the surface of an ElevationMap.
The tank gun is raised as the mouse view point to looking up. This shows how to
combine various rotations about different axes without the objects falling apart!
This demo also uses a tkinter tkwindow but creates it as method of Display. Compare
with the system used in demos/MarsStation.py
Also look out for:
2D shader usage. Drawing onto an ImageSprite canvas placed in front of the camera
imediately after reset() This is used to generate a splash screed during file
loading and to draw a telescopic site view and a navigation map
"""
import math, random, time, traceback

import demo
import pi3d

LOGGER = pi3d.Log(__name__, level='INFO')

# Create a Tkinter window
winw, winh, bord = 1200, 600, 0     #64MB GPU memory setting
# winw,winh,bord = 1920,1200,0   #128MB GPU memory setting

DISPLAY = pi3d.Display.create(tk=True, window_title='Tiger Tank demo in Pi3D',
                        w=winw, h=winh - bord, far=3000.0,
                        background=(0.4, 0.8, 0.8, 1), frames_per_second=16)

#inputs = InputEvents()
#inputs.get_mouse_movement()

pi3d.Light(lightpos=(-1, -1, 1), lightcol =(0.8, 0.8, 0.8), lightamb=(0.30, 0.30, 0.32))

win = DISPLAY.tkwin
Beispiel #3
0
#!/usr/bin/python
from __future__ import absolute_import, division, print_function, unicode_literals
""" TigerTank demo but with cast shadows
"""
import math, random, time, traceback

import demo
import pi3d

LOGGER = pi3d.Log(__name__, 'INFO')

# Create a Tkinter window
winw, winh, bord = 1200, 800, 0  #64MB GPU memory setting
# winw,winh,bord = 1920,1200,0   #128MB GPU memory setting

DISPLAY = pi3d.Display.create(tk=True,
                              window_title='Tiger Tank demo in Pi3D',
                              w=winw,
                              h=winh - bord,
                              far=3000.0,
                              background=(0.4, 0.8, 0.8, 1),
                              frames_per_second=16)

#inputs = InputEvents()
#inputs.get_mouse_movement()

mylight = pi3d.Light(lightpos=(1.0, -1.0, 1.0),
                     lightcol=(0.8, 0.8, 0.8),
                     lightamb=(0.10, 0.10, 0.12))

win = DISPLAY.tkwin
Beispiel #4
0
        self.re_init(pts=self.loc)  # reform opengles array_buffer


if __name__ == '__main__':
    from status_display import StatusDisplay

    print("""
    Space to start
    ESC to quit
    """)

    IMAGE_SIZE = 900
    PIXEL_SIZE = 5

    KEYBOARD = pi3d.Keyboard()
    LOGGER = pi3d.Log(__name__, level='INFO', file='info.log')

    BACKGROUND_COLOR = (0.3, 0.3, 0.3, 1.0)
    DISPLAY = pi3d.Display.create(background=BACKGROUND_COLOR,
                                  frames_per_second=10)
    HWIDTH, HHEIGHT = int(DISPLAY.width / 2.0), int(DISPLAY.height / 2.0)
    CAMERA = pi3d.Camera(at=(HWIDTH, -HHEIGHT, 0),
                         eye=(HWIDTH, -HHEIGHT, -0.1),
                         is_3d=False)

    points = ImageRandomiser("MasterclassImage960.png", IMAGE_SIZE, IMAGE_SIZE,
                             PIXEL_SIZE, CAMERA)
    status = StatusDisplay(925, -50, CAMERA)
    status.display_list(['team1', 'team2', 'team3', 'team4'])

    remaining_rows = list(range(0, points.num_pixels_h))
Beispiel #5
0
#!/usr/bin/python

from __future__ import absolute_import, division, print_function, unicode_literals
"""This demo shows the use of special transition shaders on the Canvas 
shape for 2D drawing. Also threading is used to allow the file access to 
be done in the background.
"""
import random, time, glob, threading
import demo
import pi3d

from six_mod.moves import queue

LOGGER = pi3d.Log(__name__, level='INFO', format='%(message)s')
LOGGER.info('''#########################################################
press ESC to escape, S to go back, any key for next slide
#########################################################''')

# Setup display and initialise pi3d
DISPLAY = pi3d.Display.create(background=(0.0, 0.0, 0.0, 1.0),
                              frames_per_second=20)
shader = [
    pi3d.Shader("shaders/blend_holes"),
    pi3d.Shader("shaders/blend_false"),
    pi3d.Shader("shaders/blend_burn"),
    pi3d.Shader("shaders/blend_bump")
]

iFiles = glob.glob("textures/*.*")
iFiles.sort()
nFi = len(iFiles)
Beispiel #6
0
import os
import threading
import time
import math
import pi3d
from .hmd import OpenHMD
from . import Gamepad

# Greetings programs...

# Created By User: Wayne Keenan
# ( [email protected]  /  https://twitter.com/wkeenan  /  https://github.com/WayneKeenan )

DEBUG = False

LOGGER = pi3d.Log(level='DEBUG', format='%(message)s')

DEFAULT_TARGET_FPS = 60

# Oculus DK2 HMD resolution (also need to update /boot/config.txt)
#DEFAULT_HMD_SCREEN_WIDTH=1920
#DEFAULT_HMD_SCREEN_HEIGHT=1080

# PSVR Resolution chosen by Pi "best for display"
DEFAULT_HMD_SCREEN_WIDTH = 1824
DEFAULT_HMD_SCREEN_HEIGHT = 984

DEFAULT_AVATAR_EYE_HEIGHT = 6.0
DEFAULT_AVATAR_MOVEMENT_SPEED = 1.0
DEFAULT_AVATAR_VIEW_SPEED = 1.0
Beispiel #7
0
This demo also shows the use of an additional orthographic camera for
rendering the string in 2D. If you change the Display size you will see
that the text stays the same size, also the text will be rendered on top
of the 3d view. x and y locations for the text represent pixel offsets
from the centre of the screen
"""
import math, random, time

import demo
import sys
if sys.version_info[0] == 3:
  unichr = chr

import pi3d

LOGGER = pi3d.Log(level='INFO', format='%(message)s')
# or you can log to file, or use default format, try uncommenting
#LOGGER = pi3d.Log(__name__, level='DEBUG', file='dump.txt')
#LOGGER = pi3d.Log(__name__, level='ERROR')
''' to display all the pi3d module logging activity you must leave the
name argument blank (it will default to None) this will set the logger
to the root logger i.e.
'''
#LOGGER = pi3d.Log(level='DEBUG')
# these can be changed subsequently using LOGGER.set_logs()
MESSAGE = """\
blurring
with
distance!
---------
justified
Beispiel #8
0
averageYaccel = 0.0
averageZaccel = 0.0
spanAcceleration = 1  #30 yielded good results
earthGAccel = -0.96
averageZgyr = 0.0
pi3d.opengles.glDisable(pi3d.GL_CULL_FACE)
#x=80,y=100,w= 1000, h = 1000, background=(0,0,0,1),use_pygame=True,frames_per_second = 30
#DISPLAY = pi3d.Display.create()
DISPLAY = pi3d.Display.create(x=80,
                              y=100,
                              w=1000,
                              h=1300,
                              background=(0, 0, 0, 1),
                              use_pygame=True,
                              frames_per_second=30)
LOGGER = pi3d.Log(level='INFO', file='pi3d.log')
shader = pi3d.Shader('uv_light')
pi3d.Light(lightpos=(1, -1, -3),
           lightcol=(1.0, 1.0, 0.8),
           lightamb=(0.25, 0.2, 0.3))

flatsh = pi3d.Shader("uv_flat")
asteroidShader = pi3d.Shader("uv_light")
spaceShipTexture = pi3d.Texture('spaceshipTexture.jpg')
asteroidSmall = pi3d.Texture('asteroidSmall.jpg')
asteroidBig = pi3d.Texture('asteroidBig.jpg')
asteroidMed = pi3d.Texture('asteroidM.jpg')
backgroundTexture = pi3d.Texture('background.png')
dangerZoneTexture = pi3d.Texture('dangerZone.jpg')
safeZoneTexture = pi3d.Texture('safeZone.jpg')
ship = pi3d.Sphere(z=20.0)
Beispiel #9
0
import demo
import pi3d

MAX_BALLS = 25
MIN_BALL_SIZE = 5
MAX_BALL_SIZE = 40
MAX_BALL_VELOCITY = 10.0

BACKGROUND_COLOR = (1.0, 1.0, 1.0, 0.0)
DISPLAY = pi3d.Display.create(background=BACKGROUND_COLOR, frames_per_second=30)
WIDTH, HEIGHT = DISPLAY.width, DISPLAY.height
ZPLANE = 1000
fov = 2.0 * math.degrees(math.atan(HEIGHT/2.0/ZPLANE))
# logger created before other pi3d components to allow logging, NB no name set
LOGGER = pi3d.Log(level='INFO') #, file='temp.txt') # to file to see log with ncurses keyboard

KEYBOARD = pi3d.Keyboard()

CAMERA = pi3d.Camera((0, 0, 0), (0, 0, -1.0),
                (1, 1100, fov,
                 WIDTH / float(HEIGHT)))
SHADER = pi3d.Shader('uv_flat')

TEXTURE_NAMES = ['textures/red_ball.png',
                 'textures/grn_ball.png',
                 'textures/blu_ball.png']
TEXTURES = [pi3d.Texture(t) for t in TEXTURE_NAMES]

def random_ball(b):
  """Return a ball with a random color, position and velocity."""