Exemplo n.º 1
0
#!/usr/bin/python
from __future__ import absolute_import, division, print_function, unicode_literals

# import demo
import pi3d
import random

DISPLAY = pi3d.Display.create(x=50, y=50)
CAMERA = pi3d.Camera()

shape = pi3d.TCone(
    z=5.0)  # try other shapes: Sphere, Torus, Cylinder, Helix etc
#shape = pi3d.Lines(z=2.0, vertices=[(i * 0.01, random.random(), random.random()) for i in range(20)], closed=True)
""" The light shader works fine for "solid" objects, i.e. for drawing
triangles, but isn't what you want generally for lines and points. Try
swapping the shaders over below.
Also see what the effect is of using a texture mapping shader such as uv_flat
which will need the alternative tex and set_draw_details lines to be
activated.
The "strip" argument to Shape.set_line_width() determines whether GL_LINES
or GL_LINE_STRIP will be used. Try swapping it to True. Try the same when
shape is a pi3d.Cuboid or pi3d.Sprite. The "closed" argument will use
GL_LINE_LOOP and add a final leg returning to the start.
"""
shader = pi3d.Shader('mat_light')
#shader = pi3d.Shader('mat_flat')
#shader = pi3d.Shader('uv_flat') #NB this will need the texture lines below to be uncommented

shape.set_shader(shader)
shape.set_material((1.0, 0.7, 0.1))
#tex = pi3d.Texture('techy2.png')
Exemplo n.º 2
0
                   lightcol=(3.0, 3.0, 2.0),
                   lightamb=(0.02, 0.01, 0.03),
                   is_point=True)

#Create inbuilt shapes
mysphere = pi3d.Sphere(radius=1,
                       sides=24,
                       slices=24,
                       name="sphere",
                       x=-4,
                       y=2,
                       z=10)
mytcone = pi3d.TCone(radiusBot=0.8,
                     radiusTop=0.6,
                     height=1,
                     sides=24,
                     name="TCone",
                     x=-2,
                     y=2,
                     z=10)
myhelix = pi3d.Helix(radius=0.4,
                     thickness=0.1,
                     ringrots=12,
                     sides=24,
                     rise=1.5,
                     loops=3.0,
                     name="helix",
                     x=0,
                     y=2,
                     z=10)
mytube = pi3d.Tube(radius=0.4,
                   thickness=0.1,
Exemplo n.º 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 = pi3d.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 = pi3d.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