第一次写博客  咳咳 有点紧张,马上要下班了就言简意赅的描述下今天的工作内容吧。

管线流动的效果的实现,Curvy的使用:

各种水的管道,希望能有一种方法表明水流的方向,于是打算通过Curvy来来实现这一效果,但是Curvy这个东西又没有办法拉直线,我很苦恼,哪位大神知道Curvy能拉直线么?或者其他比较不错的插件呢?主要介绍一下Curvy重合的CP,其他的不介绍了T.T

这是demo工程

这是重合的节点,重合节点处,可以通过操作参数,来使曲线物体向不同的方向走,控制这个不同的方向,就是Tags这个参数,在外部通过修改Tags这个参数来更换方向,SplineWalkerCon.cs文件中     、

void Update()
    {
        if (UpdateIn == CurvyUpdateMethod.Update)
            doUpdate();
    }

void doUpdate()
    {
        
        if (!Spline || !Spline.IsInitialized) return;
        // Runtime processing
        if (Application.isPlaying) {
            int dir = Dir;    
            // Move at a constant speed?
            if (MoveByWorldUnits) {
                // either used cached values(slightly faster) or interpolate position now (more exact)
                // Note that we pass mTF and mDir by reference. These values will be changed by the Move methods
                mTransform.position = (FastInterpolation) ?
                    Spline.MoveByConnectionFast(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches,buildTags()) : // linear interpolate cached values
                    Spline.MoveByConnection(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches, buildTags()); // interpolate now
            }
            else { // Move at constant F
                // either used cached values(slightly faster) or interpolate position now (more exact)
                // Note that we pass Spline, mTF and mDir by reference. These values will be changed by the MoveConnection methods
                mTransform.position = (FastInterpolation) ?
                    Spline.MoveConnectionFast(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches, buildTags()): // interpolate now
                    Spline.MoveConnection(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches, buildTags()); // interpolate now
                
            }
            // Rotate the transform to match the spline's orientation
            if (SetOrientation) {
                transform.rotation = Spline.GetOrientationFast(mTF);
            }
            
            Dir = dir;
        }
        else // Editor processing: continuously place the transform to reflect property changes in the editor
            InitPosAndRot();
    }

Spline.MoveByConnectionFast(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches,buildTags()) : // linear interpolate cached values
                    Spline.MoveByConnection(ref Spline, ref mTF, ref dir, Speed * Time.deltaTime, Clamping, MinTagMatches, buildTags()); // interpolate now

这两行代码是控制曲线上的物体移动的,调入到CurvySpline.cs之中

public Vector3 MoveConnection(ref CurvySpline spline, ref float tf, ref int direction, float fDistance, CurvyClamping clamping, int minMatchesNeeded, params string[] tags)
    {
        List<CurvyConnection> cons = GetConnectionsWithin(tf, direction, fDistance, minMatchesNeeded,true, tags);
        if (cons.Count > 0) {
            CurvyConnection con;
            if (cons.Count == 1)
                con = cons[0];
            else
                con = CurvyConnection.GetBestMatchingConnection(cons, tags);
            CurvySplineSegment cp=con.GetFromSpline(this);
            float cptf = SegmentToTF(cp);
            fDistance-= cptf-tf;
            CurvySplineSegment counterp=con.GetCounterpart(cp);
            tf = counterp.LocalFToTF(0);
            spline = counterp.Spline;
            return spline.MoveConnection(ref spline, ref tf, ref direction, fDistance, clamping, minMatchesNeeded, tags);
        }
        else
            return spline.Move(ref tf, ref direction, fDistance, clamping);
     }

接着:

public List<CurvyConnection> GetConnectionsWithin(float tf, int direction, float fDistance, int minMatchesNeeded, bool skipCurrent, params string[] tags)
    {
        List<CurvyConnection> res = new List<CurvyConnection>();
        // get Segments in the range TF => TF+f
        int fromIdx = 0;
        int toIdx = -1;
        float fdelta = fDistance * direction;
        float fromLocalF;
        float toLocalF;
        if (fdelta >= 0) {
            fromIdx = TFToSegment(tf, out fromLocalF).ControlPointIndex;
            toIdx = TFToSegment(tf + fdelta, out toLocalF).ControlPointIndex;
            if (fromLocalF > 0) // don't check a CP we already passed
                fromIdx++;
            if (toLocalF == 1)
                toIdx = Mathf.Min(ControlPointCount - 1, toIdx + 1);

if (fromIdx == toIdx && (fromLocalF == 0 && skipCurrent)) // from on CP, skip it?
                    return res;
        }
        else {
            fromIdx = TFToSegment(tf + fdelta, out fromLocalF).ControlPointIndex;
            toIdx = TFToSegment(tf, out toLocalF).ControlPointIndex;

if (fromIdx == toIdx) {
                if (fromLocalF > 0) // not reached cp yet
                    return res;
            }
            else {
                if (fromLocalF > 0)
                    fromIdx++;
                if (toLocalF == 0 && skipCurrent)
                    return res;
            }
        }

for (int idx = fromIdx; idx <= toIdx; idx++) {
            res.AddRange(this.ControlPoints[idx].GetAllConnections(minMatchesNeeded,tags));
        }
        return res;
    }

获取下一步选择节点,根据tags在外部修改的参数进行选择

public List<CurvyConnection> GetAllConnections(int minMatchesNeeded, params string[] tags)
    {
        List<CurvyConnection> res = new List<CurvyConnection>();
        CurvyConnection con = Connection;
        if (con != null && con.MatchingTags(tags).Count >= minMatchesNeeded)
            res.Add(con);
        for (int i = ConnectedBy.Count - 1; i > -1; i--)
        {

if (ConnectedBy[i].Connection != null)
            {
                if (ConnectedBy[i].Connection.Other != this)
                    ConnectedBy.RemoveAt(i);
                else
                    if (ConnectedBy[i].Connection.MatchingTags(tags).Count >= minMatchesNeeded)
                        res.Add(ConnectedBy[i].Connection);
            }
            else
                ConnectedBy.RemoveAt(i);

}
        return res;
    }

这样就得到了根据参数的下一步曲线的方向。

Unity3d 曲线Curvy插件的学习使用相关推荐

  1. Unity3D中用Vectrosity插件画直线、画点、画曲线、画方框

    Unity3D中用Vectrosity插件画直线.画点.画曲线.画方框 .Vectrosity插件是Unity3D目前发现的一个画线最好的工具插件. // Make Vector2 array; in ...

  2. curviloft插件怎么用_紫天学习星球教学:Curviloft (曲线放样) 插件完全功能讲解 (中文)...

    视频作者:TutorialsUp 视频来源:https://youtu.be/MqOzK23XUVE 中文讲解:紫天肖万涛 由 Fredo6 开发的 Curviloft (曲线放样) 插件可以非常方便 ...

  3. Unity3D 绑定机械传动 插件包

    MGS-MechanicalDrive 概述 Unity3D 绑定机械传动 插件包. 需求 制作啮合齿轮传动机构. 制作按比例速度同步传动机构. 制作蜗轮蜗杆传动机构. 制作皮带飞轮传动机构. 制作链 ...

  4. unity3d 各大插件评测

    原创文章如需转载请注明:转载自风宇冲Unity3D教程学院 引言:想用Unity3D制作优秀的游戏,插件是必不可少的.工欲善其事必先利其器.本文主旨是告诉使用Unity3D引擎的同学们如何根据需求选择 ...

  5. Unity3D 中 2D_Toolkit插件下载 和 导入方法

    Unity3D 中 2D_Toolkit插件下载 和 导入方法 1.你把下载来的包放到 安装目录:Editor\Standard Packages里面. 2.然后按ctrl+9,进入asset sto ...

  6. unity3d显示c4d材质_学习笔记分享 如何学好C4D

    我的C4D 学习宝典 固定布局                                                        工具条上设置固定宽高 背景可以设置被包含 可以完美对齐背景 ...

  7. 安卓插件化学习 - 类的加载

    安卓插件化学习 - 类的加载 引言 一.类的加载 1. 原理 2. 代码 2.1 宿主apk代码 2.1.1 插件管理器 2.1.2 配置文件 2.1.3 插件初始化 2.1.4 调用插件方法 2.2 ...

  8. Unity3D 200个插件免费分享

    插件清单:  2D_Toolkit_1.51     动画开发插件包  FingerGestures           触摸插件  ORK_Okashi_RPG_Kit       Unity3D角 ...

  9. Unity3D的uniSWF插件动态加载SWF UI资源

    uniSWF能把Flash的素材像用AS3编程类似,只不过环境要在C#或者JS中编程.要是想创建一个类似Menu菜单或者像导航一样的菜单,在Unity中首先要选择摄像机,给摄像机添加MovieClip ...

  10. pipe建模工具使用_【亲测能用】Maya曲线建模插件:Quick Pipe 1.5b下载-羽兔网

    Maya曲线建模插件Quick Pipe 1.5b是一个基于曲线建模的玛雅路径创建工具,让你快速创建简单的形状像管.管道.波纹管和更复杂的网格,如隧道.山洞.浮子.浮坡口,焊接等等.需要感兴趣的朋友可 ...

最新文章

  1. python语言代码片段-有用的Python代码片段
  2. (Alan Murta)编制的多边形集合运算软件包(general polygon clipping library,简称GPC)
  3. 【Paper】2021_Synchronization of Resilient Complex Networks Under Attacks
  4. SAP ECC 6.0有哪些增强功能
  5. LBFT跨链共识机制
  6. Python---modules(模块)
  7. 图解Android - Android GUI 系统 (2) - 窗口管理 (View, Canvas, Window Manager)
  8. PS教程第十五课:图层是最基本的要求
  9. 五个提升人生智慧的经典故事
  10. Java中static final用法小结
  11. 从头认识Spring-1.14 SpEl表达式(1)-简单介绍与嵌入值
  12. StarRocks不稳定版本(解除AVX2指令集限制)
  13. Unity3d学习之路-简单AR游戏
  14. 计算机多媒体应用技术ppt课件ppt,多媒体计算机技术原理及应用十二课件.ppt
  15. Web-AK47网络验证码攻击工具
  16. 仿hao123的导航网站纯静态版|html导航网站源码,115le仿hao123网址导航整站静态html...
  17. 基于Vue,ElementUI开发的一款表单设计器
  18. 安全操作系统的一些设计原则
  19. 《孙子初问世》--游戏策划书
  20. android 时间计划软件,时间规划管理局

热门文章

  1. AvalonDock 2.0+Caliburn.Micro+MahApps.Metro实现Metro风格插件式系统(菜单篇)
  2. DSP方案山景AP8224C2芯片可烧录适用USB声卡降噪麦克风
  3. 机顶盒ttl无法输入_请教大神,机顶盒接TTL进不了uboot模式
  4. 用图片替代cursor光标样式
  5. 红烛电子教鞭 2.5.1.0 中文绿色版
  6. Android-MeasureSpec那些事 1
  7. 完美解决IE9浏览器出现的对象未定义问题
  8. mysql数据抽取_史上最简单的数据抽取
  9. AI魔法手!用算法修复老照片
  10. 惠普计算机安转不上xp,雨林木风xp系统上安装不上惠普打印机驱动的解决办法...