Beispiel #1
0
    private void OnSceneGUI()
    {
        FractureMesh _target = (FractureMesh)target;

        GUIStyle style = new GUIStyle(GUI.skin.label);

        //style.alignment = TextAnchor.MiddleCenter;

        if (_target.showIndices)
        {
            for (int i = 0; i < _target.fracturePoints.Count; i++)
            {
                if (i != _target.gizmoPolyIndex && _target.gizmoPolyIndex != -1)
                {
                    continue;
                }

                //style.normal.textColor = FractureMesh.MeshColors[i];
                style.normal.textColor = Color.white;
                for (int j = 0; j < _target.fracturePoints[i].Count; j++)
                {
                    Handles.Label(_target.fracturePoints[i][j], "" + j, style);
                }
            }
        }
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        FractureMesh _target = (FractureMesh)target;

        if (GUILayout.Button("Calc Voronoi"))
        {
            _target.Voronoi();
            SceneView.RepaintAll();
        }

        if (GUILayout.Button("Fracture"))
        {
            _target.Fracture();
            SceneView.RepaintAll();
        }
    }
Beispiel #3
0
    public void explodeWall(float power, MeshFilter meshFilt, Vector3 hitPos)
    {
        FractureMesh fm = new FractureMesh();

        fm.victim = meshFilt;

        for (int i = 0; i < numberOfPoints; i++)
        {
            Vector3 randomPos = Random.onUnitSphere * pointsPos.Evaluate(Random.Range(0f, 1f) * power);
            randomPos.z = 0;
            fm.points.Add(hitPos + randomPos);
        }

        fm.explosionForce = power;

        fm.ApplyFracture();
        fm.ExplosionForce(hitPos);
    }