Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merge upstream/develop3d

  • Loading branch information...
commit fde70e79705bba6d821086e2bceaf199e9afc8b7 1 parent a7a4d81
@dellis1972 dellis1972 authored
Showing with 4,424 additions and 619 deletions.
  1. +1 −1  MonoGame.Framework.Content.Pipeline/{ContentImporters → }/ContentImporter.cs
  2. 0  MonoGame.Framework.Content.Pipeline/{ContentImporters → }/ContentImporterAttribute.cs
  3. 0  MonoGame.Framework.Content.Pipeline/{ContentImporters → }/ContentImporterContext.cs
  4. 0  MonoGame.Framework.Content.Pipeline/{ContentProcessors → }/ContentProcessor.cs
  5. 0  MonoGame.Framework.Content.Pipeline/{ContentProcessors → }/ContentProcessorAttribute.cs
  6. 0  MonoGame.Framework.Content.Pipeline/{ContentProcessors → }/ContentProcessorContext.cs
  7. 0  MonoGame.Framework.Content.Pipeline/{ContentImporters → }/EffectImporter.cs
  8. +213 −0 MonoGame.Framework.Content.Pipeline/Graphics/BitmapContent.cs
  9. +55 −0 MonoGame.Framework.Content.Pipeline/Graphics/BoneContent.cs
  10. +88 −0 MonoGame.Framework.Content.Pipeline/Graphics/BoneWeight.cs
  11. +128 −0 MonoGame.Framework.Content.Pipeline/Graphics/BoneWeightCollection.cs
  12. +210 −0 MonoGame.Framework.Content.Pipeline/Graphics/FontDescription.cs
  13. +67 −0 MonoGame.Framework.Content.Pipeline/Graphics/FontDescriptionStyle.cs
  14. +114 −0 MonoGame.Framework.Content.Pipeline/Graphics/GeometryContent.cs
  15. +73 −0 MonoGame.Framework.Content.Pipeline/Graphics/GeometryContentCollection.cs
  16. +95 −0 MonoGame.Framework.Content.Pipeline/Graphics/GraphicsUtil.cs
  17. +57 −0 MonoGame.Framework.Content.Pipeline/Graphics/IndexCollection.cs
  18. +174 −0 MonoGame.Framework.Content.Pipeline/Graphics/IndirectPositionCollection.cs
  19. +137 −0 MonoGame.Framework.Content.Pipeline/Graphics/MaterialContent.cs
  20. +82 −0 MonoGame.Framework.Content.Pipeline/Graphics/MeshContent.cs
  21. +76 −0 MonoGame.Framework.Content.Pipeline/Graphics/MipmapChain.cs
  22. +54 −0 MonoGame.Framework.Content.Pipeline/Graphics/MipmapChainCollection.cs
  23. +146 −0 MonoGame.Framework.Content.Pipeline/Graphics/PixelBitmapContent.cs
  24. +57 −0 MonoGame.Framework.Content.Pipeline/Graphics/PositionCollection.cs
  25. +26 −0 MonoGame.Framework.Content.Pipeline/Graphics/Texture2DContent.cs
  26. +97 −0 MonoGame.Framework.Content.Pipeline/Graphics/TextureContent.cs
  27. +55 −0 MonoGame.Framework.Content.Pipeline/Graphics/TextureReferenceDictionary.cs
  28. +261 −0 MonoGame.Framework.Content.Pipeline/Graphics/VertexChannel.cs
  29. +409 −0 MonoGame.Framework.Content.Pipeline/Graphics/VertexChannelCollection.cs
  30. +232 −0 MonoGame.Framework.Content.Pipeline/Graphics/VertexChannelGeneric.cs
  31. +223 −0 MonoGame.Framework.Content.Pipeline/Graphics/VertexChannelNames.cs
  32. +165 −0 MonoGame.Framework.Content.Pipeline/Graphics/VertexContent.cs
  33. 0  MonoGame.Framework.Content.Pipeline/{ContentImporters → }/IContentImporter.cs
  34. 0  MonoGame.Framework.Content.Pipeline/{ContentProcessors → }/IContentProcessor.cs
  35. +46 −31 MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.Windows.csproj
  36. +68 −0 MonoGame.Framework.Content.Pipeline/Processors/CompiledEffectContent.cs
  37. +86 −0 MonoGame.Framework.Content.Pipeline/Processors/EffectProcessor.cs
  38. +63 −0 MonoGame.Framework.Content.Pipeline/Processors/EffectProcessorDebugMode.cs
  39. +1 −1  ...ipeline/{ContentProcessors/SpriteFontDescriptionProcessor.cs → Processors/FontDescriptionProcessor.cs}
  40. +177 −0 MonoGame.Framework.Content.Pipeline/Processors/MaterialProcessor.cs
  41. +73 −0 MonoGame.Framework.Content.Pipeline/Processors/MaterialProcessorDefaultEffect.cs
  42. +35 −0 MonoGame.Framework.Content.Pipeline/Processors/SpriteFontContent.cs
  43. +1 −8 MonoGame.Framework.Content.Pipeline/{ContentProcessors → Processors}/TextureProcessor.cs
  44. +63 −0 MonoGame.Framework.Content.Pipeline/Processors/TextureProcessorOutputFormat.cs
  45. +124 −0 MonoGame.Framework.Content.Pipeline/Processors/VertexBufferContent.cs
  46. +75 −0 MonoGame.Framework.Content.Pipeline/Processors/VertexDeclarationContent.cs
  47. 0  MonoGame.Framework.Content.Pipeline/{ContentWriters → Serialization/Compiler}/ContentCompiler.cs
  48. 0  MonoGame.Framework.Content.Pipeline/{ContentWriters → Serialization/Compiler}/ContentTypeWriter.cs
  49. 0  ...ame.Framework.Content.Pipeline/{ContentWriters → Serialization/Compiler}/ContentTypeWriterAttribute.cs
  50. 0  MonoGame.Framework.Content.Pipeline/{ContentWriters → Serialization/Compiler}/ContentWriter.cs
  51. +49 −0 MonoGame.Framework.Content.Pipeline/Serialization/Compiler/TextureContentWriter.cs
  52. 0  MonoGame.Framework.Content.Pipeline/{ContentImporters → }/TextureImporter.cs
  53. +4 −3 MonoGame.Framework.Windows.sln
  54. +0 −89 MonoGame.Framework/Android/Input/Mouse.cs
  55. +0 −161 MonoGame.Framework/Desktop/Input/Mouse.cs
  56. +1 −1  MonoGame.Framework/Graphics/States/BlendFunction.cs
  57. +160 −0 MonoGame.Framework/Input/Mouse.cs
  58. +0 −51 MonoGame.Framework/Input/MouseState.cs
  59. +1 −47 MonoGame.Framework/Input/Touch/TouchPanel.cs
  60. +10 −10 MonoGame.Framework/MacOS/GameWindow.cs
  61. +0 −105 MonoGame.Framework/MacOS/Input/Mouse.cs
  62. +7 −3 MonoGame.Framework/MacOS/MacGamePlatform.cs
  63. +1 −1  MonoGame.Framework/MonoGame.Framework.Android.csproj
  64. +2 −2 MonoGame.Framework/MonoGame.Framework.Linux.csproj
  65. +1 −1  MonoGame.Framework/MonoGame.Framework.MacOS.csproj
  66. +1 −1  MonoGame.Framework/MonoGame.Framework.PSSuite.csproj
  67. +1 −1  MonoGame.Framework/MonoGame.Framework.Windows.csproj
  68. +0 −83 MonoGame.Framework/PSSuite/Input/Mouse.cs
  69. +34 −5 MonoGame.Framework/Windows8/MetroCoreWindowEvents.cs
  70. +45 −14 MonoGame.Framework/Windows8/MetroFrameElementEvents.cs
View
2  ...tent.Pipeline/ContentImporters/ContentImporter.cs → ...ame.Framework.Content.Pipeline/ContentImporter.cs
@@ -52,7 +52,7 @@ namespace Microsoft.Xna.Framework.Content.Pipeline
/// You can also design custom importers that accept and import types containing specific third-party extensions to the object model.
/// </summary>
public abstract class ContentImporter<T> : IContentImporter
- {
+ {
/// <summary>
/// Initializes a new instance of ContentImporter.
/// </summary>
View
0  ...line/ContentImporters/ContentImporterAttribute.cs → ...work.Content.Pipeline/ContentImporterAttribute.cs
File renamed without changes
View
0  ...peline/ContentImporters/ContentImporterContext.cs → ...mework.Content.Pipeline/ContentImporterContext.cs
File renamed without changes
View
0  ...nt.Pipeline/ContentProcessors/ContentProcessor.cs → ...me.Framework.Content.Pipeline/ContentProcessor.cs
File renamed without changes
View
0  ...ne/ContentProcessors/ContentProcessorAttribute.cs → ...ork.Content.Pipeline/ContentProcessorAttribute.cs
File renamed without changes
View
0  ...line/ContentProcessors/ContentProcessorContext.cs → ...ework.Content.Pipeline/ContentProcessorContext.cs
File renamed without changes
View
0  ...ntent.Pipeline/ContentImporters/EffectImporter.cs → ...Game.Framework.Content.Pipeline/EffectImporter.cs
File renamed without changes
View
213 MonoGame.Framework.Content.Pipeline/Graphics/BitmapContent.cs
@@ -0,0 +1,213 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides properties and methods for creating and maintaining a bitmap resource.
+ /// </summary>
+ public abstract class BitmapContent : ContentItem
+ {
+ int height;
+ int width;
+
+ /// <summary>
+ /// Gets or sets the height of the bitmap, in pixels.
+ /// </summary>
+ public int Height
+ {
+ get
+ {
+ return height;
+ }
+ set
+ {
+ if (value <= 0)
+ throw new ArgumentOutOfRangeException("height");
+ height = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the width of the bitmap, in pixels.
+ /// </summary>
+ public int Width
+ {
+ get
+ {
+ return width;
+ }
+ set
+ {
+ if (value <= 0)
+ throw new ArgumentOutOfRangeException("width");
+ width = value;
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of BitmapContent.
+ /// </summary>
+ protected BitmapContent()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of BitmapContent with the specified width or height.
+ /// </summary>
+ /// <param name="width">Width, in pixels, of the bitmap resource.</param>
+ /// <param name="height">Height, in pixels, of the bitmap resource.</param>
+ protected BitmapContent(int width, int height)
+ {
+ // Write to properties so validation is run.
+ Width = width;
+ Height = height;
+ }
+
+ /// <summary>
+ /// Copies one bitmap into another.
+ /// The destination bitmap can be in any format and size. If the destination is larger or smaller, the source bitmap is scaled accordingly.
+ /// </summary>
+ /// <param name="sourceBitmap">BitmapContent being copied.</param>
+ /// <param name="destinationBitmap">BitmapContent being overwritten.</param>
+ public static void Copy(BitmapContent sourceBitmap, BitmapContent destinationBitmap)
+ {
+ if (sourceBitmap == null)
+ throw new ArgumentNullException("sourceBitmap");
+ if (destinationBitmap == null)
+ throw new ArgumentNullException("destinationBitmap");
+ Copy(sourceBitmap, new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height), destinationBitmap, new Rectangle(0, 0, destinationBitmap.Width, destinationBitmap.Height));
+ }
+
+ /// <summary>
+ /// Copies one bitmap into another.
+ /// The destination bitmap can be in any format and size. If the destination is larger or smaller, the source bitmap is scaled accordingly.
+ /// </summary>
+ /// <param name="sourceBitmap">BitmapContent being copied.</param>
+ /// <param name="sourceRegion">Region of sourceBitmap.</param>
+ /// <param name="destinationBitmap">BitmapContent being overwritten.</param>
+ /// <param name="destinationRegion">Region of bitmap to be overwritten.</param>
+ public static void Copy(BitmapContent sourceBitmap, Rectangle sourceRegion, BitmapContent destinationBitmap, Rectangle destinationRegion)
+ {
+ ValidateCopyArguments(sourceBitmap, sourceRegion, destinationBitmap, destinationRegion);
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Reads encoded bitmap content.
+ /// </summary>
+ /// <returns>Array containing encoded bitmap data.</returns>
+ public abstract byte[] GetPixelData();
+
+ /// <summary>
+ /// Writes encoded bitmap content.
+ /// </summary>
+ /// <param name="sourceData">Array containing encoded bitmap data to be set.</param>
+ public abstract void SetPixelData(byte[] sourceData);
+
+ /// <summary>
+ /// Returns a string description of the bitmap resource.
+ /// </summary>
+ /// <returns>Description of the bitmap.</returns>
+ public override string ToString()
+ {
+ // See what Microsoft's implementation returns
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Attempts to copy a region from a specified bitmap.
+ /// </summary>
+ /// <param name="sourceBitmap">BitmapContent being copied.</param>
+ /// <param name="sourceRegion">Location of sourceBitmap.</param>
+ /// <param name="destinationRegion">Region of destination bitmap to be overwritten.</param>
+ /// <returns>true if region copy is supported; false otherwise.</returns>
+ protected abstract bool TryCopyFrom(BitmapContent sourceBitmap, Rectangle sourceRegion, Rectangle destinationRegion);
+
+ /// <summary>
+ /// Attempts to copy a region of the specified bitmap onto another.
+ /// </summary>
+ /// <param name="destinationBitmap">BitmapContent being overwritten.</param>
+ /// <param name="sourceRegion">Location of the source bitmap.</param>
+ /// <param name="destinationRegion">Region of destination bitmap to be overwritten.</param>
+ /// <returns>true if region copy is supported; false otherwise.</returns>
+ protected abstract bool TryCopyTo(BitmapContent destinationBitmap, Rectangle sourceRegion, Rectangle destinationRegion);
+
+ /// <summary>
+ /// Gets the corresponding GPU texture format for the specified bitmap type.
+ /// </summary>
+ /// <param name="format">Format being retrieved.</param>
+ /// <returns>The GPU texture format of the bitmap type.</returns>
+ public abstract bool TryGetFormat(out SurfaceFormat format);
+
+ /// <summary>
+ /// Validates the arguments to the Copy function.
+ /// </summary>
+ /// <param name="sourceBitmap">BitmapContent being copied.</param>
+ /// <param name="sourceRegion">Location of sourceBitmap.</param>
+ /// <param name="destinationBitmap">BitmapContent being overwritten.</param>
+ /// <param name="destinationRegion">Region of bitmap to be overwritten.</param>
+ protected static void ValidateCopyArguments(BitmapContent sourceBitmap, Rectangle sourceRegion, BitmapContent destinationBitmap, Rectangle destinationRegion)
+ {
+ if (sourceBitmap == null)
+ throw new ArgumentNullException("sourceBitmap");
+ if (destinationBitmap == null)
+ throw new ArgumentNullException("destinationBitmap");
+ // Make sure regions are within the bounds of the bitmaps
+ if (sourceRegion.Left < 0
+ || sourceRegion.Top < 0
+ || sourceRegion.Width <= 0
+ || sourceRegion.Height <= 0
+ || sourceRegion.Right > sourceBitmap.Width
+ || sourceRegion.Bottom > sourceBitmap.Height)
+ throw new ArgumentOutOfRangeException("sourceRegion");
+ if (destinationRegion.Left < 0
+ || destinationRegion.Top < 0
+ || destinationRegion.Width <= 0
+ || destinationRegion.Height <= 0
+ || destinationRegion.Right > destinationBitmap.Width
+ || destinationRegion.Bottom > destinationBitmap.Height)
+ throw new ArgumentOutOfRangeException("destinationRegion");
+ }
+ }
+}
View
55 MonoGame.Framework.Content.Pipeline/Graphics/BoneContent.cs
@@ -0,0 +1,55 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Represents an animation skeleton.
+ /// </summary>
+ public class BoneContent : NodeContent
+ {
+ /// <summary>
+ /// Initializes a new instance of BoneContent.
+ /// </summary>
+ public BoneContent()
+ {
+ }
+ }
+}
View
88 MonoGame.Framework.Content.Pipeline/Graphics/BoneWeight.cs
@@ -0,0 +1,88 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides properties for managing a bone weight.
+ /// </summary>
+ public struct BoneWeight
+ {
+ string boneName;
+ float weight;
+
+ /// <summary>
+ /// Gets the name of the bone.
+ /// </summary>
+ public string BoneName
+ {
+ get
+ {
+ return boneName;
+ }
+ }
+
+ /// <summary>
+ /// Gets the amount of bone influence, ranging from zero to one. The complete set of weights in a BoneWeightCollection should sum to one.
+ /// </summary>
+ public float Weight
+ {
+ get
+ {
+ return weight;
+ }
+ internal set
+ {
+ weight = value;
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of BoneWeight with the specified name and weight.
+ /// </summary>
+ /// <param name="boneName">Name of the bone.</param>
+ /// <param name="weight">Amount of influence, ranging from zero to one.</param>
+ public BoneWeight(string boneName, float weight)
+ {
+ this.boneName = boneName;
+ this.weight = weight;
+ }
+ }
+}
View
128 MonoGame.Framework.Content.Pipeline/Graphics/BoneWeightCollection.cs
@@ -0,0 +1,128 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Collection of bone weights of a vertex.
+ /// </summary>
+ public sealed class BoneWeightCollection : Collection<BoneWeight>
+ {
+ /// <summary>
+ /// Initializes a new instance of BoneWeightCollection.
+ /// </summary>
+ public BoneWeightCollection()
+ {
+ }
+
+ /// <summary>
+ /// Normalizes the contents of the weights list.
+ /// </summary>
+ public void NormalizeWeights()
+ {
+ // Normalization does the following:
+ //
+ // - Sorts weights such that the most significant weight is first.
+ // - Removes zero-value entries.
+ // - Adjusts values so the sum equals one.
+ //
+ // Throws InvalidContentException if all weights are zero.
+ NormalizeWeights(int.MaxValue);
+ }
+
+ /// <summary>
+ /// Normalizes the contents of the bone weights list.
+ /// </summary>
+ /// <param name="maxWeights">Maximum number of weights allowed.</param>
+ public void NormalizeWeights(int maxWeights)
+ {
+ // Normalization does the following:
+ //
+ // - Sorts weights such that the most significant weight is first.
+ // - Removes zero-value entries.
+ // - Discards weights with the smallest value until there are maxWeights or less in the list.
+ // - Adjusts values so the sum equals one.
+ //
+ // Throws InvalidContentException if all weights are zero.
+
+ List<BoneWeight> weights = new List<BoneWeight>(this.Items);
+
+ // Sort into descending order
+ weights.Sort((b1, b2) => { return b2.Weight.CompareTo(b1.Weight); });
+
+ // Find the sum to validate we have weights and to normalize the weights
+ float sum = 0.0f;
+ int index = 0;
+ // Cannot use a foreach or for because the index may not always increment and the length of the list may change.
+ while (index < weights.Count)
+ {
+ float weight = weights[index].Weight;
+ if ((weight > 0.0f) && (index < maxWeights))
+ {
+ sum += weight;
+ ++index;
+ }
+ else
+ {
+ // Discard any zero weights or if we have exceeded the maximum number of weights
+ weights.RemoveAt(index);
+ }
+ }
+
+ if (sum == 0.0f)
+ throw new InvalidContentException("Total bone weights in a collection must not be zero");
+
+ // Normalize each weight
+ int count = weights.Count();
+ // Old-school trick. Multiplication is faster than division, so multiply by the inverse.
+ float invSum = 1.0f / sum;
+ for (index = 0; index < count; ++index)
+ {
+ BoneWeight bw = weights[index];
+ bw.Weight *= invSum;
+ weights[index] = bw;
+ }
+ }
+ }
+}
View
210 MonoGame.Framework.Content.Pipeline/Graphics/FontDescription.cs
@@ -0,0 +1,210 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System;
+using System.Collections.Generic;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides information to the FontDescriptionProcessor describing which font to rasterize, which font size to utilize, and which Unicode characters to include in the processor output.
+ /// </summary>
+ public class FontDescription : ContentItem
+ {
+ List<char> characters;
+ char? defaultCharacter;
+ string fontName;
+ float size;
+ float spacing;
+ FontDescriptionStyle style;
+ bool useKerning;
+
+ /// <summary>
+ /// Gets the collection of characters provided by this FontDescription.
+ /// </summary>
+ [ContentSerializerIgnoreAttribute]
+ public ICollection<char> Characters
+ {
+ get
+ {
+ return characters;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the default character for the font.
+ /// </summary>
+ [ContentSerializerAttribute]
+ public Nullable<char> DefaultCharacter
+ {
+ get
+ {
+ return defaultCharacter;
+ }
+ set
+ {
+ defaultCharacter = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the name of the font, such as "Times New Roman" or "Arial". This value cannot be null or empty.
+ /// </summary>
+ public string FontName
+ {
+ get
+ {
+ return fontName;
+ }
+ set
+ {
+ if (string.IsNullOrEmpty(value))
+ throw new ArgumentNullException("FontName is null or an empty string.");
+ fontName = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the size, in points, of the font.
+ /// </summary>
+ public float Size
+ {
+ get
+ {
+ return size;
+ }
+ set
+ {
+ if (value <= 0.0f)
+ throw new ArgumentOutOfRangeException("Size is less than or equal to zero. Specify a value for this property that is greater than zero.");
+ size = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the amount of space, in pixels, to insert between letters in a string.
+ /// </summary>
+ public float Spacing
+ {
+ get
+ {
+ return spacing;
+ }
+ set
+ {
+ if (value <= 0.0f)
+ throw new ArgumentOutOfRangeException("Spacing is less than or equal to zero. Specify a value for this property that is greater than zero.");
+ spacing = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the style of the font, expressed as a combination of one or more FontDescriptionStyle flags.
+ /// </summary>
+ public FontDescriptionStyle Style
+ {
+ get
+ {
+ return style;
+ }
+ set
+ {
+ style = value;
+ }
+ }
+
+ /// <summary>
+ /// Indicates if kerning information is used when drawing characters.
+ /// </summary>
+ [ContentSerializerAttribute]
+ public bool UseKerning
+ {
+ get
+ {
+ return useKerning;
+ }
+ set
+ {
+ useKerning = value;
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of FontDescription and initializes its members to the specified font, size, and spacing, using FontDescriptionStyle.Regular as the default value for Style.
+ /// </summary>
+ /// <param name="fontName">The name of the font, such as Times New Roman.</param>
+ /// <param name="size">The size, in points, of the font.</param>
+ /// <param name="spacing">The amount of space, in pixels, to insert between letters in a string.</param>
+ public FontDescription(string fontName, float size, float spacing)
+ : this(fontName, size, spacing, FontDescriptionStyle.Regular, true)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of FontDescription and initializes its members to the specified font, size, spacing, and style.
+ /// </summary>
+ /// <param name="fontName">The name of the font, such as Times New Roman.</param>
+ /// <param name="size">The size, in points, of the font.</param>
+ /// <param name="spacing">The amount of space, in pixels, to insert between letters in a string.</param>
+ /// <param name="fontStyle">The font style for the font.</param>
+ public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle)
+ : this(fontName, size, spacing, fontStyle, true)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of FontDescription using the specified values.
+ /// </summary>
+ /// <param name="fontName">The name of the font, such as Times New Roman.</param>
+ /// <param name="size">The size, in points, of the font.</param>
+ /// <param name="spacing">The amount of space, in pixels, to insert between letters in a string.</param>
+ /// <param name="fontStyle">The font style for the font.</param>
+ /// <param name="useKerning">true if kerning information is used when drawing characters; false otherwise.</param>
+ public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle, bool useKerning)
+ {
+ // Write to the properties so the validation is run
+ FontName = fontName;
+ Size = size;
+ Spacing = spacing;
+ Style = fontStyle;
+ UseKerning = useKerning;
+ }
+ }
+}
View
67 MonoGame.Framework.Content.Pipeline/Graphics/FontDescriptionStyle.cs
@@ -0,0 +1,67 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Flags that describe style information to be applied to text.
+ /// You can combine these flags by using a bitwise OR operator (|).
+ /// </summary>
+ [Flags]
+ public enum FontDescriptionStyle
+ {
+ /// <summary>
+ /// Bold text.
+ /// </summary>
+ Bold,
+
+ /// <summary>
+ /// Italic text.
+ /// </summary>
+ Italic,
+
+ /// <summary>
+ /// Normal text.
+ /// </summary>
+ Regular,
+ }
+}
View
114 MonoGame.Framework.Content.Pipeline/Graphics/GeometryContent.cs
@@ -0,0 +1,114 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides properties that define various aspects of a geometry batch.
+ /// </summary>
+ public class GeometryContent : ContentItem
+ {
+ IndexCollection indices;
+ MaterialContent material;
+ MeshContent parent;
+ VertexContent vertices;
+
+ /// <summary>
+ /// Gets the list of triangle indices for this geometry batch. Geometry is stored as an indexed triangle list, where each group of three indices defines a single triangle.
+ /// </summary>
+ public IndexCollection Indices
+ {
+ get
+ {
+ return indices;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the material of the parent mesh.
+ /// </summary>
+ public MaterialContent Material
+ {
+ get
+ {
+ return material;
+ }
+ set
+ {
+ material = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the parent MeshContent for this object.
+ /// </summary>
+ public MeshContent Parent
+ {
+ get
+ {
+ return parent;
+ }
+ set
+ {
+ parent = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the set of vertex batches for the geometry batch.
+ /// </summary>
+ public VertexContent Vertices
+ {
+ get
+ {
+ return vertices;
+ }
+ }
+
+ /// <summary>
+ /// Creates an instance of GeometryContent.
+ /// </summary>
+ public GeometryContent()
+ {
+ indices = new IndexCollection();
+ vertices = new VertexContent();
+ }
+ }
+}
View
73 MonoGame.Framework.Content.Pipeline/Graphics/GeometryContentCollection.cs
@@ -0,0 +1,73 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides methods for maintaining a collection of geometry batches that make up a mesh.
+ /// </summary>
+ public sealed class GeometryContentCollection : ChildCollection<MeshContent, GeometryContent>
+ {
+ internal GeometryContentCollection(MeshContent parent)
+ : base(parent)
+ {
+ }
+
+ /// <summary>
+ /// Gets the parent of a child object.
+ /// </summary>
+ /// <param name="child">The child of the parent being retrieved.</param>
+ /// <returns>The parent of the child object.</returns>
+ protected override MeshContent GetParent(GeometryContent child)
+ {
+ return child.Parent;
+ }
+
+ /// <summary>
+ /// Sets the parent of the specified child object.
+ /// </summary>
+ /// <param name="child">The child of the parent being set.</param>
+ /// <param name="parent">The parent of the child object.</param>
+ protected override void SetParent(GeometryContent child, MeshContent parent)
+ {
+ child.Parent = parent;
+ }
+ }
+}
View
95 MonoGame.Framework.Content.Pipeline/Graphics/GraphicsUtil.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+
+ public static class ByteColorConverter
+ {
+ /*public static void GetPixel<T>(this byte[] data, int startIndex, SurfaceFormat format, out T result) where T : struct
+ {
+ result = new Color();
+ }*/
+
+ public static void GetPixel(this byte[] data, int startIndex, SurfaceFormat format, out Color result)
+ {
+ result = new Color();
+ }
+
+ public static void SetPixelData<T>(this byte[] data, PixelBitmapContent<T> bmpContent, int startIndex, SurfaceFormat format) where T : struct, IEquatable<T>
+ {
+ }
+
+ public static void SetPixelData(this byte[] data, PixelBitmapContent<Color> bmpContent, SurfaceFormat format)
+ {
+ var formatSize = format.Size();
+
+ for (int y = 0; y < bmpContent.Height; y++)
+ {
+ for (int x = 0; x < bmpContent.Width; x++)
+ {
+ switch(format)
+ {
+ case SurfaceFormat.Vector4:
+
+ var startIdx = (y * formatSize) + (x * formatSize);
+ var vec4 = new Vector4( BitConverter.ToSingle(data, startIdx),
+ BitConverter.ToSingle(data, startIdx + 4),
+ BitConverter.ToSingle(data, startIdx + 8),
+ BitConverter.ToSingle(data, startIdx + 12) );
+
+ bmpContent._pixelData[y][x] = new Color(vec4);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public static class GraphicsUtil
+ {
+
+ public static void PremultiplyAlpha(TextureContent content)
+ {
+ var colorTex = content.Faces[0][0] as PixelBitmapContent<Color>;
+ if (colorTex != null)
+ {
+ for (int x = 0; x < colorTex.Height; x++)
+ {
+ var row = colorTex.GetRow(x);
+ for (int y = 0; y < row.Length; y++)
+ {
+ if (row[y].A < 0xff)
+ row[y] = Color.FromNonPremultiplied(row[y].R, row[y].G, row[y].B, row[y].A);
+ }
+ }
+ }
+ else
+ {
+ var vec4Tex = content.Faces[0][0] as PixelBitmapContent<Vector4>;
+ if (vec4Tex == null)
+ throw new NotSupportedException();
+
+ for (int x = 0; x < vec4Tex.Height; x++)
+ {
+ var row = vec4Tex.GetRow(x);
+ for (int y = 0; y < row.Length; y++)
+ {
+ if (row[y].W < 1.0f)
+ {
+ row[y].X *= row[y].W;
+ row[y].Y *= row[y].W;
+ row[y].Z *= row[y].W;
+ }
+ }
+ }
+ }
+ }
+ }
+}
View
57 MonoGame.Framework.Content.Pipeline/Graphics/IndexCollection.cs
@@ -0,0 +1,57 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System.Collections.ObjectModel;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides methods for maintaining a list of index values.
+ /// </summary>
+ public sealed class IndexCollection : Collection<int>
+ {
+ /// <summary>
+ /// Initializes a new instance of IndexCollection.
+ /// </summary>
+ public IndexCollection()
+ {
+ }
+ }
+}
View
174 MonoGame.Framework.Content.Pipeline/Graphics/IndirectPositionCollection.cs
@@ -0,0 +1,174 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides methods for maintaining a list of vertex positions.
+ /// </summary>
+ /// <remarks>This class is designed to collect the vertex positions for a VertexContent object. Use the contents of the PositionIndices property (of the contained VertexContent object) to index into the Positions property of the parent mesh.</remarks>
+ public sealed class IndirectPositionCollection : IList<Vector3>, ICollection<Vector3>, IEnumerable<Vector3>, IEnumerable
+ {
+ List<Vector3> items;
+
+ /// <summary>
+ /// Number of positions in the collection.
+ /// </summary>
+ /// <value>Number of positions.</value>
+ public int Count { get { return items.Count; } }
+
+ /// <summary>
+ /// Gets or sets the position at the specified index.
+ /// </summary>
+ /// <value>Position located at index.</value>
+ public Vector3 this[int index] { get { return items[index]; } set { items[index] = value; } }
+
+ /// <summary>
+ /// Gets a value indicating whether this object is read-only.
+ /// </summary>
+ /// <value>true if this object is read-only; false otherwise.</value>
+ bool System.Collections.Generic.ICollection<Microsoft.Xna.Framework.Vector3>.IsReadOnly { get { return false; } }
+
+ /// <summary>
+ /// Initializes a new instance of IndirectPositionCollection.
+ /// </summary>
+ internal IndirectPositionCollection()
+ {
+ items = new List<Vector3>();
+ }
+
+ /// <summary>
+ /// Determines whether the specified position is in the collection.
+ /// </summary>
+ /// <param name="item">Position being searched for in the collection.</param>
+ /// <returns>true if the position was found; false otherwise.</returns>
+ public bool Contains(Vector3 item)
+ {
+ return items.Contains(item);
+ }
+
+ /// <summary>
+ /// Copies the specified positions to an array, starting at the specified index.
+ /// </summary>
+ /// <param name="array">Array of positions to be copied.</param>
+ /// <param name="arrayIndex">Index of the first copied position.</param>
+ public void CopyTo(Vector3[] array, int arrayIndex)
+ {
+ items.CopyTo(array, arrayIndex);
+ }
+
+ /// <summary>
+ /// Gets an enumerator interface for reading the position values.
+ /// </summary>
+ /// <returns>Interface for enumerating the collection of position values.</returns>
+ public IEnumerator<Vector3> GetEnumerator()
+ {
+ return items.GetEnumerator();
+ }
+
+ /// <summary>
+ /// Gets the index of the specified position in a collection.
+ /// </summary>
+ /// <param name="item">Position being searched for.</param>
+ /// <returns>Index of the specified position.</returns>
+ public int IndexOf(Vector3 item)
+ {
+ return items.IndexOf(item);
+ }
+
+ /// <summary>
+ /// Adds a new element to the end of the collection.
+ /// </summary>
+ /// <param name="item">The item to add.</param>
+ void ICollection<Vector3>.Add(Vector3 item)
+ {
+ items.Add(item);
+ }
+
+ /// <summary>
+ /// Removes all elements from the collection.
+ /// </summary>
+ void ICollection<Vector3>.Clear()
+ {
+ items.Clear();
+ }
+
+ /// <summary>
+ /// Removes the specified element from the collection.
+ /// </summary>
+ /// <param name="item">The item to be removed.</param>
+ /// <returns>true if the element was removed; false otherwise.</returns>
+ bool ICollection<Vector3>.Remove(Vector3 item)
+ {
+ return items.Remove(item);
+ }
+
+ /// <summary>
+ /// Inserts a new element into the collection.
+ /// </summary>
+ /// <param name="index">Index for element insertion.</param>
+ /// <param name="item">Element to insert.</param>
+ void IList<Vector3>.Insert(int index, Vector3 item)
+ {
+ items.Insert(index, item);
+ }
+
+ /// <summary>
+ /// Removes the element at the specified index position.
+ /// </summary>
+ /// <param name="index">Index of the element to be removed.</param>
+ void IList<Vector3>.RemoveAt(int index)
+ {
+ items.RemoveAt(index);
+ }
+
+ /// <summary>
+ /// Returns an enumerator that can iterate through the collection.
+ /// </summary>
+ /// <returns>Enumerator that can iterate through the collection.</returns>
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return items.GetEnumerator();
+ }
+ }
+}
View
137 MonoGame.Framework.Content.Pipeline/Graphics/MaterialContent.cs
@@ -0,0 +1,137 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides methods and properties for maintaining a collection of named texture references.
+ /// </summary>
+ /// <remarks>In addition to texture references, opaque data values are stored in the OpaqueData property of the base class.</remarks>
+ public class MaterialContent : ContentItem
+ {
+ TextureReferenceDictionary textures;
+
+ /// <summary>
+ /// Gets the texture collection of the material.
+ /// </summary>
+ /// <value>Collection of textures used by the material.</value>
+ public TextureReferenceDictionary Textures { get { return textures; } }
+
+ /// <summary>
+ /// Initializes a new instance of MaterialContent.
+ /// </summary>
+ public MaterialContent()
+ {
+ textures = new TextureReferenceDictionary();
+ }
+
+ /// <summary>
+ /// Gets a reference type from the OpaqueDataDictionary collection.
+ /// </summary>
+ /// <typeparam name="T">Type of the related opaque data.</typeparam>
+ /// <param name="key">Key of the property being retrieved.</param>
+ /// <returns>The related opaque data.</returns>
+ protected T GetReferenceTypeProperty<T>(string key) where T : class
+ {
+ object value;
+ if (OpaqueData.TryGetValue(key, out value))
+ return (T)value;
+ return default(T);
+ }
+
+ /// <summary>
+ /// Gets a value from the Textures collection.
+ /// </summary>
+ /// <param name="key">Key of the texture being retrieved.</param>
+ /// <returns>Reference to a texture from the collection.</returns>
+ protected ExternalReference<TextureContent> GetTexture(string key)
+ {
+ return textures[key];
+ }
+
+ /// <summary>
+ /// Gets a value type from the OpaqueDataDictionary collection.
+ /// </summary>
+ /// <typeparam name="T">Type of the value being retrieved.</typeparam>
+ /// <param name="key">Key of the value type being retrieved.</param>
+ /// <returns>Index of the value type beng retrieved.</returns>
+ protected Nullable<T> GetValueTypeProperty<T>(string key) where T : struct
+ {
+ object value;
+ if (OpaqueData.TryGetValue(key, out value))
+ return (T)value;
+ return null;
+ }
+
+ /// <summary>
+ /// Sets a value in the contained OpaqueDataDictionary object.
+ /// If null is passed, the value is removed.
+ /// </summary>
+ /// <typeparam name="T">Type of the element being set.</typeparam>
+ /// <param name="key">Name of the key being modified.</param>
+ /// <param name="value">Value being set.</param>
+ protected void SetProperty<T>(string key, T value)
+ {
+ if (value != null)
+ OpaqueData[key] = value;
+ else
+ OpaqueData.Remove(key);
+ }
+
+ /// <summary>
+ /// Sets a value in the contained TextureReferenceDictionary object.
+ /// If null is passed, the value is removed.
+ /// </summary>
+ /// <param name="key">Name of the key being modified.</param>
+ /// <param name="value">Value being set.</param>
+ /// <remarks>The key value differs depending on the type of attached dictionary.
+ /// If attached to a BasicMaterialContent dictionary (which becomes a BasicEffect object at run time), the value for the Texture key is used as the texture for the BasicEffect runtime object. Other keys are ignored.
+ /// If attached to a EffectMaterialContent dictionary, key names are the texture names used by the effect. These names are dependent upon the author of the effect object.</remarks>
+ protected void SetTexture(string key, ExternalReference<TextureContent> value)
+ {
+ if (value != null)
+ textures[key] = value;
+ else
+ textures.Remove(key);
+ }
+ }
+}
View
82 MonoGame.Framework.Content.Pipeline/Graphics/MeshContent.cs
@@ -0,0 +1,82 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides properties and methods that define various aspects of a mesh.
+ /// </summary>
+ public class MeshContent : NodeContent
+ {
+ GeometryContentCollection geometry;
+ PositionCollection positions;
+
+ /// <summary>
+ /// Gets the list of geometry batches for the mesh.
+ /// </summary>
+ public GeometryContentCollection Geometry
+ {
+ get
+ {
+ return geometry;
+ }
+ }
+
+ /// <summary>
+ /// Gets the list of vertex position values.
+ /// </summary>
+ public PositionCollection Positions
+ {
+ get
+ {
+ return positions;
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of MeshContent.
+ /// </summary>
+ public MeshContent()
+ {
+ geometry = new GeometryContentCollection(this);
+ positions = new PositionCollection();
+ }
+ }
+}
View
76 MonoGame.Framework.Content.Pipeline/Graphics/MipmapChain.cs
@@ -0,0 +1,76 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System.Collections.ObjectModel;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides methods for accessing a mipmap chain.
+ /// </summary>
+ public sealed class MipmapChain : Collection<BitmapContent>
+ {
+ /// <summary>
+ /// Initializes a new instance of MipmapChain.
+ /// </summary>
+ public MipmapChain()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of MipmapChain with the specified mipmap.
+ /// </summary>
+ /// <param name="bitmap"></param>
+ public MipmapChain(BitmapContent bitmap)
+ {
+ Add(bitmap);
+ }
+
+ /// <summary>
+ /// Constructs a new mipmap chain containing the specified bitmap.
+ /// </summary>
+ /// <param name="bitmap">Bitmap used for the mipmap chain.</param>
+ /// <returns>Resultant mipmap chain.</returns>
+ public static MipmapChain op_Implicit(BitmapContent bitmap)
+ {
+ return new MipmapChain(bitmap);
+ }
+ }
+}
View
54 MonoGame.Framework.Content.Pipeline/Graphics/MipmapChainCollection.cs
@@ -0,0 +1,54 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System.Collections.ObjectModel;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides methods for maintaining a mipmap chain.
+ /// </summary>
+ public sealed class MipmapChainCollection : Collection<MipmapChain>
+ {
+ internal MipmapChainCollection()
+ {
+ }
+ }
+}
View
146 MonoGame.Framework.Content.Pipeline/Graphics/PixelBitmapContent.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ public class PixelBitmapContent<T> : BitmapContent where T : struct, IEquatable<T>
+ {
+ internal T[][] _pixelData;
+
+ protected PixelBitmapContent()
+ {
+ }
+
+ public PixelBitmapContent(int width, int height) : base(width, height)
+ {
+ _pixelData = new T[height][];
+
+ for (int y = 0; y < height; y++)
+ _pixelData[y] = new T[width];
+ }
+
+ public T GetPixel(int x, int y)
+ {
+ checkPixelRange(y, x);
+
+ return _pixelData[y][x];
+ }
+
+ public override byte[] GetPixelData()
+ {
+ SurfaceFormat format;
+ if (!TryGetFormat(out format))
+ throw new Exception(string.Format("Tried to get pixel Data for PixedBitmapContent<{0}> with an invalid surfaceformat",
+ typeof(T)));
+
+ if (typeof(T) != typeof(Color))
+ throw new NotImplementedException("GetPixelData is not supported for Non-Color formats.");
+
+ var pixelSize = format.Size();
+ var outputData = new byte[Width * Height * pixelSize];
+
+ for (int i = 0; i < Width; i++)
+ {
+ var row = GetRow(i);
+ for (int j = 0; j < row.Length; j++)
+ {
+ var col = (row[j] as Color?).Value;
+
+ outputData[(i * row.Length) + j] = col.R;
+ outputData[(i * row.Length) + j + 1] = col.G;
+ outputData[(i * row.Length) + j + 2] = col.B;
+ outputData[(i * row.Length) + j + 3] = col.A;
+ }
+ }
+
+ return outputData;
+ }
+
+ public T[] GetRow(int y)
+ {
+ if ((y < 0) || (y >= Height))
+ throw new ArgumentOutOfRangeException("y");
+
+ return _pixelData[y];
+ }
+
+ protected override bool TryCopyFrom(BitmapContent sourceBitmap, Rectangle sourceRegion, Rectangle destRegion)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override bool TryCopyTo(BitmapContent destBitmap, Rectangle sourceRegion, Rectangle destRegion)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override bool TryGetFormat(out SurfaceFormat format)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override string ToString()
+ {
+ return base.ToString();
+ }
+
+ public override void SetPixelData(byte[] sourceData)
+ {
+ if (typeof(T) != typeof(Color))
+ throw new NotImplementedException("SetPixelData is not supported for Non-Color formats.");
+
+ SurfaceFormat format;
+ if (!TryGetFormat(out format))
+ throw new Exception(string.Format("Tried to get pixel Data for PixedBitmapContent<{0}> with an invalid surfaceformat",
+ typeof(T)));
+
+ sourceData.SetPixelData(this, 0, format);
+ /*var formatSize = format.Size();
+ for (int y = 0; y < Height; y++)
+ {
+ for (int x = 0; x < Width; x++)
+ {
+ sourceData.GetPixel((y * formatSize) + (x * formatSize), format, out _pixelData[y][x]);
+ }
+ }*/
+ }
+
+ private void SetPixelData()
+ {
+
+ }
+
+ public void SetPixel(int x, int y, T value)
+ {
+ checkPixelRange(y, x);
+
+ _pixelData[y][x] = value;
+ }
+
+ public void ReplaceColor(T originalColor, T newColor)
+ {
+ for (int y = 0; y < Height; y++)
+ {
+ for (int x = 0; x < Width; x++)
+ {
+ if (_pixelData[y][x].Equals(originalColor))
+ {
+ _pixelData[y][x] = newColor;
+ }
+ }
+ }
+ }
+
+ private void checkPixelRange(int y, int x)
+ {
+ if (x * y == 0 || x >= Height || y >= Width)
+ throw new ArgumentOutOfRangeException("x or y");
+ }
+
+
+
+ }
+}
View
57 MonoGame.Framework.Content.Pipeline/Graphics/PositionCollection.cs
@@ -0,0 +1,57 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System.Collections.ObjectModel;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides a collection of vertex position values.
+ /// </summary>
+ public sealed class PositionCollection : Collection<Vector3>
+ {
+ /// <summary>
+ /// Initializes a new instance of PositionCollection.
+ /// </summary>
+ public PositionCollection()
+ {
+ }
+ }
+}
View
26 MonoGame.Framework.Content.Pipeline/Graphics/Texture2DContent.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ public class Texture2DContent : TextureContent
+ {
+ public MipmapChain Mipmaps { get; set; }
+
+ public Texture2DContent() :
+ base(new MipmapChainCollection())
+ {
+
+ }
+
+ public override void Validate(GraphicsProfile? targetProf)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ }
+}
View
97 MonoGame.Framework.Content.Pipeline/Graphics/TextureContent.cs
@@ -0,0 +1,97 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides a base class for all texture objects.
+ /// </summary>
+ public abstract class TextureContent : ContentItem
+ {
+ MipmapChainCollection faces;
+
+ /// <summary>
+ /// Collection of image faces that hold a single mipmap chain for a regular 2D texture, six chains for a cube map, or an arbitrary number for volume and array textures.
+ /// </summary>
+ public MipmapChainCollection Faces
+ {
+ get
+ {
+ return faces;
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of TextureContent with the specified face collection.
+ /// </summary>
+ /// <param name="faces">Mipmap chain containing the face collection.</param>
+ protected TextureContent(MipmapChainCollection faces)
+ {
+ this.faces = faces;
+ }
+
+ /// <summary>
+ /// Converts all bitmaps for this texture to a different format.
+ /// </summary>
+ /// <param name="newBitmapType">Type being converted to. The new type must be a subclass of BitmapContent, such as PixelBitmapContent or DxtBitmapContent.</param>
+ public void ConvertBitmapType(Type newBitmapType)
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Generates a full set of mipmaps for the texture.
+ /// </summary>
+ /// <param name="overwriteExistingMipmaps">true if the existing mipmap set is replaced with the new set; false otherwise.</param>
+ public virtual void GenerateMipmaps(bool overwriteExistingMipmaps)
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Verifies that all contents of this texture are present, correct and match the capabilities of the device.
+ /// </summary>
+ /// <param name="targetProfile">The profile identifier that defines the capabilities of the device.</param>
+ public abstract void Validate(Nullable<GraphicsProfile> targetProfile);
+ }
+}
View
55 MonoGame.Framework.Content.Pipeline/Graphics/TextureReferenceDictionary.cs
@@ -0,0 +1,55 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides a collection of named references to texture files.
+ /// </summary>
+ public sealed class TextureReferenceDictionary : NamedValueDictionary<ExternalReference<TextureContent>>
+ {
+ /// <summary>
+ /// Initializes a new instance of TextureReferenceDictionary.
+ /// </summary>
+ public TextureReferenceDictionary()
+ {
+ }
+ }
+}
View
261 MonoGame.Framework.Content.Pipeline/Graphics/VertexChannel.cs
@@ -0,0 +1,261 @@
+#region License
+/*
+ Microsoft Public License (Ms-PL)
+ MonoGame - Copyright © 2012 The MonoGame Team
+
+ All rights reserved.
+
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
+ accept the license, do not use the software.
+
+ 1. Definitions
+ The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
+ U.S. copyright law.
+
+ A "contribution" is the original software, or any additions or changes to the software.
+ A "contributor" is any person that distributes its contribution under this license.
+ "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+ 2. Grant of Rights
+ (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+ (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
+ each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+ 3. Conditions and Limitations
+ (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+ (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
+ your patent license from such contributor to the software ends automatically.
+ (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+ notices that are present in the software.
+ (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+ a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
+ code form, you may only do so under a license that complies with this license.
+ (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
+ or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
+ permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
+ purpose and non-infringement.
+ */
+#endregion License
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
+{
+ /// <summary>
+ /// Provides methods and properties for maintaining a vertex channel.
+ /// A vertex channel is a list of arbitrary data with one value for each vertex. Channels are stored inside a GeometryContent and identified by name.
+ /// </summary>
+ public abstract class VertexChannel : IList, ICollection, IEnumerable
+ {
+ string name;
+
+ /// <summary>
+ /// Allows overriding classes to implement the list, and for properties/methods in this class to access it.
+ /// </summary>
+ internal abstract IList Items
+ {
+ get;
+ }
+
+ /// <summary>
+ /// Gets the number of elements in the vertex channel
+ /// </summary>
+ public int Count
+ {
+ get
+ {
+ return Items.Count;
+ }
+ }
+
+ /// <summary>
+ /// Gets the type of data contained in this channel.
+ /// </summary>
+ public abstract Type ElementType { get; }
+
+ /// <summary>
+ /// Gets or sets the element at the specified index.
+ /// </summary>
+ public Object this[int index]
+ {
+ get
+ {
+ return Items[index];
+ }
+ set
+ {
+ Items[index] = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the name of the vertex channel.
+ /// </summary>
+ public string Name
+ {
+ get
+ {
+ return name;
+ }
+ internal set
+ {
+ name = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether access to the collection is synchronized (thread safe).
+ /// </summary>
+ bool System.Collections.ICollection.IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Gets an object that can be used to synchronize access to the collection.
+ /// </summary>
+ Object System.Collections.ICollection.SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this list has a fixed size.
+ /// </summary>
+ bool System.Collections.IList.IsFixedSize
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this object is read-only.
+ /// </summary>
+ bool System.Collections.IList.IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Creates an instance of VertexChannel.
+ /// </summary>
+ /// <param name="name">Name of the channel.</param>
+ internal VertexChannel(string name)
+ {
+ Name = name;
+ }
+
+ /// <summary>
+ /// Determines whether the specified element is in the channel.
+ /// </summary>
+ /// <param name="value">Element being searched for.</param>
+ /// <returns>true if the element is present; false otherwise.</returns>
+ public bool Contains(Object value)
+ {
+ return Items.Contains(value);
+ }
+
+ /// <summary>
+ /// Copies the elements of the channel to an array, starting at the specified index.
+ /// </summary>
+ /// <param name="array">Array that will receive the copied channel elements.</param>
+ /// <param name="index">Starting index for copy operation.</param>
+ public void CopyTo(Array array, int index)
+ {
+ ((ICollection)Items).CopyTo(array, index);
+ }
+
+ /// <summary>
+ /// Gets an enumerator interface for reading channel content.
+ /// </summary>
+ /// <returns>Enumeration of the channel content.</returns>
+ public IEnumerator GetEnumerator()
+ {
+ return Items.GetEnumerator();
+ }
+
+ /// <summary>
+ /// Gets the index of the specified item.
+ /// </summary>
+ /// <param name="value">Item whose index is to be retrieved.</param>
+ /// <returns>Index of specified item.</returns>
+ public int IndexOf(Object value)
+ {
+ return Items.IndexOf(value);
+ }
+
+ /// <summary>
+ /// Reads channel content and automatically converts it to the specified vector format.
+ /// </summary>
+ /// <typeparam name="TargetType">Target vector format of the converted data.</typeparam>
+ /// <returns>The converted data.</returns>
+ public abstract IEnumerable<TargetType> ReadConvertedContent<TargetType>();
+
+ /// <summary>
+ /// Adds a new element to the end of the collection.
+ /// </summary>
+ /// <param name="value">The element to add.</param>
+ /// <returns>Index of the element.</returns>
+ int IList.Add(Object value)
+ {
+ return Items.Add(value);
+ }
+
+ /// <summary>
+ /// Removes all elements from the collection.
+ /// </summary>
+ void IList.Clear()
+ {
+ Items.Clear();
+ }
+
+ /// <summary>
+ /// Inserts an element into the collection at the specified position.
+ /// </summary>
+ /// <param name="index">Index at which to insert the element.</param>
+ /// <param name="value">The element to insert.</param>
+ void IList.Insert(int index, Object value)
+ {
+ Items.Insert(index, value);
+ }
+
+ /// <summary>
+ /// Inserts the range of values from the enumerable into the channel.
+ /// </summary>
+ /// <param name="index">The zero-based index at which the new elements should be inserted.</param>
+ /// <param name=<