
A brief talk about Nhair hair in Maya
1. To avoid problems with Nhair, you must follow these rules 1. If the hair has dynamics, specify the cache, turn off dynamics, and delete (turn off) the simulation node 2. If the hair has no dynamics, turn off dynamics, and delete (turn off) the simulation node Nhair's hair simulation node, that is, the nucleus node, is generally deleted directly. Maya will automatically turn on dynamics when rendering in command line, which may cause a certain impact on Nhair hair rendering
2. 2. Dynamic 1. Display in Maya
Export cache (this step is generally solved). Before exporting the cache, turn on the hair dynamics and simulation nodes. Here provides several Python scripts here to change all nodes
Explanation
# Turn on all hair dynamics
for obj in cmds.ls(type="hairSystem"):
cmds.setAttr((obj + ".simulationMethod"), 3)
print obj, cmds.getAttr(obj + ".simulationMethod")
# Turn on all simulation nodes
for obj in cmds.ls(type="nucleus"):
cmds.setAttr((obj + ".enable"), 0)
print obj, cmds.getAttr(obj + ".enable")
Select the hair node, nCache->Create New Cache->nObject, then set the export path, file format, etc., and then click “Create”
3. Turn off dynamics. Turn off (delete) the simulation node. Here is to turn off all nodes in the scene. Here provides several Python scripts here
Explanation
# Turn off all hair dynamics
for obj in cmds.ls(type="hairSystem"):
cmds.setAttr((obj + ".simulationMethod"), 1)
print obj, cmds.getAttr(obj + ".simulationMethod")
# Turn on all simulation nodes
for obj in cmds.ls(type="nucleus"):
cmds.setAttr((obj + ".enable"), 0)
print obj, cmds.getAttr(obj + ".enable")
4. Specify cache. If there is a cacheFile node, specify it directly. If not, use the following method. You can find that our file has no dynamics.
Now specify the cache. Select the shape node of the hair system.
Select: nCache->Attach Cache, change the settings, assign to the hair, and click “Merge”.
After merging, we click” Play” and we can see that the hair is dynamic. You can't see the dynamics by directly dragging the frame.
5. Check whether the cacheFile path is correct or not.
Explanation
import maya.cmds as cmds
import os
all_image = cmds.ls(exactType ="cacheFile")
for a in all_image:
b = cmds.getAttr(a+".cacheName")
c = cmds.getAttr(a+".cachePath")
print (c+"/"+b+".xml")
三、 No dynamics
It is convenient to have no dynamics. Just use the tool to turn off all hair dynamics and simulation nodes.
Explanation
# Turn off all hair dynamics
for obj in cmds.ls(type="hairSystem"):
cmds.setAttr((obj + ".simulationMethod"), 1)
print obj, cmds.getAttr(obj + ".simulationMethod")
# Close all simulation nodes
for obj in cmds.ls(type="nucleus"):
cmds.setAttr((obj + ".enable"), 0)
