コード例 #1
0
        // No config overrides on AlembicPoints

        public override void AbcSampleUpdated(AbcAPI.aiSample sample, bool topologyChanged)
        {
            if (m_abcPositions == null)
            {
                AbcAPI.aiPointsGetSummary(m_abcSchema, ref m_summary);
                m_abcPositions = new Vector3[m_summary.peakCount];
                m_abcIDs       = new ulong[m_summary.peakCount];

                m_abcData.positions = Marshal.UnsafeAddrOfPinnedArrayElement(m_abcPositions, 0);
                m_abcData.ids       = Marshal.UnsafeAddrOfPinnedArrayElement(m_abcIDs, 0);
            }

            AbcAPI.aiPointsCopyData(sample, ref m_abcData);
            AbcDirty();
        }
コード例 #2
0
ファイル: AlembicMesh.cs プロジェクト: bachlis/Kinect2Viz
        public override void AbcSampleUpdated(AbcAPI.aiSample sample, bool topologyChanged)
        {
            AlembicMaterial abcMaterials = m_trans.GetComponent <AlembicMaterial>();

            if (abcMaterials != null)
            {
                if (abcMaterials.HasFacesetsChanged())
                {
                    AbcVerboseLog("AlembicMesh.AbcSampleUpdated: Facesets updated, force topology update");
                    topologyChanged = true;
                }

                hasFacesets = (abcMaterials.GetFacesetsCount() > 0);
            }
            else if (hasFacesets)
            {
                AbcVerboseLog("AlembicMesh.AbcSampleUpdated: Facesets cleared, force topology update");
                topologyChanged = true;
                hasFacesets     = false;
            }

            if (m_freshSetup)
            {
                topologyChanged = true;

                m_freshSetup = false;
            }

            AbcAPI.aiPolyMeshGetSampleSummary(sample, ref m_sampleSummary, topologyChanged);

            AbcAPI.aiPolyMeshData vertexData = default(AbcAPI.aiPolyMeshData);

            UpdateSplits(m_sampleSummary.splitCount);

            for (int s = 0; s < m_sampleSummary.splitCount; ++s)
            {
                Split split = m_splits[s];

                split.clear  = topologyChanged;
                split.active = true;

                int vertexCount = AbcAPI.aiPolyMeshGetVertexBufferLength(sample, s);

                Array.Resize(ref split.positionCache, vertexCount);
                vertexData.positions = GetArrayPtr(split.positionCache);

                if (m_sampleSummary.hasNormals)
                {
                    Array.Resize(ref split.normalCache, vertexCount);
                    vertexData.normals = GetArrayPtr(split.normalCache);
                }
                else
                {
                    Array.Resize(ref split.normalCache, 0);
                    vertexData.normals = IntPtr.Zero;
                }

                if (m_sampleSummary.hasUVs)
                {
                    Array.Resize(ref split.uvCache, vertexCount);
                    vertexData.uvs = GetArrayPtr(split.uvCache);
                }
                else
                {
                    Array.Resize(ref split.uvCache, 0);
                    vertexData.uvs = IntPtr.Zero;
                }

                if (m_sampleSummary.hasTangents)
                {
                    Array.Resize(ref split.tangentCache, vertexCount);
                    vertexData.tangents = GetArrayPtr(split.tangentCache);
                }
                else
                {
                    Array.Resize(ref split.tangentCache, 0);
                    vertexData.tangents = IntPtr.Zero;
                }

                AbcAPI.aiPolyMeshFillVertexBuffer(sample, s, ref vertexData);

                split.center = vertexData.center;
                split.size   = vertexData.size;
            }

            if (topologyChanged)
            {
                AbcAPI.aiFacesets       facesets       = default(AbcAPI.aiFacesets);
                AbcAPI.aiSubmeshSummary submeshSummary = default(AbcAPI.aiSubmeshSummary);
                AbcAPI.aiSubmeshData    submeshData    = default(AbcAPI.aiSubmeshData);

                if (abcMaterials != null)
                {
                    abcMaterials.GetFacesets(ref facesets);
                }

                int numSubmeshes = AbcAPI.aiPolyMeshPrepareSubmeshes(sample, ref facesets);

                if (m_submeshes.Count > numSubmeshes)
                {
                    m_submeshes.RemoveRange(numSubmeshes, m_submeshes.Count - numSubmeshes);
                }

                for (int s = 0; s < m_sampleSummary.splitCount; ++s)
                {
                    m_splits[s].submeshCount = AbcAPI.aiPolyMeshGetSplitSubmeshCount(sample, s);
                }

                while (AbcAPI.aiPolyMeshGetNextSubmesh(sample, ref submeshSummary))
                {
                    if (submeshSummary.splitIndex >= m_splits.Count)
                    {
                        Debug.Log("Invalid split index");
                        continue;
                    }

                    Submesh submesh = null;

                    if (submeshSummary.index < m_submeshes.Count)
                    {
                        submesh = m_submeshes[submeshSummary.index];
                    }
                    else
                    {
                        submesh = new Submesh
                        {
                            indexCache   = new int[0],
                            facesetIndex = -1,
                            splitIndex   = -1,
                            index        = -1,
                            update       = true
                        };

                        m_submeshes.Add(submesh);
                    }

                    submesh.facesetIndex = submeshSummary.facesetIndex;
                    submesh.splitIndex   = submeshSummary.splitIndex;
                    submesh.index        = submeshSummary.splitSubmeshIndex;
                    submesh.update       = true;

                    Array.Resize(ref submesh.indexCache, 3 * submeshSummary.triangleCount);

                    submeshData.indices = GetArrayPtr(submesh.indexCache);

                    AbcAPI.aiPolyMeshFillSubmeshIndices(sample, ref submeshSummary, ref submeshData);
                }

                if (abcMaterials != null)
                {
                    abcMaterials.AknowledgeFacesetsChanges();
                }
            }
            else
            {
                for (int i = 0; i < m_submeshes.Count; ++i)
                {
                    m_submeshes[i].update = false;
                }
            }

            AbcDirty();
        }
コード例 #3
0
        // No config overrides on AlembicXForm

        public override void AbcSampleUpdated(AbcAPI.aiSample sample, bool topologyChanged)
        {
            AbcAPI.aiXFormGetData(sample, ref m_abcData);

            AbcDirty();
        }
コード例 #4
0
ファイル: AlembicLight.cs プロジェクト: bachlis/Kinect2Viz
        // No config override

        public override void AbcSampleUpdated(AbcAPI.aiSample sample, bool topologyChanged)
        {
            // ToDo
        }
コード例 #5
0
        static void SampleCallback(IntPtr __this, AbcAPI.aiSample sample, bool topologyChanged)
        {
            var _this = GCHandle.FromIntPtr(__this).Target as AlembicElement;

            _this.AbcSampleUpdated(sample, topologyChanged);
        }
コード例 #6
0
 // Called by loading thread (not necessarily the main thread)
 public abstract void AbcSampleUpdated(AbcAPI.aiSample sample, bool topologyChanged);