private void GetManipulatorProperty(ManipulatorObjectC manipulator) { m_ManipulatorObject = manipulator; // Handles work in world space, so we need to convert position and rotation to world space m_Transform = m_ManipulatorObject.transform; m_Position = m_ManipulatorObject.transform.position; m_Rotation = m_ManipulatorObject.transform.rotation = Tools.pivotRotation == PivotRotation.Local ? m_ManipulatorObject.transform.rotation : Quaternion.identity; m_Scale = m_ManipulatorObject.transform.lossyScale; m_Type = m_ManipulatorObject.type; m_Shape = m_ManipulatorObject.shape; m_Size = m_ManipulatorObject.size; m_Bounds = m_ManipulatorObject.bounds; m_Strength = m_ManipulatorObject.strength; m_SmoothStrength = m_ManipulatorObject.smoothStrength; m_SmoothDistance = m_ManipulatorObject.smoothDistance; }
//public int manipulatorInstance = ParticleToolC.manipulatorInstance; public string DebugManipulatorObject(ManipulatorObjectC manipulatorObject) { Transform _transform = manipulatorObject.transform; MANIPULATORTYPE _type = manipulatorObject.type; MANIPULATORSHAPE _shape = manipulatorObject.shape; float _size = manipulatorObject.size; Bounds _bounds = manipulatorObject.bounds; float _strength = manipulatorObject.strength; float _smoothStrength = manipulatorObject.smoothStrength; float _smoothDistance = manipulatorObject.smoothDistance; string manipulatorInfo = ("Manipulator: " + manipulatorObject.transform + "\n" + "Position: " + manipulatorObject.transform.localPosition + "\n" + "Rotation: " + manipulatorObject.transform.localRotation + "\n" + "Type: " + manipulatorObject.type + "\n" + "Size: " + manipulatorObject.size + "\n" + "Strength: " + manipulatorObject.strength + "\n"); return(manipulatorInfo); }
public Vector3 GetForce(ParticleSystem.Particle particle, ManipulatorObjectC manipulator, MANIPULATORTYPE type) { Vector3 manipulatorPosition = manipulator.transform.position; Vector3 force = Vector3.zero; Vector3 particlePosition = particle.position; float manipulatorDistance = Vector3.Distance(manipulatorPosition, particlePosition) / manipulator.smoothDistance; float manipulatorStrength = manipulator.strength * manipulator.size; float mStrengthModifier = manipulatorStrength / manipulatorDistance; float time = Time.deltaTime * (mStrengthModifier / manipulator.smoothStrength); switch (type) { case MANIPULATORTYPE.Attraction: force = Vector3.Lerp(particle.velocity, (manipulatorPosition - particlePosition) * mStrengthModifier, time); break; case MANIPULATORTYPE.Repellent: force = Vector3.Lerp(particle.velocity, (particlePosition - manipulatorPosition) * mStrengthModifier, time); break; case MANIPULATORTYPE.VortexAttraction: force = Vector3.Lerp(particle.velocity, ((manipulatorPosition - particlePosition) * mStrengthModifier - Vector3.Cross(transform.forward, manipulatorPosition - particlePosition) * mStrengthModifier), (Time.deltaTime * mStrengthModifier) / manipulator.smoothStrength); break; } return(force); }