Exemplo n.º 1
0
        //=========================================================================================
        /// <summary>
        /// デフォーマーギズモの表示
        /// </summary>
        /// <param name="editorMesh"></param>
        /// <param name="meshData">nullの場合はすべての頂点を表示</param>
        /// <param name="clothSelection"></param>
        /// <param name="size"></param>
        public static void DrawDeformerGizmo(
            IEditorMesh editorMesh,
            IEditorCloth editorCloth,
            float size = 0.005f
            )
        {
            if (ClothMonitorMenu.Monitor == null)
            {
                return;
            }
            if (ClothMonitorMenu.Monitor.UI.DrawDeformer == false)
            {
                return;
            }

            if (ClothMonitorMenu.Monitor.UI.DrawDeformerVertexPosition == false &&
                ClothMonitorMenu.Monitor.UI.DrawDeformerTriangle == false &&
                ClothMonitorMenu.Monitor.UI.DrawDeformerLine == false &&
                ClothMonitorMenu.Monitor.UI.DrawDeformerVertexAxis == false
#if MAGICACLOTH_DEBUG
                && ClothMonitorMenu.Monitor.UI.DrawDeformerVertexNumber == false &&
                ClothMonitorMenu.Monitor.UI.DrawDeformerTriangleNormal == false
#endif
                )
            {
                return;
            }

            // メッシュ頂点法線接線
            List <Vector3> posList;
            List <Vector3> norList;
            List <Vector3> tanList;
            int            vcnt = editorMesh.GetEditorPositionNormalTangent(out posList, out norList, out tanList);
            if (posList.Count == 0)
            {
                return;
            }

            // 頂点使用状態
            List <int> useList = null;
            List <int> selList = null;
            if (editorCloth != null)
            {
                useList = editorCloth.GetUseList();
                selList = editorCloth.GetSelectionList();
            }

            // 頂点
            DrawVertex(vcnt, posList, norList, tanList, useList, selList, size);

            // トライアングル
            DrawTriangle(editorMesh, posList, norList, tanList, useList);

            // ライン
            DrawLine(editorMesh, posList, norList, tanList, useList);
        }
Exemplo n.º 2
0
        //=========================================================================================
        /// <summary>
        /// ライン情報の表示
        /// </summary>
        /// <param name="editorMesh"></param>
        static void DrawLine(
            IEditorMesh editorMesh,
            List <Vector3> posList,
            List <Vector3> norList,
            List <Vector3> tanList,
            List <int> useList
            )
        {
            if (ClothMonitorMenu.Monitor.UI.DrawDeformerLine == false)
            {
                return;
            }

            var lines = editorMesh.GetEditorLineList();

            if (lines == null || lines.Count == 0)
            {
                return;
            }

            Gizmos.color = GizmoUtility.ColorStructLine;
            int lcnt = lines.Count / 2;

            for (int i = 0; i < lcnt; i++)
            {
                int index = i * 2;

                int i0 = lines[index];
                int i1 = lines[index + 1];

                // 利用頂点のみ
                if (useList != null)
                {
                    if (i0 >= useList.Count || i1 >= useList.Count)
                    {
                        continue;
                    }

                    if (useList[i0] == 0 || useList[i1] == 0)
                    {
                        continue;
                    }
                }

                if (i0 >= posList.Count || i1 >= posList.Count)
                {
                    continue;
                }

                Vector3 pos0 = posList[i0];
                Vector3 pos1 = posList[i1];

                Gizmos.DrawLine(pos0, pos1);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// ポイント選択GUIの表示と制御
        /// </summary>
        /// <param name="clothData"></param>
        /// <param name="editorMesh"></param>
        protected void DrawInspectorGUI(IEditorMesh editorMesh)
        {
            this.editorMesh = editorMesh;

            if (editorMesh == null)
            {
                return;
            }

            pointSelector.DrawInspectorGUI(this, StartEdit, EndEdit);
        }
Exemplo n.º 4
0
        //=========================================================================================
        /// <summary>
        /// トライアングル情報の表示
        /// </summary>
        /// <param name="editorMesh"></param>
        static void DrawTriangle(
            IEditorMesh editorMesh,
            List <Vector3> posList,
            List <Vector3> norList,
            List <Vector3> tanList,
            List <int> useList
            )
        {
            bool drawTriangle = ClothMonitorMenu.Monitor.UI.DrawDeformerTriangle;

#if MAGICACLOTH_DEBUG
            bool drawNormal = ClothMonitorMenu.Monitor.UI.DrawDeformerTriangleNormal;
            bool drawNumber = ClothMonitorMenu.Monitor.UI.DrawDeformerTriangleNumber;
#else
            bool drawNormal = false;
            bool drawNumber = false;
#endif
            if (!drawTriangle && !drawNormal && !drawNumber)
            {
                return;
            }

            var triangles = editorMesh.GetEditorTriangleList();

            if (triangles == null || triangles.Count == 0)
            {
                return;
            }

            //Gizmos.color = GizmoUtility.ColorTriangle;
            int tcnt = triangles.Count / 3;

            // 表示半径
            float   radius = -1;
            Vector3 center = Vector3.zero;
#if MAGICACLOTH_DEBUG
            if (ClothMonitorMenu.Monitor.UI.DebugDrawDeformerTriangleNumber >= 0)
            {
                int tindex = ClothMonitorMenu.Monitor.UI.DebugDrawDeformerTriangleNumber;
                if (tindex >= 0 && tindex < tcnt)
                {
                    int index = tindex * 3;

                    int i0 = triangles[index];
                    int i1 = triangles[index + 1];
                    int i2 = triangles[index + 2];

                    Vector3 pos0 = posList[i0];
                    Vector3 pos1 = posList[i1];
                    Vector3 pos2 = posList[i2];
                    center = (pos0 + pos1 + pos2) / 3.0f;
                    radius = 0.05f;
                }
            }
#endif

            // 表示
            for (int tindex = 0; tindex < tcnt; tindex++)
            {
                DrawTriangle1(tindex, triangles, posList, useList, center, radius, drawTriangle, drawNormal, drawNumber);
            }
        }
        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.DrawPenetrationOrigin == 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);

                // トライアングルベンド
                DrawTriangleBendRuntime(team, clothData, setup);

                // 回転ライン
                DrawRotationLineRuntime(team, clothData, setup, selList);

                // コライダー移動制限
                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);

                // トライアングルベンド
                DrawTriangleBendClothData(clothData, posList);

                // 回転ライン
                DrawRotationLineClothData(clothData, posList, selList);

                // コライダー移動制限
                DrawPenetrationClothData(team, param, clothData, posList, norList, tanList, selList);

                // ベーススキニング
                //DrawBaseSkinningClothData(team, clothData, posList, selList);

                // ボリューム
                //DrawVolumeClothData(clothData, posList);

                // 回転調整ライン
                //DrawAdjustRotationLineClothData(clothData, posList);
            }

            return(true);
        }