void AddParticles() { m_mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f); ray = _mainCamera.ScreenPointToRay(m_mousePos); //Debug.DrawRay(ray.origin, ray.direction, Color.magenta); Vector3 uvWorldPosition = Vector3.zero; if (!HitTestUVPosition(ray, ref uvWorldPosition)) { return; } Ray fluidRay = new Ray(fluidRTCam.transform.position + uvWorldPosition, Vector3.forward); //Debug.DrawRay(fluidRay.origin, fluidRay.direction, Color.green, 1f); if (m_tempCol.Raycast(fluidRay, out hitInfo, 100)) { fWidth = m_tempRend.bounds.extents.x * 2f; fRadius = (m_particlesRadius * m_fluid.GetParticlesWidth()) / fWidth; m_fluid.AddParticles(hitInfo.textureCoord, fRadius, m_particlesStrength * Time.deltaTime); m_fluid.AddParticles(hitInfo.textureCoord - new Vector2(0, wrapOffset), fRadius, m_particlesStrength * Time.deltaTime); } }
private void ManipulateParticles() { if (m_mainSimulation && !bdone) { ray = new Ray(transform.position, Vector3.forward); if (m_tempCol.Raycast(ray, out hitInfo, 10)) { fWidth = m_tempRend.bounds.extents.x * 2f; fRadius = (GetRadius() * m_mainSimulation.GetParticlesWidth()) / fWidth; m_mainSimulation.AddParticles(hitInfo.textureCoord, fRadius, m_strength * Time.deltaTime); } } }
private void LateUpdate() { for (int i = 0; i < Input.touchCount; ++i) { touch = Input.GetTouch(i); ray = Camera.main.ScreenPointToRay(new Vector3(touch.position.x, touch.position.y, 0f)); if (m_tempCol.Raycast(ray, out hitInfo, 100)) { fWidth = m_tempRend.bounds.extents.x * 2f; fRadius = (m_particlesRadius * m_fluid.GetParticlesWidth()) / fWidth; m_fluid.AddParticles(hitInfo.textureCoord, fRadius, m_particlesStrength * Time.deltaTime); if (touch.phase == TouchPhase.Moved) { direction = new Vector3(touch.deltaPosition.x, touch.deltaPosition.y) * m_velocityStrength * touch.deltaTime; fWidth = m_tempRend1.bounds.extents.x * 2f; fRadius = (m_velocityRadius * m_fluid.GetWidth()) / fWidth; m_fluid.AddVelocity(hitInfo.textureCoord, direction, fRadius); } } } }
private void ManipulateParticles() { if (Input.GetMouseButton(0) || m_alwaysOn) { Debug.Log("0"); m_mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f); ray = Camera.main.ScreenPointToRay(m_mousePos); if (m_tempCol.Raycast(ray, out hitInfo, 100)) { fWidth = m_tempRend.bounds.extents.x * 2f; fRadius = (m_particlesRadius * m_fluid.GetParticlesWidth()) / fWidth; m_fluid.AddParticles(hitInfo.textureCoord, fRadius, m_particlesStrength * Time.deltaTime); } } if (Input.GetMouseButton(1) || m_alwaysOn) { Debug.Log("1"); m_mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f); ray = Camera.main.ScreenPointToRay(m_mousePos); if (m_tempCol.Raycast(ray, out hitInfo, 100)) { Debug.Log("1 - raycast"); direction = new Vector3(1.0f, 0.0f, 0.0f); direction = direction * m_velocityStrength * Time.deltaTime; fWidth = m_tempRend.bounds.extents.x * 2f; fRadius = (m_velocityRadius * m_fluid.GetWidth()) / fWidth; if (Input.GetMouseButton(0)) { Debug.Log("1 - added velocity"); m_fluid.AddVelocity(hitInfo.textureCoord, -direction, fRadius); Debug.Log(direction); } else { m_fluid.AddVelocity(hitInfo.textureCoord, direction, fRadius); } } } }