JBooth.VertexPainterPro.PaintJob.GetPosition C# (CSharp) Method

GetPosition() public method

public GetPosition ( int i ) : Vector3
i int
return UnityEngine.Vector3
        public Vector3 GetPosition(int i)
        {
            if (stream.positions != null && stream.positions.Length == verts.Length)
            return stream.positions[i];
             return verts[i];
        }

Usage Example

Example #1
0
        void LerpFunc(PaintJob j, int idx, ref object val, float r)
        {
            if (didHit && j.stream.gameObject != target && target != null)
            {
                // convert from world space to local space
                Vector3 norm = j.stream.GetSafeNormal(idx);
                Vector4 tang = j.stream.GetSafeTangent(idx);

                var mtx = j.stream.transform.worldToLocalMatrix;
                var t   = tangent;
                t   = mtx.MultiplyVector(tangent);
                t.w = tangent.w;

                j.stream.normals[idx]  = Vector3.Lerp(norm, mtx.MultiplyVector(norm), r);
                j.stream.tangents[idx] = Vector4.Lerp(tang, t, r);
            }
            if (didHit && terrainTarget != null)
            {
                // retrieve our brush data and get the stream we're painting into

                Vector3 n = j.stream.normals[idx];
                Vector4 t = j.stream.tangents[idx];

                Vector3 pos = j.GetPosition(idx);

                Vector3 iNormal = terrainTarget.terrainData.GetInterpolatedNormal(pos.x, pos.z);
                iNormal = j.stream.transform.InverseTransformDirection(iNormal);

                j.stream.normals[idx] = Vector3.Lerp(n, iNormal, r);
                Vector3 tangentXYZ = Vector3.Cross(j.stream.normals[idx], new Vector3(0, 0, 1));
                Vector4 tangent    = new Vector4(tangentXYZ.x, tangentXYZ.y, tangentXYZ.z, -1);

                j.stream.tangents[idx] = Vector4.Lerp(t, tangent, r);
            }
        }
All Usage Examples Of JBooth.VertexPainterPro.PaintJob::GetPosition