Beispiel #1
0
    zval = (random.random() - 0.5) * 50 - 19
    zArr.append(zval)
    yArr.append(mymap.calcHeight(xval, zval))
    rArr.append(random.random() * 45)

for b in shed.buf:
    thisAbbGp = MergeShape(name="shed")
    # i.e. different merge groups for each part requiring different texture
    for i in range(len(xArr)):
        thisAbbGp.add(b, xArr[i], yArr[i], zArr[i], 0, rArr[i], 0)
    shedgp.append(thisAbbGp)
    shedgp[len(shedgp) - 1].set_draw_details(shader, b.textures, 0.0, 0.0)
    shedgp[len(shedgp) - 1].set_fog((0.1, 0.1, 0.1, 1.0), 250.0)

# monster
monst = TCone()
# use the uv_reflect shader but if shiny=0.0 there will be no reflection
# the third texture is unset so there are unpredictable results if > 0
monst.set_draw_details(shader, [monstimg, monsttex], 4.0, 0.0)
mDx, mDy, mDz = 0.1, 0, 0.2
mSx, mSy, mSz = -15, mymap.calcHeight(-15, 5) + 1, 5
gravity = 0.02

#screenshot number key p for screenshots
scshots = 1

#energy counter (space bar jumping)
hp = 25

rot = 0.0
tilt = 0.0
Beispiel #2
0
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)

arialFont = Font("AR_CENA","#dd00aa")   #load AR_CENA font and set the font colour to 'raspberry'
Beispiel #3
0
  zval = (random.random()-0.5)*50 - 19
  zArr.append(zval)
  yArr.append(mymap.calcHeight(xval, zval))
  rArr.append(random.random()*45)

for b in shed.buf:
  thisAbbGp = MergeShape(name="shed")
  # i.e. different merge groups for each part requiring different texture
  for i in range(len(xArr)):
    thisAbbGp.add(b, xArr[i], yArr[i], zArr[i], 0, rArr[i], 0)
  shedgp.append(thisAbbGp)
  shedgp[len(shedgp)-1].set_draw_details(shader, b.textures, 0.0, 0.0)
  shedgp[len(shedgp)-1].set_fog((0.1,0.1,0.1,1.0), 250.0)

# monster
monst = TCone()
# use the uv_reflect shader but if shiny=0.0 there will be no reflection
# the third texture is unset so there are unpredictable results if > 0
monst.set_draw_details(shader, [monstimg, monsttex], 4.0, 0.0)
mDx,mDy,mDz = 0.1,0,0.2
mSx,mSy,mSz = -15, mymap.calcHeight(-15,5)+1, 5
gravity = 0.02

#screenshot number key p for screenshots
scshots = 1

#energy counter (space bar jumping)
hp = 25

rot = 0.0
tilt = 0.0
Beispiel #4
0
rArr = []
for i in range(5):
  xval = (random.random()-0.5)*50 + 19
  xArr.append(xval)
  zval = (random.random()-0.5)*50 - 19
  zArr.append(zval)
  yArr.append(mymap.calcHeight(-xval, -zval))
  rArr.append(random.random()*45) # front faces approximately towards the sun (found by trial and error)
for g in shed.vGroup:
  thisAbbGp = MergeShape("shed")
  for i in range(len(xArr)):
    thisAbbGp.add(shed.vGroup[g], xArr[i], yArr[i], zArr[i], 0, rArr[i], 0)
  shedgp[g] = thisAbbGp

#monster
monst = TCone()
mDx,mDy,mDz = 0.1,0,0.2
mSx,mSy,mSz = -5, mymap.calcHeight(-5,5)+1, 5
gravity = 0.02

# 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, 4, 4, 2, "", 0,1,-2, 0.1,0.1,0.2) #yellowish 'torch' or 'sun' (could be blueish ambient with different env cube)
light.on()

#screenshot number key P for screenshots
scshots = 1

#energy counter
hp = 25