Ejemplo n.º 1
0
        void ValidateLattice()
        {
            m_s = Mathf.Clamp(m_s, 2, 32);
            m_t = Mathf.Clamp(m_t, 2, 32);
            m_u = Mathf.Clamp(m_u, 2, 32);

            int numPoints = m_s * m_t * m_u;

            if (m_points == null || m_points.Length != numPoints)
            {
                m_points = new Vector3[numPoints];

                var size = GetComponent <Transform>().localScale;

                for (int z = 0; z < m_u; ++z)
                {
                    for (int y = 0; y < m_t; ++y)
                    {
                        for (int x = 0; x < m_s; ++x)
                        {
                        }
                    }
                }

                FFDAPI.SafeDispose(ref m_pinnedPoints);
                m_pinnedPoints = new PinnedList <Vector3>(m_points);
            }
        }
Ejemplo n.º 2
0
Archivo: FFDAPI.cs Proyecto: PcloD/FFD
 // utrils
 public static void SafeDispose <T>(ref PinnedList <T> v) where T : struct
 {
     if (v != null)
     {
         v.Dispose();
         v = null;
     }
 }
Ejemplo n.º 3
0
        bool SetupLatticeWeights()
        {
            FFDAPI.SafeDispose(ref m_weights);
            m_weights = new PinnedList <FFDAPI.ffdWeights8>(m_pointsBase.Count);

            FFDAPI.ffdLatticeData        lattice = default(FFDAPI.ffdLatticeData);
            FFDAPI.ffdLatticeWeightsData weights = default(FFDAPI.ffdLatticeWeightsData);
            m_lattice.GetLatticeData(ref lattice);
            weights.weights      = m_weights;
            weights.num_vertices = m_weights.Count;
            FFDAPI.ffdLatticeSetup(ref lattice, ref weights, m_points);
            return(true);
        }
Ejemplo n.º 4
0
        bool SetupMeshData()
        {
            var tmesh = GetTargetMesh();

            if (tmesh == null)
            {
                Debug.LogWarning("Target mesh is null.");
                return(false);
            }
            else if (!tmesh.isReadable)
            {
                Debug.LogWarning("Target mesh is not readable.");
                return(false);
            }

            var smr = GetComponent <SkinnedMeshRenderer>();

            if (smr != null && smr.bones.Length > 0)
            {
                m_skinned = true;
            }

            m_baseMesh = tmesh;
            m_editMesh = Instantiate(m_baseMesh);
            SetTargetMesh(m_editMesh);

            // allocate vertex buffers
            ReleaseResources();
            m_pointsBase   = new PinnedList <Vector3>(m_baseMesh.vertices);
            m_normalsBase  = new PinnedList <Vector3>(m_baseMesh.normals);
            m_tangentsBase = new PinnedList <Vector4>(m_baseMesh.tangents);
            m_points       = m_pointsBase;
            m_normals      = m_normalsBase;
            m_tangents     = m_tangentsBase;

            return(true);
        }