protected override void UpdateMonitor(P3dPaintableTexture paintableTexture, bool preview)
        {
            if (preview == false && paintableTexture.Activated == true)
            {
                var renderTexture = paintableTexture.Current;
                var temporary     = default(RenderTexture);

                if (P3dHelper.Downsample(renderTexture, downsampleSteps, ref temporary) == true)
                {
                    Calculate(temporary, temporary, 1 << downsampleSteps);

                    P3dHelper.ReleaseRenderTexture(temporary);
                }
                else
                {
                    Calculate(renderTexture, temporary, 1);
                }
            }
        }
Esempio n. 2
0
        protected virtual void Update()
        {
            var finalCounters = counters.Count > 0 ? counters : null;
            var total         = P3dChangeCounter.GetTotal(finalCounters);
            var count         = P3dChangeCounter.GetCount(finalCounters);

            if (inverse == true)
            {
                count = total - count;
            }

            var final   = format;
            var percent = P3dHelper.RatioToPercentage(P3dHelper.Divide(count, total), decimalPlaces);

            final = final.Replace("{TOTAL}", total.ToString());
            final = final.Replace("{COUNT}", count.ToString());
            final = final.Replace("{PERCENT}", percent.ToString());

            cachedText.text = final;
        }
Esempio n. 3
0
        protected virtual void Update()
        {
            if (paintableTexture != null && paintableTexture.Activated == true)
            {
                if (speed > 0.0f)
                {
                    counter += speed * Time.deltaTime;
                }

                if (counter >= threshold)
                {
                    var step = Mathf.FloorToInt(counter * 255.0f);

                    if (step > 0)
                    {
                        var change = step / 255.0f;

                        counter -= change;

                        P3dCommandFill.Instance.SetState(false, 0);
                        P3dCommandFill.Instance.SetMaterial(blendMode, texture, color, Mathf.Min(change, 1.0f), Mathf.Min(change, 1.0f));

                        var command = P3dPaintableManager.Submit(P3dCommandFill.Instance, paintableTexture.Paintable, paintableTexture);

                        if (maskPaintableTexture != null)
                        {
                            command.LocalMaskTexture = maskPaintableTexture.Current;
                            command.LocalMaskChannel = P3dHelper.IndexToVector((int)maskChannel);
                        }
                        else if (maskTexture != null)
                        {
                            command.LocalMaskTexture = maskTexture;
                            command.LocalMaskChannel = P3dHelper.IndexToVector((int)maskChannel);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        protected override void OnInspector()
        {
            base.OnInspector();

            Draw("threshold", "The RGBA values must be within this range of a color for it to be counted.");

            Separator();

            BeginDisabled();
            EditorGUILayout.IntField("Total", Target.Total);

            for (var i = 0; i < Target.Contributions.Count; i++)
            {
                var contribution = Target.Contributions[i];
                var rect         = P3dHelper.Reserve();
                var rectL        = rect; rectL.xMax -= (rect.width - EditorGUIUtility.labelWidth) / 2 + 1;
                var rectR        = rect; rectR.xMin = rectL.xMax + 2;

                EditorGUI.IntField(rectL, contribution.Color != null ? contribution.Color.name : "", contribution.Count);
                EditorGUI.ProgressBar(rectR, contribution.Ratio, "Ratio");
            }
            EndDisabled();
        }
Esempio n. 5
0
        protected virtual void Update()
        {
            inputManager.Update(key);

            // Calculate delta
            if (CanRotate == true && Application.isPlaying == true)
            {
                var delta = inputManager.GetAverageDeltaScaled(true);

                pitch -= delta.y * pitchSensitivity;
                yaw   += delta.x * yawSensitivity;
            }

            pitch = Mathf.Clamp(pitch, pitchMin, pitchMax);

            // Smoothly dampen values
            var factor = P3dHelper.DampenFactor(dampening, Time.deltaTime);

            currentPitch = Mathf.Lerp(currentPitch, pitch, factor);
            currentYaw   = Mathf.Lerp(currentYaw, yaw, factor);

            // Apply new rotation
            transform.localRotation = Quaternion.Euler(currentPitch, currentYaw, 0.0f);
        }
Esempio n. 6
0
 /// <summary>The <b>CountA / Total</b> of the specified counters.</summary>
 public static float GetRatioA(ICollection <P3dChannelCounter> counters = null)
 {
     return(P3dHelper.Divide(GetCountA(counters), GetTotal(counters)));
 }
Esempio n. 7
0
 /// <summary>The <b>Ratio</b> of the specified counters.</summary>
 public static float GetRatio(P3dColor color, ICollection <P3dColorCounter> counters = null)
 {
     return(P3dHelper.Divide(GetCount(color, counters), GetTotal(counters)));
 }
Esempio n. 8
0
        public void UpdateGripped(P3dVrManager vrManager)
        {
            // Position?
            var position    = default(Vector3);
            var positionSet = false;

            if (vrManager.TryGetPosition(node, ref position) == true)
            {
                positionSet = true;

                if (vrManager.IsSimulation == true)
                {
                    position += transform.rotation * localOffset;

                    if (vrManager.GetTrigger(node) == true)
                    {
                        position += transform.rotation * simulatedKeyOffset;
                    }
                }

                position += transform.rotation * simulatedOffset;
            }

            // Rotation?
            var rotation    = default(Quaternion);
            var rotationSet = false;

            if (vrManager.TryGetRotation(node, ref rotation) == true)
            {
                rotationSet = true;
            }

            // Transition?
            var dampening = 1.0f;

            if (vrManager.IsSimulation == true)
            {
                dampening = P3dHelper.DampenFactor(simulatedDampening, Time.deltaTime);
            }

            if (positionSet == true)
            {
                transform.position = Vector3.Lerp(transform.position, position, dampening);
            }

            if (rotationSet == true)
            {
                transform.rotation = Quaternion.Slerp(transform.rotation, rotation, dampening);
            }

            // Events?
            if (vrManager.GetTriggerPressed(node) == true)
            {
                if (storeStates == true)
                {
                    P3dStateManager.StoreAllStates();
                }

                if (onTriggerPress != null)
                {
                    onTriggerPress.Invoke();
                }
            }

            if (vrManager.GetTriggerReleased(node) == true)
            {
                if (onTriggerRelease != null)
                {
                    onTriggerRelease.Invoke();
                }
            }

            if (vrManager.GetGripPressed(node) == true)
            {
                if (onGripPress != null)
                {
                    onGripPress.Invoke();
                }
            }

            if (vrManager.GetGripReleased(node) == true)
            {
                if (onGripRelease != null)
                {
                    onGripRelease.Invoke();
                }
            }
        }