def default_world(): """ >>> light = point_light(point(-10, 10, -10), color(1,1,1)) >>> s1 = sphere() >>> s1.material.color = color(0.8,1.0,0.6) >>> s1.material.diffuse = 0.7 >>> s1.material.specular = 0.2 >>> s2 = sphere() >>> s2.transform = scaling(0.5,0.5,0.5) >>> w = default_world() >>> w.lights[0].position.compare(light.position) True >>> w.lights[0].intensity == light.intensity array([ True, True, True]) >>> len(w.contains) == 2 True >>> w.contains[0].material.color == color(0.8,1.0,0.6) array([ True, True, True]) >>> w.contains[0].material.diffuse == 0.7 and w.contains[0].material.specular == 0.2 True >>> w.contains[1].transform.compare(scaling(0.5,0.5,0.5)) True """ light = point_light(point(-10, 10, -10), color(1, 1, 1)) s1 = shapes.sphere() s1.material.color = color(0.8, 1.0, 0.6) s1.material.diffuse = 0.7 s1.material.specular = 0.2 s2 = shapes.sphere() s2.transform = scaling(0.5, 0.5, 0.5) return World([light], [s1, s2])
def main(place): mc=Minecraft.create(place,4711) x,y,z=mc.player.getPos() shapes.sphere(mc,x,y,z,size,size,size,80) shapes.sphere(mc,x,y,z,size-1,size-1,size-1,0) shapes.cylinder(mc,x,y,z-(size+(size-1)/2-1)-size/6,(size-1)/2+1,(size-1)/2+1,int((size-1)/2),shapes.XY,80) shapes.cylinder(mc,x,y,z-(size+(size-1)/2-1),(size-1)/2,(size-1)/2,int((size-1)/2),shapes.XY,0) mc.setBlocks(x-size,y-size,z-size-(size+(size-1)/2-1)-((size-1)/2+1),x+size,y-1,z+size,80)
def molplot(AtNam,AtX,AtY,AtZ,NAtoms,scale,cscale): params = {'H':([0.80,0.80,0.80],0.25*scale), 'C':([0.55,0.55,0.55],0.4*scale), 'N':([0.01,0.01,0.90],0.4*scale), 'O':([1.00,0.00,0.00],0.4*scale), 'F':([0.70,1.00,1.00],0.4*scale), 'S':([1.00,0.78,0.16],0.5*scale), 'Pd':([0.00,0.41,0.52],0.7*scale)} fig = plt.figure() # ax = fig.gca(projection='3d') ax = Axes3D(fig) ax.set_aspect('equal') for i in range(NAtoms): color, r = params.get(AtNam[i],([0.00,1.00,1.00],0.4*scale)) x,y,z = shapes.sphere(50) ax.plot_surface(r*x+AtX[i],r*y+AtY[i],r*z+AtZ[i],color=color,facecolor=color) for j in range(i+1,NAtoms): dist = np.sqrt((AtX[i]-AtX[j])**2 + (AtY[i]-AtY[j])**2 + (AtZ[i]-AtZ[j])**2) if dist < 1.6: x,y,z = shapes.cylinder([0.06*cscale],20,2,np.array([AtX[i],AtY[i],AtZ[i]]),np.array([AtX[j],AtY[j],AtZ[j]])) # ax.plot_surface(x,y,z,color=[0.50,0.50,0.50]) ax.plot_surface(x,y,z,color=[0.00,0.00,0.00]) set_axes_equal(ax) return(fig,ax)
def main(place): mc=Minecraft.create(place,4711) x,y,z=mc.player.getPos() mc.setBlocks(x-5,y,z-20,x+5,y+5,z-8,0) shapes.sphere(mc,x,y,z-15,5,5,5,80,0,4,4,4,0.5,1) shapes.cylinder(mc,x,y,z-10,3,3,1,shapes.XY,80) shapes.cylinder(mc,x,y,z-10,2,2,1,shapes.XY,0) height=0 nx,ny,nz=x,y-1,z-15 clear=True while clear: height+=1 clearpos=0 pos=[(0,0),(5,5),(-5,5),(-5,-5),(5,-5)] for xmod,zmod in pos: if mc.getBlock(xmod+nx,ny-height,zmod+nz) in [0,8,9,10,11,31,37,38,39,40,65,78,102,107,]: clearpos+=1 if clearpos==0: clear=False shapes.cylinder(mc,x,y-1-ceil(height/2),z-15,5,ceil(height/2),5,shapes.XZ,80) mc.setBlocks(x-2,y-1-height,z-11,x+2,y-1,z-9,80)
lightUnif = glGetUniformLocation(theShaders, "light") colorUnif = glGetUniformLocation(theShaders, "color") modelUnif = glGetUniformLocation(theShaders, "model") viewUnif = glGetUniformLocation(theShaders, "view") projUnif = glGetUniformLocation(theShaders, "projection") check("positionAttrib", positionAttrib) check("normalAttrib", normalAttrib) check("modelUnif", modelUnif) check("viewUnif", viewUnif) check("projUnif", projUnif) check("colorUnif", colorUnif) check("lightUnif", lightUnif) # Vertex Data, positions and normals and texture coords mysphere = sphere(0.75, 64, 32) sphereVertices = mysphere[0] sphereElements = mysphere[1] vertexComponents = 10 # 4 position, 4 normal, 2 texture # Ask the graphics card to create a buffer for our vertex data def getFloatBuffer(arr): buff = glGenBuffers(1) glBindBuffer(GL_ARRAY_BUFFER, buff) glBufferData(GL_ARRAY_BUFFER, arr, GL_STATIC_DRAW) glBindBuffer(GL_ARRAY_BUFFER, 0) return buff def getElementBuffer(arr): buff = glGenBuffers(1) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buff)
grey_mat ) p4 = shapes.plane( vector3(5.0, 0.0, 0.0), vector3(-1.0, 0.0, 0.0), grey_mat ) p5 = shapes.plane( vector3(0.0, 0.0, -10.0), vector3(0.0, 0.0, 1.0), bluegrey_mat ) p6 = shapes.plane( vector3(0.0, 0.0, 10.0), vector3(0.0, 0.0, -1.0), bluegrey_mat ) s1 = shapes.sphere( vector3(-2.0, 2.0, -5.0), #center point 1.0, #radius orange_mat ) #material s2 = shapes.sphere( vector3(2.0, 2.0, -5.0), #center point 1.0, #radius orange_mat ) #material s3 = shapes.sphere( vector3(0.0, -1.0, -6.0), 1.5, bluegrey_mat ) s4 = shapes.sphere( vector3(0.0, 2.0, -7.0), 2.0, refl_mat ) v1 = voxel.voxel_tree( vector3(0.0, 2.0, -7.0),
lightUnif = glGetUniformLocation(theShaders, "light") colorUnif = glGetUniformLocation(theShaders, "color") modelUnif = glGetUniformLocation(theShaders, "model") viewUnif = glGetUniformLocation(theShaders, "view") projUnif = glGetUniformLocation(theShaders, "projection") check("positionAttrib", positionAttrib) check("normalAttrib", normalAttrib) check("modelUnif", modelUnif) check("viewUnif", viewUnif) check("projUnif", projUnif) check("colorUnif", colorUnif) check("lightUnif", lightUnif) # Vertex Data, positions and normals and texture coords mysphere = sphere(0.75, 12, 8) sphereVertices = mysphere[0] sphereElements = mysphere[1] vertexComponents = 10 # 4 position, 4 normal, 2 texture # Ask the graphics card to create a buffer for our vertex data def getFloatBuffer(arr): buff = glGenBuffers(1) glBindBuffer(GL_ARRAY_BUFFER, buff) glBufferData(GL_ARRAY_BUFFER, arr, GL_STATIC_DRAW) glBindBuffer(GL_ARRAY_BUFFER, 0) return buff def getElementBuffer(arr): buff = glGenBuffers(1) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buff)
lightUnif = glGetUniformLocation(theShaders, "light") colorUnif = glGetUniformLocation(theShaders, "color") modelUnif = glGetUniformLocation(theShaders, "model") viewUnif = glGetUniformLocation(theShaders, "view") projUnif = glGetUniformLocation(theShaders, "projection") check("positionAttrib", positionAttrib) check("normalAttrib", normalAttrib) check("modelUnif", modelUnif) check("viewUnif", viewUnif) check("projUnif", projUnif) check("colorUnif", colorUnif) check("lightUnif", lightUnif) # Vertex Data, positions and normals and texture coords mysphere = sphere(0.75, 16, 8) sphereVertices = mysphere[0] sphereElements = mysphere[1] vertexComponents = 10 # 4 position, 4 normal, 2 texture # Ask the graphics card to create a buffer for our vertex data def getFloatBuffer(arr): buff = glGenBuffers(1) glBindBuffer(GL_ARRAY_BUFFER, buff) glBufferData(GL_ARRAY_BUFFER, arr, GL_STATIC_DRAW) glBindBuffer(GL_ARRAY_BUFFER, 0) return buff def getElementBuffer(arr): buff = glGenBuffers(1) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buff)