def make_model(filename, name, x=0, y=0, z=0, rx=0, ry=0, rz=0): model = Model(file_string='models/' + filename, name=name, x=x, y=y, z=z, rx=rx, ry=ry, rz=rz, sx=0.1, sy=0.1, sz=0.1) model.set_shader(shader) set_fog(model) return model
from pi3d.Display import Display from pi3d.Keyboard import Keyboard from pi3d.Texture import Textures from pi3d.context.Light import Light from pi3d.shape.Model import Model # Setup display and initialise pi3d display = Display() display.create3D(50,50,display.max_width-100,display.max_height-100) # x,y,width,height display.setBackColour(0.2,0.4,0.6,1) # r,g,b,alpha # load model_loadmodel texs = Textures() mymodel = Model("models/Triceratops/Triceratops.egg",texs,"Triceratops", 0,-1,0, -90,0,0, .005,.005,.005) # Fetch key presses mykeys = Keyboard() # mastrix and rotate variables rot=0 #create a light mylight = Light(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() Utility.load_identity()
from pi3d.Shader import Shader from pi3d.shape.Model import Model from pi3d.util.Screenshot import screenshot # Setup display and initialise pi3d DISPLAY = Display.create(x=50, y=50, w=-100, h=-100, background = (0.2, 0.4, 0.6, 1)) shader = Shader('shaders/uv_light') #======================================== # load model_loadmodel mymodel = Model(file_string='models/Triceratops/Triceratops.egg', name='Triceratops', x=0, y=-1, z=40, sx=0.005, sy=0.005, sz=0.005) mymodel.set_shader(shader) # Fetch key presses mykeys = Keyboard() while 1: DISPLAY.clear() mymodel.draw() mymodel.rotateIncZ(0.001) mymodel.rotateIncX(-0.00317543) mymodel.rotateIncY(0.11) k = mykeys.read()
from pi3d.Keyboard import Keyboard from pi3d.Texture import Textures from pi3d.context.Light import Light from pi3d.shape.Model import Model from pi3d.util.Matrix import Matrix # Setup display and initialise pi3d display = Display() display.create3D(100,100,1200,900) # x,y,width,height display.setBackColour(0.2,0.4,0.6,1) # r,g,b,alpha texs = Textures() # load model_loadmodel mymodel = Model("models/teapot.egg",texs ,"teapot", 0,-1,0) # Fetch key presses mykeys = Keyboard() # setup matrices mtrx = Matrix() #create a light mylight = Light(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() mtrx.identity()
from pi3d.context.Light import Light from pi3d.shape.Model import Model from pi3d.util.Matrix import Matrix # Setup display and initialise pi3d display = Display() display.create3D(100,100,1200,900) # x,y,width,height display.setBackColour(0.2,0.4,0.6,1) # r,g,b,alpha texs = Textures() # load model_loadmodel mymodel = Model("models/teapot.obj",texs ,"teapot", 0,-1.0,0) # Fetch key presses mykeys = Keyboard() # setup matrices mtrx = Matrix() #create a light mylight = Light(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() mtrx.identity()
# Setup display and initialise pi3d DISPLAY = Display.create(x=50, y=50, w=-100, h=-100, background=(0.2, 0.4, 0.6, 1)) shader = Shader('shaders/uv_light') #======================================== # load model_loadmodel mymodel = Model(file_string='models/Triceratops/Triceratops.egg', name='Triceratops', x=0, y=-1, z=40, sx=0.005, sy=0.005, sz=0.005) mymodel.set_shader(shader) # Fetch key presses mykeys = Keyboard() while 1: DISPLAY.clear() mymodel.draw() mymodel.rotateIncZ(0.001) mymodel.rotateIncX(-0.00317543) mymodel.rotateIncY(0.11)
raspberry.cluster(treemodel1.buf[0], mymap, -250, +250, 470.0, 470.0, 5, "", 8.0, 1.0) raspberry.buf[0].set_draw_details(shader, [raspimg, raspimg], 1.0, 0.0) raspberry.set_fog((0.1, 0.1, 0.1, 1.0), 200.0) """ MergeShape can be used to join a number of Model object for much greater rendering speed however, because Models can contain multiple Buffers, each with their own texture image it is necessary to make a merge for each Buffer and, later, draw each merged object using each of the textures. The cluster method can be used where there is only one Buffer 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 """ 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)
print("Instructions:") print("") print("Keys- W - Forward,") print(" A - Left S - Back D - right") print("") print("Move mouse to pan view. Click mouse to exit or press ESCAPE") print("==============================================================") ectex = loadECfiles("textures/ecubes","sbox") myecube = EnvironmentCube(size=900.0, maptype="FACES", name="bfa", y=50.0) myecube.set_draw_details(flatsh, ectex) # load model_loadmodel mymodel = Model(file_string="models/Buckfast Abbey/BuckfastAbbey.egg", name="Abbey", rx=90, sx=0.03, sy=0.03, sz=0.03) mymodel.set_shader(shader) # Create keyboard and mouse event objects mykeys = Keyboard() mymouse = Mouse(restrict = False) mymouse.start() #screenshot number scshots = 1 #avatar camera rot=0.0 tilt=0.0 avhgt = 2.0
from pi3d.shape.Model import Model from pi3d.util.Screenshot import screenshot # Setup display and initialise pi3d DISPLAY = Display.create(x=100, y=100, background=(0.2, 0.4, 0.6, 1)) Light((1, 1, 1)) shader = Shader("shaders/mat_reflect") #======================================== # load bump and reflection textures bumptex = Texture("textures/floor_nm.jpg") shinetex = Texture("textures/stars.jpg") # load model_loadmodel mymodel = Model(file_string='models/teapot.egg', name='teapot', x=0, y=0, z=10) mymodel.set_shader(shader) # material is set in the file mymodel.set_normal_shine(bumptex, 4.0, shinetex, 0.2, is_uv = False) # Fetch key presses mykeys = Keyboard() while DISPLAY.loop_running(): mymodel.draw() mymodel.rotateIncY(2.0) mymodel.rotateIncZ(0.1) mymodel.rotateIncX(0.3) k = mykeys.read() if k >-1:
#Setup shaders flatsh = Shader("shaders/uv_flat") shade2d = Shader('shaders/2d_flat') # create splash screen and draw it splash = ImageSprite("textures/pi3d_splash.jpg", shade2d, w=10, h=10, z=0.2) splash.draw() DISPLAY.swap_buffers() #Setup environment cube ectex = EnvironmentCube.loadECfiles("textures/ecubes/Miramar", "miramar_256", "png", nobottom = True) myecube = EnvironmentCube.EnvironmentCube(size=1800.0, maptype="FACES", nobottom=True) myecube.set_draw_details(flatsh,ectex) #Load Hall model hall = Model(file_string="models/ConferenceHall/conferencehall.egg", name="Hall", sx=0.1, sy=0.1, sz=0.1) hall.set_shader(flatsh) #key presses mymouse = Mouse(restrict = False) mymouse.start() omx, omy = mymouse.position() #position vars mouserot = -70.0 tilt = 10.0 avhgt = 4.0 xm = 0.0 zm = 0.0 ym = avhgt