private static void DrawHandle(WindEffector effector, GizmoType gizmosType)
    {
        Transform transform = effector.transform;

        Handles.color        = Color.blue;
        effector.InnerRadius = Handles.RadiusHandle(Quaternion.identity, transform.position, effector.InnerRadius);
        Handles.color        = Color.cyan;
        effector.OuterRadius = Handles.RadiusHandle(Quaternion.identity, transform.position, effector.OuterRadius);
        Handles.color        = Color.red;
        effector.WindSpeed   = Handles.ScaleSlider(effector.WindSpeed, transform.position, transform.forward, transform.rotation, effector.WindSpeed, 0.1f);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(effector);
        }
        //Handles.DrawDottedLine(transform.position, transform.position, Vector3.forward * wind.InnerRadius, );
    }
Exemple #2
0
    private static Vector3 GetLocalWindVelocity(WindEffector effector, Vector3 pos)
    {
        Vector3 v = Vector3.zero;

        Vector3 localPos          = pos - effector.Position;
        Vector3 verticalComponent = Vector3.Project(localPos, effector.Forward);

        localPos -= verticalComponent;

        float radialProximity = 1f - Mathf.Clamp01(localPos.magnitude / effector.OuterRadius);

        radialProximity = Mathf.Pow(radialProximity, 1.5f);
        v += Vector3.Cross(effector.Forward, localPos).normalized *radialProximity *effector.RotationalWindSpeed;
        v += effector.Forward * (radialProximity * effector.WindSpeed);
        float verticalProximity = 1f - Mathf.Clamp01((Mathf.Abs(verticalComponent.magnitude) - effector.InnerRadius) / (effector.OuterRadius - effector.InnerRadius));

        v *= verticalProximity;

        return(v);
    }
Exemple #3
0
            private void Start()
            {
                effectorObjs = FindObjectsOfType <WindEffectorRadius>();
                effectors    = new WindEffector[effectorObjs.Length];

                for (int i = 0; i < effectorObjs.Length; i++)
                {
                    effectors[i] = new WindEffector();
                }

                windShader   = Resources.Load <ComputeShader>("WindShader");
                doWindCalcId = windShader.FindKernel("DoWindCalc");

                //Sets up objects for mass vertex calculations
                if (useMeshCombination)
                {
                    instancedMeshes   = CombineMeshes(objs);
                    objsOriginalVerts = new Vector3[instancedMeshes.Length][];
                    for (int i = 0; i < instancedMeshes.Length; i++)
                    {
                        instancedMeshes[i].MarkDynamic();
                        objsOriginalVerts[i] = instancedMeshes[i].vertices;
                    }

                    for (int i = 0; i < objs.Count; i++)
                    {
                        objs[i].gameObject.SetActive(false);
                    }
                }
                else
                {
                    instancedMeshes   = new Mesh[objs.Count];
                    objsOriginalVerts = new Vector3[objs.Count][];
                    for (int i = 0; i < objs.Count; i++)
                    {
                        instancedMeshes[i] = Instantiate(objs[i].mesh);
                        instancedMeshes[i].MarkDynamic();
                        objsOriginalVerts[i] = instancedMeshes[i].vertices;
                    }
                }
            }
Exemple #4
0
 public void RemoveEffector(WindEffector effector)
 {
     _effectors.Remove(effector);
 }
Exemple #5
0
 public void AddEffector(WindEffector effector)
 {
     _effectors.Add(effector, effector.Bounds);
 }