Example #1
0
#load environment cube
ectex = pi3d.loadECfiles("textures/ecubes", "sbox_interstellar", texs)
myecube = pi3d.createEnvironmentCube(900.0, "FACES")

# Create elevation map
mapwidth = 1000.0
mapdepth = 1000.0
mapheight = 60.0
mountimg1 = texs.loadTexture("textures/mars_colour.png")
mymap = pi3d.createElevationMapFromTexture("textures/mars_height.png",
                                           mapwidth, mapdepth, mapheight, 128,
                                           128)  #testislands.jpg

#create robot
metalimg = texs.loadTexture("textures/metalhull.jpg")
robot_head = pi3d.createSphere(2.0, 12, 12, 0.5, "", 0, 3, 0)
robot_body = pi3d.createCylinder(2.0, 4, 12, "", 0, 1, 0)
robot_leg = pi3d.createCuboid(0.7, 4.0, 1.0, "", 0, 0.8, 0)

robot = pi3d.createMergeShape()
robot.add(robot_head)
robot.add(robot_body)
robot.add(robot_leg, -2.1, 0, 0)
robot.add(robot_leg, 2.1, 0, 0)

#create space station
ssphere = pi3d.createSphere(10, 16, 16)
scorrid = pi3d.createCylinder(4, 22, 12)

station = pi3d.createMergeShape("", 0, mymap.calcHeight(0, 0), 0, 0, 0, 0, 4,
                                4, 4)
Example #2
0
# Setup display and initialise pi3d
display = pi3d.display()
display.create3D(100,100,1600,900)   	# x,y,width,height
display.setBackColour(0,0,0,1)    	# r,g,b,alpha

# Load textures

# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'cloudimg.blend = False')
cloudimg = pi3d.loadTextureAlpha("textures/earth_clouds.png",True)   
earthimg = pi3d.loadTexture("textures/world_map.jpg")
moonimg = pi3d.loadTexture("textures/moon.jpg")
starsimg = pi3d.loadTexture("textures/stars2.jpg")
watimg = pi3d.loadTexture("textures/water.jpg")
	
mysphere = pi3d.createSphere(2,24,24,0.0,"earth",0,0,0)
mysphere2 = pi3d.createSphere(2.05,24,24,0.0,"clouds",0,0,0)
mymoon = pi3d.createSphere(0.4,16,16,0.0,"moon",0,0,0)
mymoon2 = pi3d.createSphere(0.1,16,16,0.0,"moon2",0,0,0)

arialFont = pi3d.font("AR_CENA","#dd00aa")   #load AR_CENA font and set the font colour to 'raspberry'
destineFont = pi3d.font("AR_DELANEY", "#0055ff")

# Fetch key presses
mykeys = pi3d.key()

mtrx = pi3d.matrix()

rot=0.0
rot1=0.0
rot2=0.0
Example #3
0
hb2img = pi3d.loadTextureAlpha("textures/hornbeam2.png")

#load environment cube
ectex = pi3d.loadECfiles("textures/ecubes","sbox_interstellar")
myecube = pi3d.createEnvironmentCube(900.0,"FACES")

# Create elevation map
mapwidth=1000.0
mapdepth=1000.0
mapheight=60.0
mountimg1 = pi3d.loadTexture("textures/mars_colour.png")
mymap = pi3d.createElevationMapFromTexture("textures/mars_height.png",mapwidth,mapdepth,mapheight,128,128) #testislands.jpg

#create robot 
metalimg = pi3d.loadTextureAlpha("textures/metalhull.jpg")
robot_head= pi3d.createSphere(2.0,12,12,0.5,"",0,3,0)
robot_body = pi3d.createCylinder(2.0,4,12,"",0,1,0)
robot_leg = pi3d.createCuboid(0.7,4.0,1.0,"",0,0.8,0)

robot = pi3d.createMergeShape()
robot.add(robot_head)
robot.add(robot_body)
robot.add(robot_leg, -2.1,0,0)
robot.add(robot_leg, 2.1,0,0)

#create space station
ssphere = pi3d.createSphere(10,16,16)
scorrid = pi3d.createCylinder(4,22,12)

station = pi3d.createMergeShape("",0,mymap.calcHeight(0,0),0, 0,0,0, 4,4,4)
station.add(ssphere, -20,0,-20)
Example #4
0
#Create a Tkinter window
winx,winy,winw,winh = 200,200,800,600
win = pi3d.tkwin("Hello world in a Window",winx,winy,winw,winh)
win.update() #show window now (with default splash)

# Setup display and initialise pi3d
display = pi3d.display(winx,winy,winw,winh)
display.setBackColour(0,0,0,1)    	# r,g,b,alpha

# Load textures
texs=pi3d.textures()
cloudimg = texs.loadTexture("textures/earth_clouds.png",True)   
earthimg = texs.loadTexture("textures/world_map.jpg")

# Create shapes
mysphere = pi3d.createSphere(2,24,24,0.0,"earth",0,0,-6)
mysphere2 = pi3d.createSphere(2.05,24,24,0.0,"clouds",0,0,-6)

#create a light
mylight = pi3d.createLight(0,1,1,1,"",10,10,50, .8,.8,.8)
mylight.on()

# Display scene
try:
    while 1:
	#Display scene
	display.clear()
	   
	mysphere.draw(earthimg)
	mysphere.rotateIncY( 0.1 )
	mysphere2.draw(cloudimg)
Example #5
0
# Setup display and initialise pi3d
display = pi3d.display()
display.create3D(100, 100, 1600, 900)  # x,y,width,height
display.setBackColour(0, 0, 0, 1)  # r,g,b,alpha

# Load textures
texs = pi3d.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 = pi3d.createSphere(2, 24, 24, 0.0, "earth", 0, 0, 0)
mysphere2 = pi3d.createSphere(2.05, 24, 24, 0.0, "clouds", 0, 0, 0)
mymoon = pi3d.createSphere(0.4, 16, 16, 0.0, "moon", 0, 0, 0)
mymoon2 = pi3d.createSphere(0.1, 16, 16, 0.0, "moon2", 0, 0, 0)

arialFont = pi3d.font(
    "AR_CENA",
    "#dd00aa")  #load AR_CENA font and set the font colour to 'raspberry'
destineFont = pi3d.font("AR_DELANEY", "#0055ff")

# Fetch key presses
mykeys = pi3d.key()

mtrx = pi3d.matrix()

rot = 0.0
Example #6
0
# before running this example
#

import pi3d

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

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

#Create inbuilt shapes
mysphere = pi3d.createSphere(1,24,24,0.0,"sphere",-4,2,-7)
mytcone = pi3d.createTCone(0.8,0.6,1,24,"TCone", -2,2,-7)
myspiral = pi3d.createSpiral(0.4,0.1,12,24,1.5,3.0,"spiral", 0,2,-7)
mytube = pi3d.createTube(0.4,0.1,1.5,24,"tube",2,2,-7, 30,0,0)
myextrude = pi3d.createExtrude( ((-0.5, 1),(0.5,0),(0.5,-0.2),(-0.5,-0.3)), 0.05,"Extrude",4,2,-7)

mycone = pi3d.createCone(1,2,24,"Cone",-4,-1,-7)
mycylinder = pi3d.createCylinder(.7,1.5,24,"Cyli",-2,-1,-7)
myhemisphere = pi3d.createSphere(1,24,24,0.5,"hsphere",0,-1,-7)
mytorus = pi3d.createTorus(1,0.3,12,24,"Torus", 2,-1,-7)
mylathe = pi3d.createLathe( ((1,0),(0.1,0.2),(0.08,0.21),(0.08,1),(0.7,1.2),(0.9, 1.4), (1.1,1.7)), 24,"Cup",4,-1,-7, 0,0,0, 0.8,0.8,0.8)

arialFont = pi3d.font("AR_CENA","#dd00aa")   #load AR_CENA font and set the font colour to 'raspberry'
destineFont = pi3d.font("AR_Destine", "#0055ff")

Example #7
0
# Setup display and initialise pi3d
display = pi3d.display(10,10,1200,900)
display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha

# Load textures
texs=pi3d.textures()
# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'rockimg2.blend = False')
groundimg = texs.loadTexture("textures/pong2.jpg")
monstimg = texs.loadTexture("textures/pong3.png")
# environment cube
ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg")
myecube = pi3d.createEnvironmentCube(900.0,"CROSS")
#ball
radius = 1
ball = pi3d.createSphere(radius,12,12,0.0,"sphere",-4,2,-7)
#monster
monster = pi3d.createPlane(5.0, 5.0, "monster", 0,0,0, 0,0,0)
# Create elevation map
mapwidth=50.0                              
mapdepth=50.0
maphalf=23.0
mapheight=20.0
#set smooth to give proper normals
mymap = pi3d.createElevationMapFromTexture("textures/pong.jpg",mapwidth,mapdepth,mapheight,64,64,2,"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 = pi3d.createLight(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()