CpuAnimatedVertexBufferWriter.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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;
  17. using Microsoft.Xna.Framework.Content.Pipeline;
  18. using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
  19. using nkast.Aether.Content.Pipeline.Animation;
  20. using nkast.Aether.Content.Pipeline.Graphics;
  21. namespace nkast.Aether.Content.Pipeline.Serialization
  22. {
  23. [ContentTypeWriter]
  24. public class CpuAnimatedVertexBufferWriter : ContentTypeWriter<CpuAnimatedVertexBufferContent>
  25. {
  26. protected override void Write(ContentWriter output, CpuAnimatedVertexBufferContent buffer)
  27. {
  28. WriteVertexBuffer(output, buffer);
  29. output.Write(buffer.IsWriteOnly);
  30. }
  31. private void WriteVertexBuffer(ContentWriter output, DynamicVertexBufferContent buffer)
  32. {
  33. var vertexCount = buffer.VertexData.Length / buffer.VertexDeclaration.VertexStride;
  34. output.WriteRawObject(buffer.VertexDeclaration);
  35. output.Write((UInt32)vertexCount);
  36. output.Write(buffer.VertexData);
  37. }
  38. public override string GetRuntimeReader(TargetPlatform targetPlatform)
  39. {
  40. return "nkast.Aether.Animation.Content.CpuAnimatedVertexBufferReader, Aether.Animation";
  41. }
  42. }
  43. }