Esempio n. 1
0
  /** Construct a new stage from the information contained in the node bundle. */
  @SuppressWarnings("deprecation")
  public BundleStage(
      StageInformation stageInfo,
      UtilContext context,
      MasterMgrClient client,
      NodeMod mod,
      TreeMap<String, BaseAnnotation> annotations,
      TreeMap<String, String> toolsetRemap,
      TreeMap<String, String> selectionKeyRemap,
      TreeMap<String, String> licenseKeyRemap,
      TreeMap<String, String> hardwareKeyRemap) {
    super("Bundle", "Description...", stageInfo, context, client, mod, StageFunction.aNone);

    pOrigNodeMod = mod;

    {
      String ntset = toolsetRemap.get(mod.getToolset());
      if (ntset != null) pRemappedToolset = ntset;
      else pRemappedToolset = super.getToolset();
    }

    JobReqs jreqs = mod.getJobRequirements();
    if (jreqs != null) {
      {
        TreeSet<String> selectionKeys = new TreeSet<String>();
        for (String key : jreqs.getSelectionKeys()) {
          String nkey = selectionKeyRemap.get(key);
          if (nkey != null) selectionKeys.add(nkey);
        }
        addSelectionKeys(selectionKeys);
      }

      {
        TreeSet<String> licenseKeys = new TreeSet<String>();
        for (String key : jreqs.getLicenseKeys()) {
          String nkey = licenseKeyRemap.get(key);
          if (nkey != null) licenseKeys.add(nkey);
        }
        addLicenseKeys(licenseKeys);
      }

      {
        TreeSet<String> hardwareKeys = new TreeSet<String>();
        for (String key : jreqs.getHardwareKeys()) {
          String nkey = hardwareKeyRemap.get(key);
          if (nkey != null) hardwareKeys.add(nkey);
        }
        addHardwareKeys(hardwareKeys);
      }
    }

    for (String aname : annotations.keySet()) addAnnotation(aname, annotations.get(aname));

    {
      TreeMap<String, BaseAnnotation> annots = mod.getAnnotations();
      for (String aname : annots.keySet()) addVersionAnnotation(aname, annots.get(aname));
    }
  }
  /**
   * Perform execution of the tool.
   *
   * <p>
   *
   * @param mclient The network connection to the plmaster(1) daemon.
   * @param qclient The network connection to the plqueuemgr(1) daemon.
   * @return Whether to continue and collect user input for the next phase of the tool.
   * @throws PipelineException If unable to sucessfully execute this phase of the tool.
   */
  public synchronized boolean executePhase(MasterMgrClient mclient, QueueMgrClient qclient)
      throws PipelineException {
    boolean newCheckOut = false;
    String matName = null;
    String texName = null;

    {
      /*find out if it is a fresh checkout*/
      JToolDialog tool = new JToolDialog("MaterialsCheckOut", new JPanel(), "Continue");
      JConfirmDialog dialog = new JConfirmDialog(tool, "Do you want a completely fresh checkout");
      dialog.setVisible(true);
      newCheckOut = dialog.wasConfirmed();
    }

    {
      /*-check out the asset and mat nodes-*/
      jcheckOut(mclient, pUser, pView, pPrimary, null, keep, pFroz);
      NodeMod assetMod = mclient.getWorkingVersion(pUser, pView, pPrimary);
      {
        JobReqs jreqs = assetMod.getJobRequirements();
        jreqs.addSelectionKey("LinuxOnly");
        assetMod.setJobRequirements(jreqs);
        mclient.modifyProperties(pUser, pView, assetMod);
      }

      Set<String> assetSrcs = assetMod.getSourceNames();
      err.println("The asset sources are: ");

      for (String src : assetSrcs) {
        err.println(src);

        if (src.matches(matPattern)) {
          matName = src;
          err.println("Found mat node:\n\t " + src);
          if (newCheckOut) {
            err.println("Clean mat checkout");
            jcheckOut(mclient, pUser, pView, src, null, over, frozU);
          } else {

            OverallNodeState state =
                mclient.status(pUser, pView, src).getHeavyDetails().getOverallNodeState();

            if (!state.equals(OverallNodeState.Modified)) {
              err.println("Mat node has not been modified");
              jcheckOut(mclient, pUser, pView, src, null, keep, pFroz);
            }
          }
        } else if (src.matches(matPattern + "Exp")) {
          err.println("Matexp is:\n\t" + src);
          jcheckOut(mclient, pUser, pView, src, null, keep, modi);
          {
            NodeMod expMod = mclient.getWorkingVersion(pUser, pView, src);
            JobReqs jreqs = expMod.getJobRequirements();
            jreqs.addSelectionKey("LinuxOnly");
            expMod.setJobRequirements(jreqs);
            mclient.modifyProperties(pUser, pView, expMod);
          }
        } else {
          jcheckOut(mclient, pUser, pView, src, null, over, froz);
        }
      } // end for
      err.println("mat node: " + matName);
      if (matName == null)
        throw new PipelineException("This asset node does not have an " + "attached mat node");
    }

    {
      /*find the texture node and check out so it can be changed. If new checkout, fresh textures*/
      NodeMod matMod = mclient.getWorkingVersion(pUser, pView, matName);
      TreeSet<String> matSrcs = new TreeSet<String>(matMod.getSourceNames());
      for (String src : matSrcs) {
        if (src.matches(texPattern)) {
          texName = src;
          err.println("Found tex node:\n\t " + src);
          if (newCheckOut) {
            err.println("Clean");
            jcheckOut(mclient, pUser, pView, src, null, over, frozU);
          } else {
            err.println("Old stuff");
            jcheckOut(mclient, pUser, pView, src, null, keep, pFroz);
            jcheckOut(mclient, pUser, pView, src, null, keep, modi);
          }
          continue;
        } // end if
        jcheckOut(mclient, pUser, pView, src, null, over, froz);
      } // end for
      err.println("tex node: " + texName);
      if (texName == null)
        throw new PipelineException(
            "This asset node does not have an associated " + "texture node");
    }

    err.println("Checked out the asset, mat and texture nodes");

    {
      /*check out finalise scripts*/
      jcheckOut(
          mclient,
          pUser,
          pView,
          "/projects/lr/assets/tools/mel/finalize-character",
          null,
          over,
          froz);
      jcheckOut(
          mclient, pUser, pView, "/projects/lr/assets/tools/mel/finalize-set", null, over, froz);
      jcheckOut(
          mclient, pUser, pView, "/projects/lr/assets/tools/mel/finalize-prop", null, over, froz);
    }

    err.close();

    return false;
  } // end executePhase
 private static void doReqs(NodeMod mod) throws PipelineException {
   JobReqs req = mod.getJobRequirements();
   req.addSelectionKey("Lair");
   mod.setJobRequirements(req);
 }
  @Override
  public void run(String[] args) {
    try {
      TreeMap<String, LinkedList<String>> parsedArgs = argParser(args);
      if (!checkArgsAndSetParams(parsedArgs)) {
        return;
      }
    } catch (PipelineException ex) {
      System.err.println("There was a problem reading the arguments.\n" + ex.getMessage());
      printHelp();
      return;
    }

    for (String turntableName : turntables) {
      logLine("Doing turntable: " + turntableName);
      for (String passName : passes) {
        logLine("\tDoing pass: "******"\t\tDoing asset: " + as.assetName);
            LairTurntable tt = new LairTurntable(as, turntableName, passName);
            w = new Wrapper(user, view, toolset, client);

            logLine("\t\tFreezing all the textures");
            getLatest(w, as.texGroup, over, froz);

            logLine("\t\tChecking out the final model scene");
            getNewest(w, as.finalScene, keep, pFroz);
            getNewest(w, as.lr_finalScene, keep, pFroz);

            logLine("\t\tChecking out the shader scene.");
            getNewest(w, as.shdScene, keep, pFroz);

            logLine("\t\tChecking out the turntable scene.");
            getNewest(w, tt.turntableScene, keep, pFroz);

            logLine("\t\tChecking out the overRide scene.");
            getNewest(w, tt.ttCamOverMI, keep, pFroz);

            logLine("\t\tChecking out the options scene.");
            getNewest(w, tt.ttOptionsMI, keep, pFroz);

            logLine("\t\tChecking out the camera MI node.");
            getNewest(w, tt.ttCamMI, keep, pFroz);

            logLine("\t\tChecking out the light MI node.");
            getNewest(w, tt.ttLightMI, keep, pFroz);

            logLine("\t\tChecking out the shade MI node.");
            getNewest(w, tt.ttShadeMI, keep, pFroz);

            logLine("\t\tChecking out the geo MI node.");
            getNewest(w, tt.ttGeoMI, keep, pFroz);

            logLine("\t\tChecking out the images node.");
            getNewest(w, tt.ttImages, keep, pFroz);

            logLine("\t\tFixing the turntable node");
            {
              NodeMod mod = client.getWorkingVersion(user, view, tt.turntableScene);
              if (toolset != null) mod.setToolset(toolset);
              client.modifyProperties(user, view, mod);
            }

            logLine("\t\tFixing the camera override node");
            {
              NodeMod mod = client.getWorkingVersion(user, view, tt.ttCamOverMI);
              if (toolset != null) mod.setToolset(toolset);
              BaseAction act = mod.getAction();
              act.setSingleParamValue("ImageWidth", 1280);
              act.setSingleParamValue("ImageHeight", 720);
              act.setSingleParamValue("AspectRatio", 1.777);
              act.setSingleParamValue("Aperture", 1.41732);
              act.setSingleParamValue("OverrideFocal", false);
              act.setSingleParamValue("OverrideClipping", false);
              mod.setAction(act);
              client.modifyProperties(user, view, mod);
            }

            logLine("\t\tFixing the camera node");
            {
              NodeMod mod = client.getWorkingVersion(user, view, tt.ttCamMI);
              if (toolset != null) mod.setToolset(toolset);
              client.modifyProperties(user, view, mod);
            }

            logLine("\t\tFixing the light node");
            {
              NodeMod mod = client.getWorkingVersion(user, view, tt.ttLightMI);
              if (toolset != null) mod.setToolset(toolset);
              client.modifyProperties(user, view, mod);
            }

            logLine("\t\tFixing the geo node");
            {
              NodeMod mod = client.getWorkingVersion(user, view, tt.ttGeoMI);
              if (toolset != null) mod.setToolset(toolset);
              BaseAction act = mod.getAction();
              act.setSingleParamValue("CustomText", true);
              mod.setAction(act);
              client.modifyProperties(user, view, mod);
            }

            logLine("\t\tFixing the shader node");
            {
              NodeMod mod = client.getWorkingVersion(user, view, tt.ttShadeMI);
              if (toolset != null) mod.setToolset(toolset);
              BaseAction act = mod.getAction();
              BaseAction act2 = LairConstants.actionMayaMiShader();
              act2.setSingleParamValues(act);
              mod.setAction(act2);
              JobReqs req = mod.getJobRequirements();
              req.addSelectionKey("MentalRay");
              mod.setJobRequirements(req);
              mod.setExecutionMethod(ExecutionMethod.Parallel);
              mod.setBatchSize(100);
              client.modifyProperties(user, view, mod);
            }

            logLine("\t\tFixing the images node");
            {
              NodeMod mod = client.getWorkingVersion(user, view, tt.ttImages);
              if (toolset != null) mod.setToolset(toolset);
              BaseAction act = mod.getAction();
              act.setSingleParamValue("TexturePath", "$WORKING");
              mod.setAction(act);
              JobReqs req = mod.getJobRequirements();
              req.addSelectionKey("MentalRay");
              mod.setJobRequirements(req);
              mod.setExecutionMethod(ExecutionMethod.Parallel);
              mod.setBatchSize(5);
              client.modifyProperties(user, view, mod);
            }

            logLine(
                "All Done.  Remember to set your export set on the mod node "
                    + "if you want to export a custom part of the body");
          } catch (PipelineException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    }
  }