GpuAnimatedModelProcessor.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #region License
  2. // Copyright 2011-2016 Kastellanos Nikolaos
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #endregion
  16. using System.ComponentModel;
  17. using Microsoft.Xna.Framework.Content.Pipeline;
  18. using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
  19. using Microsoft.Xna.Framework.Content.Pipeline.Processors;
  20. using Microsoft.Xna.Framework.Graphics;
  21. namespace nkast.Aether.Content.Pipeline.Processors
  22. {
  23. [ContentProcessor(DisplayName = "GPU AnimatedModel - Aether")]
  24. public class GpuAnimatedModelProcessor : ModelProcessor
  25. {
  26. private int _maxBones = SkinnedEffect.MaxBones;
  27. private int _generateKeyframesFrequency = 0;
  28. private bool _fixRealBoneRoot = false;
  29. [DisplayName("MaxBones")]
  30. [DefaultValue(SkinnedEffect.MaxBones)]
  31. public virtual int MaxBones
  32. {
  33. get { return _maxBones; }
  34. set { _maxBones = value; }
  35. }
  36. [DisplayName("Generate Keyframes Frequency")]
  37. [DefaultValue(0)] // (0=no, 30=30fps, 60=60fps)
  38. public virtual int GenerateKeyframesFrequency
  39. {
  40. get { return _generateKeyframesFrequency; }
  41. set { _generateKeyframesFrequency = value; }
  42. }
  43. [DisplayName("Fix BoneRoot from MG importer")]
  44. [DefaultValue(false)]
  45. public virtual bool FixRealBoneRoot
  46. {
  47. get { return _fixRealBoneRoot; }
  48. set { _fixRealBoneRoot = value; }
  49. }
  50. [DefaultValue(MaterialProcessorDefaultEffect.SkinnedEffect)]
  51. public override MaterialProcessorDefaultEffect DefaultEffect
  52. {
  53. get { return base.DefaultEffect; }
  54. set { base.DefaultEffect = value; }
  55. }
  56. public GpuAnimatedModelProcessor()
  57. {
  58. DefaultEffect = MaterialProcessorDefaultEffect.SkinnedEffect;
  59. }
  60. public override ModelContent Process(NodeContent input, ContentProcessorContext context)
  61. {
  62. var animationProcessor = new AnimationsProcessor();
  63. animationProcessor.MaxBones = this.MaxBones;
  64. animationProcessor.GenerateKeyframesFrequency = this.GenerateKeyframesFrequency;
  65. animationProcessor.FixRealBoneRoot = this._fixRealBoneRoot;
  66. var animation = animationProcessor.Process(input, context);
  67. ModelContent model = base.Process(input, context);
  68. model.Tag = animation;
  69. return model;
  70. }
  71. }
  72. }