Esempio n. 1
0
def main():
    CAMERA = pi3d.Camera.instance()
    tex = pi3d.Texture("textures/grass.jpg")
    flatsh = pi3d.Shader("uv_flat")
    # Create elevation map
    mapwidth, mapdepth, mapheight = 200.0, 200.0, 50.0
    mymap = pi3d.ElevationMap("textures/Map.png",
                              width=mapwidth,
                              depth=mapdepth,
                              height=mapheight,
                              divx=128,
                              divy=128,
                              ntiles=20)
    mymap.set_draw_details(flatsh, [tex], 1.0, 1.0)

    rot = 0.0  # rotation of camera
    tilt = 0.0  # tilt of camera
    height = 20
    viewhight = 4
    sky = 200
    xm, ym, zm = 0.0, height, 0.0
    on_ground = False
    # Main display loop
    while DISPLAY.loop_running() and not INPUTS.key_state("KEY_ESC"):
        INPUTS.do_input_events()
        #Camera steered by mouse
        #Note:Some mice devices will be located on
        #get_mouse_movement(1) instead of get_mouse_movement()
        mx, my, mv, mh, md = INPUTS.get_mouse_movement()
        #mx, my, mv, mh, md = INPUTS.get_mouse_movement(1)
        rot -= (mx) * 0.2
        tilt -= (my) * 0.2
        CAMERA.reset()
        CAMERA.rotate(-tilt, rot, 0)
        CAMERA.position((xm, ym, zm))
        mymap.draw()
        if INPUTS.key_state("KEY_W"):
            xm -= sin(radians(rot))
            zm += cos(radians(rot))
        elif INPUTS.key_state("KEY_S"):
            xm += sin(radians(rot))
            zm -= cos(radians(rot))
        elif INPUTS.key_state("KEY_R"):
            ym += 2
            on_ground = False
        elif INPUTS.key_state("KEY_T"):
            ym -= 2
        ym -= 0.1  #Float down!
        #Limit the movement
        xm = limit(xm, -(mapwidth / 2), mapwidth / 2)
        zm = limit(zm, -(mapdepth / 2), mapdepth / 2)
        if ym >= sky:
            ym = sky
        #Check on_ground
        ground = mymap.calcHeight(xm, zm) + viewhight
        if on_ground or (ym <= ground):
            ym = mymap.calcHeight(xm, zm) + viewhight
            on_ground = True
Esempio n. 2
0
  def __init__(self):

    shader = pi3d.Shader("uv_reflect")
    bumpsh = pi3d.Shader("uv_bump")
    flatsh = pi3d.Shader("uv_flat")
    #shade2d = pi3d.Shader('2d_flat')

    ectex = pi3d.loadECfiles("../textures/ecubes/RedPlanet", "redplanet_256", "png", True)
    self.myecube = pi3d.EnvironmentCube(size=1800.0, maptype="FACES")
    self.myecube.set_draw_details(flatsh,ectex)

    # Create elevation map
    mapwidth=2000.0
    mapdepth=2000.0
    mapheight=100.0
    redplanet = pi3d.Texture("../textures/mars_colour.png")
    bumpimg = pi3d.Texture("../textures/mudnormal.jpg")
    self.mymap = pi3d.ElevationMap(mapfile='../textures/mars_height.png',
                     width=mapwidth, depth=mapdepth, height=mapheight,
                     divx=64, divy=64)
    self.mymap.set_draw_details(bumpsh,[redplanet, bumpimg],128.0, 0.0)
    self.mymap.set_fog((0.3, 0.15, 0.1, 0.0), 1000.0)

    #Load Corridors sections

    sttnbmp = pi3d.Texture("../textures/floor_nm.jpg")
    sttnshn = pi3d.Texture("../textures/stars.jpg")
    x,z = 0,0
    y = self.mymap.calcHeight(x, z)
    #corridor with windows
    self.cor_win = pi3d.Model(file_string="../models/MarsStation/corridor_win_lowpoly.egg",
                x=x, y=y, z=z, sx=0.1, sy=0.1, sz=0.1)
    self.cor_win.set_shader(shader)
    #normal corridor
    self.corridor = pi3d.Model(file_string="../models/MarsStation/corridor_lowpoly.egg",
                 x=x, y=y, z=z, sx=0.1, sy=0.1, sz=0.1)
    self.corridor.set_shader(shader)
    #corridor crossing
    self.cor_cross = pi3d.Model(file_string="../models/MarsStation/cross_room.egg",
                 x=x, y=y, z=z, sx=0.1, sy=0.1, sz=0.1)
    self.cor_cross.set_shader(shader)
    self.cor_cross.set_normal_shine(sttnbmp, 32.0, sttnshn, 0.1)
    #corridor crossing with doors
    self.cor_cross_doors = pi3d.Model(file_string="../models/MarsStation/cross_room_doors.egg",
                        x=x, y=y, z=z, sx=0.1, sy=0.1, sz=0.1)
    self.cor_cross_doors.set_shader(shader)
    self.cor_cross_doors.set_normal_shine(sttnbmp, 32.0, sttnshn, 0.1)
    #corridor with 90 degree bend
    self.cor_bend = pi3d.Model(file_string="../models/MarsStation/bend_lowpoly.egg",
                 x=x, y=y, z=z, sx=0.1, sy=0.1, sz=0.1)
    self.cor_bend.set_shader(shader)
    self.cor_bend.set_normal_shine(sttnbmp, 32.0)
    self.cor_bend.rotateToY(180)
Esempio n. 3
0
 def do_pickle(self, fog=((0.3, 0.3, 0.4, 0.95), 450.0)):
     '''run once to save pkl files from ElevationMaps and Models combined
 as MergeShapes as defined in the SceneryItem objects listed in
 scenery_list
 '''
     for key in self.scenery_list:
         s_item = self.scenery_list[key]
         if s_item.put_on is None:  #this is a map - do all these first pass
             LOGGER.debug('pickling %s', key)
             mymap = pi3d.ElevationMap(mapfile='{}/{}.png'.format(
                 self.path, key),
                                       name=key,
                                       width=(self.msize + 0.001),
                                       depth=(self.msize + 0.001),
                                       height=s_item.height,
                                       x=s_item.x,
                                       y=s_item.y,
                                       z=s_item.z,
                                       divx=32,
                                       divy=32)
             mymap.set_fog(*fog)
             mymap.set_alpha(s_item.alpha)
             with open('{}/{}.pkl'.format(self.path, key), 'wb') as f:
                 pickle.dump(mymap, f)
             s_item.shape = mymap  # temp store all these for the sake of make_pickle
     for key in self.scenery_list:
         s_item = self.scenery_list[key]
         if s_item.put_on is not None:  #model so need to put on map
             LOGGER.debug('pickling %s', key)
             md = s_item.model_details
             if not md['model'] in self.models:
                 self.models[md['model']] = pi3d.Model(
                     file_string='{}/{}.obj'.format(self.path, md['model']))
             m_item = self.scenery_list[s_item.put_on]
             xpos = s_item.x - m_item.x  # relative to map it's put on
             zpos = s_item.z - m_item.z
             mymerge = pi3d.MergeShape(name=key, x=s_item.x, z=s_item.z)
             mymerge.cluster(self.models[md['model']], m_item.shape, 0.0,
                             0.0, md['w'], md['d'], md['n'], key,
                             md['maxs'], md['mins'])
             mymerge.set_fog(*fog)
             with open('{}/{}.pkl'.format(self.path, key), 'wb') as f:
                 pickle.dump(mymerge, f)
     for key in self.scenery_list:  #tidy up memory usage
         s_item = self.scenery_list[key]
         s_item.shape = None
Esempio n. 4
0
def world3dA(inHeightmap, inWidth, inDepth, inHeight, inTextureMap, inBumpMap):
    from PIL import Image
    import numpy as np
    DISPLAY = pi3d.Display.create(x=50, y=50, far=5000, near=0.5)

    CAMERA = pi3d.Camera.instance()
    base_tex = np.array(Image.open(inTextureMap))
    # texture for land
    base_gr = base_tex.copy()
    ix = np.where(base_gr[:,:,2] > 20) # i.e. was blue
    base_gr[ix[0], ix[1], 1] += 50 # increase green
    base_gr[ix[0], ix[1], 2] = 0  # reduce blue
    texg = pi3d.Texture(base_gr)
    # texture for water
    base_bl = base_tex.copy()
    base_bl[:,:] = [0, 0, 60, 170] # uniform slightly transparrent
    texb = pi3d.Texture(base_bl)
    grass_tex = pi3d.Texture('/home/patrick/raspberry_pi/pi3d_demos/textures/grasstile_n.jpg')
    w_norm = pi3d.Texture('/home/patrick/raspberry_pi/pi3d_demos/textures/water/n_norm000.png')


    shader = pi3d.Shader("uv_bump")
    rshader = pi3d.Shader("uv_reflect")
    mapwidth = inWidth
    mapdepth = inDepth
    mapheight = inHeight
    
    mymap = pi3d.ElevationMap(inHeightmap, width=mapwidth, depth=mapdepth, height=mapheight, divx=199, divy=199, ntiles=1, name="sub", y=-0.0)
    mymap.set_draw_details(shader, [texg, grass_tex], 200.0)
    wmap = pi3d.ElevationMap(inHeightmap, width=mapwidth, depth=mapdepth, height=mapheight * 0.1, divx=40, divy=40, ntiles=1, name="water", y=25.0)
    wmap.set_draw_details(rshader, [texb, w_norm, texg], 500.0, 0.2)
    rot = 0.0
    tilt = 0.0
    height = 20.0
    viewHeight = 1.5
    sky = 2000
    xm, ym, zm = 0.0, height, 0.0
    onGround = False
 
    mykeys = pi3d.Keyboard()
    mymouse = pi3d.Mouse(restrict=False)
    mymouse.start()
    
    omx, omy = mymouse.position()
    fr = 0
    while DISPLAY.loop_running():
        mx, my = mymouse.position()

        rot -= (mx - omx) * 0.2
        tilt -= (my - omy) * 0.2

        omx = mx
        omy = my

        CAMERA.reset()
        CAMERA.rotate(-tilt, rot, 0)
        CAMERA.position((xm, ym, zm))

        mymap.draw()
        wmap.draw()

        k = mykeys.read()

        if k > -1:
            if k == 48:  # ESCAPE key - '0' Key
                DISPLAY.destroy()
                mykeys.close()
                mymouse.stop()
                break
            elif k == 87 or k == 119:
                #        if inputs.key_state("KEY_W"):
                xm -= sin(radians(rot)) * 2.0
                zm += cos(radians(rot)) * 2.0
            elif k == 83 or k == 115:
                #        elif inputs.key_state("KEY_S"):
                xm += sin(radians(rot)) * 2.0
                zm -= cos(radians(rot)) * 2.0
            elif k == 82 or k == 114:
                #        elif inputs.key_state("KEY_R"):
                ym += 4
                onGround = False
            elif k == 84 or k == 116:
                #        elif inputs.key_state("KEY_T"):
                ym -= 4
        
        ym -= 0.2
        
        xm = limit(xm, -(mapwidth / 2), (mapwidth / 2))
        zm = limit(zm, -(mapdepth / 2), (mapdepth / 2))
        
        if ym >= sky:
            ym = sky
        
        ground = max(mymap.calcHeight(xm, zm), wmap.calcHeight(xm, zm)) + viewHeight
        
        if (onGround is True) or (ym <= ground):
            ym = ground
            onGround = True

        pi3d.screenshot("/home/patrick/Downloads/Untitled Folder/scr_caps/world{:04d}.jpg".format(fr))
        fr += 1
Esempio n. 5
0
                         suffix='png')
myecube = pi3d.EnvironmentCube(size=1800.0, maptype='FACES')
myecube.set_draw_details(flatsh, ectex)

# Create elevation map
mapwidth = 1800.0
mapdepth = 1800.0
mapheight = 120.0
mountimg1 = pi3d.Texture('textures/mountains3_512.jpg')
bumpimg = pi3d.Texture('textures/grasstile_n.jpg')
tigerbmp = pi3d.Texture('models/Tiger/tiger_bump.jpg')
topbmp = pi3d.Texture('models/Tiger/top_bump.jpg')
#roadway = pi3d.Texture('textures/road5.png')
mymap = pi3d.ElevationMap(mapfile='textures/mountainsHgt2.png',
                          width=mapwidth,
                          depth=mapdepth,
                          height=mapheight,
                          divx=64,
                          divy=64)

mymap.set_draw_details(shader, [mountimg1, bumpimg], 128.0, 0.0)

FOG = (0.5, 0.5, 0.5, 0.8)


def set_fog(shape):
    shape.set_fog(FOG, 1000.0)


#Load tank
tank_body = pi3d.Model(file_string='models/Tiger/body.obj',
                       sx=0.1,
Esempio n. 6
0
# Load textures for the environment cube
ectex = pi3d.loadECfiles("textures/ecubes", "sbox")
myecube = pi3d.EnvironmentCube(size=7000.0, maptype="FACES", camera=CAMERA)
myecube.set_draw_details(FLATSH, ectex)
myecube.set_fog((0.5, 0.5, 0.5, 1.0), 4000)
# Create elevation map
mapwidth = 10000.0
mapdepth = 10000.0
mapheight = 1000.0
mountimg1 = pi3d.Texture("textures/mountains3_512.jpg")
bumpimg = pi3d.Texture("textures/grasstile_n.jpg")
reflimg = pi3d.Texture("textures/stars.jpg")
mymap = pi3d.ElevationMap("textures/mountainsHgt.jpg",
                          name="map",
                          width=mapwidth,
                          depth=mapdepth,
                          height=mapheight,
                          divx=64,
                          divy=64,
                          camera=CAMERA)
mymap.set_draw_details(SHADER, [mountimg1, bumpimg, reflimg], 1024.0, 0.0)
mymap.set_fog((0.5, 0.5, 0.5, 1.0), 4000)
# init events
inputs = pi3d.InputEvents()
inputs.get_mouse_movement()
CAMERA.position((0.0, 0.0, -10.0))
cam_rot, cam_pitch = 0, 0
cam_toggle = True  #control mode
while DISPLAY.loop_running() and not inputs.key_state("KEY_ESC"):
    inputs.do_input_events()
    #""" mouse input
    mx, my, mv, mh, md = inputs.get_mouse_movement()
Esempio n. 7
0
#monster
monster = pi3d.Plane(camera, light, 5.0, 5.0, "monster", 0, 0, 0, 0, 0, 0)
monster.set_draw_details(flatsh, [monstimg])

# Create elevation map
mapwidth = 50.0
mapdepth = 50.0
maphalf = 22.0
mapheight = 40.0

mymap = pi3d.ElevationMap("textures/pong.jpg",
                          camera=camera,
                          light=light,
                          width=mapwidth,
                          depth=mapdepth,
                          height=mapheight,
                          divx=32,
                          divy=32,
                          ntiles=4,
                          name="sub")
mymap.set_draw_details(shader, [groundimg, groundimg, ballimg], 1.0, 0.0)

#avatar camera
avhgt = 2.0
xm = 0.0
zm = 0.0
ym = 0.0
lastX0 = 0.0
lastZ0 = 0.0
camera.position((xm, 2 + ym, -maphalf - 2.5))
Esempio n. 8
0
flatsh = pi3d.Shader("uv_flat")
# Load textures
ceilingimg = pi3d.Texture("textures/squareblocks4.png")
wallimg = pi3d.Texture("textures/squareblocksred.png")
floorimg = pi3d.Texture("textures/dunes3_512.jpg")
bumpimg = pi3d.Texture("textures/mudnormal.jpg")
startimg = pi3d.Texture("textures/rock1.jpg")
endimg = pi3d.Texture("textures/water.jpg")
# Create elevation map
mapwidth = 1000.0
mapdepth = 1000.0
#We shall assume we are using a flat floor in this example
mapheight = 0.0
mymap = pi3d.ElevationMap(mapfile="textures/floor.png",
                          width=mapwidth,
                          depth=mapdepth,
                          height=mapheight,
                          divx=64,
                          divy=64)
mymap.set_draw_details(shader, [floorimg, bumpimg], 128.0, 0.0)
levelList = [
    "textures/inside_map0.png", "textures/inside_map1.png",
    "textures/inside_map2.png"
]
avhgt = 5.0
aveyelevel = 4.0
MAP_BLOCK = 15.0
aveyeleveladjust = aveyelevel - avhgt / 2
PLAYERHEIGHT = (mymap.calcHeight(5, 5) + avhgt / 2)
#Start the player in the top-left corner
startpos = [(8 * MAP_BLOCK), PLAYERHEIGHT, (8 * MAP_BLOCK)]
endpos = [0, PLAYERHEIGHT, 0]  #Set the end pos in the centre
Esempio n. 9
0
DISPLAY.swap_buffers()
#############################
ectex = pi3d.loadECfiles("textures/ecubes/RedPlanet", "redplanet_256", "png",
                         True)
myecube = pi3d.EnvironmentCube(size=1800.0, maptype="FACES")
myecube.set_draw_details(flatsh, ectex)

# Create elevation map
mapwidth = 2000.0
mapdepth = 2000.0
mapheight = 100.0
redplanet = pi3d.Texture("textures/mars_colour.png")
bumpimg = pi3d.Texture("textures/mudnormal.jpg")
mymap = pi3d.ElevationMap(mapfile='textures/mars_height.png',
                          width=mapwidth,
                          depth=mapdepth,
                          height=mapheight,
                          divx=64,
                          divy=64)
mymap.set_draw_details(shader, [redplanet, bumpimg], 128.0, 0.0)
mymap.set_fog((0.3, 0.15, 0.1, 0.0), 1000.0)

#Load Corridors sections

sttnbmp = pi3d.Texture("textures/floor_nm.jpg")
sttnshn = pi3d.Texture("textures/stars.jpg")
x, z = 0, 0
y = mymap.calcHeight(x, z)
#corridor with windows
cor_win = pi3d.Model(file_string="models/MarsStation/corridor_win_lowpoly.egg",
                     x=x,
                     y=y,
Esempio n. 10
0
monsttex = pi3d.Texture("textures/floor_nm.jpg")
shineimg = pi3d.Texture("textures/stars.jpg")

# environment cube
ectex = pi3d.Texture("textures/ecubes/skybox_stormydays.jpg")
myecube = pi3d.EnvironmentCube(size=900.0, maptype="CROSS")
myecube.set_draw_details(flatsh, ectex)

# Create elevation map
mapwidth = 1000.0
mapdepth = 1000.0
mapheight = 100.0
mymap = pi3d.ElevationMap("textures/maze1.jpg",
                          width=mapwidth,
                          depth=mapdepth,
                          height=mapheight,
                          divx=128,
                          divy=128,
                          name="sub")
mymap.set_draw_details(shader, [rockimg1, rockimg2, shineimg], 128.0, 0.05)

# Create fog for more realistic fade in distance. This can be turned on and off between drawing different object (i.e backgound not foggy)
mymap.set_fog((0.1, 0.1, 0.1, 1.0), 200.0)

#Create tree models
treeplane = pi3d.Plane(w=4.0, h=5.0)

treemodel1 = pi3d.MergeShape(name="baretree")
treemodel1.add(treeplane.buf[0], 0, 0, 0)
treemodel1.add(treeplane.buf[0], 0, 0, 0, 0, 90, 0)
Esempio n. 11
0
plnnorm = pi3d.Texture("planet10.jpg", normal_map=-2.0)
mudnorm = pi3d.Texture("mudnormal.jpg")
flrnorm = pi3d.Texture("floor_nm.jpg")
grsnorm = pi3d.Texture("grasstile_n.jpg")
ectex = pi3d.Texture('skybox_interstellar.jpg')

FOG = ((0.3, 0.3, 0.4, 0.8), 350.0) # distant hills look distant

myecube = pi3d.EnvironmentCube(size=900.0, maptype='CROSS')
myecube.set_draw_details(flatsh, [ectex])

# Create elevation map
mapsize = 900.0
mapheight = 150.0
mymap = pi3d.ElevationMap("mars_height.png", name="map",
                     width=mapsize, depth=mapsize, height=mapheight,
                     divx=32, divy=32) 
mymap.set_draw_details(shader, [plntimg, mudnorm], 128.0, 0.0)
mymap.set_fog(*FOG)

# ball stuff
DRAG = 0.02                          # 2% reduction in speed each frame
G = -0.01                            # g -> change in y velocity each frame
rot = 0.0                            # rotation of camera about vertical axis
ballrot = 180.0                      # heading of ball about vert axis (y)
tilt = 0.0                           # rotation of camera about local x axis (left to right horizontal)
RADIUS = 1.0                         # radius of ball
ball = pi3d.Triangle(corners=((-0.01, 0.0), (0.0, 0.01), (0.01, 0.0))) # an 'empty' game object
ball_shape = pi3d.Sphere(radius=RADIUS, slices=24, sides=24) # the visible shape
ball.add_child(ball_shape)           # to get realistic 'rolling'
ball_shape.set_draw_details(shader, [plntimg, plnnorm], 1.0)
Esempio n. 12
0
def pi_3d(inHeightmap, inWidth, inDepth, inHeight, inTextureMap, inBumpMap):
    rads = 0.017453292512  # degrees to radians

    # helpful messages
    # Esc to quit, W to go forward, Mouse to steer
    # At the edge you will turn into a ghost and be able to fly and pass through rocks!

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

    shader = pi3d.Shader("uv_bump")
    flatsh = pi3d.Shader("uv_flat")
    light = pi3d.Light((1, 1, 1), (400.0, 400.0, 350.0), (0.03, 0.03, 0.05), True)
    # sun = pi3d.Light((0.0, 1000.0, 0.0), (0.5, 1.0, 0.7), (0.3, 0.1, 0.1), is_point=True)
    
    # load Textures
    rockimg1 = pi3d.Texture("textures/techy1.jpg")
    rockimg2 = pi3d.Texture("textures/rocktile2.jpg")
    shineimg = pi3d.Texture("textures/stars.jpg")
    
    # environment cube
    ectex = pi3d.Texture("textures/ecubes/skybox_stormydays.jpg")
    myecube = pi3d.EnvironmentCube(size=900.0, maptype="CROSS")
    myecube.set_draw_details(flatsh, ectex)
    
    # Create elevation map
    # inWidth = Width of Map (i.e. 1024.0)
    # inDepth = Depth of Map (i.e. 1024.0)
    # inHeight = Height of Map (i.e 0.5)
    mapwidth = inWidth
    mapdepth = inDepth
    mapheight = inHeight
    bumpsh = pi3d.Shader('uv_bump')
    
    # inHeightmap = Maps/seed_XXXXX_grayscale.png
    # inTextureMap = Maps/seed_XXXXX_elevation.png
    # inBumpMap = Maps/seed_XXXXX_normal.png
    mymap = pi3d.ElevationMap(inHeightmap, width=mapwidth, depth=mapdepth, height=mapheight, divx=199, divy=199, name="sub")
    mymap.set_draw_details(shader, [rockimg1, rockimg2, shineimg], 128.0, 0.05)
    redplanet = pi3d.Texture(inTextureMap)
    bumpimg = pi3d.Texture(inBumpMap)
    mymap.set_draw_details(bumpsh, [redplanet, bumpimg], 128.0, 0.0)
    mymap.set_fog((0.3, 0.15, 0.1, 0.0), 1000.0)
    
    rot = 0.0
    tilt = 0.0
    avhgt = 3.0
    xm, oxm = 0.0, -1.0
    zm, ozm = 0.0, -1.0
    ym = mymap.calcHeight(xm, zm) + avhgt
    
    # Fetch key presses
    mykeys = pi3d.Keyboard()
    mymouse = pi3d.Mouse(restrict=False)
    mymouse.start()
    
    omx, omy = mymouse.position()
    
    fly = False
    walk = True
    
    CAMERA = pi3d.Camera.instance()

    print ('at line 71 - Code3D')
    while DISPLAY.loop_running():
        # movement of camera
        mx, my = mymouse.position()
        rot -= (mx - omx) * 0.2
        tilt += (my - omy) * 0.1
    
        dx = -math.sin(rot * rads)
        dz = math.cos(rot * rads)
        dy = math.sin(tilt * rads)

        if walk:
            if fly:
                xm += dx * 3
                zm += dz * 3
                ym += dy * 3
            else:
                dy = mymap.calcHeight(xm + dx * 1.5, zm + dz * 1.5) + avhgt - ym

            if dy < 1.2:  # limit steepness so can't climb up walls
                xm += dx * 0.5
                zm += dz * 0.5
                ym += dy * 0.5
        
            if xm < -490 or xm > 490 or zm < -490 or zm > 490:
                fly = True  # reached the edge
      
        if not (mx == omx and my == omy and oxm == xm and ozm == zm):
            CAMERA.reset()
            CAMERA.rotate(tilt, 0, 0)
            CAMERA.rotate(0, rot, 0)
            CAMERA.position((xm, ym, zm))
        
        omx = mx
        omy = my
        oxm = xm
        ozm = zm
        light.position((xm, ym + 15.0, zm))
        light.is_point = True
    
        mymap.set_light(light)
    
        myecube.position(xm, ym, zm)
        myecube.draw()
        mymap.draw()

        # key presses (ESCAPE to terminate)
        k = mykeys.read()

        if k > -1:
            if k == 119:  # W Key toggle
                walk = not walk
            elif k == 115:  # S Key
                walk = False
                dy = -(mymap.calcHeight(xm - dx, zm - dz) + avhgt) - ym
          
                if dy > -1.0:
                    xm -= dx
                    zm -= dz
                    ym += dy
            elif k == 27:  # ESCAPE key
                DISPLAY.destroy()
                mykeys.close()
                mymouse.stop()
                break
    
        # this will save a little time each loop if the camera is not moved
        CAMERA.was_moved = False
    
    quit()
Esempio n. 13
0
class Main(object):
    # Setup display and initialise pi3d
    DISPLAY = pi3d.Display.create(depth=16)
    pi3d.Light(lightpos=(1, -1, -3),
               lightcol=(1.0, 1.0, 0.8),
               lightamb=(0.25, 0.2, 0.3))
    # load shader
    shader = pi3d.Shader("uv_bump")
    shinesh = pi3d.Shader("uv_reflect")
    flatsh = pi3d.Shader("uv_flat")

    bumpimg = pi3d.Texture("textures/grasstile_n.jpg")
    reflimg = pi3d.Texture("textures/stars.jpg")
    rockimg = pi3d.Texture("textures/rock1.jpg")

    FOG = ((0.3, 0.3, 0.4, 0.8), 650.0)

    ectex = pi3d.loadECfiles("textures/ecubes", "sbox")
    myecube = pi3d.EnvironmentCube(size=900.0, maptype="FACES", name="cube")
    myecube.set_draw_details(flatsh, ectex)

    # Create elevation map
    mapsize = 1000.0
    mapheight = 60.0
    mountimg1 = pi3d.Texture("textures/mountains3_512.jpg")
    mymap = pi3d.ElevationMap("textures/mountainsHgt.png",
                              name="map",
                              width=mapsize,
                              depth=mapsize,
                              height=mapheight,
                              divx=32,
                              divy=32)
    mymap.set_draw_details(shader, [mountimg1, bumpimg, reflimg], 128.0, 0.0)
    mymap.set_fog(*FOG)

    #Create monument
    monument = pi3d.Model(file_string="models/pi3d.obj", name="monument")
    monument.set_shader(shinesh)
    monument.set_normal_shine(bumpimg, 16.0, reflimg, 0.4)
    monument.set_fog(*FOG)
    monument.translate(100.0, -mymap.calcHeight(100.0, 235) + 12.0, 235.0)
    monument.scale(20.0, 20.0, 20.0)
    monument.rotateToY(65)

    #Ball
    ball = pi3d.Triangle(corners=((-0.01, 0.0), (0.0, 0.01), (0.01, 0.0)))
    sphere = pi3d.Sphere()
    sphere.set_draw_details(shader, [rockimg, bumpimg], 1.0)
    ball.add_child(sphere)

    #avatar camera
    rot = 0.0
    tilt = 0.0
    avhgt = 1.0
    xm = 0.0
    zm = 0.0
    ym = mymap.calcHeight(xm, zm) + avhgt

    go_flag = False
    vx, vz = 0.0, 0.0
    gx, gz = 0.0, 0.0

    CAMERA = pi3d.Camera.instance()
    CAMERA2D = pi3d.Camera(is_3d=False)
    font = pi3d.Pngfont("fonts/GillSansMT.png", (200, 30, 10, 255))
    font.blend = True
    txt = None

    if pi3d.PLATFORM == pi3d.PLATFORM_ANDROID:  #*****************************
        from jnius import autoclass
        Hardware = autoclass(b'org.renpy.android.Hardware')
        Hardware.accelerometerEnable(True)

    def pi3dloop(self, dt):
        self.DISPLAY.loop_running()
        self.CAMERA.relocate(self.rot, self.tilt, [self.xm, self.ym, self.zm],
                             [-OFFSET, -OFFSET, -OFFSET])
        self.myecube.position(self.xm, self.ym, self.zm)
        self.ball.position(self.xm, self.ym, self.zm)

        # for opaque objects it is more efficient to draw from near to far as the
        # shader will not calculate pixels already concealed by something nearer
        self.ball.draw()
        self.mymap.draw()
        self.myecube.draw()
        dx = math.copysign(self.mapsize, self.xm)
        dz = math.copysign(self.mapsize, self.zm)
        mid = 0.3 * self.mapsize
        if abs(self.xm) > mid:  #nearing edge
            self.mymap.position(dx, 0.0, 0.0)
            self.mymap.draw()
        if abs(self.zm) > mid:  #other edge
            self.mymap.position(0.0, 0.0, dz)
            self.mymap.draw()
            if abs(self.xm) > mid:  #i.e. in corner, both edges
                self.mymap.position(dx, 0.0, dz)
                self.mymap.draw()
        self.mymap.position(0.0, 0.0, 0.0)
        self.monument.draw()

        if pi3d.PLATFORM == pi3d.PLATFORM_ANDROID:  #*****************************
            if self.DISPLAY.android.screen.moved:
                self.rot -= self.DISPLAY.android.screen.touch.dx * 0.25
                self.tilt += self.DISPLAY.android.screen.touch.dy * 0.25
                self.DISPLAY.android.screen.moved = False
                self.DISPLAY.android.screen.tapped = False
            elif self.DISPLAY.android.screen.double_tapped:
                self.go_flag = not self.go_flag
                self.DISPLAY.android.screen.double_tapped = False
                from kivy.network.urlrequest import UrlRequest

                def url_success(req, results):
                    self.txt = pi3d.String(camera=self.CAMERA2D,
                                           font=self.font,
                                           string=results,
                                           is_3d=False,
                                           y=self.DISPLAY.height / 2.0 + 30.0)
                    self.txt.set_shader(self.flatsh)
                    self.monument.rotateIncY(4)  # rotate by some random amount

                req = UrlRequest(
                    "http://www.eldwick.org.uk/files/rogo/test2.php?num=1",
                    url_success)
            if self.txt is not None:
                self.txt.draw()
                (x, y, z) = self.Hardware.accelerometerReading()
                sr, _, cr = self.CAMERA.get_direction()
                self.gx = y * cr + (z - x) * sr
                self.gz = (
                    z - x) * cr - y * sr  # i.e. hold at 45 degrees for neutral
        else:
            mx, my = self.mymouse.position()

            #if mx>display.left and mx<display.right and my>display.top and my<display.bottom:
            self.rot -= (mx - self.omx) * 0.2
            self.tilt += (my - self.omy) * 0.2
            self.omx = mx
            self.omy = my

            #Press ESCAPE to terminate
            k = self.mykeys.read()
            if k > -1:
                sr, _, cr = self.CAMERA.get_direction()
                if k == ord('w'):  #key W
                    self.go_flag = not self.go_flag
                elif k == 261 or k == 137:  # rgt
                    self.gx += 0.5 * cr
                    self.gz -= 0.5 * sr
                elif k == 260 or k == 136:  # lft
                    self.gx -= 0.5 * cr
                    self.gz += 0.5 * sr
                elif k == 259 or k == 134:  # up
                    self.gz += 0.5 * cr
                    self.gx += 0.5 * sr
                elif k == 258 or k == 135:  # dwn
                    self.gz -= 0.5 * cr
                    self.gx -= 0.5 * sr
                elif k == 27:  #Escape key
                    return False

        if self.go_flag:
            self.xm += self.vx
            self.zm += self.vz
            ht, norm = self.mymap.calcHeight(self.xm, self.zm, True)
            self.ym = ht + self.avhgt
            self.vx += norm[0] * SLOPE_F + self.gx * TILT_F
            self.vz += norm[2] * SLOPE_F + self.gz * TILT_F
            self.vx *= FRICTION
            self.vz *= FRICTION
            self.ball.rotateToY(math.degrees(math.atan2(self.vx, self.vz)))
            self.sphere.rotateIncX(math.degrees(
                (self.vx**2 + self.vz**2)**0.5))
            halfmap = self.mapsize / 2.0  # save doing this four times!
            self.xm = (self.xm + halfmap) % self.mapsize - halfmap
            self.zm = (self.zm + halfmap) % self.mapsize - halfmap

        else:
            self.vx = 0.0
            self.vz = 0.0
            self.gx = 0.0
            self.gz = 0.0
        return True

    def run(self):
        if pi3d.PLATFORM == pi3d.PLATFORM_ANDROID:  #*****************************
            self.DISPLAY.android.set_loop(self.pi3dloop)
            self.DISPLAY.android.run()
            self.Hardware.accelerometerEnable(False)
        else:
            # Fetch key presses
            self.mykeys = pi3d.Keyboard()
            self.mymouse = pi3d.Mouse(restrict=False)
            self.mymouse.start()
            self.omx, self.omy = self.mymouse.position()
            while self.pi3dloop(0.0):
                pass
            self.mykeys.close()
            self.mymouse.stop()

        self.DISPLAY.stop()
Esempio n. 14
0
  def __init__(self):

    # load shader
    shader = pi3d.Shader("uv_bump")
    #shinesh = pi3d.Shader("uv_reflect")
    flatsh = pi3d.Shader("uv_flat")

    tree1img = pi3d.Texture("../textures/tree1.png")
    tree2img = pi3d.Texture("../textures/tree2.png")
    hb2img = pi3d.Texture("../textures/hornbeam2.png")
    bumpimg = pi3d.Texture("../textures/grasstile_n.jpg")
    reflimg = pi3d.Texture("../textures/stars.jpg")
    floorimg = pi3d.Texture("../textures/floor_nm.jpg")

    FOG = ((0.3, 0.3, 0.4, 0.8), 650.0)
    TFOG = ((0.2, 0.24, 0.22, 1.0), 150.0)

    ectex=pi3d.loadECfiles("../textures/ecubes","sbox")
    self.myecube = pi3d.EnvironmentCube(size=900.0, maptype="FACES", name="cube")
    self.myecube.set_draw_details(flatsh, ectex)
    self.myecube.position(0,0,0)

    # Create elevation map
    mapsize = 1000.0
    mapheight = 60.0
    mountimg1 = pi3d.Texture("../textures/mountains3_512.jpg")
    self.mymap = pi3d.ElevationMap("../textures/mountainsHgt.png", name="map",
                         width=mapsize, depth=mapsize, height=mapheight,
                         divx=32, divy=32) 
    self.mymap.set_draw_details(shader, [mountimg1, bumpimg, reflimg], 128.0, 0.0)
    self.mymap.set_fog(*FOG)

    self.building = pi3d.Model(file_string="../models/ConferenceHall/conferencehall.egg", name="Hall", sx=0.1, sy=0.1, sz=0.1)
    self.building.set_shader(flatsh)

    #Create tree models
    treeplane = pi3d.Plane(w=4.0, h=5.0)

    treemodel1 = pi3d.MergeShape(name="baretree")
    treemodel1.add(treeplane.buf[0], 0,0,0)
    treemodel1.add(treeplane.buf[0], 0,0,0, 0,90,0)

    treemodel2 = pi3d.MergeShape(name="bushytree")
    treemodel2.add(treeplane.buf[0], 0,0,0)
    treemodel2.add(treeplane.buf[0], 0,0,0, 0,60,0)
    treemodel2.add(treeplane.buf[0], 0,0,0, 0,120,0)

    #Scatter them on map using Merge shape's cluster function
    self.mytrees1 = pi3d.MergeShape(name="trees1")
    self.mytrees1.cluster(treemodel1.buf[0], self.mymap,0.0,0.0,200.0,200.0,20,"",8.0,3.0)
    self.mytrees1.set_draw_details(flatsh, [tree2img], 0.0, 0.0)
    self.mytrees1.set_fog(*TFOG)

    self.mytrees2 = pi3d.MergeShape(name="trees2")
    self.mytrees2.cluster(treemodel2.buf[0], self.mymap,0.0,0.0,200.0,200.0,20,"",6.0,3.0)
    self.mytrees2.set_draw_details(flatsh, [tree1img], 0.0, 0.0)
    self.mytrees2.set_fog(*TFOG)

    self.mytrees3 = pi3d.MergeShape(name="trees3")
    self.mytrees3.cluster(treemodel2, self.mymap,0.0,0.0,300.0,300.0,20,"",4.0,2.0)
    self.mytrees3.set_draw_details(flatsh, [hb2img], 0.0, 0.0)
    self.mytrees3.set_fog(*TFOG)

    #screenshot number
    scshots = 1
Esempio n. 15
0
FOG = ((0.3, 0.3, 0.4, 0.8), 650.0)
TFOG = ((0.2, 0.24, 0.22, 1.0), 150.0)

#myecube = pi3d.EnvironmentCube(900.0,"HALFCROSS")
ectex = pi3d.loadECfiles("textures/ecubes", "sbox")
myecube = pi3d.EnvironmentCube(size=900.0, maptype="FACES", name="cube")
myecube.set_draw_details(flatsh, ectex)

# Create elevation map
mapsize = 1000.0
mapheight = 60.0
mountimg1 = pi3d.Texture("textures/mountains3_512.jpg")
mymap = pi3d.ElevationMap("textures/mountainsHgt.png",
                          name="map",
                          width=mapsize,
                          depth=mapsize,
                          height=mapheight,
                          divx=32,
                          divy=32)
mymap.set_draw_details(shader, [mountimg1, bumpimg, reflimg], 128.0, 0.0)
mymap.set_fog(*FOG)

#Create tree models
treeplane = pi3d.Plane(w=4.0, h=5.0)

treemodel1 = pi3d.MergeShape(name="baretree")
treemodel1.add(treeplane.buf[0], 0, 0, 0)
treemodel1.add(treeplane.buf[0], 0, 0, 0, 0, 90, 0)

treemodel2 = pi3d.MergeShape(name="bushytree")
treemodel2.add(treeplane.buf[0], 0, 0, 0)
Esempio n. 16
0
reflcn = pi3d.Texture("textures/stars.jpg")

#load environment cube
ectex = pi3d.loadECfiles("textures/ecubes", "sbox_interstellar")
myecube = pi3d.EnvironmentCube(size=900.0, maptype="FACES")
myecube.set_draw_details(flatsh, ectex)

# Create elevation map
mapwidth = 1000.0
mapdepth = 1000.0
mapheight = 60.0
mountimg1 = pi3d.Texture("textures/mars_colour.png")
bumpimg = pi3d.Texture("textures/mudnormal.jpg")
mymap = pi3d.ElevationMap(mapfile="textures/mars_height.png",
                          width=mapwidth,
                          depth=mapdepth,
                          height=mapheight,
                          divx=128,
                          divy=128)
mymap.set_draw_details(bumpsh, [mountimg1, bumpimg], 128.0, 0.0)
mymap.set_fog((0.3, 0.15, 0.1, 0.7), 700.0)

#create robot
metalimg = pi3d.Texture("textures/metalhull.jpg")
robot_head = pi3d.Sphere(radius=1.0)
robot_body = pi3d.Cylinder(radius=1.0, height=2.0, sides=12)
robot_leg = pi3d.Cuboid(w=0.35, h=2.0)

robot = pi3d.MergeShape()
robot.add(robot_head.buf[0], 0.0, 1.6)
robot.add(robot_body.buf[0], 0.0, 0.5)
robot.add(robot_leg.buf[0], -1.04, 0, 0)
Esempio n. 17
0
FOG = ((0.3, 0.3, 0.4, 0.8), 650.0)
TFOG = ((0.2, 0.24, 0.22, 1.0), 350.0)

#myecube = pi3d.EnvironmentCube(900.0,"HALFCROSS")
ectex=pi3d.loadECfiles("textures/ecubes","sbox")
myecube = pi3d.EnvironmentCube(size=900.0, maptype="FACES", name="cube")
myecube.set_draw_details(flatsh, ectex)

# Create elevation map
mapwidth = 1000.0
mapdepth = 1000.0
mapheight = 45.0 # can't cope with much elevation
mountimg1 = pi3d.Texture("textures/mountains3_512.jpg")
mymap = pi3d.ElevationMap("textures/mountainsHgt.jpg", name="map",
                     width=mapwidth, depth=mapdepth, height=mapheight,
                     divx=32, divy=32) #testislands.jpg
mymap.set_draw_details(shader, [mountimg1, bumpimg, bumpimg], 128.0, 0.0)
mymap.set_fog(*FOG)

#Create tree models
treeplane = pi3d.Plane(w=4.0, h=5.0)

treemodel1 = pi3d.MergeShape(name="baretree")
treemodel1.merge([[treeplane, 0,0,0, 0,0,0, 1,1,1],
                [treeplane, 0,0,0, 0,90,0, 1,1,1]])

treemodel2 = pi3d.MergeShape(name="bushytree")
treemodel2.merge([[treeplane, 0,0,0, 0,0,0, 1,1,1],
                [treeplane, 0,0,0, 0,60,0, 1,1,1],
                [treeplane, 0,0,0, 0,120,0, 1,1,1]])
Esempio n. 18
0
class Main(object):
    # Setup display and initialise pi3d
    DISPLAY = pi3d.Display.create()
    pi3d.Light(lightpos=(1, -1, -3),
               lightcol=(1.0, 1.0, 0.8),
               lightamb=(0.25, 0.2, 0.3))
    # load shader
    shader = pi3d.Shader("uv_bump")
    shinesh = pi3d.Shader("uv_reflect")
    flatsh = pi3d.Shader("uv_flat")

    tree2img = pi3d.Texture("textures/tree2.png")
    tree1img = pi3d.Texture("textures/tree1.png")
    hb2img = pi3d.Texture("textures/hornbeam2.png")
    bumpimg = pi3d.Texture("textures/grasstile_n.jpg")
    reflimg = pi3d.Texture("textures/stars.jpg")
    rockimg = pi3d.Texture("textures/rock1.jpg")

    FOG = ((0.3, 0.3, 0.4, 0.8), 650.0)
    TFOG = ((0.2, 0.24, 0.22, 1.0), 150.0)

    #myecube = pi3d.EnvironmentCube(900.0,"HALFCROSS")
    ectex = pi3d.loadECfiles("textures/ecubes", "sbox")
    myecube = pi3d.EnvironmentCube(size=900.0, maptype="FACES", name="cube")
    myecube.set_draw_details(flatsh, ectex)

    # Create elevation map
    mapsize = 1000.0
    mapheight = 60.0
    mountimg1 = pi3d.Texture("textures/mountains3_512.jpg")
    mymap = pi3d.ElevationMap("textures/mountainsHgt.png",
                              name="map",
                              width=mapsize,
                              depth=mapsize,
                              height=mapheight,
                              divx=32,
                              divy=32)
    mymap.set_draw_details(shader, [mountimg1, bumpimg, reflimg], 128.0, 0.0)
    mymap.set_fog(*FOG)

    #Create tree models
    treeplane = pi3d.Plane(w=4.0, h=5.0)

    treemodel1 = pi3d.MergeShape(name="baretree")
    treemodel1.add(treeplane.buf[0], 0, 0, 0)
    treemodel1.add(treeplane.buf[0], 0, 0, 0, 0, 90, 0)

    treemodel2 = pi3d.MergeShape(name="bushytree")
    treemodel2.add(treeplane.buf[0], 0, 0, 0)
    treemodel2.add(treeplane.buf[0], 0, 0, 0, 0, 60, 0)
    treemodel2.add(treeplane.buf[0], 0, 0, 0, 0, 120, 0)

    #Scatter them on map using Merge shape's cluster function
    mytrees1 = pi3d.MergeShape(name="trees1")
    mytrees1.cluster(treemodel1.buf[0], mymap, 0.0, 0.0, 200.0, 200.0, 20, "",
                     8.0, 3.0)
    mytrees1.set_draw_details(flatsh, [tree2img], 0.0, 0.0)
    mytrees1.set_fog(*TFOG)

    mytrees2 = pi3d.MergeShape(name="trees2")
    mytrees2.cluster(treemodel2.buf[0], mymap, 0.0, 0.0, 200.0, 200.0, 20, "",
                     6.0, 3.0)
    mytrees2.set_draw_details(flatsh, [tree1img], 0.0, 0.0)
    mytrees2.set_fog(*TFOG)

    mytrees3 = pi3d.MergeShape(name="trees3")
    mytrees3.cluster(treemodel2, mymap, 0.0, 0.0, 300.0, 300.0, 20, "", 4.0,
                     2.0)
    mytrees3.set_draw_details(flatsh, [hb2img], 0.0, 0.0)
    mytrees3.set_fog(*TFOG)

    #Create monument
    monument = pi3d.Model(file_string="models/pi3d.obj", name="monument")
    monument.set_shader(shinesh)
    monument.set_normal_shine(bumpimg, 16.0, reflimg, 0.4)
    monument.set_fog(*FOG)
    monument.translate(100.0, -mymap.calcHeight(100.0, 235) + 12.0, 235.0)
    monument.scale(20.0, 20.0, 20.0)
    monument.rotateToY(65)

    #avatar camera
    rot = 0.0
    tilt = 0.0
    avhgt = 3.5
    xm = 0.0
    zm = 0.0
    ym = mymap.calcHeight(xm, zm) + avhgt

    go_flag = False
    go_speed = 0.2

    CAMERA = pi3d.Camera.instance()

    def pi3dloop(self, dt):
        self.DISPLAY.loop_running()
        self.CAMERA.reset()
        self.CAMERA.rotate(self.tilt, self.rot, 0)
        self.CAMERA.position((self.xm, self.ym, self.zm))
        self.myecube.position(self.xm, self.ym, self.zm)

        # for opaque objects it is more efficient to draw from near to far as the
        # shader will not calculate pixels already concealed by something nearer
        self.myecube.draw()
        self.mymap.draw()
        dx = math.copysign(self.mapsize, self.xm)
        dz = math.copysign(self.mapsize, self.zm)
        mid = 0.3 * self.mapsize
        if abs(self.xm) > mid:  #nearing edge
            self.mymap.position(dx, 0.0, 0.0)
            self.mymap.draw()
        if abs(self.zm) > mid:  #other edge
            self.mymap.position(0.0, 0.0, dz)
            self.mymap.draw()
            if abs(self.xm) > mid:  #i.e. in corner, both edges
                self.mymap.position(dx, 0.0, dz)
                self.mymap.draw()
        self.mymap.position(0.0, 0.0, 0.0)
        self.monument.draw()
        self.mytrees1.draw()
        self.mytrees2.draw()
        self.mytrees3.draw()

        if pi3d.PLATFORM == PLATFORM_ANDROID:  #*****************************
            if self.DISPLAY.android.screen.moved:
                self.rot -= self.DISPLAY.android.screen.touch.dx * 0.25
                self.tilt += self.DISPLAY.android.screen.touch.dy * 0.25
                self.DISPLAY.android.screen.moved = False
                self.DISPLAY.android.screen.tapped = False
            elif self.DISPLAY.android.screen.tapped:
                self.go_speed *= 1.5
                self.DISPLAY.android.screen.tapped = False
            elif self.DISPLAY.android.screen.double_tapped:
                self.go_flag = not self.go_flag
                self.DISPLAY.android.screen.double_tapped = False
        else:
            mx, my = self.mymouse.position()

            #if mx>display.left and mx<display.right and my>display.top and my<display.bottom:
            self.rot -= (mx - self.omx) * 0.2
            self.tilt += (my - self.omy) * 0.2
            self.omx = mx
            self.omy = my

            #Press ESCAPE to terminate
            k = self.mykeys.read()
            if k > -1:
                if k == ord('w'):  #key W
                    self.go_flag = not self.go_flag
                elif k == 27:  #Escape key
                    return False

        if self.go_flag:
            self.xm -= math.sin(math.radians(self.rot)) * self.go_speed
            self.zm += math.cos(math.radians(self.rot)) * self.go_speed
            self.ym = self.mymap.calcHeight(self.xm, self.zm) + self.avhgt
            halfmap = self.mapsize / 2.0  # save doing this four times!
            self.xm = (self.xm + halfmap) % self.mapsize - halfmap
            self.zm = (self.zm + halfmap) % self.mapsize - halfmap

        else:
            self.go_speed = 0.2
        return True

    def run(self):
        if pi3d.PLATFORM == PLATFORM_ANDROID:  #*****************************
            self.DISPLAY.android.set_loop(self.pi3dloop)
            self.DISPLAY.android.run()
        else:
            # Fetch key presses
            self.mykeys = pi3d.Keyboard()
            self.mymouse = pi3d.Mouse(restrict=False)
            self.mymouse.start()
            self.omx, self.omy = self.mymouse.position()
            while self.pi3dloop(0.0):
                pass
            self.mykeys.close()
            self.mymouse.stop()

        self.DISPLAY.stop()