Exemplo n.º 1
0
 public static void DrawGizmo(MagicaSphereCollider scr, bool selected)
 {
     Gizmos.color = selected ? GizmoUtility.ColorCollider : GizmoUtility.ColorNonSelectedCollider;
     GizmoUtility.DrawWireSphere(
         scr.transform.position,
         scr.transform.rotation,
         Vector3.one * scr.GetScale(),
         scr.Radius,
         true,
         true
         );
 }
Exemplo n.º 2
0
        /// <summary>
        /// スプリングの範囲球ギズモ
        /// </summary>
        /// <param name="scr"></param>
        static void DrawSpringSphere(MagicaMeshSpring scr)
        {
            var t = scr.CenterTransform;

            if (t == null)
            {
                return;
            }

            Gizmos.color = Color.cyan;
            GizmoUtility.DrawWireSphere(t.position, t.rotation, scr.Params.SpringRadiusScale, scr.Params.SpringRadius, true, true);

            // 軸矢印
            Handles.color = Color.yellow;
            Handles.Slider(t.position, scr.CenterTransformDirection, scr.Params.SpringRadius, Handles.ArrowHandleCap, 1.0f);
        }
 public static void DrawGizmo(MagicaSphereCollider scr, bool selected)
 {
     if (scr == null)
     {
         return;
     }
     Gizmos.color = selected ? GizmoUtility.ColorCollider : GizmoUtility.ColorNonSelectedCollider;
     GizmoUtility.DrawWireSphere(
         //scr.transform.position,
         scr.transform.TransformPoint(scr.Center),
         scr.transform.rotation,
         Vector3.one * scr.GetScale(),
         scr.Radius,
         true,
         true
         );
 }
        /// <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));
                }
            }
        }
        //=========================================================================================
        /// <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;
            }

            // チームスケール
            var   teamTransform = team.InfluenceTarget ? team.InfluenceTarget : team.transform;
            float teamScale     = clothData.initScale.magnitude > 0.0f ? teamTransform.lossyScale.magnitude / clothData.initScale.magnitude : 1.0f;

            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].x * teamScale : 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));
                }
            }
        }