国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Bezier Curve 貝塞爾曲線 - 在Unity中實(shí)現(xiàn)路徑編輯

這篇具有很好參考價(jià)值的文章主要介紹了Bezier Curve 貝塞爾曲線 - 在Unity中實(shí)現(xiàn)路徑編輯。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。


簡介

貝塞爾曲線(Bezier Curve),又稱貝茲曲線或貝濟(jì)埃曲線,是計(jì)算機(jī)圖形學(xué)中相當(dāng)重要的參數(shù)曲線,在我們常用的軟件如Photo Shop中就有貝塞爾曲線工具,本文簡單介紹貝塞爾曲線在Unity中的實(shí)現(xiàn)與應(yīng)用。

一階貝塞爾曲線

給頂點(diǎn)P0、P1,只是一條兩點(diǎn)之間的直線,公式如下:

B(t) = P0 + (P1 - P0) t = (1 - t) P0 + t P1, t ∈ [0, 1]

等同于線性插值,代碼實(shí)現(xiàn)如下:

/// <summary>
/// 一階貝塞爾曲線
/// </summary>
/// <param name="p0">起點(diǎn)</param>
/// <param name="p1">終點(diǎn)</param>
/// <param name="t">[0,1]</param>
/// <returns></returns>
public static Vector3 Bezier1(Vector3 p0, Vector3 p1, float t)
{
    return (1 - t) * p0 + t * p1;
}

二階貝塞爾曲線

路徑由給定點(diǎn)P0、P1、P2的函數(shù)計(jì)算,公式如下:

B(t) = (1 - t)2 P0 + 2t (1 - t) P1 + t2P2, t ∈[0, 1]

代碼實(shí)現(xiàn)如下:

/// <summary>
/// 二階貝塞爾曲線
/// </summary>
/// <param name="p0">起點(diǎn)</param>
/// <param name="p1">控制點(diǎn)</param>
/// <param name="p2">終點(diǎn)</param>
/// <param name="t">[0,1]</param>
/// <returns></returns>
public static Vector3 Bezier2(Vector3 p0, Vector3 p1, Vector3 p2, float t)
{
    Vector3 p0p1 = (1 - t) * p0 + t * p1;
    Vector3 p1p2 = (1 - t) * p1 + t * p2;
    return (1 - t) * p0p1 + t * p1p2;
}

三階貝塞爾曲線

P0、P1、P2、P3四個(gè)點(diǎn)在平面或三維空間中定義了三次方貝塞爾曲線。曲線起始于P0走向P1,并從P2的方向來到P3,一般不會(huì)經(jīng)過P1、P2,這兩個(gè)點(diǎn)只是提供方向信息,可以將P1、P2理解為控制點(diǎn)。P0和P1之間的間距,決定了曲線在轉(zhuǎn)而趨近P3之前,走向P2的長度有多長,公式如下:

B(t) = P0(1 - t)3 + 3P1t(1 - t)2 + 3P2t2(1 - t) + P3t3, t ∈ [0, 1]

代碼實(shí)現(xiàn)如下:

/// <summary>
/// 三階貝塞爾曲線
/// </summary>
/// <param name="p0">起點(diǎn)</param>
/// <param name="p1">控制點(diǎn)1</param>
/// <param name="p2">控制點(diǎn)2</param>
/// <param name="p3">終點(diǎn)</param>
/// <param name="t">[0,1]</param>
/// <returns></returns>
public static Vector3 Bezier3(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
{
    Vector3 p0p1 = (1 - t) * p0 + t * p1;
    Vector3 p1p2 = (1 - t) * p1 + t * p2;
    Vector3 p2p3 = (1 - t) * p2 + t * p3;
    Vector3 p0p1p2 = (1 - t) * p0p1 + t * p1p2;
    Vector3 p1p2p3 = (1 - t) * p1p2 + t * p2p3;
    return (1 - t) * p0p1p2 + t * p1p2p3;
}

圖形理解 Bezier Curve

使用Gizmos繪制Bezier Curve,通過圖形理解貝塞爾曲線:

一階貝塞爾曲線

P0為起點(diǎn),P1為終點(diǎn),t從0到1時(shí),在貝塞爾曲線上對應(yīng)的點(diǎn)為Pt,可以將t為理解為動(dòng)畫播放中的normalized time

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

代碼如下:

using UnityEngine;
using SK.Framework;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class Example : MonoBehaviour
{
    private float t;

    private void Update()
    {
        if (t < 1f)
        {
            t += Time.deltaTime * .2f;
            t = Mathf.Clamp01(t);
        }
    }

#if UNITY_EDITOR
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.grey;
        Vector3 p0 = Vector3.left * 5f;
        Vector3 p1 = Vector3.right * 5f;
        Gizmos.DrawLine(p0, p1);
        Handles.Label(p0, "P0");
        Handles.Label(p1, "P1");
        Handles.SphereHandleCap(0, p0, Quaternion.identity, .1f, EventType.Repaint);
        Handles.SphereHandleCap(0, p1, Quaternion.identity, .1f, EventType.Repaint);
        Vector3 pt = BezierCurveUtility.Bezier1(p0, p1, t);
        Gizmos.color = Color.red;
        Gizmos.DrawLine(p0, pt);
        Handles.Label(pt, string.Format("Pt (t = {0})", t));
        Handles.SphereHandleCap(0, pt, Quaternion.identity, .1f, EventType.Repaint);
    }
#endif
}

二階貝塞爾曲線

P0為起點(diǎn),P1為控制點(diǎn),P2為終點(diǎn),t從0到1時(shí),在貝塞爾曲線上對應(yīng)的點(diǎn)為Pt

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

代碼如下:

using UnityEngine;
using SK.Framework;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class Example : MonoBehaviour
{
    private float t;

    private void Update()
    {
        if (t < 1f)
        {
            t += Time.deltaTime * .2f;
            t = Mathf.Clamp01(t);
        }
    }

#if UNITY_EDITOR
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.grey;
        Vector3 p0 = Vector3.left * 5f;
        Vector3 p1 = Vector3.left * 2f + Vector3.forward * 2f;
        Vector3 p2 = Vector3.right * 5f;
        Gizmos.DrawLine(p0, p1);
        Gizmos.DrawLine(p2, p1);
        Handles.Label(p0, "P0");
        Handles.Label(p1, "P1");
        Handles.Label(p2, "P2");
        Handles.SphereHandleCap(0, p0, Quaternion.identity, .1f, EventType.Repaint);
        Handles.SphereHandleCap(0, p1, Quaternion.identity, .1f, EventType.Repaint);
        Handles.SphereHandleCap(0, p2, Quaternion.identity, .1f, EventType.Repaint);

        Gizmos.color = Color.green;
        for (int i = 0; i < 100; i++)
        {
            Vector3 curr = BezierCurveUtility.Bezier2(p0, p1, p2, i / 100f);
            Vector3 next = BezierCurveUtility.Bezier2(p0, p1, p2, (i + 1) / 100f);
            Gizmos.color = t > (i / 100f) ? Color.red : Color.green;
            Gizmos.DrawLine(curr, next);
        }
        Vector3 pt = BezierCurveUtility.Bezier2(p0, p1, p2, t);
        Handles.Label(pt, string.Format("Pt (t = {0})", t));
        Handles.SphereHandleCap(0, pt, Quaternion.identity, .1f, EventType.Repaint);
    }
#endif
}

三階貝塞爾曲線

P0為起點(diǎn),P1為第一個(gè)控制點(diǎn),P2為第二個(gè)控制點(diǎn),P3為終點(diǎn),t從0到1時(shí),在貝塞爾曲線上對應(yīng)的點(diǎn)為Pt

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

代碼如下:

using UnityEngine;
using SK.Framework;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class Example : MonoBehaviour
{
    private float t;

    private void Update()
    {
        if (t < 1f)
        {
            t += Time.deltaTime * .2f;
            t = Mathf.Clamp01(t);
        }
    }

#if UNITY_EDITOR
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.grey;
        Vector3 p0 = Vector3.left * 5f;
        Vector3 p1 = Vector3.left * 2f + Vector3.forward * 2f;
        Vector3 p2 = Vector3.right * 3f + Vector3.back * 4f;
        Vector3 p3 = Vector3.right * 5f;
        Gizmos.DrawLine(p0, p1);
        Gizmos.DrawLine(p1, p2);
        Gizmos.DrawLine(p2, p3);
        Handles.Label(p0, "P0");
        Handles.Label(p1, "P1");
        Handles.Label(p2, "P2");
        Handles.Label(p3, "P3");
        Handles.SphereHandleCap(0, p0, Quaternion.identity, .1f, EventType.Repaint);
        Handles.SphereHandleCap(0, p1, Quaternion.identity, .1f, EventType.Repaint);
        Handles.SphereHandleCap(0, p2, Quaternion.identity, .1f, EventType.Repaint);
        Handles.SphereHandleCap(0, p3, Quaternion.identity, .1f, EventType.Repaint);

        Gizmos.color = Color.green;
        for (int i = 0; i < 100; i++)
        {
            Vector3 curr = BezierCurveUtility.Bezier3(p0, p1, p2, p3, i / 100f);
            Vector3 next = BezierCurveUtility.Bezier3(p0, p1, p2, p3, (i + 1) / 100f);
            Gizmos.color = t > (i / 100f) ? Color.red : Color.green;
            Gizmos.DrawLine(curr, next);
        }
        Vector3 pt = BezierCurveUtility.Bezier3(p0, p1, p2, p3, t);
        Handles.Label(pt, string.Format("Pt (t = {0})", t));
        Handles.SphereHandleCap(0, pt, Quaternion.identity, .1f, EventType.Repaint);
    }
#endif
}

應(yīng)用

常見的如道路編輯、河流編輯功能都可以通過貝塞爾曲線實(shí)現(xiàn):

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

本文以一個(gè)簡單的路徑編輯為例,通過使用三階貝塞爾曲線實(shí)現(xiàn)路徑的編輯:

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

Bezier Curve

  • segments:貝塞爾曲線的段數(shù),值越大曲線精度越高;
  • loop:是否循環(huán)(首尾相連);
  • points :點(diǎn)集合(結(jié)構(gòu)體中包含坐標(biāo)點(diǎn)和控制點(diǎn));
using System;
using UnityEngine;
using System.Collections.Generic;

namespace SK.Framework
{
    /// <summary>
    /// 貝塞爾曲線
    /// </summary>
    [Serializable]
    public class BezierCurve
    {
        /// <summary>
        /// 段數(shù)
        /// </summary>
        [Range(1, 100)] public int segments = 10;

        /// <summary>
        /// 是否循環(huán)
        /// </summary>
        public bool loop;

        /// <summary>
        /// 點(diǎn)集合
        /// </summary>
        public List<BezierCurvePoint> points = new List<BezierCurvePoint>(2)
        {
            new BezierCurvePoint() { position = Vector3.back * 5f, tangent = Vector3.back * 5f + Vector3.left * 3f },
            new BezierCurvePoint() { position = Vector3.forward * 5f, tangent = Vector3.forward * 5f + Vector3.right * 3f }
        };

        /// <summary>
        /// 根據(jù)歸一化位置值獲取對應(yīng)的貝塞爾曲線上的點(diǎn)
        /// </summary>
        /// <param name="t">歸一化位置值 [0,1]</param>
        /// <returns></returns>
        public Vector3 EvaluatePosition(float t)
        {
            Vector3 retVal = Vector3.zero;
            if (points.Count > 0)
            {
                float max = points.Count - 1 < 1 ? 0 : (loop ? points.Count : points.Count - 1);
                float standardized = (loop && max > 0) ? ((t %= max) + (t < 0 ? max : 0)) : Mathf.Clamp(t, 0, max);
                int rounded = Mathf.RoundToInt(standardized);
                int i1, i2;
                if (Mathf.Abs(standardized - rounded) < Mathf.Epsilon)
                    i1 = i2 = (rounded == points.Count) ? 0 : rounded;
                else
                {
                    i1 = Mathf.FloorToInt(standardized);
                    if (i1 >= points.Count)
                    {
                        standardized -= max;
                        i1 = 0;
                    }
                    i2 = Mathf.CeilToInt(standardized);
                    i2 = i2 >= points.Count ? 0 : i2;
                }
                retVal = i1 == i2 ? points[i1].position : BezierCurveUtility.Bezier3(points[i1].position,
                    points[i1].position + points[i1].tangent, points[i2].position
                    - points[i2].tangent, points[i2].position, standardized - i1);
            }
            return retVal;
        }
    }
}
using System;
using UnityEngine;

namespace SK.Framework
{
    [Serializable]
    public struct BezierCurvePoint
    {
        /// <summary>
        /// 坐標(biāo)點(diǎn)
        /// </summary>
        public Vector3 position;

        /// <summary>
        /// 控制點(diǎn) 與坐標(biāo)點(diǎn)形成切線
        /// </summary>
        public Vector3 tangent;
    }
}

SimpleBezierCurvePath

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

using UnityEngine;
using System.Collections.Generic;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace SK.Framework
{
    /// <summary>
    /// 貝塞爾曲線路徑
    /// </summary>
    public class SimpleBezierCurvePath : MonoBehaviour
    {
        [SerializeField] private BezierCurve curve;

        public bool Loop { get { return curve.loop; } }

        public List<BezierCurvePoint> Points { get { return curve.points; } }

        /// <summary>
        /// 根據(jù)歸一化位置值獲取對應(yīng)的貝塞爾曲線上的點(diǎn)
        /// </summary>
        /// <param name="t">歸一化位置值 [0,1]</param>
        /// <returns></returns>
        public Vector3 EvaluatePosition(float t)
        {
            return curve.EvaluatePosition(t);
        }

#if UNITY_EDITOR
        /// <summary>
        /// 路徑顏色(Gizmos)
        /// </summary>
        public Color pathColor = Color.green;

        private void OnDrawGizmos()
        {
            if (curve.points.Count == 0) return;
            //緩存顏色
            Color cacheColor = Gizmos.color;
            //路徑繪制顏色
            Gizmos.color = pathColor;
            //步長
            float step = 1f / curve.segments;
            //緩存上個(gè)坐標(biāo)點(diǎn)
            Vector3 lastPos = transform.TransformPoint(curve.EvaluatePosition(0f));
            float end = (curve.points.Count - 1 < 1 ? 0 : (curve.loop ? curve.points.Count : curve.points.Count - 1)) + step * .5f;
            for (float t = step; t <= end; t += step)
            {
                //計(jì)算位置
                Vector3 p = transform.TransformPoint(curve.EvaluatePosition(t));
                //繪制曲線
                Gizmos.DrawLine(lastPos, p);
                //記錄
                lastPos = p;
            }
            //恢復(fù)顏色
            Gizmos.color = cacheColor;
        }
#endif
    }

#if UNITY_EDITOR
    [CustomEditor(typeof(SimpleBezierCurvePath))]
    public class SimpleBezierCurvePathEditor : Editor
    {
        private SimpleBezierCurvePath path;
        private const float sphereHandleCapSize = .2f;

        private void OnEnable()
        {
            path = target as SimpleBezierCurvePath;
        }

        private void OnSceneGUI()
        {
            //路徑點(diǎn)集合為空
            if (path.Points == null || path.Points.Count == 0) return;
            //當(dāng)前選中工具非移動(dòng)工具
            if (Tools.current != Tool.Move) return;
            //顏色緩存
            Color cacheColor = Handles.color;
            Handles.color = Color.yellow;
            //遍歷路徑點(diǎn)集合
            for (int i = 0; i < path.Points.Count; i++)
            {
                DrawPositionHandle(i);
                DrawTangentHandle(i);

                BezierCurvePoint point = path.Points[i];
                //局部轉(zhuǎn)全局坐標(biāo) 路徑點(diǎn)、控制點(diǎn) 
                Vector3 position = path.transform.TransformPoint(point.position);
                Vector3 controlPoint = path.transform.TransformPoint(point.tangent);
                //繪制切線
                Handles.DrawDottedLine(position, controlPoint + position, 1f);
            }
            //恢復(fù)顏色
            Handles.color = cacheColor;
        }

        //路徑點(diǎn)操作柄繪制
        private void DrawPositionHandle(int index)
        {
            BezierCurvePoint point = path.Points[index];
            //局部轉(zhuǎn)全局坐標(biāo)
            Vector3 position = path.transform.TransformPoint(point.position);
            //操作柄的旋轉(zhuǎn)類型
            Quaternion rotation = Tools.pivotRotation == PivotRotation.Local
                ? path.transform.rotation : Quaternion.identity;
            //操作柄的大小
            float size = HandleUtility.GetHandleSize(position) * sphereHandleCapSize;
            //在該路徑點(diǎn)繪制一個(gè)球形
            Handles.color = Color.white;
            Handles.SphereHandleCap(0, position, rotation, size, EventType.Repaint);
            Handles.Label(position, string.Format("Point{0}", index));
            //檢測變更
            EditorGUI.BeginChangeCheck();
            //坐標(biāo)操作柄
            position = Handles.PositionHandle(position, rotation);
            //變更檢測結(jié)束 如果發(fā)生變更 更新路徑點(diǎn)
            if (EditorGUI.EndChangeCheck())
            {
                //記錄操作
                Undo.RecordObject(path, "Position Changed");
                //全局轉(zhuǎn)局部坐標(biāo)
                point.position = path.transform.InverseTransformPoint(position);
                //更新路徑點(diǎn)
                path.Points[index] = point;
            }
        }

        //控制點(diǎn)操作柄繪制
        private void DrawTangentHandle(int index)
        {
            BezierCurvePoint point = path.Points[index];
            //局部轉(zhuǎn)全局坐標(biāo)
            Vector3 cp = path.transform.TransformPoint(point.position + point.tangent);
            //操作柄的旋轉(zhuǎn)類型
            Quaternion rotation = Tools.pivotRotation == PivotRotation.Local
                ? path.transform.rotation : Quaternion.identity;
            //操作柄的大小
            float size = HandleUtility.GetHandleSize(cp) * sphereHandleCapSize;
            //在該控制點(diǎn)繪制一個(gè)球形
            Handles.color = Color.yellow;
            Handles.SphereHandleCap(0, cp, rotation, size, EventType.Repaint);
            //檢測變更
            EditorGUI.BeginChangeCheck();
            //坐標(biāo)操作柄
            cp = Handles.PositionHandle(cp, rotation);
            //變更檢測結(jié)束 如果發(fā)生變更 更新路徑點(diǎn)
            if (EditorGUI.EndChangeCheck())
            {
                //記錄操作
                Undo.RecordObject(path, "Control Point Changed");
                //全局轉(zhuǎn)局部坐標(biāo)
                point.tangent = path.transform.InverseTransformPoint(cp) - point.position;
                //更新路徑點(diǎn)
                path.Points[index] = point;
            }
        }
    }
#endif
}

SimpleBezierCurvePathAlonger

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

  • path:貝塞爾曲線路徑;
  • speed:移動(dòng)速度;
  • update Mode:更新方式(FixedUpdate、Update、LateUpdate)
using UnityEngine;

namespace SK.Framework
{
    public class SimpleBezierCurvePathAlonger : MonoBehaviour
    {
        public enum UpdateMode
        {
            FixedUpdate,
            Update,
            LateUpdate,
        }

        [SerializeField] private SimpleBezierCurvePath path;

        [SerializeField] private float speed = .1f;

        [SerializeField] private UpdateMode updateMode = UpdateMode.Update;

        private float normalized = 0f;

        private Vector3 lastPosition;

        private void FixedUpdate()
        {
            if (updateMode == UpdateMode.FixedUpdate && path != null)
                MoveAlongPath();
        }

        private void Update()
        {
            if (updateMode == UpdateMode.Update && path != null)
                MoveAlongPath();
        }

        private void LateUpdate()
        {
            if (updateMode == UpdateMode.LateUpdate && path != null)
                MoveAlongPath();
        }

        private void MoveAlongPath()
        {
            float t = normalized + speed * Time.deltaTime;
            float max = path.Points.Count - 1 < 1 ? 0 : (path.Loop ? path.Points.Count : path.Points.Count - 1);
            normalized = (path.Loop && max > 0) ? ((t %= max) + (t < 0 ? max : 0)) : Mathf.Clamp(t, 0, max);
            transform.position = path.EvaluatePosition(normalized);
            Vector3 forward = transform.position - lastPosition;
            transform.forward = forward != Vector3.zero ? forward : transform.forward;
            lastPosition = transform.position;
        }
    }
}

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

源碼已上傳至SKFramework框架Package Manager中:

unity 貝塞爾曲線編輯器,Unity 開發(fā)日志,Unity Editor,Unity,貝塞爾曲線,路徑編輯,動(dòng)畫

參考鏈接:文章來源地址http://www.zghlxwxcb.cn/news/detail-818242.html

  1. 貝塞爾曲線 - 百度百科
  2. Unity Cinemachine Path
  3. Unity 貝塞爾曲線(Beizer curve)的原理與運(yùn)用

到了這里,關(guān)于Bezier Curve 貝塞爾曲線 - 在Unity中實(shí)現(xiàn)路徑編輯的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • unity 曲線可視化圖表制作(lineRenderer + 貝塞爾曲線)

    unity 曲線可視化圖表制作(lineRenderer + 貝塞爾曲線)

    需求要實(shí)現(xiàn)一個(gè)動(dòng)態(tài)變化的曲線 思路: 分為兩部分:畫線和平滑曲線 首先解決畫線問題: 1.lineRenderer 2.texture的setpixel 肯定選已經(jīng)做好的輪子1啦 平滑曲線思路: 1.拋物線 2.貝塞爾曲線 拋物線做連續(xù)的曲線太抽象了 肯定選貝塞爾曲線 先了解一下貝塞爾曲線 一次貝塞爾 對應(yīng)

    2023年04月08日
    瀏覽(26)
  • Unity ——使用貝塞爾曲線對三維管狀物體進(jìn)行彎曲

    Unity ——使用貝塞爾曲線對三維管狀物體進(jìn)行彎曲

    參考鏈接:【Unity】彈性魚竿簡單實(shí)現(xiàn)-通過貝塞爾曲線修改Mesh - 簡書 參考論文:吳曉亮, 黃襄念. Unity 中使用貝塞爾曲線對三維物體進(jìn)行彎曲[J]. 現(xiàn)代計(jì)算機(jī), 2016 (5): 57-59. unity項(xiàng)目下載:https://download.csdn.net/download/weixin_43042683/87690343 效果圖 隨著虛擬現(xiàn)實(shí)的發(fā)展,在游戲引擎中

    2024年02月11日
    瀏覽(46)
  • 【游戲開發(fā)實(shí)戰(zhàn)】Unity實(shí)現(xiàn)類似GitHub地球射線的效果(LineRenderer | 貝塞爾曲線)

    【游戲開發(fā)實(shí)戰(zhàn)】Unity實(shí)現(xiàn)類似GitHub地球射線的效果(LineRenderer | 貝塞爾曲線)

    一、前言 嗨,大家伙,我是新發(fā)。 好久不見,這是2022年第一篇博客,今天有同學(xué)私信我,問我在 Unity 中如何實(shí)現(xiàn)這種地球輻射線的效果, 這一看,我就想到了 GitHub 主頁的地球射線, 那么,今天就來講講如何實(shí)現(xiàn)這個(gè)效果吧~ 本文最終效果如下: 本文工程源碼見文章末尾

    2024年02月06日
    瀏覽(30)
  • 【unity小技巧】使用貝塞爾曲線實(shí)現(xiàn)導(dǎo)彈隨機(jī)攻擊敵人,也可以用于平滑拾取物品

    參考原視頻鏈接: 【視頻】:https://www.bilibili.com/video/BV1aU4y1v7yM/ 注意 :本文為學(xué)習(xí)筆記記錄,推薦支持原作者,去看原視頻自己手敲代碼理解更加深入

    2024年02月13日
    瀏覽(25)
  • Unity實(shí)現(xiàn)殺戮尖塔出牌效果( 三. 貝塞爾曲線引導(dǎo)箭頭繪制,卡牌使用效果制作)

    Unity實(shí)現(xiàn)殺戮尖塔出牌效果( 三. 貝塞爾曲線引導(dǎo)箭頭繪制,卡牌使用效果制作)

    1. 攻擊類型卡牌 ①拖拽超過一定高度之后卡牌會(huì)移動(dòng)到手牌中心位置 ②出現(xiàn)攻擊引導(dǎo)箭頭 (塞貝爾曲線) ③成功指向目標(biāo)怪物后打出 2. 技能能力類型卡牌 ①可自由拖動(dòng) ②脫離手牌高度后打出 這里只展示此效果核心代碼內(nèi)容,重復(fù)代碼不做贅述,上期(二.鼠標(biāo)指向卡牌時(shí),

    2024年04月12日
    瀏覽(139)
  • 二階貝塞爾曲線生成弧線

    二階貝塞爾曲線生成弧線

    本文分享一個(gè)二階貝塞爾曲線曲線生成弧線的算法。 示例使用openlayers實(shí)現(xiàn)。

    2024年01月22日
    瀏覽(23)
  • 【LVGL筆記】-- 貝塞爾曲線繪制

    【LVGL筆記】-- 貝塞爾曲線繪制

    什么是貝塞爾曲線 貝塞爾曲線 (Bézier Curve,也被稱為貝塞爾多項(xiàng)式(Bézier Polynomial),是由一系列控制點(diǎn)(Control Point)所定義的一條平滑曲線。 Pierre Bézier 于1960年開始利用該曲線設(shè)計(jì)雷諾的車身線條,故命名為貝塞爾曲線。目前,貝塞爾曲線被廣泛應(yīng)用于圖形設(shè)計(jì)、路徑

    2024年02月02日
    瀏覽(27)
  • c++計(jì)算貝塞爾曲線(折線平滑為曲線)坐標(biāo)方法

    效果可查看上一篇博文: js手動(dòng)畫平滑曲線,貝塞爾曲線擬合 【代碼】js手動(dòng)畫平滑曲線,貝塞爾曲線擬合。 https://blog.csdn.net/qiufeng_xinqing/article/details/131711963?spm=1001.2014.3001.5502 代碼如下:

    2024年02月16日
    瀏覽(25)
  • CSS動(dòng)畫中的貝塞爾曲線

    CSS動(dòng)畫中的貝塞爾曲線

    最近在學(xué)習(xí)CSS動(dòng)畫,其中動(dòng)畫時(shí)間函數(shù)的部分涉及到了 貝塞爾曲線 的相關(guān)知識。對于這部分知識,之前一直沒有好好學(xué)習(xí)過,正好借著這個(gè)機(jī)會(huì)學(xué)習(xí)下。 首先簡單介紹下貝塞爾曲線。 貝塞爾曲線(Bézier curve),又稱貝茲曲線或貝濟(jì)埃曲線,是應(yīng)用于二維圖形應(yīng)用程序的數(shù)學(xué)曲

    2024年02月09日
    瀏覽(27)
  • 徹底搞懂貝塞爾曲線的原理

    徹底搞懂貝塞爾曲線的原理

    貝塞爾曲線介紹 我們在前面講了繪制自定義曲線,而實(shí)際開發(fā)過程還會(huì)遇到更復(fù)雜的圖形繪制,比如下面的這些圖形: 這時(shí)候就需要用到貝塞爾曲線了。下面是百科關(guān)于貝塞爾曲線的介紹。 貝塞爾曲線就是這樣的一條曲線,它是依據(jù)四個(gè)位置任意的點(diǎn)坐標(biāo)繪制出的一條光滑

    2024年02月20日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包