コード例 #1
0
 public static void CaptureMesh(usdi.Mesh usd, ref usdi.MeshData data, MeshBuffer dst_buf)
 {
     data = usdi.MeshData.default_value;
     if (dst_buf.vertices != null)
     {
         data.points     = usdi.GetArrayPtr(dst_buf.vertices);
         data.num_points = dst_buf.vertices.Length;
     }
     if (dst_buf.indices != null)
     {
         data.indices     = usdi.GetArrayPtr(dst_buf.indices);
         data.num_indices = dst_buf.indices.Length;
     }
     if (dst_buf.normals != null)
     {
         data.normals = usdi.GetArrayPtr(dst_buf.normals);
     }
     if (dst_buf.tangents != null)
     {
         data.tangents = usdi.GetArrayPtr(dst_buf.tangents);
     }
     if (dst_buf.uvs != null)
     {
         data.uvs = usdi.GetArrayPtr(dst_buf.uvs);
     }
     if (dst_buf.weights != null && dst_buf.bones != null)
     {
         data.weights          = usdi.GetArrayPtr(dst_buf.weights);
         data.bindposes        = usdi.GetArrayPtr(dst_buf.bindposes);
         data.num_bones        = dst_buf.bones.Length;
         data.max_bone_weights = 4;
         usdi.usdiMeshAssignBones(usd, ref data, dst_buf.bones, dst_buf.bones.Length);
         usdi.usdiMeshAssignRootBone(usd, ref data, dst_buf.rootBone);
     }
 }
コード例 #2
0
 public static void CaptureMesh(
     usdi.Mesh usd, ref usdi.MeshData data, MeshBuffer buf,
     Mesh mesh, MeshCaptureFlags flags)
 {
     buf.vertices = flags.points ? mesh.vertices : null;
     buf.normals  = flags.normals ? mesh.normals : null;
     buf.tangents = flags.tangents ? mesh.tangents : null;
     buf.indices  = flags.indices ? mesh.triangles : null;
     buf.uvs      = flags.uvs ? mesh.uv : null;
     CaptureMesh(usd, ref data, buf);
 }
コード例 #3
0
        public override void usdiOnUnload()
        {
            base.usdiOnUnload();

            if (m_asyncRead != null)
            {
                m_asyncRead.Wait();
                m_asyncRead = null;
            }

            m_mesh = default(usdi.Mesh);
            m_buf.Clear();
        }
コード例 #4
0
        public static void CaptureMesh(
            usdi.Mesh usd, ref usdi.MeshData data, MeshBuffer buf,
            SkinnedMeshRenderer smr, MeshCaptureFlags flags, bool captureBones)
        {
            Cloth cloth = smr.GetComponent <Cloth>();

            if (cloth != null)
            {
                var mesh = buf.bakedMesh;
                smr.BakeMesh(mesh);

                buf.vertices = flags.points ? cloth.vertices : null;
                buf.normals  = flags.normals ? cloth.normals : null;
                buf.tangents = flags.tangents ? mesh.tangents : null;
                buf.indices  = flags.indices ? mesh.triangles : null;
                buf.uvs      = flags.uvs ? mesh.uv : null;
            }
            else if (captureBones && buf.bones != null)
            {
                var mesh = smr.sharedMesh;

                buf.vertices = flags.points ? mesh.vertices : null;
                buf.normals  = flags.normals ? mesh.normals : null;
                buf.tangents = flags.tangents ? mesh.tangents : null;
                buf.indices  = flags.indices ? mesh.triangles : null;
                buf.uvs      = flags.uvs ? mesh.uv : null;

                buf.weights   = mesh.boneWeights;
                buf.bindposes = mesh.bindposes;
            }
            else
            {
                var mesh = buf.bakedMesh;
                smr.BakeMesh(mesh);

                buf.vertices = flags.points ? mesh.vertices : null;
                buf.normals  = flags.normals ? mesh.normals : null;
                buf.tangents = flags.tangents ? mesh.tangents : null;
                buf.indices  = flags.indices ? mesh.triangles : null;
                buf.uvs      = flags.uvs ? mesh.uv : null;
            }

            CaptureMesh(usd, ref data, buf);
        }
コード例 #5
0
        public override void usdiOnLoad()
        {
            base.usdiOnLoad();

            m_mesh = usdi.usdiAsMesh(m_schema);
            usdi.usdiMeshGetSummary(m_mesh, ref m_meshSummary);
            if (m_submeshes.Count == 0)
            {
                usdiAddSubmesh();
            }

            if (isInstance)
            {
            }
            else
            {
                m_allocateMeshDataRequired = true;
            }
        }
コード例 #6
0
        public override void usdiOnLoad(usdi.Schema schema)
        {
            base.usdiOnLoad(schema);

            m_mesh = usdi.usdiAsMesh(schema);
            if (!m_mesh)
            {
                Debug.LogWarning("schema is not Mesh!");
                return;
            }

            usdi.usdiMeshGetSummary(m_mesh, ref m_meshSummary);
            m_umesh           = usdiGetOrAddMeshComponents();
            m_meshVertexCount = m_umesh.vertexCount;

            m_renderer = GetComponent <MeshRenderer>();

            usdiGatherExistingSplits();
            for (int i = 0; i < m_children.Count; ++i)
            {
                m_children[i].usdiOnLoad(this, m_children.Count);
            }
        }
コード例 #7
0
        public override void usdiOnLoad()
        {
            base.usdiOnLoad();

            m_mesh = usdi.usdiAsMesh(m_schema);
            usdi.usdiMeshGetSummary(m_mesh, ref m_meshSummary);
            if (m_submeshes.Count == 0)
            {
                usdiAddSubmesh();
            }

            if (isInstance)
            {
                //
            }
            else
            {
                m_allocateMeshDataRequired = true;
                if (m_meshSummary.num_bones > 0 && m_stream.importSettings.swapHandedness)
                {
                    Debug.LogWarning("Swap Handedness import option is enabled. This may cause broken skinning animation.");
                }
            }
        }
コード例 #8
0
 override public void OnUnload()
 {
     base.OnUnload();
     m_rep       = default(usdi.Mesh);
     m_submeshes = null;
 }
コード例 #9
0
 public MeshUpdater(usdi.Mesh rep, GameObject go)
     : base(rep, go)
 {
     m_rep       = rep;
     m_submeshes = new List <Submesh>();
 }