示例#1
0
def Init():
	global curPic
	global canvas
	global disp
	global soundTex
	global q
	
	#Max out the analog volume
	os.system("amixer cset numid=1 400") 
	
	#Create black display with 2D flat shader and Canvas object
	disp = Display.create(background=(0.0, 0.0, 0.0, 1.0), x=0, y=0)
	shader = Shader("/home/pi/Frame/pi3d/shaders/2d_flat")
	canvas = Canvas()
	canvas.set_shader(shader)
	
	#Queue for gmail thread
	q = Queue.Queue()
	
	InitGmail()
	
	random.seed()
	
	#The image to be displayed whilst a sound is being played
	soundTex = Texture("/home/pi/Frame/pi3d/sound.jpg")
	
	#Init GPIO pins. Buttons on 7 and 8 for shutdown and snapchat functions. Snapchat indicator LED on 25.
	GPIO.setmode(GPIO.BCM)
	GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(8, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(25, GPIO.OUT, initial=GPIO.LOW)
	
	#Process all unprocessed pics
	ResizePics()
	
	#Load all processed pics
	FindPics()
	
	#Shuffle the list
	Shuffle()
	
	#Load the first, but wait until it's done
	LoadPic(0, True)
	curPic = 1
	
	#Display the loaded pic
	SwapBuffers()
示例#2
0
    def __init__(self):
        super(Pi3dDisplay, self).__init__()
        self.timeout = Expression.convert(Settings.get('network', 'timeout'))
        keywords = {}

        background = Settings.get('pi3d', 'background')
        if background:
            keywords.update(background=background)

        dimensions = Settings.get('pi3d', 'dimensions')
        if dimensions:
            x, y, width, height = dimensions
            keywords.update(x=x, y=y, width=width, height=height)

        for k in ['aspect', 'depth', 'far', 'near', 'tk', 'window_title']:
            keywords[k] = Settings.get('pi3d', k)

        from pi3d import Display
        self.display = Display.create(**keywords)
        Settings.add_client(self)
        Shader.SHADER()
示例#3
0
    def __init__(self):
        super(Pi3dDisplay, self).__init__()
        self.timeout = Expression.convert(Settings.get('network', 'timeout'))
        keywords = {}

        background = Settings.get('pi3d', 'background')
        if background:
            keywords.update(background=background)

        dimensions = Settings.get('pi3d', 'dimensions')
        if dimensions:
            x, y, width, height = dimensions
            keywords.update(x=x, y=y, width=width, height=height)

        for k in ['aspect', 'depth', 'far', 'near', 'tk', 'window_title']:
            keywords[k] = Settings.get('pi3d', k)

        from pi3d import Display
        self.display = Display.create(**keywords)
        Settings.add_client(self)
        Shader.SHADER()
示例#4
0
文件: Amazing.py 项目: akissu/pi3d
print("############################################################")
print("Esc to quit, W to go forward, Mouse to steer, Space to jump.")

print("N.B. W now works as a TOGGLE one press to go one to stop.")

print("At the edge you will turn into a ghost and be able to fly ")
print("and pass through rocks! There are limited numbers of jumps.")
print("Good turnings are often greener and tend to be near")
print("(but in the opposite direction to) big holes")
print("############################################################")
print("If you get touched by a monster you will return to the start!")
print("############################################################")
print()

# Setup display and initialise pi3d
DISPLAY = Display.create(x=100, y=100, background=(0.4, 0.8, 0.8, 1))

shader = Shader("shaders/uv_reflect")
flatsh = Shader("shaders/uv_flat")
#========================================

# load Textures
rockimg1 = Texture("textures/techy1.jpg")
rockimg2 = Texture("textures/rocktile2.jpg")
tree2img = Texture("textures/tree2.png")
raspimg = Texture("textures/Raspi256x256.png")
monstimg = Texture("textures/pong2.jpg")
monsttex = Texture("textures/floor_nm.jpg")
shineimg = Texture("textures/stars.jpg")

# environment cube
示例#5
0
from pi3d.Keyboard import Keyboard
from pi3d.Mouse import Mouse
from pi3d.Texture import Texture

from pi3d.Light import Light
from pi3d.Camera import Camera
from pi3d.Shader import Shader

from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.EnvironmentCube import loadECfiles
from pi3d.shape.Model import Model

from pi3d.util.Screenshot import screenshot

# Setup display and initialise pi3d
DISPLAY = Display.create(x=100, y=100)
DISPLAY.set_background(1.0,0.4,0.6,1)    	# r,g,b,alpha
Light((5, -10, -20), (0.6, 0.6, 0.5), (0.3, 0.3, 0.4))

# load shader
shader = Shader("shaders/uv_light")
flatsh = Shader("shaders/uv_flat")

print("==============================================================")
print("Instructions:")
print("")
print("Keys-             W - Forward,")
print("        A - Left   S - Back     D - right")
print("")
print("Move mouse to pan view.  Click mouse to exit or press ESCAPE")
print("==============================================================")
示例#6
0
文件: Clouds3d.py 项目: Arexxk/pi3d
from pi3d.Camera import Camera
from pi3d.Shader import Shader

z = 0
x = 0
speed = 1
widex = 100
widey = 80
cloudno = 20
cloud_depth = 350.0
zd = 1.0 * cloud_depth / cloudno

MARGIN = 100

# Setup display and initialise pi3d
DISPLAY = Display.create(x=MARGIN, y=MARGIN)
scnx = DISPLAY.width
scny = DISPLAY.height

DISPLAY.set_background(0,0.7,1,1)
shader = Shader("shaders/uv_flat")
#############################

cloudTex = []
cloudTex.append(Texture("textures/cloud2.png",True))
cloudTex.append(Texture("textures/cloud3.png",True))
cloudTex.append(Texture("textures/cloud4.png",True))
cloudTex.append(Texture("textures/cloud5.png",True))
cloudTex.append(Texture("textures/cloud6.png",True))

# Setup cloud positions and cloud image refs
示例#7
0
文件: Blur.py 项目: Arexxk/pi3d
from pi3d.Keyboard import Keyboard
from pi3d.Camera import Camera

from pi3d.Light import Light
from pi3d.Shader import Shader

from pi3d.util.String import String
from pi3d.util.Ttffont import Ttffont
from pi3d.util.Defocus import Defocus
from pi3d.util.Screenshot import screenshot
from pi3d.shape.MergeShape import MergeShape
from pi3d.shape.Sphere import Sphere
from pi3d.shape.Sprite import Sprite

# Setup display and initialise pi3d
DISPLAY = Display.create(x=10, y=10, w=900, h=600, frames_per_second=25)
DISPLAY.set_background(0.4, 0.6, 0.8, 1.0)      # r,g,b,alpha

persp_cam = Camera.instance() # default instance camera perspecive view
ortho_cam = Camera(is_3d=False) # 2d orthographic view camera

#setup textures, light position and initial model position
Light((0, 5, 0))
#create shaders
shader = Shader("shaders/uv_reflect")
flatsh = Shader("shaders/uv_flat")
defocus = Defocus()

#Create textures
shapeimg = Texture("textures/straw1.jpg")
shapebump = Texture("textures/floor_nm.jpg", True)
示例#8
0
from pi3d.util.Screenshot import screenshot
from pi3d.util.TkWin import TkWin

from pi3d.Light import Light

from pi3d.event.Event import InputEvents

LOGGER = Log.logger(__name__)

# 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 = Display.create(tk=True, window_title='Tiger Tank demo in Pi3D',
                        w=winw, h=winh - bord, far=2200.0,
                        background=(0.4, 0.8, 0.8, 1), frames_per_second=16)

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

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

win = DISPLAY.tkwin

shader = Shader('shaders/uv_reflect')
flatsh = Shader('shaders/uv_flat')
shade2d = Shader('shaders/2d_flat')

#========================================
# create splash screen and draw it
def main():
    print("pi3d Geodesic Plotter: {}".format(argv))
    if len(argv) < 2:
        raise Exception('>>> ERROR! Please supply a parameter file name <<<')
    parameters = loads(open(argv[1]).read())['IC']
    interval = parameters['plotratio']
    m = parameters['M'] if 'M' in parameters else 1.0
    a = parameters['Lfac'] if 'Lfac' in parameters else parameters['a'] if 'a' in parameters else 1.0
    a2 = a**2
    # Setup display and initialise pi3d
    display = Display.create(x=0, y=0, frames_per_second=0)
    display.set_background(0, 0, 0, 1)  # r,g,b,alpha
    # Camera
    camera = Camera()
    rot = tilt = 0
    rot_tilt = True
    cam_rad = 30.0
    # Bodies
    body_shader = Shader("mat_light")
    track_shader = Shader("mat_flat")
    black_hole = Body(body_shader, (0.0, 0.0, 1.0), m * (1.0 + sqrt(1.0 - a2)), position=[0.0, 0.0, 0.0])
    particle = Body(body_shader, (0.0, 1.0, 0.0), 0.125, track_shader=track_shader)
    # Enable key presses
    axis = Lines(vertices=[(0, 0, 5,), (0, 0, -5,)])
    keys = Keyboard()
    # Display scene
    counter = 1
    cumulative_error = 0.0
    line = stdin.readline()
    while display.loop_running():
        data = loads(line)
        # monitor errors
        current_error = data['v4e']
        cumulative_error += current_error if current_error >= 0.0 else -current_error
        # camera control
        if rot_tilt:
            camera.reset()
            camera.rotate(-tilt, rot, 0)
            camera.position((cam_rad * sin(radians(rot)) * cos(radians(tilt)), cam_rad * sin(radians(tilt)),
                             -cam_rad * cos(radians(rot)) * cos(radians(tilt))))
            rot_tilt = False
        # plot the black hole
        black_hole.position_and_draw()
        axis.draw()
        # plot the orbiter
        if counter % interval == 0:
            r = float(data['r'])
            th = float(data['th'])
            ph = float(data['ph'])
            ra_sth = sqrt(r**2 + a2) * sin(th)
            particle.pos = [ra_sth * cos(ph), ra_sth * sin(ph), r * cos(th)]
            particle.set_material(error_colour(current_error))
            particle.position_and_draw(trace_material=error_colour(cumulative_error / counter))
        # process keyboard input
        key = keys.read()
        if key > -1:
            rot_tilt = True
            if key == 112:
                screenshot("orbit.jpg")
            elif key == 119:  # key W rotate camera up
                tilt += 2.0
            elif key == 115:  # kry S down
                tilt -= 2.0
            elif key == 97:  # key A left
                rot -= 2
            elif key == 100:  # key D right
                rot += 2
            elif key == 61:  # key += in
                cam_rad -= 0.5
            elif key == 45:  # key _- out
                cam_rad += 0.5
            elif key == 27:
                keys.close()
                display.destroy()
                break
        # prepare for next iteration
        line = stdin.readline()
        counter += 1
        if not line:
            display.stop()
示例#10
0
from pi3d.Keyboard import Keyboard
from pi3d.Camera import Camera

from pi3d.Light import Light
from pi3d.Shader import Shader

from pi3d.util.String import String
from pi3d.util.Ttffont import Ttffont
from pi3d.util.Defocus import Defocus
from pi3d.util.Screenshot import screenshot
from pi3d.shape.MergeShape import MergeShape
from pi3d.shape.Sphere import Sphere
from pi3d.shape.Sprite import Sprite

# Setup display and initialise pi3d
DISPLAY = Display.create(x=10, y=10, w=900, h=600, frames_per_second=25)
DISPLAY.set_background(0.4, 0.6, 0.8, 1.0)  # r,g,b,alpha

persp_cam = Camera.instance()  # default instance camera perspecive view
ortho_cam = Camera(is_3d=False)  # 2d orthographic view camera

#setup textures, light position and initial model position
Light((0, 5, 0))
#create shaders
shader = Shader("shaders/uv_reflect")
flatsh = Shader("shaders/uv_flat")
defocus = Defocus()

#Create textures
shapeimg = Texture("textures/straw1.jpg")
shapebump = Texture("textures/floor_nm.jpg", True)
示例#11
0
from pi3d.Camera import Camera
from pi3d.Shader import Shader

z = 0
x = 0
speed = 1
widex = 100
widey = 80
cloudno = 20
cloud_depth = 350.0
zd = 1.0 * cloud_depth / cloudno

MARGIN = 100

# Setup display and initialise pi3d
DISPLAY = Display.create(x=MARGIN, y=MARGIN)
scnx = DISPLAY.width
scny = DISPLAY.height

DISPLAY.set_background(0, 0.7, 1, 1)
shader = Shader("shaders/uv_flat")
#############################

cloudTex = []
cloudTex.append(Texture("textures/cloud2.png", True))
cloudTex.append(Texture("textures/cloud3.png", True))
cloudTex.append(Texture("textures/cloud4.png", True))
cloudTex.append(Texture("textures/cloud5.png", True))
cloudTex.append(Texture("textures/cloud6.png", True))

# Setup cloud positions and cloud image refs
示例#12
0
import demo

from pi3d import Display
from pi3d.Keyboard import Keyboard
from pi3d.Texture import Texture
from pi3d.Camera import Camera
from pi3d.Shader import Shader
from pi3d.shape.Canvas import Canvas

print("#########################################################")
print("press ESC to escape, S to go back, any key for next slide")
print("#########################################################")

# Setup display and initialise pi3d
DISPLAY = Display.create(background=(0.0, 0.0, 0.0, 0.0), x=100, y=100)
shader = Shader("shaders/2d_flat")
#############################
slide = [None]*5
sz = [None]*5
iFiles = glob.glob("textures/*.jpg")
nFiles = len(iFiles)

def tex_load(fname, j, slide, sz):
  """ here the images are scaled to fit the Display size, if they were to be
  rendered pixel for pixel as the original then the mipmap=False argument would
  be used, which is faster, and w and h values set to the Texture size i.e.

  tex = Texture(f, mipmap=False)
  ...
  wi, hi = tex.ix, tex.iy
示例#13
0
from pi3d import Display
from pi3d.Keyboard import Keyboard
from pi3d.Mouse import Mouse
from pi3d.Texture import Texture
from pi3d.Camera import Camera
from pi3d.Shader import Shader

from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.EnvironmentCube import loadECfiles

from pi3d.util.Screenshot import screenshot
from pi3d.util import Utility

# Setup display and initialise pi3d
DISPLAY = Display.create(x=50, y=50)

shader = Shader('shaders/uv_flat')
#========================================

#select the environment cube with 'box'...
box = 3
if box == 0:
    ectex = [Texture('textures/ecubes/skybox_interstellar.jpg')]
    myecube = EnvironmentCube(size=900.0, maptype='CROSS')
elif box == 1:
    ectex = [Texture('textures/ecubes/SkyBox.jpg')]
    myecube = EnvironmentCube(size=900.0, maptype='HALFCROSS')
elif box == 2:
    ectex = loadECfiles('textures/ecubes', 'sbox_interstellar', nobottom=True)
    myecube = EnvironmentCube(size=900.0, maptype='FACES', nobottom=True)
示例#14
0
from pi3d.shape.Model import Model
from pi3d.shape.Sprite import ImageSprite

from pi3d.util.Screenshot import screenshot
from pi3d.util.TkWin import TkWin

from pi3d.Light import Light

rads = 0.017453292512  # degrees to radians

#Create a Tkinter window in Display
winw,winh = 200, 600   	#64MB GPU memory setting
#winw,winh = 1920,1180	#128MB GPU memory setting

DISPLAY = Display.create(tk=True, window_title='ConferenceHall demo in Pi3D',
                        w=winw, h=winh, far=2200.0, fov = 60,
                        background=(0.4, 0.8, 0.8, 1), frames_per_second=20)
win = DISPLAY.tkwin

#Setup shaders
flatsh = Shader("shaders/uv_flat")
shade2d = Shader('shaders/2d_flat')

# create splash screen and draw it 
splash = ImageSprite("textures/pi3d_splash.jpg", shade2d, w=10, h=10, z=0.2)
splash.draw()
DISPLAY.swap_buffers()

#Setup environment cube
ectex = EnvironmentCube.loadECfiles("textures/ecubes/Miramar", "miramar_256", "png", nobottom = True)
myecube = EnvironmentCube.EnvironmentCube(size=1800.0, maptype="FACES", nobottom=True)
示例#15
0
from pi3d import Display
from pi3d.Keyboard import Keyboard
from pi3d.Mouse import Mouse
from pi3d.Texture import Texture
from pi3d.Camera import Camera
from pi3d.Shader import Shader

from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.EnvironmentCube import loadECfiles

from pi3d.util.Screenshot import screenshot
from pi3d.util import Utility

# Setup display and initialise pi3d
DISPLAY = Display.create(x=50, y=50)

shader = Shader('shaders/uv_flat')
#========================================

#select the environment cube with 'box'...
box = 3
if box == 0:
  ectex = [Texture('textures/ecubes/skybox_interstellar.jpg')]
  myecube = EnvironmentCube(size=900.0, maptype='CROSS')
elif box == 1:
  ectex = [Texture('textures/ecubes/SkyBox.jpg')]
  myecube = EnvironmentCube(size=900.0, maptype='HALFCROSS')
elif box == 2:
  ectex = loadECfiles('textures/ecubes','sbox_interstellar', nobottom=True)
  myecube = EnvironmentCube(size=900.0, maptype='FACES', nobottom=True)
示例#16
0
"""
import demo

from pi3d.util import Utility
from pi3d import Display
from pi3d.Keyboard import Keyboard

from pi3d.Shader import Shader

from pi3d.shape.Model import Model
from pi3d.util.Screenshot import screenshot

# Setup display and initialise pi3d
DISPLAY = Display.create(x=50,
                         y=50,
                         w=-100,
                         h=-100,
                         background=(0.2, 0.4, 0.6, 1))

shader = Shader('shaders/uv_light')
#========================================

# load model_loadmodel
mymodel = Model(file_string='models/Triceratops/Triceratops.egg',
                name='Triceratops',
                x=0,
                y=-1,
                z=40,
                sx=0.005,
                sy=0.005,
                sz=0.005)
示例#17
0
def main():
    print(f'Multi 3D ODE Plotter: {argv}', file=stderr)
    argc = len(argv) - 1
    if argc == 0 or argc == 1:  # single particle plot from stdin, optional arg is track length
        files = [stdin]
    elif argc == 7:  # called by IC script, 1 + 6 particle file names
        files = []
        for arg in argv[1:]:
            files.append(open(arg))
    else:
        raise Exception('>>> ERROR! Please supply 1, 2 or 7 arguments! <<<')
    # Setup display and initialise pi3d
    display = Display.create(x=0, y=0, frames_per_second=60)
    display.set_background(0, 0, 0, 1)  # r,g,b,alpha
    # Camera
    camera = Camera()
    rot, tilt = 135.0, 90.0 - 54.73561
    cam_rad = 50.0
    font = Font(
        '/usr/share/fonts/truetype/liberation2/LiberationMono-Regular.ttf',
        color='green',
        codepoints='-0123456789. txyz:=+',
        font_size=18)
    font.blend = True
    hud = String(
        camera=Camera(is_3d=False),
        font=font,
        is_3d=False,
        string=f' t {0.0:-5.1f}  x {0.0:-5.1f}  y {0.0:-5.1f}  z {0.0:-5.1f}')
    hud.set_shader(Shader('uv_flat'))
    (lt, bm, ft, rt, tp, bk) = hud.get_bounds()
    hud.position((-display.width + rt - lt) / 2.0,
                 (0.9 * display.height - tp + bm) / 2.0, 1.0)
    hud.draw(
    )  # NB has to be drawn before quick_change() is called as buffer needs to exist
    particles = []
    if argc == 0:
        particles.append(
            Body(Shader('mat_light'), (0.0, 1.0, 1.0),
                 0.1,
                 track_shader=Shader('mat_flat')))
    elif argc == 1:
        particles.append(
            Body(Shader('mat_light'), (0.0, 1.0, 1.0),
                 0.05,
                 track_shader=Shader('mat_flat'),
                 track_max=int(argv[1])))
    elif argc == 7:
        particles.append(
            Body(Shader('mat_light'), (0.0, 1.0, 1.0),
                 0.1,
                 track_shader=Shader('mat_flat')))
        particles.append(
            Body(Shader('mat_light'), (0.0, 1.0, 1.0),
                 0.1,
                 track_shader=Shader('mat_flat')))
        particles.append(
            Body(Shader('mat_light'), (1.0, 1.0, 0.0),
                 0.1,
                 track_shader=Shader('mat_flat')))
        particles.append(
            Body(Shader('mat_light'), (1.0, 1.0, 0.0),
                 0.1,
                 track_shader=Shader('mat_flat')))
        particles.append(
            Body(Shader('mat_light'), (1.0, 0.0, 1.0),
                 0.1,
                 track_shader=Shader('mat_flat')))
        particles.append(
            Body(Shader('mat_light'), (1.0, 0.0, 1.0),
                 0.1,
                 track_shader=Shader('mat_flat')))
        particles.append(
            Body(Shader('mat_light'), (1.0, 1.0, 1.0),
                 0.1,
                 track_shader=Shader('mat_flat')))
    # Enable key presses and mouse
    keys = Keyboard()
    mouse = Mouse(restrict=False)
    mouse.start()
    omx, omy = mouse.position()
    # Display scene
    while display.loop_running():
        # prepare for next iteration
        lines = []
        for file in files:
            lines.append(file.readline())
        if not lines[0]:
            display.stop()
        data = [[float(item) for item in lines[0].split()[:4]]]
        if argc == 7:
            data = []
            for line in lines:
                data.append([float(item) for item in line.split()[:4]])
        hud.quick_change(
            f' t{data[0][3]:-5.1f}  x{data[0][0]:-5.1f}  y{data[0][1]:-5.1f}  z{data[0][2]:-5.1f}'
        )
        hud.draw()
        # camera control
        camera.reset()
        camera.rotate(-tilt, rot, 0)
        r_rot, r_tilt = radians(rot), radians(tilt)
        camera.position(
            (cam_rad * sin(r_rot) * cos(r_tilt), cam_rad * sin(r_tilt),
             -cam_rad * cos(r_rot) * cos(r_tilt)))
        # plot the particles
        particles[0].pos = [data[0][0], data[0][1], data[0][2]]
        particles[0].position_and_draw(trace_material=(0.0, 0.25, 0.0))
        if argc == 7:
            particles[1].pos = [data[1][0], data[1][1], data[1][2]]
            particles[1].position_and_draw(trace_material=(0.0, 0.25, 0.0))
            particles[2].pos = [data[2][0], data[2][1], data[2][2]]
            particles[2].position_and_draw(trace_material=(0.4, 0.0, 0.0))
            particles[3].pos = [data[3][0], data[3][1], data[3][2]]
            particles[3].position_and_draw(trace_material=(0.4, 0.0, 0.0))
            particles[4].pos = [data[4][0], data[4][1], data[4][2]]
            particles[4].position_and_draw(trace_material=(0.0, 0.0, 0.5))
            particles[5].pos = [data[5][0], data[5][1], data[5][2]]
            particles[5].position_and_draw(trace_material=(0.0, 0.0, 0.5))
            particles[6].pos = [data[6][0], data[6][1], data[6][2]]
            particles[6].position_and_draw(trace_material=(0.25, 0.25, 0.25))
        # process mouse & keyboard input
        mx, my = mouse.position()
        if mouse.button_status() == mouse.LEFT_BUTTON:
            rot -= (mx - omx) * 0.2
            tilt -= (my - omy) * 0.2
        elif mouse.button_status() == mouse.RIGHT_BUTTON:
            cam_rad += (my - omy) * 0.1
        omx, omy = mx, my
        key = keys.read()
        if key > -1:
            if key == 112:  # 'p'
                screenshot('trajectory.jpg')
            elif key == 27:  # 'ESC'
                keys.close()
                mouse.stop()
                display.stop()
                break
示例#18
0
文件: LoadModel.py 项目: Arexxk/pi3d
defined in this egg file
"""
import demo

from pi3d import Display
from pi3d.Keyboard import Keyboard
from pi3d.Texture import Texture

from pi3d.Shader import Shader
from pi3d.Light import Light

from pi3d.shape.Model import Model
from pi3d.util.Screenshot import screenshot

# Setup display and initialise pi3d
DISPLAY = Display.create(x=100, y=100, background=(0.2, 0.4, 0.6, 1))

Light((1, 1, 1))

shader = Shader("shaders/mat_reflect")
#========================================
# load bump and reflection textures
bumptex = Texture("textures/floor_nm.jpg")
shinetex = Texture("textures/stars.jpg")

# load model_loadmodel
mymodel = Model(file_string='models/teapot.egg', name='teapot', x=0, y=0, z=10)
mymodel.set_shader(shader)
# material is set in the file
mymodel.set_normal_shine(bumptex, 4.0, shinetex, 0.2, is_uv = False)
示例#19
0
文件: ForestWalk.py 项目: akissu/pi3d
from pi3d.Light import Light
from pi3d.Camera import Camera
from pi3d.Shader import Shader

from pi3d.shape.ElevationMap import ElevationMap
from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.EnvironmentCube import loadECfiles
from pi3d.shape.MergeShape import MergeShape
from pi3d.shape.Plane import Plane
from pi3d.shape.Sphere import Sphere

from pi3d.util.Screenshot import screenshot

# Setup display and initialise pi3d
DISPLAY = Display.create(x=200, y=200)
DISPLAY.set_background(0.4, 0.8, 0.8, 1)  # r,g,b,alpha
# yellowish directional light blueish ambient light
Light(lightpos=(1, -1, -3),
      lightcol=(1.0, 1.0, 0.8),
      lightamb=(0.25, 0.2, 0.3))

#========================================

# load shader
shader = Shader("shaders/uv_reflect")
flatsh = Shader("shaders/uv_flat")

tree2img = Texture("textures/tree2.png")
tree1img = Texture("textures/tree1.png")
hb2img = Texture("textures/hornbeam2.png")
示例#20
0
from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.Plane import Plane
from pi3d.shape.Sphere import Sphere

from pi3d.util.String import String
from pi3d.util.Screenshot import screenshot
from pi3d.util.Defocus import Defocus

#helpful messages
print("############################################################")
print("Mouse to move left and right and up and down")
print("############################################################")
print()

# Setup display and initialise pi3d
DISPLAY = Display.create(x=200, y=200, frames_per_second=20)
DISPLAY.set_background(0.4, 0.8, 0.8, 1)  # r,g,b,alpha
camera = Camera((0, 0, 0), (0, 0, -1),
                (1, 1000, 30.0, DISPLAY.width / DISPLAY.height))
light = Light((10, -10, 20))
# load shader
shader = Shader("shaders/uv_reflect")
flatsh = Shader("shaders/uv_flat")
defocus = Defocus()
#========================================

# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'rockimg2.blend = False')
groundimg = Texture("textures/stripwood.jpg")
monstimg = Texture("textures/pong3.png")
ballimg = Texture("textures/pong2.jpg")
示例#21
0
TODO it would be nice to show a comparison with a low poly version of this
with normal mapping for the details of the model.
"""
import demo

from pi3d.util import Utility
from pi3d import Display
from pi3d.Keyboard import Keyboard

from pi3d.Shader import Shader

from pi3d.shape.Model import Model
from pi3d.util.Screenshot import screenshot

# Setup display and initialise pi3d
DISPLAY = Display.create(x=50, y=50, w=-100, h=-100,
                         background = (0.2, 0.4, 0.6, 1))

shader = Shader('shaders/uv_light')
#========================================

# load model_loadmodel
mymodel = Model(file_string='models/Triceratops/Triceratops.egg',
                name='Triceratops', x=0, y=-1, z=40,
                sx=0.005, sy=0.005, sz=0.005)
mymodel.set_shader(shader)

# Fetch key presses
mykeys = Keyboard()

while 1:
  DISPLAY.clear()
示例#22
0
文件: ForestWalk.py 项目: Arexxk/pi3d
from pi3d.Light import Light
from pi3d.Camera import Camera
from pi3d.Shader import Shader

from pi3d.shape.ElevationMap import ElevationMap
from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.EnvironmentCube import loadECfiles
from pi3d.shape.MergeShape import MergeShape
from pi3d.shape.Plane import Plane
from pi3d.shape.Sphere import Sphere

from pi3d.util.Screenshot import screenshot

# Setup display and initialise pi3d
DISPLAY = Display.create(x=200, y=200)
DISPLAY.set_background(0.4,0.8,0.8,1)      # r,g,b,alpha
# yellowish directional light blueish ambient light
Light(lightpos=(1, -1, -3), lightcol =(1.0, 1.0, 0.8), lightamb=(0.25, 0.2, 0.3))

#========================================

# load shader
shader = Shader("shaders/uv_reflect")
flatsh = Shader("shaders/uv_flat")

tree2img = Texture("textures/tree2.png")
tree1img = Texture("textures/tree1.png")
hb2img = Texture("textures/hornbeam2.png")
bumpimg = Texture("textures/grasstile_n.jpg")
reflimg = Texture("textures/stars.jpg")
示例#23
0
文件: Water.py 项目: Arexxk/pi3d
from pi3d.Shader import Shader

from pi3d.shape.Sphere import Sphere
from pi3d.util.String import String
from pi3d.util.Ttffont import Ttffont
from pi3d.shape.MergeShape import MergeShape
from pi3d.shape.Plane import Plane
from pi3d.util.Screenshot import screenshot

print("=====================================================")
print("press escape to escape")
print("move this terminal window to top of screen to see FPS")
print("=====================================================")

# Setup display and initialise pi3d
DISPLAY = Display.create(x=200, y=150, frames_per_second=25.0)
DISPLAY.set_background(0.4, 0.6, 0.8, 0.5)      # r,g,b,alpha

#setup textures, light position and initial model position
Light((5, -5, 8))
#create shaders
shader = Shader("shaders/uv_reflect")
matsh = Shader("shaders/mat_reflect")
flatsh = Shader("shaders/uv_flat")

#Create textures
shapeimg = Texture("textures/straw1.jpg")
shapebump = Texture("textures/mudnormal.jpg")
waterbump = []
iFiles = glob.glob("textures/water/n_norm???.png")
iFiles.sort() # order is vital to animation!
示例#24
0
文件: Silo.py 项目: Arexxk/pi3d
from pi3d.Camera import Camera
from pi3d.Shader import Shader

from pi3d.shape.ElevationMap import ElevationMap
from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.EnvironmentCube import loadECfiles
from pi3d.shape.Building import Building, corridor, SolidObject, Size, Position

from pi3d.util.Screenshot import screenshot

from pi3d.Light import Light

from pi3d.event.Event import InputEvents

# Setup display and initialise pi3d
DISPLAY = Display.create(x=150, y=150, background=(0.4, 0.8, 0.8, 1))
shader = Shader("shaders/uv_reflect")
flatsh = Shader("shaders/uv_flat")
#############################

# Load textures
blockimg = Texture("textures/squareblocks4.png")
roofedgeimg = Texture("textures/roofedging.png")
roofimg = Texture("textures/Roof.png")
greenimg = Texture("textures/squareblocks4green.png")
ectex = loadECfiles("textures/ecubes", "sbox", "jpg")
myecube = EnvironmentCube(size=900.0, maptype="FACES")
myecube.set_draw_details(flatsh, ectex)

# Create elevation map
mapwidth=1000.0