def create_light_plane(self, scene, mat, origin, u, v, name): plane = Geom.CRectangle(origin, u, v) points = plane.getVertices() triangles = plane.getTriangles() normals = plane.getNormals() lightPlane = MXS.createMxObject(scene, "light_plane", points, normals, triangles) lightMat = scene.readMaterial(self.pzLightMat) lightMat = scene.addMaterial(lightMat) lightPlane.setMaterial(mat) MXS.setObjectInvisible(lightPlane)
def create_background(self, scene): depth = self.depth * 10 height = self.height * 10 width = self.width * 10 origin = [-depth/2, -height/2, -width/2] u = [depth, 0, 0] v = [0, width, 0] w = [0, 0, height] box =Geom.CBox(origin, u, v, w, direction = -1) points = box.getVertices() triangles = box.getTriangles() normals = box.getNormals() background = MXS.createMxObject(scene, "background", points, normals, triangles) mat = scene.readMaterial(self.pzBackgroundMat) mat = scene.addMaterial(mat) background.setMaterial(mat)
def scatter_sphere(self, scene): # Add a new material to the sphere mat = scene.readMaterial(self.pzSphereMat) mat = scene.addMaterial(mat) radius = self.radius # scatter dots into scenes for i in range(self.numbOfDots): # Create a instance of the sphere in the scene x = random.random() * self.depth - self.depth/2 y = random.random() * self.width - self.width/2 z = random.random() * self.height - self.width/2 dot = Geom.CSphere([x, y, z], radius) points = dot.getVertices() normals = dot.getNormals() triangles = dot.getTriangles() obj = MXS.createMxObject(scene, "dot_{}".format(i), points, normals, triangles) # Assign the material to the object of the new sphere obj.setMaterial(mat)