Skip to content

Commit

Permalink
Merge pull request #8279 from Maniekko/docs/models
Browse files Browse the repository at this point in the history
[Documentation]: Adds XML documentation for the Model classes
  • Loading branch information
SimonDarksideJ committed May 10, 2024
2 parents dc41cdc + a9cbd2e commit 3d5494e
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 124 deletions.
89 changes: 40 additions & 49 deletions MonoGame.Framework/Graphics/ModelBone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

namespace Microsoft.Xna.Framework.Graphics
{
// Summary:
// Represents bone data for a model. Reference page contains links to related
// conceptual articles.
public sealed class ModelBone
/// <summary>
/// Represents bone data for a model.
/// </summary>
public sealed class ModelBone
{
private List<ModelBone> children = new List<ModelBone>();

private List<ModelMesh> meshes = new List<ModelMesh>();

/// <summary>
/// List of the meshes for this bone.
/// </summary>
public List<ModelMesh> Meshes {
get {
return this.meshes;
Expand All @@ -22,26 +25,30 @@ public sealed class ModelBone
}
}

// Summary:
// Gets a collection of bones that are children of this bone.
public ModelBoneCollection Children { get; private set; }
//
// Summary:
// Gets the index of this bone in the Bones collection.
/// <summary>
/// Gets a collection of bones that are children of this bone.
/// </summary>
public ModelBoneCollection Children { get; private set; }

/// <summary>
/// Gets the index of this bone in the <see cref="Model.Bones">Model.Bones</see> collection.
/// </summary>
public int Index { get; set; }
//
// Summary:
// Gets the name of this bone.

/// <summary>
/// Gets the name of this bone.
/// </summary>
public string Name { get; set; }
//
// Summary:
// Gets the parent of this bone.

/// <summary>
/// Gets the parent of this bone.
/// </summary>
public ModelBone Parent { get; set; }
//
// Summary:
// Gets or sets the matrix used to transform this bone relative to its parent
// bone.

internal Matrix transform;
/// <summary>
/// Gets or sets the matrix used to transform this bone relative to its parent bone.
/// </summary>
public Matrix Transform
{
get { return this.transform; }
Expand All @@ -55,48 +62,32 @@ public Matrix Transform
get;
set;
}


/// <summary>
/// Creates a new collection of <see cref="ModelBone"/> to denote the child bones in this model.
/// </summary>
public ModelBone ()
{
Children = new ModelBoneCollection(new List<ModelBone>());
}


/// <summary>
/// Add a <see cref="ModelMesh"/> to the mesh collection.
/// </summary>
/// <param name="mesh"><see cref="ModelMesh"/> to be added</param>
public void AddMesh(ModelMesh mesh)
{
meshes.Add(mesh);
}

/// <summary>
/// Adds a new child bone to this bone.
/// </summary>
/// <param name="modelBone"><see cref="ModelBone"/> to be added.</param>
public void AddChild(ModelBone modelBone)
{
children.Add(modelBone);
Children = new ModelBoneCollection(children);
}
}

//// Summary:
//// Represents bone data for a model. Reference page contains links to related
//// conceptual articles.
//public sealed class ModelBone
//{
// // Summary:
// // Gets a collection of bones that are children of this bone.
// public ModelBoneCollection Children { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets the index of this bone in the Bones collection.
// public int Index { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets the name of this bone.
// public string Name { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets the parent of this bone.
// public ModelBone Parent { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets or sets the matrix used to transform this bone relative to its parent
// // bone.
// public Matrix Transform { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }
//}
}
122 changes: 48 additions & 74 deletions MonoGame.Framework/Graphics/ModelMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

namespace Microsoft.Xna.Framework.Graphics
{

// Summary:
// Represents a mesh that is part of a Model.
/// <summary>
/// Represents a mesh that is part of a <see cref="Model"/>.
/// </summary>
public sealed class ModelMesh
{
private GraphicsDevice graphicsDevice;

/// <summary>
/// Creates a new instance of <see cref="ModelMesh"/>.
/// </summary>
/// <param name="graphicsDevice">The graphicss device.</param>
/// <param name="parts">Parts of this mesh.</param>
public ModelMesh(GraphicsDevice graphicsDevice, System.Collections.Generic.List<ModelMeshPart> parts)
{
// TODO: Complete member initialization
Expand All @@ -24,8 +29,8 @@ public ModelMesh(GraphicsDevice graphicsDevice, System.Collections.Generic.List<

Effects = new ModelEffectCollection();
}
/*internal void BuildEffectList()

/*internal void BuildEffectList()
{
List<Effect> effects = new List<Effect>();
foreach (ModelMeshPart item in parts)
Expand All @@ -38,38 +43,45 @@ public ModelMesh(GraphicsDevice graphicsDevice, System.Collections.Generic.List<
}
Effects = new ModelEffectCollection(effects);
}*/

// Summary:
// Gets the BoundingSphere that contains this mesh.
public BoundingSphere BoundingSphere { get; set; }
//
// Summary:
// Gets a collection of effects associated with this mesh.

/// <summary>
/// Gets the <see cref="BoundingSphere"/> that encompasses this mesh.
/// </summary>
public BoundingSphere BoundingSphere { get; set; }

/// <summary>
/// Gets a collection of effects associated with this mesh.
/// </summary>
public ModelEffectCollection Effects { get; internal set; }
//
// Summary:
// Gets the ModelMeshPart objects that make up this mesh. Each part of a mesh
// is composed of a set of primitives that share the same material.
public ModelMeshPartCollection MeshParts { get; set; }
//
// Summary:
// Gets the name of this mesh.
public string Name { get; set; }
//
// Summary:
// Gets the parent bone for this mesh. The parent bone of a mesh contains a
// transformation matrix that describes how the mesh is located relative to
// any parent meshes in a model.
public ModelBone ParentBone { get; set; }
//
// Summary:
// Gets or sets an object identifying this mesh.

/// <summary>
/// Gets the collection of <see cref="ModelMeshPart"/> objects that make up this mesh.
/// Each part of a mesh is composed of a set of primitives that share the same material.
/// </summary>
public ModelMeshPartCollection MeshParts { get; set; }

/// <summary>
/// Gets the name of this mesh.
/// </summary>
public string Name { get; set; }

/// <summary>
/// Gets the parent bone for this mesh. <para/>
/// The parent bone of a mesh contains a transformation matrix that describes
/// how the mesh is located relative to any parent meshes in a model.
/// </summary>
public ModelBone ParentBone { get; set; }

/// <summary>
/// Gets or sets an object identifying this mesh.
/// </summary>
public object Tag { get; set; }

// Summary:
// Draws all of the ModelMeshPart objects in this mesh, using their current
// Effect settings.
public void Draw()

/// <summary>
/// Draws all of the <see cref="ModelMeshPart"/> objects in this mesh,
/// using their current <see cref="Effect"/> settings.
/// </summary>
public void Draw()
{
for(int i = 0; i < MeshParts.Count; i++)
{
Expand All @@ -90,42 +102,4 @@ public void Draw()
}
}
}


//// Summary:
//// Represents a mesh that is part of a Model.
//public sealed class ModelMesh
//{
// // Summary:
// // Gets the BoundingSphere that contains this mesh.
// public BoundingSphere BoundingSphere { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets a collection of effects associated with this mesh.
// public ModelEffectCollection Effects { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets the ModelMeshPart objects that make up this mesh. Each part of a mesh
// // is composed of a set of primitives that share the same material.
// public ModelMeshPartCollection MeshParts { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets the name of this mesh.
// public string Name { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets the parent bone for this mesh. The parent bone of a mesh contains a
// // transformation matrix that describes how the mesh is located relative to
// // any parent meshes in a model.
// public ModelBone ParentBone { get { throw new NotImplementedException(); } }
// //
// // Summary:
// // Gets or sets an object identifying this mesh.
// public object Tag { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }

// // Summary:
// // Draws all of the ModelMeshPart objects in this mesh, using their current
// // Effect settings.
// public void Draw() { throw new NotImplementedException(); }
//}
}
}
38 changes: 37 additions & 1 deletion MonoGame.Framework/Graphics/ModelMeshPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@

namespace Microsoft.Xna.Framework.Graphics
{
/// <summary>
/// Represents a batch of geometry information to submit to the graphics device during rendering.
/// Each <b>ModelMeshPart</b> is a subdivision of a <see cref="ModelMesh"/> object.
/// The <see cref="ModelMesh"/> class is split into multiple <b>ModelMeshPart</b> objects,
/// typically based on material information.
/// </summary>
/// <remarks>
/// It is not necessary to use this class directly.
/// In advanced rendering scenarios, it is possible to draw using <b>ModelMeshPart</b> properties in combination
/// with the vertex and index buffers on <see cref="ModelMesh"/>.
/// However, in most cases, <see cref="ModelMesh.Draw()"/> will be sufficient.
/// </remarks>
public sealed class ModelMeshPart
{
private Effect _effect;

/// <summary>
/// Gets or sets the material <see cref="Effect"/> for this mesh part.
/// </summary>
public Effect Effect
{
get
Expand Down Expand Up @@ -42,18 +57,39 @@ public Effect Effect
}
}

/// <summary>
/// Gets the index buffer for this mesh part.
/// </summary>
public IndexBuffer IndexBuffer { get; set; }

/// <summary>
/// Gets the number of vertices used during a draw call.
/// </summary>
public int NumVertices { get; set; }

/// <summary>
/// Gets the number of primitives to render.
/// </summary>
public int PrimitiveCount { get; set; }

/// <summary>
/// Gets the location in the index array at which to start reading vertices.
/// </summary>
public int StartIndex { get; set; }

/// <summary>
/// Gets or sets an object identifying this model mesh part.
/// </summary>
public object Tag { get; set; }

/// <summary>
/// Gets the vertex buffer for this mesh part.
/// </summary>
public VertexBuffer VertexBuffer { get; set; }

/// <summary>
/// Gets the offset (in vertices) from the top of vertex buffer.
/// </summary>
public int VertexOffset { get; set; }

internal int VertexBufferIndex { get; set; }
Expand All @@ -71,4 +107,4 @@ public Effect Effect
[Obsolete("This constructor is deprecated and will be made internal in a future release.")]
public ModelMeshPart() { }
}
}
}

0 comments on commit 3d5494e

Please sign in to comment.