def create_text(pos, message): """Create a text.""" tex = rt.text() tex.size = Y_STEP tex.text = message tex.position = rt.Point3(pos.x, pos.y - OBJECT_DIMENSION, pos.z) tex.wirecolor = rt.Color(255, 128, 255)
def create_text(xpos, ypos, rot, message): """Create a visible label on the ground for a given teapot""" tex = rt.text() tex.size = 10 tex.text = message tex.position = rt.Point3(xpos, ypos, 0) tex.rotation = rot tex.wireColor = rt.Color(255, 128, 255)
def main(): """Create a mesh, color it, and output information about its maps.""" # reset the scene rt.resetMaxFile(rt.Name('noPrompt')) # create a mesh mesh = make_pyramid_mesh() print("Updating the color per vertex channel") rt.setNumCPVVerts(mesh, 2) rt.buildVCFaces(mesh) rt.setVertColor(mesh, 1, rt.Color(255, 0, 0)) rt.setVertColor(mesh, 2, rt.Color(0, 0, 255)) rt.setVCFace(mesh, 1, rt.Point3(1, 1, 2)) rt.setVCFace(mesh, 2, rt.Point3(1, 2, 2)) rt.setVCFace(mesh, 3, rt.Point3(2, 2, 2)) rt.setVCFace(mesh, 4, rt.Point3(1, 1, 1)) rt.setCVertMode(mesh, True) rt.update(mesh) output_channels(mesh)
def solid_material(color): """Create a material.""" material = rt.StandardMaterial() material.Ambient = color material.Diffuse = color material.Specular = rt.Color(255, 255, 255) material.Shininess = 50.0 material.ShinyStrength = 70.0 material.SpecularLevel = 70.0 return material
def create_curve_shape( curve_data, curve_size=1.0, translate_offset=(0.0, 0.0, 0.0), scale=(1.0, 1.0, 1.0), axis_order='XYZ', color=None, mirror=None): """ Creates a NURBS curve based on the given curve data :param curve_data: dict, data, {"shapeName": {"cvs": [], "knots":[], "degree": int, "form": int, "matrix": []}} will be created :return: tuple(MObject, list(MObject)), tuple containing the parent MObject and the list of MObject shapes """ translate_offset = CurveCV(translate_offset) scale = CurveCV(scale) order = [{'X': 0, 'Y': 1, 'Z': 2}[x] for x in axis_order] curves_to_create = OrderedDict() for shape_name, shape_data in curve_data.items(): curves_to_create[shape_name] = list() shape_parent = shape_data.get('shape_parent', None) if shape_parent: if shape_parent in curves_to_create: curves_to_create[shape_parent].append(shape_name) created_curves = list() nurbs_set = rt.NURBSSet() for shape_name, shape_children in curves_to_create.items(): if shape_name not in created_curves: _, new_shapes = _create_curve(shape_name, curve_data[shape_name], curve_size, translate_offset, scale, order, mirror, nurbs_set=nurbs_set) n = rt.NURBSNode(nurbs_set, name='nurbs01') # TODO: Here we need to support both colors between 1.0 and 255, this is hacky way. Find a better solution. if color: if all(i > 1.0 for i in color): n.wirecolor = rt.Color(*color) else: color = [i * 255 for i in color] n.wirecolor = rt.Color(*color) return n
''' from pymxs import runtime as rt # pylint: disable=import-error def create_sphere(): """Create a sphere of radius 5.""" return rt.sphere(radius=5) def solid_material(color): """Create a material.""" material = rt.StandardMaterial() material.Ambient = color material.Diffuse = color material.Specular = rt.Color(255, 255, 255) material.Shininess = 50.0 material.ShinyStrength = 70.0 material.SpecularLevel = 70.0 return material def apply_material_to_nodes(material, nodes=rt.rootnode.children): """Apply a material to multiple nodes.""" for node in nodes: node.Material = material create_sphere() MAT = solid_material(rt.Color(0, 0, 255)) apply_material_to_nodes(MAT)