Пример #1
0
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,
                     sy=0.8,
                     sz=0.8)
mylathe.set_draw_details(matsh, [shapebump, shapeshine], 0.0, 1.0)
mylathe.set_alpha(0.5)
mytorus = pi3d.Torus(radius=1,
                     thickness=0.3,
                     ringrots=12,
                     sides=24,
                     name="Torus",
                     x=2,
                     y=-1,
                     z=10)
Пример #2
0
    pts.append((ca * eyeRadius, sa * eyeRadius))

#angle1BackOfEye = zangle(scleraFrontPtsBackOfEye, eyeRadius)[1] # Sclera front angle
angle2BackOfEye = zangle(scleraBackPtsBackOfEye, eyeRadius)[1]  # " back angle
aRangeBackOfEye = 180 - angle2BackOfEye
ptsBackOfEye = []
for i in range(24):
    caBackOfEye, saBackOfEye = pi3d.Utility.from_polar((90 + 10) -
                                                       aRangeBackOfEye * i /
                                                       23)
    ptsBackOfEye.append((caBackOfEye * eyeRadius, saBackOfEye * eyeRadius))

# Scleras are generated independently (object isn't re-used) so each
# may have a different image map (heterochromia, corneal scar, or the
# same image map can be offset on one so the repetition isn't obvious).
leftEye = pi3d.Lathe(path=pts, sides=64)
leftEye.set_textures([scleraMap])
leftEye.set_shader(shader)
reAxis(leftEye, 0)
rightEye = pi3d.Lathe(path=pts, sides=64)
rightEye.set_textures([scleraMap])
rightEye.set_shader(shader)
reAxis(rightEye, 0.5)  # Image map offset = 180 degree rotation

leftEyeBackOfEye = pi3d.Lathe(path=ptsBackOfEye, sides=64)
leftEyeBackOfEye.set_textures([scleraMapBackOfEye])
leftEyeBackOfEye.set_shader(shader)
reAxis(leftEyeBackOfEye, 0)
rightEyeBackOfEye = pi3d.Lathe(path=ptsBackOfEye, sides=64)
rightEyeBackOfEye.set_textures([scleraMapBackOfEye])
rightEyeBackOfEye.set_shader(shader)
Пример #3
0
upperEyelid.set_textures([lidMap])
upperEyelid.set_shader(shader)
lowerEyelid = mesh_init((33, 5), (0, 0.5 / lidMap.iy), False, True)
lowerEyelid.set_textures([lidMap])
lowerEyelid.set_shader(shader)

# Generate sclera for eye...start with a 2D shape for lathing...
angle1 = zangle(scleraFrontPts, eyeRadius)[1]  # Sclera front angle
angle2 = zangle(scleraBackPts, eyeRadius)[1]  # " back angle
aRange = 180 - angle1 - angle2
pts = []
for i in range(24):
    ca, sa = pi3d.Utility.from_polar((90 - angle1) - aRange * i / 23)
    pts.append((ca * eyeRadius, sa * eyeRadius))

eye = pi3d.Lathe(path=pts, sides=64)
eye.set_textures([scleraMap])
eye.set_shader(shader)
re_axis(eye, 0.5)  ## RIGHT IS 0.0

# Init global stuff --------------------------------------------------------

# mykeys = pi3d.Keyboard() # For capturing key presses

startX = random.uniform(-30.0, 30.0)
n = math.sqrt(900.0 - startX * startX)
startY = random.uniform(-n, n)
destX = startX
destY = startY
curX = startX
curY = startY
Пример #4
0
rightLowerEyelid.set_textures([lidMap])
rightLowerEyelid.set_shader(shader)

# Generate scleras for each eye...start with a 2D shape for lathing...
angle1 = zangle(scleraFrontPts, eyeRadius)[1] # Sclera front angle
angle2 = zangle(scleraBackPts , eyeRadius)[1] # " back angle
aRange = 180 - angle1 - angle2
pts    = []
for i in range(24):
	ca, sa = pi3d.Utility.from_polar((90 - angle1) - aRange * i / 23)
	pts.append((ca * eyeRadius, sa * eyeRadius))

# Scleras are generated independently (object isn't re-used) so each
# may have a different image map (heterochromia, corneal scar, or the
# same image map can be offset on one so the repetition isn't obvious).
leftEye = pi3d.Lathe(path=pts, sides=64)
leftEye.set_textures([scleraMap])
leftEye.set_shader(shader)
reAxis(leftEye, 0)
rightEye = pi3d.Lathe(path=pts, sides=64)
rightEye.set_textures([scleraMap])
rightEye.set_shader(shader)
reAxis(rightEye, 0.5) # Image map offset = 180 degree rotation


# Init global stuff --------------------------------------------------------

mykeys = pi3d.Keyboard() # For capturing key presses

startX       = random.uniform(-30.0, 30.0)
n            = math.sqrt(900.0 - startX * startX)
Пример #5
0
    tanks.append([tank_body.shallow_clone(), None, None])
    tanks[-1][1] = tank_turret.shallow_clone()
    tanks[-1][2] = tank_gun.shallow_clone()
    tanks[-1][0].xyz = (random.random() * 800.0 - 400.0, 0.0,
                        random.random() * 600.0 - 100.0)
### because these children will inherit matrix operation applied to
#   their parent they don't need to be scaled
#   as these are cloned the child references get duplicated if add_child()
#   is used so the children attribute has to be overwritten with a new list (of one)
for t in tanks:
    t[0].children = [t[1]]  #turret is child of body
    t[1].children = [t[2]]  #gun is child of turret

#Make some missiles
missile = pi3d.Lathe(path=((0.0, 1.5), (0.1, 1.5), (0.13, 0.7), (0.2, 0.6),
                           (0.2, 0.01), (0.19, 0.0), (0.0, 0.0)),
                     sides=12)
missile.set_material((1.0, 0.0, 1.0))  # purple beer bottle!
missile.set_shader(
    matsh)  # mat_light is default if nothing specified better to be explicit

missiles = []  # will be list of missiles
for t in tanks:
    missiles.append(missile.shallow_clone())
    missiles[-1].x_vel = 0.0  # add velocity attributes to the instance
    missiles[-1].y_vel = -5.0  # this may or may not be good practice but
    missiles[-1].z_vel = 0.0  # python allows it so why not...
    missiles[
        -1].next_tm = 0.0  # also add next fire time to missiles to restrict fire rate
    missiles[-1].expl = 0.0  # also add exploding factor