Beispiel #1
0
                          depth=mapdepth,
                          height=mapheight,
                          divx=64,
                          divy=64,
                          camera=CAMERA,
                          texmap='textures/roads.jpg')
mymap.set_draw_details(ELEVSH, [
    grassimg, grassbmp, rockimg, rockbmp, mountimg1, rockbmp, roadimg, mudbmp
],
                       64.0,
                       0.0,
                       umult=96.0,
                       vmult=96.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()
    if cam_toggle:
        a.set_ailerons(-mx * 0.001)
        a.set_elevator(my * 0.001)
    else:
        cam_rot -= mx * 0.1
        cam_pitch -= my * 0.1
    #"""
Beispiel #2
0
#!/usr/bin/python3
'''3dWorld.py'''
''' An example of generating a 3D environment using an elevation map
'''
from math import sin, cos, radians
import pi3d

DISPLAY = pi3d.Display.create(x=50, y=50)
#Capture mouse and key presses
INPUTS = pi3d.InputEvents()


def limit(value, min_value, max_value):
    if value < min_value:
        value = min_value
    elif value > max_value:
        value = max_value
    return value


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,