def placeMirror(): mirrorPos = [0, 1.5, -2]; global wall, mirrorRight, mirrorLeft, mirrorPlane wall = viz.addTexQuad() wall.setPosition(0, 0, mirrorPos[2] - 0.02) wall.setScale(20, 20, 1) # Apply nice repeating brick texture wallmatrix = vizmat.Transform() wallmatrix.setScale(20, 20, 1) wall.texmat( wallmatrix ) bricks = viz.addTexture('brick.jpg') bricks.wrap(viz.WRAP_T, viz.REPEAT) bricks.wrap(viz.WRAP_S, viz.REPEAT) wall.texture(bricks) mirrorPlane = vizshape.addPlane() mirrorPlane.setPosition(mirrorPos, viz.ABS_GLOBAL) mirrorPlane.setEuler(0, 90, 0) mirrorPlane.setScale(0.09, 1, 0.05) windowBox = mirrorPlane.getBoundingBox(mode = viz.ABS_GLOBAL) x0 = windowBox.xmin x1 = windowBox.xmax y0 = windowBox.ymin y1 = windowBox.ymax z = windowBox.zmax viz.startlayer(viz.QUADS) viz.texcoord(0,0) viz.vertex( x0 , y0 , z ) viz.texcoord(0,1) viz.vertex( x0 , y1, z ) viz.texcoord(1,1) viz.vertex( x1 , y1, z) viz.texcoord(1,0) viz.vertex( x1 , y0 , z) mirrorRight = viz.endlayer( ) mirrorLeft = mirrorRight.copy() #specify the matrix m = viz.Matrix() #Try moving the mirror #print "z: " + str(z); m.setPosition([0, 0, z]) m.setEuler(0, 0, 0) #Apply mirror settings to mirror object mirrorPlane.alpha(0.0) addMirror(mirrorRight,m,viz.RIGHT_EYE) addMirror(mirrorLeft,m,viz.LEFT_EYE) # Add collision mirrorPlane.collideBox() wall.visible(viz.OFF) mirrorRight.visible(viz.OFF) mirrorLeft.visible(viz.OFF)
def placeMirror(): global m windowBox = mirrorPlane.getBoundingBox(mode = viz.ABS_GLOBAL) x0 = windowBox.xmin x1 = windowBox.xmax y0 = windowBox.ymin y1 = windowBox.ymax z = windowBox.zmax viz.startlayer(viz.QUADS) viz.texcoord(0,0) viz.vertex( x0 , y0 , z ) viz.texcoord(0,1) viz.vertex( x0 , y1, z ) viz.texcoord(1,1) viz.vertex( x1 , y1, z) viz.texcoord(1,0) viz.vertex( x1 , y0 , z) mirrorRight = viz.endlayer( ) mirrorLeft = mirrorRight.copy() #specify the matrix m = viz.Matrix() #Try moving the mirror #m.setPosition([ 0.5*(x0+x1), 0.5*(y0+y1), z]) m.setPosition([0,0,z]) m.setEuler(180, 0, 0) # Adjust these! # #m.setPosition([0,0,z-1.50]) #this makes the mirror not reflect the space of the 4th row #m.setScale(2, 2, 2) #Apply mirror settings to mirror object mirrorPlane.alpha(0.0) addMirror(mirrorRight,m,viz.RIGHT_EYE) addMirror(mirrorLeft,m,viz.LEFT_EYE)