学习做网站多久,宝安区是深圳最差的区,凡科网是什么,怎么在拼多多开网店首先声明#xff1a;maya建议用2022版本及一下#xff0c;因为要用到Python 2 ,Maya2023以后默认是Python3不再支持Python2;
第一步#xff1a;Xgen做好的毛发转成交互式Groom 第二步#xff1a;导出刚生成的交互式Groom缓存#xff0c;需要设置一下当前帧#xff0c;和…首先声明maya建议用2022版本及一下因为要用到Python 2 ,Maya2023以后默认是Python3不再支持Python2;
第一步Xgen做好的毛发转成交互式Groom 第二步导出刚生成的交互式Groom缓存需要设置一下当前帧和写入宽度到这里其实就可以直接导入到UE了为了后面能做多颜色毛发和渐变毛发可以继续看如果不需要到这一步就可以直接打开UE导入了按照后面的流程导入UE就可以了
第三步导入刚刚导出的缓存文件导入后会根据毛发数量自动分组 第四步利用官方文档的Python脚本分别重新导出这三个分好组的缓存文件这一步的目的是为了让缓存文件拥有UV方便进去UE后根据需求继续调整举例做渐变毛发和多颜色毛发可以直接复制有几个代码需要修改看说明
from maya import cmds
from maya import OpenMaya
import osdef create_root_uv_attribute(curves_group, mesh_node, uv_setmap1):Create groom_root_uv attribute on group of curves.# check curves groupif not cmds.objExists(curves_group):raise RuntimeError(Group not found: {}.format(curves_group))# get curves in groupcurve_shapes cmds.listRelatives(curves_group, shapesTrue, noIntermediateTrue)curve_shapes cmds.ls(curve_shapes, typenurbsCurve)if not curve_shapes:raise RuntimeError(Invalid curves group. No nurbs-curves found in group.)else:print found curvesprint curve_shapes# get curve rootspoints list()for curve_shape in curve_shapes:point cmds.pointPosition({}.cv[0].format(curve_shape), worldTrue)points.append(point)# get uvsvalues list()uvs find_closest_uv_point(points, mesh_node, uv_setuv_set)for u, v in uvs:values.append([u, v, 0])#print (str(u) , str(v) )# create attributename groom_root_uvcmds.addAttr(curves_group, lnname, dtvectorArray)cmds.addAttr(curves_group, ln{}_AbcGeomScope.format(name), dtstring)cmds.addAttr(curves_group, ln{}_AbcType.format(name), dtstring)cmds.setAttr({}.{}.format(curves_group, name), len(values), *values, typevectorArray)cmds.setAttr({}.{}_AbcGeomScope.format(curves_group, name), uni, typestring)cmds.setAttr({}.{}_AbcType.format(curves_group, name), vector2, typestring)return uvsdef find_closest_uv_point(points, mesh_node, uv_setmap1):Find mesh UV-coordinates at given points.# check meshif not cmds.objExists(mesh_node):raise RuntimeError(Node not found: {}.format(mesh_node))# check uv_setuv_sets cmds.polyUVSet(mesh_node, qTrue, allUVSetsTrue)if uv_set not in uv_sets:raise RuntimeError(Invalid uv_set provided: {}.format(uv_set))# get mesh as dag-pathselection_list OpenMaya.MSelectionList()selection_list.add(mesh_node)mesh_dagpath OpenMaya.MDagPath()selection_list.getDagPath(0, mesh_dagpath)mesh_dagpath.extendToShape()# get mesh function setfn_mesh OpenMaya.MFnMesh(mesh_dagpath)uvs list()for i in range(len(points)):script_util OpenMaya.MScriptUtil()script_util.createFromDouble(0.0, 0.0)uv_point script_util.asFloat2Ptr()point OpenMaya.MPoint(*points[i])fn_mesh.getUVAtPoint(point, uv_point, OpenMaya.MSpace.kWorld, uv_set)u OpenMaya.MScriptUtil.getFloat2ArrayItem(uv_point, 0, 0)v OpenMaya.MScriptUtil.getFloat2ArrayItem(uv_point, 0, 1)uvs.append((u, v))return uvsdef abc_export(filepath, nodeNone, start_frame1, end_frame1, data_formatotawa, uv_writeTrue):job_command -frameRange {} {} .format(start_frame, end_frame)job_command -dataFormat {} .format(data_format)job_command -attr groom_root_uv if uv_write:job_command -uvWrite job_command -root {} .format(node) job_command -file {} .format(filepath) cmds.AbcExport(verboseTrue, jjob_command)def main():export_directory D:/Dev/Refhair_file os.path.join(export_directory, hair_export.abc)curve_top_group description1|SplineGrp0uv_meshpPlane1create_root_uv_attribute( curve_top_group , uv_mesh)abc_export(hair_file, curve_top_group)main() 第五步由于是分别导出的3个文件因为三个分别导入UE有些麻烦也没必要需要重新整合一下重新开一个新的maya文件把3个缓存文件重新导入到新的maya里面再次整体导出一个缓存文件这里需要添加一个groom_root_UV(说明 :groom_root_uv属性为每根头发指定它所附加到的基础网格uv。该属性是可选的如果未指定将使用球形贴图在引擎中自动生成一个根UV) 第六步导入UE需要设置一下项目设置和插件 然后导入窗口的旋转设置一下 这里可以设置一下基础属性 这里可以开启物理模拟 可以创建绑定这样就可以替换默认的头发了也可以通道添加组件添加到骨骼模型上 打开角色蓝图就可以替换之前的模型资产和材质了 材质球设置 这里可以通过绘画贴图来实现不同颜色的发色