Exemplo n.º 1
0
                         y=2,
                         z=10)
# Extrude can use three different textures if they are loaded prior to draw()
myextrude.set_shader(shinesh)
myextrude.buf[0].set_draw_details(shinesh, [coffimg, shapebump, shapeshine],
                                  4.0, 0.2)
myextrude.buf[1].set_draw_details(shinesh, [patimg, shapebump, shapeshine],
                                  4.0, 0.2)
myextrude.buf[2].set_draw_details(shinesh, [shapeshine, shapebump, shapeshine],
                                  4.0, 0.2)

mycone = pi3d.Cone(radius=1, height=2, sides=24, name="Cone", x=-4, y=-1, z=10)
mycylinder = pi3d.Cylinder(radius=0.7,
                           height=1.5,
                           sides=24,
                           name="Cyli",
                           x=-2,
                           y=-1,
                           z=10)
# NB Lathe needs to start at the top otherwise normals are calculated in reverse,
# also inside surfaces need to be defined otherwise normals are wrong
mylathe = pi3d.Lathe(path=((0.0, 1.0), (0.6, 1.2), (0.8, 1.4), (1.09, 1.7),
                           (1.1, 1.7), (0.9, 1.4), (0.7, 1.2), (0.08, 1),
                           (0.08, 0.21), (0.1, 0.2), (1.0, 0.05), (1.0, 0.0),
                           (0.001, 0.0), (0.0, 0.0)),
                     sides=24,
                     name="Cup",
                     x=0,
                     y=-1,
                     z=10,
                     sx=0.8,
Exemplo n.º 2
0
import numpy as np

RANGE = 100.0
MODEL_PATH = '{}'
display = pi3d.Display.create(background=(0.0, 0.0, 0.0, 0.0))
shader = pi3d.Shader('uv_light')
laser_shader = pi3d.Shader('mat_flat')

# pod and laser
pod = pi3d.Model(file_string=MODEL_PATH.format('pod_2.obj'), z=20.0)
laser_base = pi3d.Model(file_string=MODEL_PATH.format('laser_base_2.obj'),
                        y=3.15)
laser_gun = pi3d.Model(file_string=MODEL_PATH.format('laser_gun_2.obj'),
                       y=0.4,
                       z=-0.4)
laser_tip = pi3d.Cylinder(radius=0.05, height=5.0, rx=90.0, y=0.28)
laser_tip.set_material((1.0, 0.0, 0.0))
laser_tip.set_alpha(0.0)
laser_gun.add_child(laser_tip)
laser_base.add_child(laser_gun)
pod.add_child(laser_base)
pod.set_shader(shader)  # all use uv_light shader
laser_tip.set_shader(laser_shader)

# asteroid
asteroid = pi3d.Model(file_string=MODEL_PATH.format('asteroid_large_1.obj'),
                      z=50,
                      y=10,
                      x=20)
asteroid.set_shader(shader)
test = pi3d.Texture('backgrounds/IMG-20160924-WA0008.jpg')

myglass = pi3d.Tube(CAMERA3D,
                    radius=0.3,
                    sides=30,
                    thickness=0.05,
                    height=1,
                    name="Glass",
                    x=0,
                    y=0,
                    z=0)  #child has z = 0
#myglass.set_alpha(0.4)
#myglass.set_material((0.1,0.1,0.1))
#myglass.set_draw_details(matl, [], 0.0, 1.0)

mybottom = pi3d.Cylinder(radius=0.3, height=0.05, sides=30, y=0, x=0, z=0)

#mybottom.set_draw_details(shinesh, [], 0.0, 0.5)

mywater = pi3d.Cylinder(
    radius=0.295, sides=30, height=0.7, y=0.1,
    x=0.1)  #y= (glassheight - waterheight / 2) - bottomheight
mywater.set_alpha(0.7)
mywater.set_material((0, 0, 0.7))
mywater.set_draw_details(matl, [test], 0, 1)
mymerge = pi3d.MergeShape(CAMERA3D, x=0, y=0, z=2)
mymerge.add(myglass, 0.1)
mymerge.add(mybottom, 0.1, 0.475, 0)

mymerge.set_alpha(0.7)
mymerge.set_material((0.1, 0.1, 0.1))
Exemplo n.º 4
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)
robot.add(robot_leg.buf[0], 1.05, 0, 0)
robot.set_draw_details(shader, [metalimg, metalimg, reflcn], 0.0, 0.5)

#create space station
ssphere = pi3d.Sphere(radius=10, slices=16, sides=16)
scorrid = pi3d.Cylinder(radius=4, height=22)

station = pi3d.MergeShape(y=mymap.calcHeight(0, 0), rx=4, ry=4, rz=4)
station.add(ssphere.buf[0], -20, 0, 20)
Exemplo n.º 5
0
matsh = pi3d.Shader("mat_reflect")
#################################
# Textures
patimg = pi3d.Texture("textures/PATRN.PNG")
shapebump = pi3d.Texture("textures/floor_nm.jpg")
shapshine = pi3d.Texture("textures/stars.jpg")
light = pi3d.Light(lightpos=(-1.0, 0.0, 10.0),
                   lightcol=(3.0, 3.0, 2.0),
                   lightamb=(0.02, 0.01, 0.03),
                   is_point=True)

# Create shape
cylinder = pi3d.Cylinder(radius=0.7,
                         height=1.5,
                         sides=24,
                         name="Cylinder",
                         x=0,
                         y=0,
                         z=10)

# Text
arialFont = pi3d.Font("fonts/FreeMonoBoldOblique.ttf", (221, 0, 170, 255))
mystring = pi3d.String(font=arialFont, string="Something", z=4)
mystring.set_shader(flatsh)

# Fetch key presses
mykeys = pi3d.Keyboard()

orientation = sense.get_orientation_degrees()
ORIGINAL_YAW = orientation['yaw']
ORIGINAL_PITCH = orientation['pitch']