示例#1
0
 protected override void OnResetPlugin()
 {
     acceleration = new FluvioMinMaxCurve { scalar = 1000.0f, minConstant = 0.0f, maxConstant = 1000.0f };
     SetCurveAsSigned(acceleration, true);
     radius = 10.0f;
     alwaysOn = false;
     mouseButton = 0;
     useMultiTouch = true;
 }
示例#2
0
 protected override void OnResetPlugin()
 {
     acceleration = new FluvioMinMaxCurve {
         scalar = 1000.0f, minConstant = 0.0f, maxConstant = 1000.0f
     };
     SetCurveAsSigned(acceleration, true);
     radius        = 10.0f;
     alwaysOn      = false;
     mouseButton   = 0;
     useMultiTouch = true;
 }
示例#3
0
        protected override bool OnStartPluginFrame(ref FluvioTimeStep timeStep)
        {
            // Clear all touch points
            m_TouchPointsCount = 0;

            // This plugin only runs in Play mode
            if (!Application.isPlaying)
            {
                return(false);
            }

            // Get camera and near clip
            var cam = Camera.main;

            if (!cam)
            {
                return(false);
            }

            // Get plane passing through fluid position facing the camera
            var plane = new Plane(-cam.transform.forward, fluid.transform.position);

            if (Input.touchCount == 0 || !useMultiTouch)
            {
                // Check for mouse button
                var mouseIsPressed = Input.GetMouseButton(mouseButton);

                if (alwaysOn || mouseIsPressed)
                {
                    var touchPosition = Input.mousePosition;
                    AddTouchPoint(touchPosition, cam, plane);
                }
            }
            else
            {
                // Check all touches
                for (int i = 0, l = Input.touchCount; i < l; ++i)
                {
                    var touch = Input.GetTouch(i);
                    AddTouchPoint(touch.position, cam, plane);
                }
            }

            // Make sure we have an acceleration curve, and that it is signed (-1 to 1)
            if (acceleration == null)
            {
                acceleration = new FluvioMinMaxCurve {
                    scalar = 1000.0f, minConstant = 0.0f, maxConstant = 1000.0f
                }
            }
            ;

            SetCurveAsSigned(acceleration, true);

            // Return false if we didn't add any touch points
            return(m_TouchPointsCount > 0);
        }

        void AddTouchPoint(Vector3 touchPosition, Camera cam, Plane plane)
        {
            if (m_TouchPointsCount == m_TouchPoints.Length)
            {
                return;
            }

            // Get orthographic world point
            var ortho = cam.orthographic;

            cam.orthographic = true;
            var worldPoint = cam.ScreenToWorldPoint(new Vector3(touchPosition.x, touchPosition.y, cam.nearClipPlane));

            cam.orthographic = ortho;

            // Create ray
            var ray = new Ray(worldPoint, -plane.normal);

            m_TouchPoints[m_TouchPointsCount] = ray.GetPoint(plane.GetDistanceToPoint(ray.origin));

            ++m_TouchPointsCount;
        }
示例#4
0
        protected override bool OnStartPluginFrame(ref FluvioTimeStep timeStep)
        {
            // Clear all touch points
            m_TouchPointsCount = 0;

            // This plugin only runs in Play mode
            if (!Application.isPlaying)
                return false;

            // Get camera and near clip
            var cam = Camera.main;

            if (!cam)
                return false;

            // Get plane passing through fluid position facing the camera
            var plane = new Plane(-cam.transform.forward, fluid.transform.position);

            if (Input.touchCount == 0 || !useMultiTouch)
            {
                // Check for mouse button
                var mouseIsPressed = Input.GetMouseButton(mouseButton);

                if (alwaysOn || mouseIsPressed)
                {
                    var touchPosition = Input.mousePosition;
                    AddTouchPoint(touchPosition, cam, plane);
                }
            }
            else
            {
                // Check all touches
                for (int i = 0, l = Input.touchCount; i < l; ++i)
                {
                    var touch = Input.GetTouch(i);
                    AddTouchPoint(touch.position, cam, plane);
                }
            }

            // Make sure we have an acceleration curve, and that it is signed (-1 to 1)
            if (acceleration == null)
                acceleration = new FluvioMinMaxCurve {scalar = 1000.0f, minConstant = 0.0f, maxConstant = 1000.0f};

            SetCurveAsSigned(acceleration, true);

            // Return false if we didn't add any touch points
            return m_TouchPointsCount > 0;
        }