void ConvertXform(UsdXform xf, string path)
        {
            if (xf == null)
            {
                return;
            }

            var ttrans = typeof(Transform);
            var cvs    = new CurveData[] {
                new CurveData(ttrans, path, "m_LocalPosition.x", m_epsilon_Position),
                new CurveData(ttrans, path, "m_LocalPosition.y", m_epsilon_Position),
                new CurveData(ttrans, path, "m_LocalPosition.z", m_epsilon_Position),
                new CurveData(ttrans, path, "m_LocalRotation.x", m_epsilon_Rotation),
                new CurveData(ttrans, path, "m_LocalRotation.y", m_epsilon_Rotation),
                new CurveData(ttrans, path, "m_LocalRotation.z", m_epsilon_Rotation),
                new CurveData(ttrans, path, "m_LocalRotation.w", m_epsilon_Rotation),
                new CurveData(ttrans, path, "m_LocalScale.x", m_epsilon_Scale),
                new CurveData(ttrans, path, "m_LocalScale.y", m_epsilon_Scale),
                new CurveData(ttrans, path, "m_LocalScale.z", m_epsilon_Scale),
            };

            usdi.usdiXformEachSample(xf.nativeXformPtr, (ref usdi.XformData data, double t_) => {
                float t = (float)t_ * m_rcpTimeScale;
                if (data.flags.updatedPosition)
                {
                    cvs[0].curve.AddKey(t, data.position.x);
                    cvs[1].curve.AddKey(t, data.position.y);
                    cvs[2].curve.AddKey(t, data.position.z);
                }
                if (data.flags.updatedRotation)
                {
                    cvs[3].curve.AddKey(t, data.rotation.x);
                    cvs[4].curve.AddKey(t, data.rotation.y);
                    cvs[5].curve.AddKey(t, data.rotation.z);
                    cvs[6].curve.AddKey(t, data.rotation.w);
                }
                if (data.flags.updatedScale)
                {
                    cvs[7].curve.AddKey(t, data.scale.x);
                    cvs[8].curve.AddKey(t, data.scale.y);
                    cvs[9].curve.AddKey(t, data.scale.z);
                }
            });

            if (m_keyframeReduction)
            {
                foreach (var c in cvs)
                {
                    DoReduction(c);
                }
            }
            foreach (var c in cvs)
            {
                c.Set(m_animClip);
            }
        }
Exemple #2
0
        UsdSchema usdiCreateNode(usdi.Schema schema)
        {
            UsdSchema ret = null;

            if (ret == null)
            {
                var s = usdi.usdiAsPoints(schema);
                if (s)
                {
                    ret = new UsdPoints();
                }
            }
            if (ret == null)
            {
                var s = usdi.usdiAsMesh(schema);
                if (s)
                {
                    ret = new UsdMesh();
                }
            }
            if (ret == null)
            {
                var s = usdi.usdiAsCamera(schema);
                if (s)
                {
                    ret = new UsdCamera();
                }
            }
            if (ret == null)
            {
                // Xform must be latter because some schemas are subclass of Xform
                var s = usdi.usdiAsXform(schema);
                if (s)
                {
                    ret = new UsdXform();
                }
            }
            if (ret == null)
            {
                ret = new UsdSchema();
            }
            ret.nativeSchemaPtr = schema;
            ret.stream          = this;
            return(ret);
        }