Esempio n. 1
0
        public virtual PosOri GetInterpPoint(float t)
        {
            var length = Length();
            var tgtPos = t * length;

            IndexOf(tgtPos, out int index, out float distance);

            Vector3 point = Vector3.zero;
            Vector3 dir   = Vector3.up;

            if (index < MaxIndex)
            {
                point = mVerts[index];
                dir   = mVerts[index + 1] - point;
            }

            if (index == MaxIndex)
            {
                point = mVerts[MaxIndex];
                dir   = point - mVerts[MaxIndex - 1];
            }

            dir = dir.normalized;
            var overShoot = tgtPos - distance;

            var    quat   = GetDir(index);
            var    pos    = point + overShoot * dir;
            PosOri posOri = new PosOri(pos, quat);

            return(posOri);
        }
Esempio n. 2
0
        virtual public Vector3[] GetNormals(PosOri posOri, bool faceted)
        {
            if (faceted)
            {
                var facetedNormals = new Vector3[2 * mVerts.Count];
                for (int currentIndex = 0; currentIndex < 2 * mVerts.Count; currentIndex += 2)
                {
                    var nextIndex = (currentIndex + 1) % mVerts.Count;
                    facetedNormals[currentIndex]     = GetNormal(currentIndex - 1, currentIndex, posOri.orientation);
                    facetedNormals[currentIndex + 1] = GetNormal(currentIndex, nextIndex, posOri.orientation);
                }
            }

            var normals = new Vector3[mVerts.Count];

            for (int currentIndex = 0; currentIndex < mVerts.Count; currentIndex++)
            {
                var nextIndex = (currentIndex + 1) % mVerts.Count;
                normals[currentIndex] = GetNormal(currentIndex, nextIndex, posOri.orientation);
            }

            return(normals);
        }
Esempio n. 3
0
        public Vector3[] GetVerts(PosOri posOri, bool faceted)
        {
            if (faceted)
            {
                var facetedVerts = new Vector3[2 * mVerts.Count];
                for (int i = 0, j = 0; i < mVerts.Count; i++, j += 2)
                {
                    facetedVerts[j]     = posOri.position + posOri.orientation * mVerts[i];
                    facetedVerts[j + 1] = posOri.position + posOri.orientation * mVerts[i];
                }

                return(facetedVerts);
            }

            var verts = new Vector3[mVerts.Count];

            for (var i = 0; i < mVerts.Count; i++)
            {
                verts[i] = posOri.position + posOri.orientation * mVerts[i];
            }

            return(verts);
        }