Ejemplo n.º 1
0
def gear_CreateSymmetryMappingTemplate_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    deformers = XSIFactory.CreateObject("XSI.Collection")
    deformers.Unique = True
    for sel in xsi.Selection:

        # Check input
        if sel.Type not in ["polymsh", "crvlist", "surfmsh"]:
            gear.log("Invalid selection", gear.sev_warning)
            continue

        # Get Envelope
        envelope_op = ope.getOperatorFromStack(sel, "envelopop")
        if not envelope_op:
            gear.log("There's no envelope on " + sel.Fullname, gear.sev_warning)
            continue

        deformers.AddItems(envelope_op.Deformers)

    if deformers.Count:
        env.createSymmetryMappingTemplate(deformers)
Ejemplo n.º 2
0
def gear_CreateSymmetryMappingTemplate_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    deformers = XSIFactory.CreateObject("XSI.Collection")
    deformers.Unique = True
    for sel in xsi.Selection:

        # Check input
        if sel.Type not in ["polymsh", "crvlist", "surfmsh"]:
            gear.log("Invalid selection", gear.sev_warning)
            continue

        # Get Envelope
        envelope_op = ope.getOperatorFromStack(sel, "envelopop")
        if not envelope_op:
            gear.log("There's no envelope on " + sel.Fullname,
                     gear.sev_warning)
            continue

        deformers.AddItems(envelope_op.Deformers)

    if deformers.Count:
        env.createSymmetryMappingTemplate(deformers)
Ejemplo n.º 3
0
def gear_CreateSymmetryMappingTemplate_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    mesh = xsi.Selection(0)

    # Check input
    if mesh.Type not in ["polymsh", "crvlist", "surfmsh"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Get Envelope
    envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
    if not envelope_op:
        gear.log("There's no envelope on " + mesh.Fullname, gear.sev_error)
        return

    env.createSymmetryMappingTemplate(envelope_op.Deformers)
Ejemplo n.º 4
0
def gear_CreateSymmetryMappingTemplate_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    mesh = xsi.Selection(0)

    # Check input
    if mesh.Type not in ["polymsh", "crvlist", "surfmsh"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Get Envelope
    envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
    if not envelope_op:
        gear.log("There's no envelope on " + mesh.Fullname, gear.sev_error)
        return

    env.createSymmetryMappingTemplate(envelope_op.Deformers)
Ejemplo n.º 5
0
    def finalize(self):

        # Properties --------------------------------------
        self.plog.log("Filling layout and logic")
        self.ui.fillLayoutAndLogic()

        # Groups ------------------------------------------
        self.plog.log("Creating groups")
        # Retrieve group content from components
        for name in self.componentsIndex:
            component = self.components[name]
            for name, objects in component.groups.items():
                self.addToGroup(objects, name)

        # Creating all groups
        for name, objects in self.groups.items():
            collection = XSIFactory.CreateObject("XSI.Collection")
            collection.AddItems(objects)
            self.groups[name] = self.model.AddGroup(collection, name + "_grp")

        # Hidden
        if self.options["setHidden"]:
            self.groups["hidden"].Parameters("viewvis").Value = 0
            self.groups["hidden"].Parameters("rendvis").Value = 0

        # Unselectable
        if self.options["setUnselectable"]:
            self.groups["unselectable"].Parameters("selectability").Value = 0

        # Deformers
        if self.options["setDeformers"]:
            self.groups["deformers"].Parameters("viewvis").Value = 0
            self.groups["deformers"].Parameters("rendvis").Value = 0

        # Geometries
        if self.options["setGeometries"]:
            self.groups["geometries"].Parameters("selectability").Value = 0
            prop = self.groups["geometries"].AddProperty("GeomApprox")
            par.addExpression(prop.Parameters("gapproxmosl"), self.pOGLLevel)

        # Skin --------------------------------------------
        if self.options["addGeometry"]:
            self.plog.log("Applying skin")

            # Import geometry
            if self.options["geo_path"] and os.path.exists(self.options["geo_path"]):
                geo_model = xsi.ImportModel(self.options["geo_path"], xsi.ActiveSceneRoot, False, None)(1)

                geo_objects = geo_model.FindChildren()

                self.model.AddChild(geo_model.children)
                for group in geo_model.Groups:
                    target_group = pri.createOrReturnGroup(self.model, group.Name)
                    target_group.AddMember(group.Members)
                xsi.DeleteObj(geo_model)

                # Apply skin
                if self.options["skin_path"] and os.path.exists(self.options["skin_path"]):
                    xml_objs = io.getObjectDefinitions(self.options["skin_path"], geo_objects, False)

                    for obj in geo_objects:

                        if obj.Name not in xml_objs.keys():
                            continue

                        io.importSkin(xml_objs[obj.Name], obj)

        # Symmetry Mapping Template -----------------------
        if self.options["mode"] == 1:

            env.createSymmetryMappingTemplate(self.groups["deformers"].Members)

            for geo in self.groups["geometries"].Members:
                if geo.Type == "polymsh":
                    xsi.CreateSymmetryMap("SymmetryMap", geo, "Symmetry Map")

        # Mirror Animation Template -----------------------
        if self.options["mode"] == 0:
            cnx_prop = ani.createMirrorCnxTemplate(self.model)
            for count, compName in enumerate(self.componentsIndex):
                component = self.components[compName]
                inversed_params = component.inv_params.GetAsText().split(",")
                for ctl in component.controlers:
                    ani.addMirroringRule(ctl, cnx_prop, inversed_params, True)

        # Reset Pose --------------------------------------
        self.plog.log("Creating rest pose")
        controlers = XSIFactory.CreateObject("XSI.Collection")
        for group in self.model.Groups:
            if group.Name.startswith("controlers"):
                controlers.AddItems(group.Members)

        keyableParams = controlers.FindObjectsByMarkingAndCapabilities(None, c.siKeyable)
        xsi.StoreAction(self.model, keyableParams, 1, "reset", False)

        # Isolate and popup -------------------------------
        if self.options["isolateResult"]:
            xsi.SelectObj(self.model, "BRANCH")
            xsi.IsolateSelected(False, -1)
            xsi.DeselectAll()

        if self.options["popUpControls"]:
            xsi.InspectObj(self.ui.anim_prop)
Ejemplo n.º 6
0
    def finalize(self):

        # Properties --------------------------------------
        self.plog.log("Filling layout and logic")
        self.ui.fillLayoutAndLogic()

        # Groups ------------------------------------------
        self.plog.log("Creating groups")
        # Retrieve group content from components
        for name in self.componentsIndex:
            component = self.components[name]
            for name, objects in component.groups.items():
                self.addToGroup(objects, name)

        # Creating all groups
        for name, objects in self.groups.items():
            collection = XSIFactory.CreateObject("XSI.Collection")
            collection.AddItems(objects)
            self.groups[name] = self.model.AddGroup(collection, name + "_grp")

        # Hidden
        if self.options["setHidden"]:
            self.groups["hidden"].Parameters("viewvis").Value = 0
            self.groups["hidden"].Parameters("rendvis").Value = 0

        # Unselectable
        if self.options["setUnselectable"]:
            self.groups["unselectable"].Parameters("selectability").Value = 0

        # Deformers
        if self.options["setDeformers"]:
            self.groups["deformers"].Parameters("viewvis").Value = 0
            self.groups["deformers"].Parameters("rendvis").Value = 0

        # Geometries
        if self.options["setGeometries"]:
            self.groups["geometries"].Parameters("selectability").Value = 0
            prop = self.groups["geometries"].AddProperty("GeomApprox")
            par.addExpression(prop.Parameters("gapproxmosl"), self.pOGLLevel)

        # Skin --------------------------------------------
        if self.options["addGeometry"]:
            self.plog.log("Applying skin")

            # Import geometry
            if self.options["geo_path"] and os.path.exists(
                    self.options["geo_path"]):
                geo_model = xsi.ImportModel(self.options["geo_path"],
                                            xsi.ActiveSceneRoot, False,
                                            None)(1)

                geo_objects = geo_model.FindChildren()

                self.model.AddChild(geo_model.children)
                for group in geo_model.Groups:
                    target_group = pri.createOrReturnGroup(
                        self.model, group.Name)
                    target_group.AddMember(group.Members)
                xsi.DeleteObj(geo_model)

                # Apply skin
                if self.options["skin_path"] and os.path.exists(
                        self.options["skin_path"]):
                    xml_objs = io.getObjectDefinitions(
                        self.options["skin_path"], geo_objects, False)

                    for obj in geo_objects:

                        if obj.Name not in xml_objs.keys():
                            continue

                        io.importSkin(xml_objs[obj.Name], obj)

        # Symmetry Mapping Template -----------------------
        if self.options["mode"] == 1:

            env.createSymmetryMappingTemplate(self.groups["deformers"].Members)

            for geo in self.groups["geometries"].Members:
                if geo.Type == "polymsh":
                    xsi.CreateSymmetryMap("SymmetryMap", geo, "Symmetry Map")

        # Mirror Animation Template -----------------------
        if self.options["mode"] == 0:
            cnx_prop = ani.createMirrorCnxTemplate(self.model)
            for count, compName in enumerate(self.componentsIndex):
                component = self.components[compName]
                inversed_params = component.inv_params.GetAsText().split(",")
                for ctl in component.controlers:
                    ani.addMirroringRule(ctl, cnx_prop, inversed_params, True)

        # Reset Pose --------------------------------------
        self.plog.log("Creating rest pose")
        controlers = XSIFactory.CreateObject("XSI.Collection")
        for group in self.model.Groups:
            if group.Name.startswith("controlers"):
                controlers.AddItems(group.Members)

        keyableParams = controlers.FindObjectsByMarkingAndCapabilities(
            None, c.siKeyable)
        xsi.StoreAction(self.model, keyableParams, 1, "reset", False)

        # Isolate and popup -------------------------------
        if self.options["isolateResult"]:
            xsi.SelectObj(self.model, "BRANCH")
            xsi.IsolateSelected(False, -1)
            xsi.DeselectAll()

        if self.options["popUpControls"]:
            xsi.InspectObj(self.ui.anim_prop)