Example #1
0
# 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")

# environment cube
ectex = Texture("textures/ecubes/skybox_stormydays.jpg")
myecube = EnvironmentCube(camera, light, 900.0, "CROSS")
myecube.set_draw_details(flatsh, [ectex])

#ball
maxdsz = 0.3
radius = 1.0
ball = Sphere(camera, light, radius, 12, 12, 0.0, "sphere", -4, 8, -7)
# Shape.set_draw_details is a wrapper for calling the method on each item in buf
# as is done explicitly here for no reason than to show that it can be done!
ball.buf[0].set_draw_details(shader, [ballimg], 0.0, 0.0)

#monster
monster = Plane(camera, light, 5.0, 5.0, "monster", 0, 0, 0, 0, 0, 0)
monster.buf[0].set_draw_details(flatsh, [monstimg])

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

mymap = ElevationMap("textures/pong.jpg",
Example #2
0
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 = 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 = 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 monolith
monolith = Sphere(radius=8.0, slices=12, sides=48,
                  sy=10.0, name="monolith")
monolith.translate(100.0, -mymap.calcHeight(100.0, 350) + 10.0, 350.0)
monolith.set_draw_details(shader, [rockimg, bumpimg, reflimg], 32.0, 0.3)
monolith.set_fog(*FOG)

#screenshot number
scshots = 1

#avatar camera
rot = 0.0
tilt = 0.0
avhgt = 3.5
xm = 0.0
zm = 0.0
ym = mymap.calcHeight(xm, zm) + avhgt
Example #3
0
#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!
for f in iFiles:
    waterbump.append(Texture(f))
num_n = len(waterbump)
shapeshine = Texture("textures/stars.jpg")

#Create shape
myshape = MergeShape()
num = (2, 2)
asphere = Sphere(sides=32)
for i in range(num[0]):
    for j in range(num[1]):
        myshape.add(asphere, -num[0] * 0.9 + 1.8 * i, -num[1] * 0.9 + 1.8 * j,
                    0.0)

myshape.position(0.0, 0.0, 5)
myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 1.0, 0.1)
myshape.set_material((1.0, 0.5, 0.2, 0.5))

mywater = Plane(w=130.0, h=130.0)
mywater.set_draw_details(matsh, [waterbump[0], shapeshine], 12.0, 0.6)
mywater.set_material((0.0, 0.05, 0.1))
mywater.set_fog((0.4, 0.6, 0.8, 0.0), 150)
mywater.rotateToX(90.001)
mywater.position(0.0, -2.0, 0.0)
Example #4
0
mytrees1.set_draw_details(flatsh, [tree2img], 0.0, 0.0)
mytrees1.set_fog(*TFOG)

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

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

#Create monolith
monolith = Sphere(radius=8.0, slices=12, sides=48, sy=10.0, name="monolith")
monolith.translate(100.0, -mymap.calcHeight(100.0, 350) + 10.0, 350.0)
monolith.set_draw_details(shader, [rockimg, bumpimg, reflimg], 32.0, 0.3)
monolith.set_fog(*FOG)

#screenshot number
scshots = 1

#avatar camera
rot = 0.0
tilt = 0.0
avhgt = 3.5
xm = 0.0
zm = 0.0
ym = mymap.calcHeight(xm, zm) + avhgt
Example #5
0
File: Pong.py Project: JamesR1/pi3d
display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha

# Load textures
texs = Textures()
# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'rockimg2.blend = False')
groundimg = texs.loadTexture("textures/stripwood.jpg")
monstimg = texs.loadTexture("textures/pong3.png")
ballimg = texs.loadTexture("textures/cloud6.png", True)
# environment cube
ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg")
myecube = EnvironmentCube(900.0,"CROSS")
#ball
maxdsz = 0.3
radius = 1.0
ball = Sphere(radius,12,12,0.0,"sphere",-4,8,-7)
#monster
monster = Plane(5.0, 5.0, "monster", 0,0,0, 0,0,0)

# Create elevation map
mapwidth=50.0
mapdepth=50.0
maphalf=22.0
mapheight=40.0
#set smooth to give proper normals the bouncing won't work properly without and it doesn't look as good
mymap = ElevationMap("textures/pong.jpg",mapwidth,mapdepth,mapheight,32,32,4,"sub",0,0,0, smooth=True)

# lighting. The default light is a point light but I have made the position method capable of creating
# a directional light and this is what I do inside the loop. If you want a torch you don't need to move it about
light = Light(0, 2, 2, 1, "", 1,2,3, 0.1,0.1,0.2) #yellowish 'torch' or 'sun' with low level blueish ambient
light.position(1,2,3,0) # set to directional light by setting position with 0 fourth parameter
Example #6
0
#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)
shapeshine = Texture("textures/pong3.png")

#Create shape
myshape = MergeShape(camera=persp_cam)  #specify perspective view
asphere = Sphere(sides=16, slices=16)
myshape.radialCopy(asphere, step=72)
myshape.position(0.0, 0.0, 5.0)
myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 8.0, 0.1)

mysprite = Sprite(w=10.0, h=10.0, camera=persp_cam)
mysprite.position(0.0, 0.0, 15.0)
mysprite.set_draw_details(flatsh, [shapebump])

tick = 0
next_time = time.time() + 2.0

#load ttf font and set the font colour to 'raspberry'
arialFont = Ttffont("fonts/FreeMonoBoldOblique.ttf", "#dd00aa")
mystring = String(font=arialFont,
                  string="blurring with distance!",
Example #7
0
display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha


# Load textures
texs=Textures()
# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'rockimg2.blend = False')
groundimg = texs.loadTexture("textures/piom2.jpg")
monstimg = texs.loadTexture("textures/piom3.jpg")
# environment cube
ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg")
myecube = EnvironmentCube(900.0,"CROSS")

#monster
radius = 1
ball = Sphere(radius,12,12,0.0,"sphere",-4,2,-7)

# Create elevation map
mapwidth=50.0                              
mapdepth=50.0
maphalf=23.0
mapheight=8
#set smooth to give proper normals
mymap = ElevationMap("textures/Piom1b.jpg",mapwidth,mapdepth,mapheight,64,64,128,"sub",0,0,0, smooth=True) ################### increased tiles to 32
# lighting. The default light is a point light but I have made the position method capable of creating
# a directional light and this is what I do inside the loop. If you want a torch you don't need to move it about
light = Light(0, 2, 2, 1, "", 1,2,3, 0.1,0.1,0.2) #yellowish 'torch' or 'sun' with low level blueish ambient
light.position(1,2,3,0) # set to directional light by settin position with 0 fourth parameter
light.on()

########## need to create instances of these before using them in the loop! #################
Example #8
0
from pi3d.shape.Plane import Plane

from pi3d.util import Draw

# Setup display and initialise pi3d
display = Display()
display.create3D(0,0)   	# x,y,width,height
display.setBackColour(0,0,0,1)    	# r,g,b,alpha

# Load textures
texs = Textures()
patimg = texs.loadTexture("textures/PATRN.PNG")
coffimg = texs.loadTexture("textures/COFFEE.PNG")

#Create inbuilt shapes
mysphere = Sphere(1,24,24,0.0,"sphere",-4,2,-7)
mytcone = TCone(0.8,0.6,1,24,"TCone", -2,2,-7)
myhelix = Helix(0.4,0.1,12,24,1.5,3.0,"helix", 0,2,-7)
mytube = Tube(0.4,0.1,1.5,24,"tube",2,2,-7, 30,0,0)
myextrude = Extrude( ((-0.5, 0.5), (0.5,0.7), (0.9,0.2), (0.2,0.05), (1.0,0.0), (0.5,-0.7), (-0.5, -0.5)), 0.5,"Extrude",4,2,-7)

mycone = Cone(1,2,24,"Cone",-4,-1,-7)
mycylinder = Cylinder(.7,1.5,24,"Cyli",-2,-1,-7)
myhemisphere = Sphere(1,24,24,0.5,"hsphere",0,-1,-7)
mytorus = Torus(1,0.3,12,24,"Torus", 2,-1,-7)
#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 = Lathe( ((0,1),(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.05),(1,0),(0,0)), 24,"Cup",4,-1,-7, 0,0,0, 0.8,0.8,0.8)

myPlane = Plane(4,4,"plane",0,0,0)
myPlane.translate(0,0,-10)
Example #9
0
mapdepth = 1000.0
mapheight = 60.0
mountimg1 = Texture("textures/mars_colour.png")
bumpimg = Texture("textures/mudnormal.jpg")
mymap = ElevationMap(mapfile="textures/mars_height.png",
                     width=mapwidth,
                     depth=mapdepth,
                     height=mapheight,
                     divx=128,
                     divy=128)
mymap.set_draw_details(shader, [mountimg1, bumpimg], 128.0, 0.0)
mymap.set_fog((0.3, 0.15, 0.1, 0.1), 300.0)

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

robot = 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 = Sphere(radius=10, slices=16, sides=16)
scorrid = Cylinder(radius=4, height=22)

station = MergeShape(y=mymap.calcHeight(0, 0), rx=4, ry=4, rz=4)
Example #10
0
mytrees1.cluster(treemodel1.buf[0], mymap,0.0,0.0,120.0,120.0,30,"",8.0,3.0)
mytrees1.set_draw_details(flatsh, [tree2img], 0.0, 0.0)
mytrees1.set_fog(*TFOG)

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

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

#Create monolith
monolith = Sphere(radius=8.0, slices=12, sides=48,
                  sy=10.0, name="monolith")
monolith.translate(100.0, -mymap.calcHeight(100.0, 350) + 10.0, 350.0)
monolith.set_draw_details(shader, [rockimg, bumpimg, reflimg], 32.0, 0.3)
monolith.set_fog(*FOG)

#screenshot number
scshots = 1

#avatar camera
rot = 0.0
tilt = 0.0
avhgt = 3.5
xm = 0.0
zm = 0.0
ym = mymap.calcHeight(xm, zm) + avhgt
Example #11
0
# Setup display and initialise pi3d
display = Display()
display.create3D(0,0)   	# x,y,width,height defaults to full screen if w,h ommitted
display.setBackColour(0,0,0,1)    	# r,g,b,alpha

# Load textures
texs=Textures()
# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'cloudimg.blend = False')
cloudimg = texs.loadTexture("textures/earth_clouds.png",True)
earthimg = texs.loadTexture("textures/world_map.jpg")
moonimg = texs.loadTexture("textures/moon.jpg")
starsimg = texs.loadTexture("textures/stars2.jpg")
watimg = texs.loadTexture("textures/water.jpg")

mysphere = Sphere(2,24,24,0.0,"earth",0,0,-5.8)
mysphere2 = Sphere(2.05,24,24,0.0,"clouds",0,0,-5.8)
mymoon = Sphere(0.4,16,16,0.0,"moon",0,0,0)
mymoon2 = Sphere(0.1,16,16,0.0,"moon2",0,0,0)
myplane = Plane(50,50, "stars", 0,0,-10)

# Fetch key presses
mykeys = Keyboard()

rot=0.0
rot1=90.0
rot2=0.0
m1Rad = 4 # radius of moon orbit
m2Rad = 0.55 # radius moon's moon orbit