Debugging VR mode, remove vrzero
Access to different view on normal mode with 'o' Add objects in a different filemaster
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
@ -0,0 +1,35 @@
|
||||||
|
# Blender MTL File: 'Full_remake.blend'
|
||||||
|
# Material Count: 3
|
||||||
|
|
||||||
|
newmtl face.png.004
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.250000 0.250000 0.250000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd face.png
|
||||||
|
|
||||||
|
newmtl pants.png.003
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.250000 0.250000 0.250000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd pants.png
|
||||||
|
|
||||||
|
newmtl shirt.png.004
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.250000 0.250000 0.250000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd shirt.png
|
|
@ -0,0 +1 @@
|
||||||
|
Model ripped by Roxas358, no credit needed.
|
After Width: | Height: | Size: 333 KiB |
272
src/RUN.py
|
@ -5,7 +5,9 @@ import math,random
|
||||||
import pi3d
|
import pi3d
|
||||||
import avatars
|
import avatars
|
||||||
import maps
|
import maps
|
||||||
|
import building
|
||||||
import objects
|
import objects
|
||||||
|
import os
|
||||||
#import sys
|
#import sys
|
||||||
from serial_data import Serial_data
|
from serial_data import Serial_data
|
||||||
#sys.path.insert(0, "../python-vrzero")
|
#sys.path.insert(0, "../python-vrzero")
|
||||||
|
@ -18,45 +20,39 @@ USE_TUNNEL = True # If mode stereo is on, use Tunnel effect
|
||||||
SHOW_STAT = False # Show FPS stat (Calibrated for Raspberry Pi)
|
SHOW_STAT = False # Show FPS stat (Calibrated for Raspberry Pi)
|
||||||
|
|
||||||
# Change screen size to adapt your config
|
# Change screen size to adapt your config
|
||||||
DEFAULT_SCREEN_WIDTH=300
|
DEFAULT_SCREEN_WIDTH=1200
|
||||||
DEFAULT_SCREEN_HEIGHT=200
|
DEFAULT_SCREEN_HEIGHT=600
|
||||||
DEFAULT_EYE_SEPERATION=0.65
|
DEFAULT_EYE_SEPERATION=0.65
|
||||||
|
|
||||||
# height of the camera
|
# height of the camera
|
||||||
DEFAULT_AVATAR_EYE_HEIGHT = 4.0
|
DEFAULT_AVATAR_EYE_HEIGHT = 4.0
|
||||||
DEFAULT_AVATAR_MOVEMENT_SPEED = 0.6
|
DEFAULT_AVATAR_MOVEMENT_SPEED = 0.6
|
||||||
|
|
||||||
# two maps for now, so Hall (True) or Forest (False) :)
|
# Select your map moon or forest
|
||||||
MAP_HALL = True
|
MAP = 'forest'
|
||||||
|
|
||||||
# Select your Avatars here (you can manualy add more)
|
# Select your Avatars here (you can manualy add more)
|
||||||
AVATAR_1 = 'Lego'
|
AVATAR_1 = 'Link'
|
||||||
AVATAR_2 = 'Roshi'
|
AVATAR_2 = 'Goku'
|
||||||
|
|
||||||
|
os.putenv('SDL_FBDEV', '/dev/fb0')
|
||||||
|
os.putenv('SDL_VIDEODRIVER', 'fbcon')
|
||||||
|
|
||||||
|
DISPLAY = pi3d.Display.create(w=DEFAULT_SCREEN_WIDTH, h=DEFAULT_SCREEN_HEIGHT, use_pygame=True)
|
||||||
|
DISPLAY.set_background(0.0,0.0,0.0,1)
|
||||||
|
DISPLAY.frames_per_second = 30
|
||||||
|
pi3d.Light(lightpos=(1, -1, -3), lightcol=(1.0, 1.0, 0.8), lightamb=(0.25, 0.2, 0.3))
|
||||||
|
|
||||||
|
# Initialize Camera
|
||||||
if(USE_STEREO):
|
if(USE_STEREO):
|
||||||
engine.show_stats=SHOW_STAT
|
shader_name = "barrel" if USE_TUNNEL else "uv_flat"
|
||||||
engine.debug = True
|
CAMERA = pi3d.StereoCam(separation=DEFAULT_EYE_SEPERATION, interlace=0, shader=shader_name)
|
||||||
engine.use_simple_display=not USE_TUNNEL
|
else:
|
||||||
engine._avatar_eye_height = DEFAULT_AVATAR_EYE_HEIGHT
|
CAMERA = pi3d.Camera(absolute=False)
|
||||||
engine._avatar_movement_speed = DEFAULT_AVATAR_MOVEMENT_SPEED
|
|
||||||
engine.hmd_screen_width = DEFAULT_SCREEN_WIDTH
|
|
||||||
engine.hmd_screen_height = DEFAULT_SCREEN_HEIGHT
|
|
||||||
engine.hmd_eye_seperation = DEFAULT_EYE_SEPERATION
|
|
||||||
engine.init()
|
|
||||||
#engine.use_crosseyed_method=False
|
|
||||||
|
|
||||||
# Setup display and initialise pi3d
|
|
||||||
if(USE_STEREO == False):
|
|
||||||
DISPLAY = pi3d.Display.create()
|
|
||||||
#DISPLAY = pi3d.Display.create(x=250, y=250)
|
|
||||||
DISPLAY.set_background(0.4,0.8,0.8,1) # r,g,b,alpha
|
|
||||||
DISPLAY.frames_per_second = 30
|
|
||||||
# yellowish directional light blueish ambient light
|
|
||||||
pi3d.Light(lightpos=(1, -1, -3), lightcol=(1.0, 1.0, 0.8), lightamb=(0.25, 0.2, 0.3))
|
|
||||||
|
|
||||||
#========================================
|
#========================================
|
||||||
|
|
||||||
# Create Hero & map, Select your avatars here
|
# Create Hero & map, Select your avatars here
|
||||||
#avatar = avatars.cloud()
|
|
||||||
if AVATAR_1 == 'Link':
|
if AVATAR_1 == 'Link':
|
||||||
avatar = avatars.link()
|
avatar = avatars.link()
|
||||||
elif AVATAR_1 == 'Cloud':
|
elif AVATAR_1 == 'Cloud':
|
||||||
|
@ -81,62 +77,43 @@ elif AVATAR_2 == 'Roshi':
|
||||||
elif AVATAR_2 == 'Goku':
|
elif AVATAR_2 == 'Goku':
|
||||||
avatar2 = avatars.goku()
|
avatar2 = avatars.goku()
|
||||||
|
|
||||||
if MAP_HALL:
|
if MAP == 'forest':
|
||||||
map1 = maps.hall()
|
|
||||||
else:
|
|
||||||
map1 = maps.forest()
|
map1 = maps.forest()
|
||||||
|
elif MAP == 'moon':
|
||||||
|
map1 = maps.moon()
|
||||||
|
|
||||||
bulle = objects.object()
|
bulle = objects.object()
|
||||||
|
|
||||||
#avatar
|
#avatar
|
||||||
step = [0.0, 0.0, 0.0]
|
#step = [0.0, 0.0, 0.0]
|
||||||
xm = 0.0
|
xm = 0.0
|
||||||
zm = 0.0
|
zm = 0.0
|
||||||
if MAP_HALL:
|
ym = map1.mymap.calcHeight(xm, zm) + 9 + DEFAULT_AVATAR_EYE_HEIGHT
|
||||||
avhgt = 15 # doit etre DEFAULT_AVATAR_EYE_HEIGHT
|
xc = 0.0
|
||||||
ym = avhgt
|
yc = 0.0
|
||||||
else:
|
zc = 0.0
|
||||||
avhgt = 9
|
|
||||||
ym = map1.mymap.calcHeight(xm, zm) + avhgt
|
|
||||||
|
|
||||||
# camera position
|
# camera position
|
||||||
rot = 0.0
|
rot = 0.0
|
||||||
tilt = -7.0
|
tilt = -0.0
|
||||||
norm = None
|
norm = None
|
||||||
crab = False
|
crab = False
|
||||||
roll = 0.0
|
roll = 0.0
|
||||||
|
|
||||||
|
stereo_rot = 0.0
|
||||||
|
stereo_tilt = 0.0
|
||||||
|
stereo_roll = 0.0
|
||||||
|
|
||||||
# variables
|
# variables
|
||||||
#distance_hero = 15
|
|
||||||
synchro_serial=0
|
synchro_serial=0
|
||||||
movement = 0
|
movement = 0
|
||||||
mv_tmp = 0
|
mv_tmp = 0
|
||||||
mv_run = 0
|
mv_run = 0
|
||||||
mv_run_diff = 0
|
mv_run_diff = 0
|
||||||
avatar_speed = DEFAULT_AVATAR_MOVEMENT_SPEED
|
avatar_speed = DEFAULT_AVATAR_MOVEMENT_SPEED
|
||||||
lx = 0
|
|
||||||
ly = 0
|
|
||||||
lz = 0
|
|
||||||
orientation = 0
|
orientation = 0
|
||||||
camera_distance = -13
|
camera_distance = -20
|
||||||
|
|
||||||
|
|
||||||
shader_light = pi3d.Shader("uv_light")
|
|
||||||
coffimg = pi3d.Texture("../textures/COFFEE.PNG")
|
|
||||||
earth = pi3d.Texture("../textures/rock1.png")
|
|
||||||
flatsh = pi3d.Shader("uv_flat")
|
|
||||||
font = pi3d.Pngfont("../fonts/GillSansMT.png", (255,80,0,255))
|
|
||||||
mystring = pi3d.String(font=font, string="NOW NO EXCUSES", size=0.8, x=2, y=2, z=2, is_3d=True)
|
|
||||||
mystring2 = pi3d.String(font=font, string="BE YOUR HERO !!!", size=0.8, x=2, y=2, z=2, is_3d=True)
|
|
||||||
#mystring.translate(0.0, 0.0, 1)
|
|
||||||
mystring.scale(3, 3, 3)
|
|
||||||
mystring.set_shader(flatsh)
|
|
||||||
mystring2.scale(3, 3, 3)
|
|
||||||
mystring2.set_shader(flatsh)
|
|
||||||
myPlane = pi3d.Plane(w=7, h=1.8, name="plane")
|
|
||||||
myTriangle = pi3d.Triangle(sx=2, sy=2, sz=2, name="triangle", rz = 180)
|
|
||||||
mycone = pi3d.Cone(radius=1, height=2, sides=24, name="Cone", rz=180)
|
|
||||||
#myTriangle.set_shader(shader)
|
|
||||||
|
|
||||||
# Fetch key presses
|
# Fetch key presses
|
||||||
mykeys = pi3d.Keyboard()
|
mykeys = pi3d.Keyboard()
|
||||||
|
@ -148,14 +125,13 @@ pos_forarmR = [0, 0, 0]
|
||||||
pos_armL = [0, 0, 0]
|
pos_armL = [0, 0, 0]
|
||||||
pos_forarmL = [0, 0, 0]
|
pos_forarmL = [0, 0, 0]
|
||||||
body_orientation = 0
|
body_orientation = 0
|
||||||
|
flag_jump = 0
|
||||||
|
flag_view = True
|
||||||
|
jump_height = 28
|
||||||
timer =0
|
timer =0
|
||||||
keep_running = True
|
keep_running = True
|
||||||
|
|
||||||
|
|
||||||
# Initialize Camera
|
|
||||||
if(USE_STEREO == False):
|
|
||||||
CAMERA = pi3d.Camera(absolute=False)
|
|
||||||
|
|
||||||
def roger_handler(sensor, Euler0, Euler1, Euler2):
|
def roger_handler(sensor, Euler0, Euler1, Euler2):
|
||||||
global pos_armR, pos_forarmR, pos_armL, pos_forarmL, timer, body_orientation, mv_run, mv_run_diff, xm, zm
|
global pos_armR, pos_forarmR, pos_armL, pos_forarmL, timer, body_orientation, mv_run, mv_run_diff, xm, zm
|
||||||
timer += 1
|
timer += 1
|
||||||
|
@ -206,7 +182,6 @@ def roger_handler(sensor, Euler0, Euler1, Euler2):
|
||||||
#print("ORIENTATION : ", camera_orientation)
|
#print("ORIENTATION : ", camera_orientation)
|
||||||
|
|
||||||
camera_orientation = 0
|
camera_orientation = 0
|
||||||
|
|
||||||
|
|
||||||
if math.fabs(joystick_v_axis_pos) > 0.1:
|
if math.fabs(joystick_v_axis_pos) > 0.1:
|
||||||
xm -= math.sin(math.pi/2+camera_orientation*20)*-joystick_v_axis_pos*avatar_speed
|
xm -= math.sin(math.pi/2+camera_orientation*20)*-joystick_v_axis_pos*avatar_speed
|
||||||
|
@ -230,70 +205,49 @@ if(USE_SERIAL):
|
||||||
ser = Serial_data('ABCDEFJ', roger_handler)
|
ser = Serial_data('ABCDEFJ', roger_handler)
|
||||||
ser.start()
|
ser.start()
|
||||||
|
|
||||||
def update():
|
#============================================================================================================
|
||||||
global xm, ym, zm, step, norm, roll, orientation, movement, lx, ly, lz, mv_run, mv_run_diff, body_orientation, synchro_serial
|
|
||||||
|
|
||||||
if(USE_STEREO):
|
def update_position():
|
||||||
(x, y, z) = engine.avatar_position
|
global xm, ym, zm, xc, yc, zc
|
||||||
if MAP_HALL:
|
|
||||||
pass
|
ym = map1.mymap.calcHeight(xm, zm)
|
||||||
else:
|
|
||||||
engine.avatar_y_pos = map1.mymap.calcHeight(x, z+18) + engine.avatar_eye_height +0
|
avatar.center.position(xm, ym, zm)
|
||||||
|
avatar2.center.position(-10, map1.mymap.calcHeight(-10, 15), 15)
|
||||||
if not USE_STEREO:
|
#avatar2.center.position(-5, map1.mymap.calcHeight(-5, 5), 5)
|
||||||
if step != [0.0, 0.0, 0.0]: #i.e. previous loop set movmement
|
bulle.myplane.position(-10, map1.mymap.calcHeight(-10, 15)+11, 15.2)
|
||||||
pass
|
|
||||||
if MAP_HALL:
|
|
||||||
ym = 0
|
|
||||||
else:
|
|
||||||
ym, norm = map1.mymap.calcHeight(xm, zm, True)
|
|
||||||
ym += avhgt
|
|
||||||
#print(" Position : ", xm, " === ", ym, " === ",zm, " === ")
|
|
||||||
step = [0.0, 0.0, 0.0]
|
|
||||||
|
|
||||||
|
|
||||||
map1.myecube.position(xm, ym, zm)
|
map1.myecube.position(xm, ym, zm)
|
||||||
roll = 0.0
|
|
||||||
#map1.mymap.position(0.0, 0.0, 0.0)
|
|
||||||
#avatar.body.position(xm, mymap.calcHeight(xm, zm+distance_hero)+5.5, zm+distance_hero)
|
|
||||||
|
|
||||||
if MAP_HALL:
|
def update_avatar():
|
||||||
avatar.center.position(xm, ym-5, zm) # others
|
global xm, ym, zm, mv_run, mv_run_diff, body_orientation, synchro_serial, flag_jump
|
||||||
avatar2.center.position(-10, 10, 15) # equivalent a -13, 15 et 0
|
|
||||||
#bulle.Position(xm,ym,zm)
|
|
||||||
mystring.position(-10, 18.5, 14.9)
|
|
||||||
mystring2.position(-10, 17.5, 14.9)
|
|
||||||
#bulle.mycone.position(-10, ym+2, 15)
|
|
||||||
myPlane.position(-10, 18, 15)
|
|
||||||
else:
|
|
||||||
avatar.center.position(xm, map1.mymap.calcHeight(xm, zm), zm)
|
|
||||||
avatar2.center.position(-30, map1.mymap.calcHeight(-30, 80), 80)
|
|
||||||
#print(xm, ym, zm)
|
|
||||||
|
|
||||||
|
# if we are moving
|
||||||
if(mv_run_diff > 0):
|
if(mv_run_diff > 0):
|
||||||
avatar.run(mv_run, mv_run_diff)
|
avatar.run(mv_run, mv_run_diff)
|
||||||
|
|
||||||
|
# if we are jumping
|
||||||
|
#if(flag_jump > 0):
|
||||||
|
# avatar.jump(flag_jump, xm, ym, zm, body_orientation)
|
||||||
|
# flag_jump -=1
|
||||||
synchro_serial=10
|
synchro_serial=10
|
||||||
|
|
||||||
|
# if we are standing
|
||||||
if(synchro_serial == 1):
|
if(synchro_serial == 1):
|
||||||
avatar.stand()
|
avatar.stand()
|
||||||
|
|
||||||
if (synchro_serial > 0):
|
#avatar.pose()
|
||||||
synchro_serial -=1
|
|
||||||
|
|
||||||
avatar.center.rotateToY(body_orientation)
|
avatar.center.rotateToY(body_orientation)
|
||||||
#bulle.mycone.rotateToY(movement)
|
|
||||||
|
|
||||||
|
if (synchro_serial > 0):
|
||||||
|
synchro_serial -=1
|
||||||
mv_run_diff=0
|
mv_run_diff=0
|
||||||
lx = xm
|
|
||||||
ly = ym
|
|
||||||
lz = zm
|
|
||||||
movement += 4
|
|
||||||
|
|
||||||
|
|
||||||
def update_scenario():
|
def update_scenario():
|
||||||
global xm, ym, zm
|
global xm, ym, zm
|
||||||
#print(xm, ym, zm)
|
#print(xm, ym, zm)
|
||||||
if -15 <= xm and xm <= -5 and 14 <= ym and ym <= 16 and 10 <= zm and zm <= 19:
|
if -15 <= xm and xm <= -5 and 10 <= zm and zm <= 19:
|
||||||
if -13 <= xm and xm <= -10:
|
if -13 <= xm and xm <= -10:
|
||||||
xm = -13
|
xm = -13
|
||||||
elif -10 <= xm and xm <= -7:
|
elif -10 <= xm and xm <= -7:
|
||||||
|
@ -302,28 +256,25 @@ def update_scenario():
|
||||||
zm = 13
|
zm = 13
|
||||||
elif 14.5 <= zm and zm <= 16:
|
elif 14.5 <= zm and zm <= 16:
|
||||||
zm = 16
|
zm = 16
|
||||||
#bulle.myPlane.draw(shader_light, [earth])
|
bulle.myplane.draw()
|
||||||
mystring.draw()
|
|
||||||
mystring2.draw()
|
|
||||||
myPlane.draw(shader_light, [earth])
|
|
||||||
|
|
||||||
|
|
||||||
def draw():
|
def draw():
|
||||||
global mv_tmp
|
#global body_rotation
|
||||||
mv_tmp += 0.2
|
#avatar.center.rotateToY(180)
|
||||||
|
#avatar.center.position(-5, 74.5, 1)
|
||||||
#bulle.mycone.draw(shader, [coffimg])
|
#global mv_tmp
|
||||||
#avatar.handR.rotateToY(50 * math.sin(mv_tmp))
|
#mv_tmp += 0.2
|
||||||
|
#avatar.pose()
|
||||||
|
#avatar2.pose()
|
||||||
avatar2.center.draw()
|
avatar2.center.draw()
|
||||||
avatar.center.draw()
|
avatar.center.draw()
|
||||||
|
map1.building()
|
||||||
map1.mymap.draw()
|
map1.mymap.draw()
|
||||||
map1.myecube.draw()
|
map1.myecube.draw()
|
||||||
#mystring.draw()
|
|
||||||
#myTriangle.draw()
|
|
||||||
|
|
||||||
|
|
||||||
def read_inputs():
|
def read_inputs():
|
||||||
global mymouse, my, mx, rot, tilt, keep_running, xm, zm, mv_run, mv_run_diff, body_orientation
|
global mymouse, my, mx, rot, tilt, keep_running, xm, zm, mv_run, mv_run_diff, body_orientation, flag_jump, flag_view
|
||||||
|
|
||||||
k = mykeys.read() # Read Keyboard inputs
|
k = mykeys.read() # Read Keyboard inputs
|
||||||
|
|
||||||
|
@ -348,19 +299,20 @@ def read_inputs():
|
||||||
mv_run += math.fabs(avatar_speed*2/3)
|
mv_run += math.fabs(avatar_speed*2/3)
|
||||||
mv_run_diff = 1
|
mv_run_diff = 1
|
||||||
body_orientation = 270
|
body_orientation = 270
|
||||||
|
elif k == 99: #key c jump
|
||||||
|
flag_jump = 28
|
||||||
|
elif k == 111: #key c jump
|
||||||
|
view = flag_view
|
||||||
|
flag_view = not view
|
||||||
elif k == 112: #key p picture
|
elif k == 112: #key p picture
|
||||||
pi3d.screenshot("forestWalk" + str(scshots) + ".jpg")
|
pi3d.screenshot("forestWalk" + str(scshots) + ".jpg")
|
||||||
scshots += 1
|
scshots += 1
|
||||||
elif k == 10: #key RETURN
|
elif k == 10: #key RETURN
|
||||||
mc = 0
|
mc = 0
|
||||||
elif k == 27: #Escape key to exit
|
elif k == 27: #Escape key to exit
|
||||||
print("***** Try to quit *****")
|
print("***** EXIT *****")
|
||||||
if USE_STEREO:
|
DISPLAY.destroy()
|
||||||
engine.hmd.close()
|
keep_running = False
|
||||||
engine.DISPLAY.destroy()
|
|
||||||
engine.keep_running = False
|
|
||||||
else:
|
|
||||||
keep_running = False
|
|
||||||
mykeys.close()
|
mykeys.close()
|
||||||
if USE_SERIAL:
|
if USE_SERIAL:
|
||||||
ser.stop()
|
ser.stop()
|
||||||
|
@ -376,41 +328,43 @@ def read_inputs():
|
||||||
rot = - mx * 0.8
|
rot = - mx * 0.8
|
||||||
tilt = my * 0.8
|
tilt = my * 0.8
|
||||||
|
|
||||||
|
|
||||||
def camera_update():
|
def camera_update():
|
||||||
global xm, ym, zm, rot, tilt, norm
|
global xm, ym, zm, xc, yc, zc, rot, tilt, norm, flag_view, stereo_rot, stereo_tilt, stereo_roll
|
||||||
camRad = [camera_distance, camera_distance, camera_distance]
|
|
||||||
#print("DBG {:03.2f},{:03.2f},{:03.2f} dist {:03.2f},{:03.2f},{:03.2f}".format(xm, ym, zm, *step))
|
if(USE_STEREO):
|
||||||
#xm, ym, zm = CAMERA.relocate(rot, tilt, point=[xm, ym, zm], distance=step,
|
stereo_rot += rot
|
||||||
# normal=norm, crab=crab, slope_factor=1.5)
|
stereo_tilt += tilt
|
||||||
|
stereo_roll += roll
|
||||||
|
CAMERA.move_camera([xm, map1.mymap.calcHeight(xm, zm)+5, zm], stereo_rot, stereo_tilt, - stereo_roll)
|
||||||
|
|
||||||
|
for i in range(2):
|
||||||
|
CAMERA.start_capture(i)
|
||||||
|
draw()
|
||||||
|
CAMERA.end_capture(i)
|
||||||
|
CAMERA.draw()
|
||||||
|
|
||||||
if MAP_HALL:
|
|
||||||
CAMERA.relocate(rot, tilt, point=[xm, ym, zm], distance=camRad)
|
|
||||||
else:
|
else:
|
||||||
CAMERA.relocate(rot, tilt, point=[xm, map1.mymap.calcHeight(xm, zm)+3, zm], distance=camRad)
|
if flag_view:
|
||||||
CAMERA.rotateZ(roll)
|
camRad = [camera_distance, camera_distance, camera_distance]
|
||||||
|
else:
|
||||||
|
camRad = [0, 0, 0]
|
||||||
|
|
||||||
|
#CAMERA.relocate(rot, tilt, point=[-5, 84.5, -0], distance=camRad)
|
||||||
|
xc, yc, zc = CAMERA.relocate(rot, tilt, point=[xm, map1.mymap.calcHeight(xm, zm)+5, zm], distance=camRad)
|
||||||
|
draw()
|
||||||
|
print( xm, ym, zm, " ---- ", xc, yc, zc)
|
||||||
|
#CAMERA.rotateZ(roll)
|
||||||
|
|
||||||
|
|
||||||
# Main loop
|
# Main loop
|
||||||
if(USE_STEREO):
|
while DISPLAY.loop_running() or keep_running:
|
||||||
while engine.DISPLAY.loop_running() or engine.keep_running:
|
read_inputs()
|
||||||
#read_inputs()
|
update_position()
|
||||||
engine.poll_inputs()
|
update_avatar()
|
||||||
engine.update_avatar()
|
update_scenario()
|
||||||
update()
|
camera_update()
|
||||||
engine.update_camera()
|
#engine.stats()
|
||||||
engine.render_stereo_scene(draw)
|
|
||||||
engine.stats()
|
|
||||||
if USE_SERIAL:
|
|
||||||
ser.stop()
|
|
||||||
|
|
||||||
else: # not stereo
|
|
||||||
while DISPLAY.loop_running() or keep_running:
|
|
||||||
read_inputs()
|
|
||||||
camera_update()
|
|
||||||
update()
|
|
||||||
update_scenario()
|
|
||||||
draw()
|
|
||||||
print(" STOP STOP")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -119,9 +119,6 @@ class cloud(BaseAvatar):
|
||||||
self.head.rotateToY(0)
|
self.head.rotateToY(0)
|
||||||
self.head.rotateToX(0)
|
self.head.rotateToX(0)
|
||||||
|
|
||||||
def jump(self, position):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class lego(BaseAvatar):
|
class lego(BaseAvatar):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -310,9 +307,52 @@ class link(BaseAvatar):
|
||||||
self.head.rotateToY(0)
|
self.head.rotateToY(0)
|
||||||
self.head.rotateToX(0)
|
self.head.rotateToX(0)
|
||||||
|
|
||||||
def jump(self, position):
|
def pose(self):
|
||||||
self.armL.rotateToX(20 * math.sin(position))
|
|
||||||
self.armR.rotateToX(-20 * math.sin(position))
|
self.legR.rotateToX(15)
|
||||||
|
self.legL.rotateToX(-15)
|
||||||
|
self.footR.rotateToX(-10)
|
||||||
|
self.footL.rotateToX(0)
|
||||||
|
|
||||||
|
#self.armL.rotateToZ(280)
|
||||||
|
self.armL.rotateToZ(40)
|
||||||
|
self.forarmL.rotateToY(10)
|
||||||
|
|
||||||
|
self.armR.rotateToX(30)
|
||||||
|
self.armR.rotateToY(280)
|
||||||
|
#self.armR.rotateToZ(280)
|
||||||
|
self.forarmR.rotateToZ(90)
|
||||||
|
self.forarmR.rotateToY(300)
|
||||||
|
|
||||||
|
self.body.rotateToY(0)
|
||||||
|
self.body.rotateToX(0)
|
||||||
|
self.head.rotateToY(0)
|
||||||
|
self.head.rotateToX(0)
|
||||||
|
|
||||||
|
def jump(self, position, x, y, z, orientation):
|
||||||
|
positionJump = position
|
||||||
|
positionRun = 70
|
||||||
|
if orientation == 0:
|
||||||
|
z += - (14 -position/2)
|
||||||
|
elif orientation == 90:
|
||||||
|
x += -(14 -position/2)
|
||||||
|
elif orientation == 180:
|
||||||
|
z += (14 -position/2)
|
||||||
|
elif orientation == 270:
|
||||||
|
x += (14 -position/2)
|
||||||
|
if positionJump >= 14:
|
||||||
|
self.center.position(x, y + (7 - positionJump/4), z)
|
||||||
|
else :
|
||||||
|
self.center.position(x, y + (positionJump/4), z)
|
||||||
|
self.legR.rotateToX(25 * math.sin(positionRun))
|
||||||
|
self.legL.rotateToX(-25 * math.sin(positionRun))
|
||||||
|
self.footR.rotateToX(-20+ 20 * math.sin(positionRun))
|
||||||
|
self.footL.rotateToX(-20 -20 * math.sin(positionRun))
|
||||||
|
|
||||||
|
self.armL.rotateToZ(300)
|
||||||
|
self.armR.rotateToZ(60)
|
||||||
|
self.armR.rotateToY(35.0 * math.sin(positionRun))
|
||||||
|
self.armL.rotateToY(35.0 * math.sin(positionRun))
|
||||||
|
|
||||||
class goku(BaseAvatar):
|
class goku(BaseAvatar):
|
||||||
|
|
||||||
|
@ -339,7 +379,7 @@ class goku(BaseAvatar):
|
||||||
|
|
||||||
self.armL = pi3d.Model(file_string="../Blender/DBZ/Goku/goku_armL.obj", cy=-29, cx=-5, cz=0.4)
|
self.armL = pi3d.Model(file_string="../Blender/DBZ/Goku/goku_armL.obj", cy=-29, cx=-5, cz=0.4)
|
||||||
self.armL.set_shader(shader)
|
self.armL.set_shader(shader)
|
||||||
self.handL = pi3d.Model(file_string="../Blender/DBZ/Goku/goku_handL.obj", cy=-29, cx=-11, cz=0.8)
|
self.handL = pi3d.Model(file_string="../Blender/DBZ/Goku/goku_handL2.obj", cy=-29, cx=-11, cz=0.8)
|
||||||
self.handL.set_shader(shader)
|
self.handL.set_shader(shader)
|
||||||
|
|
||||||
self.legL = pi3d.Model(file_string="../Blender/DBZ/Goku/goku_legL.obj", cy = -21)
|
self.legL = pi3d.Model(file_string="../Blender/DBZ/Goku/goku_legL.obj", cy = -21)
|
||||||
|
@ -423,6 +463,30 @@ class goku(BaseAvatar):
|
||||||
self.head.rotateToY(0)
|
self.head.rotateToY(0)
|
||||||
self.head.rotateToX(0)
|
self.head.rotateToX(0)
|
||||||
|
|
||||||
|
def pose(self):
|
||||||
|
|
||||||
|
self.legR.rotateToX(40)
|
||||||
|
self.legL.rotateToX(-40)
|
||||||
|
self.footR.rotateToX(-35)
|
||||||
|
self.footL.rotateToX(0)
|
||||||
|
|
||||||
|
#self.armL.rotateToZ(280)
|
||||||
|
#self.armL.rotateToZ(40)
|
||||||
|
#self.forarmL.rotateToY(10)
|
||||||
|
|
||||||
|
self.armL.rotateToX(30)
|
||||||
|
self.armL.rotateToY(-280)
|
||||||
|
|
||||||
|
#self.armR.rotateToZ(90)
|
||||||
|
self.armR.rotateToZ(70)
|
||||||
|
self.handR.rotateToY(-90)
|
||||||
|
#self.handR.rotateToY(350)
|
||||||
|
|
||||||
|
self.body.rotateToY(0)
|
||||||
|
self.body.rotateToX(-30)
|
||||||
|
#self.head.rotateToY(0)
|
||||||
|
self.head.rotateToX(20)
|
||||||
|
|
||||||
def jump(self, position):
|
def jump(self, position):
|
||||||
self.armL.rotateToX(20 * math.sin(position))
|
self.armL.rotateToX(20 * math.sin(position))
|
||||||
self.armR.rotateToX(-20 * math.sin(position))
|
self.armR.rotateToX(-20 * math.sin(position))
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/python
|
||||||
|
|
||||||
|
|
||||||
|
import pi3d
|
||||||
|
import math,random
|
||||||
|
|
||||||
|
class hall(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
#Setup shaders
|
||||||
|
flatsh = pi3d.Shader("uv_flat")
|
||||||
|
#shade2d = pi3d.Shader('2d_flat')
|
||||||
|
|
||||||
|
# create splash screen and draw it
|
||||||
|
#splash = pi3d.ImageSprite("../textures/pi3d_splash.jpg", shade2d, w=10, h=10, z=0.2)
|
||||||
|
#splash.draw()
|
||||||
|
#DISPLAY.swap_buffers()
|
||||||
|
|
||||||
|
#Setup environment cube
|
||||||
|
ectex = pi3d.loadECfiles("../textures/ecubes/Miramar", "miramar_256", "png", nobottom = True)
|
||||||
|
self.myecube = pi3d.EnvironmentCube(size=1800.0, maptype="FACES", nobottom=True)
|
||||||
|
self.myecube.set_draw_details(flatsh, ectex)
|
||||||
|
|
||||||
|
#Load Hall model
|
||||||
|
self.mymap = pi3d.Model(file_string="../models/ConferenceHall/conferencehall.egg", name="Hall", sx=0.1, sy=0.1, sz=0.1)
|
||||||
|
self.mymap.set_shader(flatsh)
|
||||||
|
self.mymap.position(0.0,10.0, 0.0)
|
||||||
|
|
97
src/maps.py
|
@ -41,25 +41,94 @@ class forest(object):
|
||||||
#screenshot number
|
#screenshot number
|
||||||
scshots = 1
|
scshots = 1
|
||||||
|
|
||||||
class hall(object):
|
def building(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class moon(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#Setup shaders
|
|
||||||
|
shader = pi3d.Shader("uv_reflect")
|
||||||
|
bumpsh = pi3d.Shader("uv_bump")
|
||||||
flatsh = pi3d.Shader("uv_flat")
|
flatsh = pi3d.Shader("uv_flat")
|
||||||
#shade2d = pi3d.Shader('2d_flat')
|
#shade2d = pi3d.Shader('2d_flat')
|
||||||
|
|
||||||
# create splash screen and draw it
|
ectex = pi3d.loadECfiles("../textures/ecubes/RedPlanet", "redplanet_256", "png", True)
|
||||||
#splash = pi3d.ImageSprite("../textures/pi3d_splash.jpg", shade2d, w=10, h=10, z=0.2)
|
self.myecube = pi3d.EnvironmentCube(size=1800.0, maptype="FACES")
|
||||||
#splash.draw()
|
self.myecube.set_draw_details(flatsh,ectex)
|
||||||
#DISPLAY.swap_buffers()
|
|
||||||
|
|
||||||
#Setup environment cube
|
# Create elevation map
|
||||||
ectex = pi3d.loadECfiles("../textures/ecubes/Miramar", "miramar_256", "png", nobottom = True)
|
mapwidth=2000.0
|
||||||
self.myecube = pi3d.EnvironmentCube(size=1800.0, maptype="FACES", nobottom=True)
|
mapdepth=2000.0
|
||||||
self.myecube.set_draw_details(flatsh, ectex)
|
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)
|
||||||
|
|
||||||
|
def building(self):
|
||||||
|
mody = 3
|
||||||
|
spc = 39.32
|
||||||
|
#pi3d.Utility.draw_level_of_detail([xm, ym, zm], [0, mody, 0], [[opendist,cor_cross],[1000,cor_cross_doors]])
|
||||||
|
#90 degree units
|
||||||
|
self.corridor.rotateToY(90)
|
||||||
|
self.cor_win.rotateToY(90)
|
||||||
|
self.cor_win.position(0, mody, spc*1.5)
|
||||||
|
self.cor_win.draw()
|
||||||
|
self.corridor.position(0, mody, spc*2.5)
|
||||||
|
self.corridor.draw()
|
||||||
|
self.cor_win.position(0, mody, spc*3.5)
|
||||||
|
self.cor_win.draw()
|
||||||
|
self.cor_win.position(0, mody, spc*6.5)
|
||||||
|
self.cor_win.draw()
|
||||||
|
#0 degree units
|
||||||
|
self.corridor.rotateToY(0)
|
||||||
|
self.cor_win.rotateToY(0)
|
||||||
|
#pi3d.Utility.draw_level_of_detail([xm, ym, zm], [0, mody, spc*5],[[opendist,cor_cross],[1000,cor_cross_doors]])
|
||||||
|
#pi3d.Utility.draw_level_of_detail([xm, ym, zm],[0, mody, spc*8], [[opendist,cor_cross],[1000,cor_cross_doors]])
|
||||||
|
self.cor_win.position(-spc*1.5, mody, spc*5)
|
||||||
|
self.cor_win.draw()
|
||||||
|
self.cor_bend.position(-spc*2.5, mody, spc*5)
|
||||||
|
self.cor_bend.draw()
|
||||||
|
#pi3d.Utility.draw_level_of_detail([xm, ym, zm],[-spc*2.6, mody, spc*6.6],[[opendist,cor_cross],[1000,cor_cross_doors]])
|
||||||
|
self.cor_win.position(spc*1.5, mody, spc*5)
|
||||||
|
self.cor_win.draw()
|
||||||
|
self.corridor.position(spc*2.5, mody, spc*5)
|
||||||
|
self.corridor.draw()
|
||||||
|
#pi3d.Utility.draw_level_of_detail([xm, ym, zm],[spc*4, mody, spc*5],[[opendist,cor_cross],[1000,cor_cross_doors]])
|
||||||
|
|
||||||
#Load Hall model
|
|
||||||
self.mymap = pi3d.Model(file_string="../models/ConferenceHall/conferencehall.egg", name="Hall", sx=0.1, sy=0.1, sz=0.1)
|
|
||||||
self.mymap.set_shader(flatsh)
|
|
||||||
self.mymap.position(0.0,10.0, 0.0)
|
|
||||||
|
|
||||||
|
|
|
@ -5,28 +5,33 @@ import pi3d
|
||||||
import math,random
|
import math,random
|
||||||
|
|
||||||
|
|
||||||
shader_light = pi3d.Shader("uv_light")
|
#shader_light = pi3d.Shader("uv_light")
|
||||||
earth = pi3d.Texture("../textures/rock1.png")
|
#earth = pi3d.Texture("../textures/rock1.png")
|
||||||
flatsh = pi3d.Shader("uv_flat")
|
|
||||||
|
|
||||||
class object(object):
|
class object(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
global flatsh
|
|
||||||
|
|
||||||
#font = pi3d.Pngfont("../fonts/GillSansMT.png", (221,0,170,255))
|
flatsh = pi3d.Shader("uv_flat")
|
||||||
font = pi3d.Pngfont("../fonts/GillSansMT.png", (255,80,0,255))
|
font = pi3d.Pngfont("../fonts/GillSansMT.png", (255,80,0,255))
|
||||||
self.mystring = pi3d.String(font=font, string="NOW NO EXCUSES", size=0.8, x=2, y=2, z=2, is_3d=True)
|
self.mystring = pi3d.String(font=font, string="NOW NO EXCUSES", size=0.8, x=0, y=-0.2, z=-0.5, is_3d=True, rx = 270)
|
||||||
self.mystring2 = pi3d.String(font=font, string="BE YOUR HERO !!!", size=0.8, x=2, y=2, z=2, is_3d=True)
|
self.mystring2 = pi3d.String(font=font, string="BE YOUR HERO !!!", size=0.8, x=0, y=-0.2, z=0.5, is_3d=True, rx = 270)
|
||||||
#mystring.translate(0.0, 0.0, 1)
|
#mystring.translate(0.0, 0.0, 1)
|
||||||
self.mystring.scale(3, 3, 3)
|
self.mystring.scale(3, 3, 3)
|
||||||
self.mystring.set_shader(flatsh)
|
self.mystring.set_shader(flatsh)
|
||||||
self.mystring2.scale(3, 3, 3)
|
self.mystring2.scale(3, 3, 3)
|
||||||
self.mystring2.set_shader(flatsh)
|
self.mystring2.set_shader(flatsh)
|
||||||
self.myPlane = pi3d.Plane(w=7, h=1.8, name="plane")
|
#self.myplane = pi3d.Plane(w=7, h=2.5, name="plane")
|
||||||
|
self.myplane = pi3d.Cylinder(radius=3, height=0.1, name="plane", rx = 90)
|
||||||
|
#self.myplane.set_shader(flatsh)
|
||||||
|
self.myplane.add_child(self.mystring)
|
||||||
|
self.myplane.add_child(self.mystring2)
|
||||||
|
"""
|
||||||
self.myTriangle = pi3d.Triangle(sx=2, sy=2, sz=2, name="triangle", rz = 180)
|
self.myTriangle = pi3d.Triangle(sx=2, sy=2, sz=2, name="triangle", rz = 180)
|
||||||
self.mycone = pi3d.Cone(radius=1, height=2, sides=24, name="Cone", rz=180)
|
self.mycone = pi3d.Cone(radius=1, height=2, sides=24, name="Cone", rz=180)
|
||||||
#self.myTriangle.set_shader(shader)
|
#self.myTriangle.set_shader(shader)
|
||||||
|
"""
|
||||||
|
|
||||||
def Position(self, xm, ym, zm):
|
def Position(self, xm, ym, zm):
|
||||||
self.mystring.position(-10, ym+2.5, 14.9)
|
self.mystring.position(-10, ym+2.5, 14.9)
|
||||||
|
|
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 380 KiB |
After Width: | Height: | Size: 39 KiB |