//========================================================================================= /// <summary> /// ランタイム状態での頂点表示 /// </summary> /// <param name="scr"></param> /// <param name="deformer"></param> /// <param name="clothData"></param> static void DrawVertexRuntime( PhysicsTeam team, ClothData clothData, ClothParams param, ClothSetup setup, List <int> selList ) { bool drawVertex = ClothMonitorMenu.Monitor.UI.DrawClothVertex; bool drawRadius = ClothMonitorMenu.Monitor.UI.DrawClothRadius; bool drawDepth = ClothMonitorMenu.Monitor.UI.DrawClothDepth; bool drawBase = ClothMonitorMenu.Monitor.UI.DrawClothBase; bool drawAxis = ClothMonitorMenu.Monitor.UI.DrawClothAxis; #if MAGICACLOTH_DEBUG bool number = ClothMonitorMenu.Monitor.UI.DrawClothVertexNumber; bool drawIndex = ClothMonitorMenu.Monitor.UI.DrawClothVertexIndex; bool drawFriction = ClothMonitorMenu.Monitor.UI.DrawClothFriction; bool drawDepthNumber = ClothMonitorMenu.Monitor.UI.DrawClothDepthNumber; #else bool number = false; bool drawIndex = false; bool drawFriction = false; bool drawDepthNumber = false; #endif if (!number && !drawVertex && !drawDepth && !drawBase && !drawAxis && !drawIndex && !drawFriction && !drawDepthNumber) { return; } int vcnt = clothData.useVertexList.Count; for (int i = 0; i < vcnt; i++) { int vindex = clothData.useVertexList[i]; int pindex = team.ParticleChunk.startIndex + i; Vector3 pos = MagicaPhysicsManager.Instance.Particle.posList[pindex]; float depth = MagicaPhysicsManager.Instance.Particle.depthList[pindex]; //float radius = PhysicsManager.Instance.Particle.radiusList[pindex]; float radius = drawRadius ? MagicaPhysicsManager.Instance.Particle.radiusList[pindex] : 0.001f; //float radius = param.GetRadius(depth); if (drawVertex || drawDepth || drawAxis) { Quaternion rot = MagicaPhysicsManager.Instance.Particle.rotList[pindex]; Gizmos.color = GetVertexColor(vindex, depth, selList); GizmoUtility.DrawWireSphere(pos, rot, Vector3.one, radius, drawVertex || drawDepth, drawAxis); } if (drawBase) { Vector3 bpos = MagicaPhysicsManager.Instance.Particle.basePosList[pindex]; Quaternion brot = MagicaPhysicsManager.Instance.Particle.baseRotList[pindex]; Gizmos.color = GizmoUtility.ColorBasePosition; GizmoUtility.DrawWireSphere(bpos, brot, Vector3.one, radius, true, false); } if (number) { Handles.Label(pos, i.ToString()); } if (drawIndex) { Handles.Label(pos, pindex.ToString()); } if (drawFriction) { float friction = MagicaPhysicsManager.Instance.Particle.frictionList[pindex]; Handles.Label(pos, string.Format("{0:#.##}", friction)); } //if (drawDepthNumber) if (drawDepth) { float d = MagicaPhysicsManager.Instance.Particle.depthList[pindex]; Handles.Label(pos, string.Format("{0:#.##}", d)); } } }
/// <summary> /// エディタ状態での頂点表示 /// </summary> /// <param name="scr"></param> /// <param name="deformer"></param> /// <param name="clothData"></param> static void DrawVertexClothData( ClothData clothData, ClothParams param, int vcnt, List <Vector3> posList, List <Vector3> norList, List <Vector3> tanList, List <int> selList ) { bool drawVertex = ClothMonitorMenu.Monitor.UI.DrawClothVertex; bool drawRadius = ClothMonitorMenu.Monitor.UI.DrawClothRadius; bool drawDepth = ClothMonitorMenu.Monitor.UI.DrawClothDepth; bool drawBase = ClothMonitorMenu.Monitor.UI.DrawClothBase; bool drawAxis = ClothMonitorMenu.Monitor.UI.DrawClothAxis; #if MAGICACLOTH_DEBUG bool number = ClothMonitorMenu.Monitor.UI.DrawClothVertexNumber; bool drawDepthNumber = ClothMonitorMenu.Monitor.UI.DrawClothDepthNumber; #else bool number = false; bool drawDepthNumber = false; #endif if (!number && !drawVertex && !drawDepth && !drawBase && !drawAxis && !drawDepthNumber) { return; } for (int i = 0; i < clothData.VertexUseCount; i++) { int vindex = clothData.useVertexList[i]; if (vindex >= posList.Count) { continue; } Vector3 pos = posList[vindex]; if (drawVertex || drawDepth || drawBase || drawAxis) { Vector3 nor = norList[vindex]; Vector3 tan = tanList[vindex]; Quaternion rot = Quaternion.LookRotation(nor, tan); float depth = clothData == null ? 0.0f : clothData.vertexDepthList[i]; //float radius = param.GetRadius(depth); float radius = drawRadius ? param.GetRadius(depth) : 0.001f; if (drawBase) { Gizmos.color = GizmoUtility.ColorBasePosition; GizmoUtility.DrawWireSphere(pos, rot, Vector3.one, radius, true, false); } else { Gizmos.color = GetVertexColor(vindex, depth, selList); GizmoUtility.DrawWireSphere(pos, rot, Vector3.one, radius, drawVertex || drawDepth, drawAxis); } } if (number) { Handles.Label(pos, i.ToString()); } //if (drawDepthNumber) if (drawDepth) { float depth = clothData == null ? 0.0f : clothData.vertexDepthList[i]; Handles.Label(pos, string.Format("{0:#.##}", depth)); } } }
public static bool DrawClothGizmo( PhysicsTeam team, ClothData clothData, ClothParams param, ClothSetup setup, IEditorMesh editorMesh, IEditorCloth editorCloth ) { if (ClothMonitorMenu.Monitor.UI.DrawCloth == false) { return(false); } if (ClothMonitorMenu.Monitor.UI.DrawClothVertex == false && ClothMonitorMenu.Monitor.UI.DrawClothDepth == false && ClothMonitorMenu.Monitor.UI.DrawClothBase == false && ClothMonitorMenu.Monitor.UI.DrawClothCollider == false && ClothMonitorMenu.Monitor.UI.DrawClothStructDistanceLine == false && ClothMonitorMenu.Monitor.UI.DrawClothBendDistanceLine == false && ClothMonitorMenu.Monitor.UI.DrawClothNearDistanceLine == false && ClothMonitorMenu.Monitor.UI.DrawClothRotationLine == false && ClothMonitorMenu.Monitor.UI.DrawClothTriangleBend == false && ClothMonitorMenu.Monitor.UI.DrawClothPenetration == false //&& ClothMonitorMenu.Monitor.UI.DrawClothBaseSkinning == false && ClothMonitorMenu.Monitor.UI.DrawClothAxis == false //&& ClothMonitorMenu.Monitor.UI.DrawClothVolume == false #if MAGICACLOTH_DEBUG && ClothMonitorMenu.Monitor.UI.DrawClothVertexNumber == false && ClothMonitorMenu.Monitor.UI.DrawClothVertexIndex == false //&& ClothMonitorMenu.Monitor.UI.DrawAdjustRotationLine == false #endif ) { return(false); } if (clothData == null) { return(false); } if (Application.isPlaying) { if (clothData == null) { return(false); } if (team.IsActive() == false) { return(false); } // 頂点使用状態 //var useList = editorCloth.GetUseList(); var selList = editorCloth.GetSelectionList(); // 頂点情報 DrawVertexRuntime(team, clothData, param, setup, selList); // コライダー DrawCollider(team); // ライン DrawLineRuntime(team, clothData, setup, selList); // 回転ライン DrawRotationLineRuntime(team, clothData, setup, selList); // トライアングルベンド DrawTriangleBendRuntime(team, clothData, setup); // コライダー移動制限 DrawPenetrationRuntime(team, param, clothData, selList); // ボリューム //DrawVolumeRuntime(team, clothData, setup); // 回転調整ライン //DrawAdjustRotationLineRuntime(team, clothData); } else { // メッシュ頂点法線接線 List <Vector3> posList; List <Vector3> norList; List <Vector3> tanList; int vcnt = editorMesh.GetEditorPositionNormalTangent(out posList, out norList, out tanList); // 頂点使用状態 //var useList = editorCloth.GetUseList(); var selList = editorCloth.GetSelectionList(); // 頂点情報 DrawVertexClothData(clothData, param, vcnt, posList, norList, tanList, selList); // コライダー DrawCollider(team); // ライン DrawLineClothData(clothData, posList, selList); // 回転ライン DrawRotationLineClothData(clothData, posList, selList); // トライアングルベンド DrawTriangleBendClothData(clothData, posList); // コライダー移動制限 DrawPenetrationClothData(team, param, clothData, posList, norList, tanList, selList); // ベーススキニング //DrawBaseSkinningClothData(team, clothData, posList, selList); // ボリューム //DrawVolumeClothData(clothData, posList); // 回転調整ライン //DrawAdjustRotationLineClothData(clothData, posList); } return(true); }