Ejemplo n.º 1
0
set_fog(mymap)

#Load tank
tank_body = make_model('Tiger/body.obj', 'TigerBody')
tank_body.set_normal_shine(tigerbmp)

tank_gun = make_model('Tiger/gun.obj', 'TigerGun')

tank_turret = make_model('Tiger/turret.obj', 'TigerTurret')
tank_turret.set_normal_shine(topbmp)


#Load church
x, z = 20, -320
y = mymap.calcHeight(x,z)

church = make_model('AllSaints/AllSaints.obj', 'church', x, y, z)

#Load cottages
x, z = 250,-40
y = mymap.calcHeight(x,z)

cottages = make_model('Cottages/cottages_low.obj', 'cottagesLo', x, y, z, ry=-5)

#cross-hairs in gun sight
targtex = Texture("textures/target.png", blend=True)
target = ImageSprite(targtex, shade2d, w=10, h=10, z=0.4)
target.set_2d_size(targtex.ix, targtex.iy, (DISPLAY.width - targtex.ix)/2,
                  (DISPLAY.height - targtex.iy)/2)
Ejemplo n.º 2
0
#mygrass2 = MergeShape("grass2")
#mygrass2.cluster(mygrass, mymap,100.0,0.0,100.0,100.0,1,"",1.0,1.0)

#         (shape,elevmap,xpos,zpos,w,d,count,options,minscl,maxscl)


#screenshot number
scshots = 1

#avatar camera
rot=0.0
tilt=0.0
avhgt = 2.0
xm=0.0
zm=0.0
ym= -(mymap.calcHeight(xm,zm)+avhgt)

# setup matrices
mtrx = Matrix()

# Fetch key presses
mykeys = Keyboard()
mymouse = Mouse()
mymouse.start()

omx=mymouse.x
omy=mymouse.y

# Display scene and rotate cuboid
while 1:
  display.clear()
Ejemplo n.º 3
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

# Fetch key presses
Ejemplo n.º 4
0
             y=3,
             sx=2,
             sy=2,
             sz=2)

shedgp = []
xArr = []
yArr = []
zArr = []
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)

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
Ejemplo n.º 5
0
 of random locations and y-rotations
"""
shed = Model(file_string="models/shed1.obj",
             name="shed", y=3, sx=2, sy=2, sz=2)

shedgp = []
xArr = []
yArr = []
zArr = []
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)

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
Ejemplo n.º 6
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

# Fetch key presses
Ejemplo n.º 7
0
metalimg = texs.loadTexture("textures/metalhull.jpg")
robot_head= Sphere(2.0,12,12,0.5,"",0,3,0)
robot_body = Cylinder(2.0,4,12,"",0,1,0)
robot_leg = Cuboid(0.7,4.0,1.0,"",0,0.8,0)

robot = MergeShape()
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 = Sphere(10,16,16)
scorrid = Cylinder(4,22,12)

station = MergeShape("",0,mymap.calcHeight(0,0),0, 0,0,0, 4,4,4)
station.add(ssphere, -20,0,-20)
station.add(ssphere, 20,0,-20)
station.add(ssphere, 20,0,20)
station.add(ssphere, -20,0,20)
station.add(scorrid, -20,0,0, 90,0,0)
station.add(scorrid, 0,0,20, 90,90,0)
station.add(scorrid, 0,0,-20, 90,90,0)

#avatar camera
rot=0.0
tilt=0.0
avhgt = 2.0
xm=0.0
zm=0.0
ym= -(mymap.calcHeight(xm,zm)+avhgt)
Ejemplo n.º 8
0
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)
station.add(ssphere.buf[0], -20, 0, 20)
station.add(ssphere.buf[0], 20, 0, 20)
station.add(ssphere.buf[0], 20, 0, -20)
station.add(ssphere.buf[0], -20, 0, -20)
station.add(scorrid.buf[0], -20, 0, 0, 90, 0, 0)
station.add(scorrid.buf[0], 0, 0, -20, 90, 90, 0)
station.add(scorrid.buf[0], 0, 0, 20, 90, 90, 0)
station.set_draw_details(shader, [metalimg, metalimg], 0.0)
station.set_fog((0.3,0.15,0.1,0.1), 300.0)

#avatar camera
rot = 0.0
tilt = -10.0
avhgt = 2.0
xm = 0.0
Ejemplo n.º 9
0
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)
station.add(ssphere.buf[0], -20, 0, 20)
station.add(ssphere.buf[0], 20, 0, 20)
station.add(ssphere.buf[0], 20, 0, -20)
station.add(ssphere.buf[0], -20, 0, -20)
station.add(scorrid.buf[0], -20, 0, 0, 90, 0, 0)
station.add(scorrid.buf[0], 0, 0, -20, 90, 90, 0)
station.add(scorrid.buf[0], 0, 0, 20, 90, 90, 0)
station.set_draw_details(shader, [metalimg, metalimg], 0.0)
station.set_fog((0.3, 0.15, 0.1, 0.1), 300.0)

#avatar camera
rot = 0.0
tilt = -10.0
avhgt = 2.0
xm = 0.0
Ejemplo n.º 10
0
  b.set_light(inLight, 0)
mymap.set_light(inLight, 0)
inFlag = True

#screenshot number
scshots = 1

#avatar camera
rot=0.0
tilt=0.0
avhgt = 5.0
aveyelevel = 4.0

aveyeleveladjust = aveyelevel - avhgt/2

man = SolidObject("man", Size(1, avhgt, 1), Position(0, (mymap.calcHeight(5, 5) + avhgt/2), 0), 1)

inputs = InputEvents()

inputs.get_mouse_movement()
mouseOn = True

frame = 400
record = False
CAMERA = Camera.instance()
while DISPLAY.loop_running() and not inputs.key_state("KEY_ESC"):
  CAMERA.reset()
  CAMERA.rotate(tilt, rot, 0)
  CAMERA.position((man.x(), man.y(), man.z() - aveyeleveladjust))

  myecube.position(man.x(), man.y(), man.z() - aveyeleveladjust)
Ejemplo n.º 11
0
# it is necessary to make a merge for each vGroup and, later, draw each merged object using each
# of the textures
# The cluster method can be used where there is only one vGroup but with more than one the different
# parts of the object get split up by the randomisation! Here I manually do the same thing as cluster
# by first generating an array of random locations and y-rotations
shedgp = {}
xArr = []
yArr = []
zArr = []
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