private AnimCurve CreateAnimCurve() { //Create empty curve AnimCurve curve = new AnimCurve(); curve.Offset = 0; curve.StartFrame = 0; curve.EndFrame = MatAnimWrapper.FrameCount; curve.CurveType = AnimCurveType.StepInt; curve.AnimDataOffset = 0; curve.Scale = 1; //Start with sbyte. Increase only if index is > 255 curve.KeyType = AnimCurveKeyType.SByte; //Set by frame count curve.FrameType = CurveHelper.GetFrameType((uint)MatAnimWrapper.FrameCount); return(curve); }
public void SaveData() { if (!IsEdited) //Use original data instead of generic data from editors { return; } if (VisibilityAnimU != null) { VisibilityAnimU.Name = Text; VisibilityAnimU.Names = BoneNames; VisibilityAnimU.Path = ""; } else { VisibilityAnim.Name = Text; VisibilityAnim.Names = BoneNames; VisibilityAnim.Path = ""; VisibilityAnim.FrameCount = FrameCount; VisibilityAnim.BaseDataList = new bool[BoneNames.Count]; int boneIndex = 0; foreach (BooleanKeyGroup value in Values) { if (!value.Constant) { AnimCurve curve = new AnimCurve(); curve.AnimDataOffset = (uint)BoneNames.IndexOf(value.Text); curve.Scale = value.Scale; curve.Offset = value.Offset; curve.KeyType = AnimCurveKeyType.SByte; curve.FrameType = CurveHelper.GetFrameType((uint)FrameCount); curve.CurveType = AnimCurveType.StepBool; if (IsBaked) { curve.CurveType = AnimCurveType.BakedBool; } curve.Delta = value.Delta; curve.EndFrame = value.EndFrame; curve.StartFrame = value.StartFrame; List <bool> KeyBooleans = new List <bool>(); List <float> KeyFrames = new List <float>(); for (int frame = 0; frame < value.Keys.Count; frame++) { bool currentValue = value.Keys[frame].Visible; float currentFrame = value.Keys[frame].Frame; if (frame > 0) { bool previousValue = value.Keys[frame - 1].Visible; if (previousValue != currentValue) { KeyFrames.Add(currentFrame); KeyBooleans.Add(currentValue); } } else { KeyFrames.Add(currentFrame); KeyBooleans.Add(currentValue); VisibilityAnim.BaseDataList[boneIndex] = currentValue; } } curve.KeyStepBoolData = KeyBooleans.ToArray(); for (int frame = 0; frame < FrameCount; frame++) { } } else { //Else for constant types it's only base values } boneIndex++; } } }