示例#1
0
 private Vector3 TransformationCompDefaultValue(TransformationComp comp)
 {
     // XXX a neat way to solve the never-ending special cases for scaling
     // would be to do everything in log space!
     return comp == TransformationComp.Scaling ? new Vector3(1.0f, 1.0f, 1.0f) : new Vector3();
 }
示例#2
0
 private string NameTransformationChainNode(string name, TransformationComp comp)
 {
     return name + MAGIC_NODE_TAG + "_" + NameTransformationComp(comp);
 }
示例#3
0
 private string NameTransformationCompProperty(TransformationComp comp)
 {
     switch (comp)
     {
         case TransformationComp.Translation:
             return "Lcl Translation";
         case TransformationComp.RotationOffset:
             return "RotationOffset";
         case TransformationComp.RotationPivot:
             return "RotationPivot";
         case TransformationComp.PreRotation:
             return "PreRotation";
         case TransformationComp.Rotation:
             return "Lcl Rotation";
         case TransformationComp.PostRotation:
             return "PostRotation";
         case TransformationComp.RotationPivotInverse:
             return "RotationPivotInverse";
         case TransformationComp.ScalingOffset:
             return "ScalingOffset";
         case TransformationComp.ScalingPivot:
             return "ScalingPivot";
         case TransformationComp.Scaling:
             return "Lcl Scaling";
         case TransformationComp.ScalingPivotInverse:
             return "ScalingPivotInverse";
         case TransformationComp.GeometricScaling:
             return "GeometricScaling";
         case TransformationComp.GeometricRotation:
             return "GeometricRotation";
         case TransformationComp.GeometricTranslation:
             return "GeometricTranslation";
         default:
             break;
     }
     Debug.Assert(false);
     return null;
 }
示例#4
0
        private bool IsRedundantAnimationData(Model target, TransformationComp comp, List<AnimationCurveNode> curves)
        {
            Debug.Assert(curves.Count > 0);

            // look for animation nodes with
            //  * sub channels for all relevant components set
            //  * one key/value pair per component
            //  * combined values match up the corresponding value in the bind pose node transformation
            // only such nodes are 'redundant' for this function.

            if (curves.Count > 1)
            {
                return false;
            }

            var nd = curves[0];
            var subCurves = nd.Curves;

            AnimationCurve dx;
            AnimationCurve dy;
            AnimationCurve dz;

            subCurves.TryGetValue("d|X", out dx);
            subCurves.TryGetValue("d|Y", out dy);
            subCurves.TryGetValue("d|Z", out dz);

            if (dx == null || dy == null || dz == null)
            {
                return false;
            }

            var vx = dx.Values;
            var vy = dy.Values;
            var vz = dz.Values;

            if (vx.Count != 1 || vy.Count != 1 || vz.Count != 1)
            {
                return false;
            }

            var dynVal = new Vector3(vx[0], vy[0], vz[0]);
            var staticVal = PropertyHelper.PropertyGet<Vector3>(target.Props,
                NameTransformationCompProperty(comp),
                TransformationCompDefaultValue(comp));

            const float epsilon = 1e-6f;
            return (dynVal - staticVal).LengthSquared() < epsilon;
        }