MorphShapes.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Animation
  8. * @{
  9. */
  10. /// <summary>
  11. /// Name and weight of a single shape in a morph target animation. Each shape internally represents a set of vertices
  12. /// that describe the morph shape.
  13. /// </summary>
  14. public class MorphShape
  15. {
  16. /// <summary>
  17. /// Unique name of the shape within a channel.
  18. /// </summary>
  19. public string Name { get; }
  20. /// <summary>
  21. /// Weight of the shape, determining how are different shapes within a channel blended.
  22. /// </summary>
  23. public float Weight { get; }
  24. /// <summary>
  25. /// Constructor for internal runtime use.
  26. /// </summary>
  27. /// <param name="name">Unique name of the shape within a channel.</param>
  28. /// <param name="weight">Weight in range [0, 1]. Determines how are sequential shapes animated between within a
  29. /// morph channel.e.g. if there is a shape A with weight 0.3 and shape B with weight 0.8
  30. /// then shape A will be displayed first and then be blended towards shape B as time passes.
  31. /// </param>
  32. private MorphShape(string name, float weight)
  33. {
  34. Name = name;
  35. Weight = weight;
  36. }
  37. }
  38. /// <summary>
  39. /// A collection of morph shapes that are sequentially blended together. Each shape has a weight in range [0, 1] which
  40. /// determines at what point is that shape blended. As the channel percent moves from 0 to 1, different shapes will be
  41. /// blended with those before or after them, depending on their weight.
  42. /// </summary>
  43. public class MorphChannel
  44. {
  45. /// <summary>
  46. /// Unique name of the channel, within a single morph animation.
  47. /// </summary>
  48. public string Name { get; }
  49. /// <summary>
  50. /// All morph shapes within a channel, in order from lowest to highest weight.
  51. /// </summary>
  52. public MorphShape[] Shapes { get; }
  53. /// <summary>
  54. /// Constructor for internal runtime use.
  55. /// </summary>
  56. /// <param name="name">Unique name of the channel, within a single morph animation.</param>
  57. /// <param name="shapes">A set of shapes beloning to a channel.</param>
  58. private MorphChannel(string name, MorphShape[] shapes)
  59. {
  60. Name = name;
  61. Shapes = shapes;
  62. }
  63. }
  64. /// <summary>
  65. /// Contains a set of morph shapes, used for morph target animation. Each morph shape contains a single possible shape
  66. /// that can be added on top of the base shape in order to create the animation.
  67. /// </summary>
  68. public class MorphShapes : ScriptObject
  69. {
  70. /// <summary>
  71. /// Constructor for internal runtime use only.
  72. /// </summary>
  73. private MorphShapes()
  74. { }
  75. /// <summary>
  76. /// Returns a list of all available morph channels.
  77. /// </summary>
  78. public MorphChannel[] Channels
  79. {
  80. get { return Internal_GetChannels(mCachedPtr); }
  81. }
  82. [MethodImpl(MethodImplOptions.InternalCall)]
  83. private static extern MorphChannel[] Internal_GetChannels(IntPtr instance);
  84. }
  85. /** @} */
  86. }