93 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
		
		
			
		
	
	
			93 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| 
								 | 
							
								## MUTools Maya部分笔记
							 | 
						|||
| 
								 | 
							
								1. AddMesh()
							 | 
						|||
| 
								 | 
							
								2. SendCommand()
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								### 导入Maya文件命令Mel
							 | 
						|||
| 
								 | 
							
								>file -f -o "C:/Users/admin/Desktop/test.mb";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								### Maya插件获取场景数据
							 | 
						|||
| 
								 | 
							
								DBU_ScenePrimitiveCollector::AssembleData,具有2个分支UpdateOutline与CollectFeedback同时负责序列化:
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								1. AdditionalMessage
							 | 
						|||
| 
								 | 
							
								2. 写入文件头(虽然这个写入步骤在UpdateOutline之后,但在写Outline数据时偏移了sizeof(UPDATEMSG))
							 | 
						|||
| 
								 | 
							
								3. UpdateOutline
							 | 
						|||
| 
								 | 
							
									1. OutlineEntityList
							 | 
						|||
| 
								 | 
							
										1. NameStream中每个节点名称字符串的偏移
							 | 
						|||
| 
								 | 
							
										2. ChildNode数目
							 | 
						|||
| 
								 | 
							
									2. UPDATEMSG MSGHEAD 文件头信息。
							 | 
						|||
| 
								 | 
							
									3. NameStream 存储每个节点名称的流
							 | 
						|||
| 
								 | 
							
								4.  CollectFeedback
							 | 
						|||
| 
								 | 
							
									1. UpdateEntityList
							 | 
						|||
| 
								 | 
							
									2. MeshStream->AddrList
							 | 
						|||
| 
								 | 
							
									3. MeshStream->ByteStream
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								UE中的反序列化,根据文件头信息的HasOutline与HasFeedbackData,有以下两个分支:
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								1. 读取文件头信息
							 | 
						|||
| 
								 | 
							
								2. HasOutline
							 | 
						|||
| 
								 | 
							
									1. OutlineRootData
							 | 
						|||
| 
								 | 
							
									2. OutlineData 
							 | 
						|||
| 
								 | 
							
									3. NamesData 节点名称流
							 | 
						|||
| 
								 | 
							
								3. HasFeedbackData
							 | 
						|||
| 
								 | 
							
									1. NamesData 
							 | 
						|||
| 
								 | 
							
									2. UpdateEntities
							 | 
						|||
| 
								 | 
							
									3. AddrList
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								### 更新大纲Mesh数据
							 | 
						|||
| 
								 | 
							
								UpdateOutline只有Maya大纲的名称与当前节点的子节点数目数据。其他模型信息集中在CollectFeedback阶段。
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								DBU_AddMesh来管理列表(监视每个Mesh状态),如果entity的meshDirty=true则将其加入`vector<MeshAndID> MeshList`。最后使用
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								```c++
							 | 
						|||
| 
								 | 
							
								MeshStream = new AssembleMeshStream(MeshList);
							 | 
						|||
| 
								 | 
							
								```
							 | 
						|||
| 
								 | 
							
								来生成这个MeshStream。(来进行顶点、UV、法线、顶点处理)
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								```c++
							 | 
						|||
| 
								 | 
							
								bool DBU_ScenePrimitiveCollector::AssembleData(MString& Result,vector<char> &ByteStream, bool CollectFeedback,bool UpdateOutline, MString AdditionalMessage)
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
									MStatus status;
							 | 
						|||
| 
								 | 
							
									//if (DBU_AddMesh::First == nullptr)
							 | 
						|||
| 
								 | 
							
									//	CollectFeedback = false;
							 | 
						|||
| 
								 | 
							
									if (CollectFeedback)
							 | 
						|||
| 
								 | 
							
									{
							 | 
						|||
| 
								 | 
							
										std::chrono::steady_clock::time_point _start_time = std::chrono::steady_clock::now();
							 | 
						|||
| 
								 | 
							
										DBU_AddMesh::LastSentUpdateList.clear();
							 | 
						|||
| 
								 | 
							
										DBU_AddMesh* curr = DBU_AddMesh::First;
							 | 
						|||
| 
								 | 
							
										while (curr)
							 | 
						|||
| 
								 | 
							
										{
							 | 
						|||
| 
								 | 
							
											curr->CollectEntity();
							 | 
						|||
| 
								 | 
							
											auto Next = curr->Next;
							 | 
						|||
| 
								 | 
							
											curr = Next;
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
								```
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								DBU_AddMesh::CollectEntity()
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								DBU_AddMesh节点在连接时候,将srcPlug的DAG路径加入NodeRegisteredDAGPaths。
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								MPlug & srcPlug->MObject FromWhat->MFnDagNode FromNode->MDagPath dagPath
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								### MUTools UE
							 | 
						|||
| 
								 | 
							
								通过MeshList的Index进行同步。
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								点击Outline Import后的逻辑 为发送遍历Entiry ,并且发送Mel:
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								$indices = {      XXXX    };
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								int $i;
							 | 
						|||
| 
								 | 
							
									for($i=0;$i<size($indices);$i++)
							 | 
						|||
| 
								 | 
							
									{
							 | 
						|||
| 
								 | 
							
									DBU_AddSynchronize(DBU_GetSentOutlinerEntityPath $indices[$i]);
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								print `lsType "DBU_AddMesh"`;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								调用DBU_AddSynchronize(DBU_GetSentOutlinerEntityPath)节点
							 |