コード例 #1
0
ファイル: CurveExtruder.cs プロジェクト: unitycoder/Drawing3D
        /// <summary>
        /// overrides the <see cref="ProjectPoint(xyz)"/> method of <see cref="Surface"/>.
        /// </summary>
        /// <param name="Point">Point, wich will be projected th the surface</param>
        /// <returns>u amd v parameter. A call <b>Point</b></returns>
        public override xy  ProjectPoint(xyz Point)
        {
            xyz    p     = Base.Relativ(Point);
            xyz    PD    = new xyz(0, 0, 0);
            xyz    PU    = new xyz(0, 0, 0);
            double Lam   = -1;
            double Param = -1;

            DownPlane.Cross(new LineType(p, Direction), out Lam, out PD);
            UpPlane.Cross(new LineType(p, Direction), out Lam, out PU);

            xyzArray A = CurveArray;

            xyz R = StandardBase.Relativ(p);

            double u    = Curve.Arcus(new xy(R.X, R.y));
            xy     PP11 = Curve.Value(u);

            if (PP11.dist(new xy(R.X, R.Y)) > 0.5)
            {
            }
            else
            {
            }
            A.Distance(new LineType(p, Direction), 1e10, out Param, out Lam);
            if (Height < 0)
            {
                double v = p.dist(PD) / PU.dist(PD);

                xyz PP = Value(u, v);

                return(new xy(u, v));
            }
            else
            {
                xy       pt  = Curve.Value(u);
                xyz      K   = StandardBase.BaseX * pt.x + StandardBase.BaseY * pt.y;
                Plane    P   = new Plane(Base.BaseO, Base.BaseZ);
                LineType L   = new LineType(K, Direction);
                xyz      pkt = new xyz(0, 0, 0);
                P.Cross(L, out Lam, out pkt);
                double v   = pkt.dist(p) / Height;
                xyz    PP1 = Value(u, v);

                return(new xy(u, v));
            }
        }
コード例 #2
0
ファイル: CurveExtruder.cs プロジェクト: unitycoder/Drawing3D
        /// <summary>
        /// overrides the <see cref="Value(double, double)"/> method of a <see cref="Surface"/>.
        /// </summary>
        /// <param name="u">first u-parameter</param>
        /// <param name="v">second v-parameter</param>
        /// <returns>coordinate of the extruded object</returns>
        public override xyz Value(double u, double v)
        {
            double Lam = -1;
            xyz    Q   = new xyz(0, 0, 0);
            xy     P   = Curve.Value(u);
            xyz    K   = StandardBase.BaseO + StandardBase.BaseX * P.x + StandardBase.BaseY * P.y;

            if (Height < 0)
            {
                xyz Pkt  = new xyz(0, 0, 0);
                xyz Pkt2 = new xyz(0, 0, 0);
                DownPlane.Cross(new LineType(K, Direction), out Lam, out Pkt);
                UpPlane.Cross(new LineType(K, Direction), out Lam, out Pkt2);
                xyz N = Base.Absolut(Pkt + (Pkt2 - Pkt) * v);
                if (ZHeight(u, v) > 0)
                {
                    return(Base.Absolut(Pkt + (Pkt2 - Pkt) * v + Normal(u, v) * ZHeight(u, v)));
                }
                else
                {
                    return(Base.Absolut(Pkt + (Pkt2 - Pkt) * v));
                }
            }
            else
            {
                LineType L  = new LineType(K, Direction);
                Plane    PL = new Plane(Base.BaseO, Base.BaseZ);
                Q = new xyz(0, 0, 0);
                PL.Cross(L, out Lam, out Q);
                if (ZHeight(u, v) > 0)
                {
                    return(Q + Direction.normalized() * (Height * v) + Normal(u, v) * ZHeight(u, v));
                }
                else
                {
                    return(Q + Direction.normalized() * (Height * v));
                }
            }
        }
コード例 #3
0
        public void Lerp(LerpData ld, bool canSkipLerp = false)
        {
            #region Drag

            UpdateCoverImage();

            if (this == _dragging)
            {
                if (isFading || !Shortcuts.editingNodes || !Input.GetMouseButton(0))
                {
                    _dragging = null;
                }
                else
                {
                    Vector3 pos;
                    if (UpPlane.MouseToPlane(out pos, MainCamera))
                    {
                        transform.localPosition          = pos + _dragOffset;
                        ActiveConfig.targetLocalPosition = transform.localPosition;
                    }
                }

                SetDirty();
            }


            #endregion

            #region Lerp Visual
            if (includedInLerp)
            {
                var ac = ActiveConfig;

                var needShaderUpdate = false;

                if (!lerpsFinished && (this != _dragging))
                {
                    needShaderUpdate = true;

                    _shBlur = Mathf.Lerp(_shBlur,
                                         Mathf.Clamp01((transform.localPosition - _localPos.targetValue).magnitude * 5),
                                         Time.deltaTime * 10);

                    fadePortion = Mathf.Lerp(fadePortion, isFading ? 0 : 1, ld.MinPortion);

                    var scale = _localScale.CurrentValue;

                    if (scale.x > 0)
                    {
                        _shSquare.x = scale.x > scale.y ? ((scale.x - scale.y) / scale.x) : 0;
                    }
                    else
                    {
                        _shSquare.x = 0;
                    }
                    if (scale.y > 0)
                    {
                        _shSquare.y = scale.y > scale.x ? ((scale.y - scale.x) / scale.y) : 0;
                    }
                    else
                    {
                        _shSquare.y = 0;
                    }

                    var textSize = new Vector2(17 + scale.x * 3, 5f + Mathf.Max(0, (scale.y - 1f) * 3f));

                    textA.rectTransform.sizeDelta = textSize;
                    textB.rectTransform.sizeDelta = textSize;
                }

                if (!lerpsFinished && (this != _dragging) && ld.MinPortion == 1 && LerpPosition)
                {
                    lerpsFinished = true;
                }

                if (newText != null || _activeTextAlpha < 1)
                {
                    lerpsFinished = false;

                    _activeTextAlpha = newText == null
                        ? Mathf.Lerp(_activeTextAlpha, 1, ld.Portion())
                        : LerpUtils.LerpBySpeed(_activeTextAlpha, 1, 4);

                    if (_activeTextAlpha == 1 && newText != null)
                    {
                        _activeTextIsA   = !_activeTextIsA;
                        ActiveText.text  = newText;
                        gameObject.name  = newText;
                        _activeTextAlpha = 0;
                        newText          = null;
                    }

                    needShaderUpdate = true;
                }

                bool skipLerpPossible = (_canJumpToPosition && fadePortion < 0.1f && !isFading);

                bgColor = Color.Lerp(bgColor, ac.targetColor, ld.Portion(skipLerpPossible));
                _textColor.Lerp(ld, skipLerpPossible);

                if (LerpPosition)
                {
                    _localPos.Lerp(ld);
                }

                _localScale.Lerp(ld, skipLerpPossible);
                _shadeCorners.Lerp(ld, skipLerpPossible);
                _shadeSelected.Lerp(ld, skipLerpPossible);
                _textureFadeIn.Lerp(ld, skipLerpPossible);
                _texTransition.Lerp(ld, skipLerpPossible);

                if (needShaderUpdate)
                {
                    OnShaderParametersChanged();
                }


                if (fadePortion == 0 && isFading && Application.isPlaying)
                {
                    BoxButtons.inst.Deactivate(this);
                }
            }
            #endregion

            #region Link

            bool gotLinkTarget = false;

            if (!_latestParent)
            {
                if (source != null && source.parentNode != null && source.parentNode == CurrentNode)
                {
                    _latestParent = source.parentNode.visualRepresentation as NodeCircleController;
                }
            }

            if (_latestParent)
            {
                if (_latestParent.gameObject.activeSelf)
                {
                    if (!_latestParent.isFading && (_latestParent.source != null) &&
                        (source != null) && (_latestParent.source == source.parentNode))
                    {
                        linkRenderer.startColor = linkRenderer.startColor.LerpBySpeed(bgColor, 5);
                        linkRenderer.endColor   = linkRenderer.endColor.LerpBySpeed(_latestParent.bgColor, 5);

                        if (!linkRenderer.gameObject.activeSelf)
                        {
                            linkRenderer.gameObject.SetActive(true);
                        }

                        gotLinkTarget = true;
                    }

                    linkRenderer.SetPosition(0, transform.position + Vector3.down * 0.1f);
                    linkRenderer.SetPosition(1, _latestParent.transform.position + Vector3.down * 0.1f);
                }
            }

            if (!gotLinkTarget)
            {
                linkRenderer.LerpAlpha_DisableIfZero(0, 1);
            }

            #endregion

            if (LevelArea)
            {
                LevelArea.Lerp(ld, false);
            }

            if (_mouseDown && ((Time.time - _overDownTime) > 0.2f))
            {
                _mouseDown    = false;
                lerpsFinished = false;
                audioSource.Stop();
                Debug.Log("Stopping on leave");
                audioSource.PlayOneShot(Shortcuts.Assets.onMouseLeaveSound);
            }
        }