From 1ecc704c166df641894c09032e6f67065406790f Mon Sep 17 00:00:00 2001 From: "SND\\GinieDp_cp" Date: Mon, 27 Aug 2012 21:24:20 +0000 Subject: [PATCH] --- .../Graphics/GeometryContent.cs | 2 +- .../Graphics/IndirectPositionCollection.cs | 119 ++++++--- .../Graphics/VertexChannel.cs | 251 +++++++++--------- .../Graphics/VertexContent.cs | 11 +- 4 files changed, 220 insertions(+), 163 deletions(-) diff --git a/ANX.Framework.Content.Pipeline/Graphics/GeometryContent.cs b/ANX.Framework.Content.Pipeline/Graphics/GeometryContent.cs index 70f2f786..4e823366 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/GeometryContent.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/GeometryContent.cs @@ -42,7 +42,7 @@ namespace ANX.Framework.Content.Pipeline.Graphics public GeometryContent() { Indices = new IndexCollection(); - Vertices = new VertexContent(); + Vertices = new VertexContent(this); } } } diff --git a/ANX.Framework.Content.Pipeline/Graphics/IndirectPositionCollection.cs b/ANX.Framework.Content.Pipeline/Graphics/IndirectPositionCollection.cs index c5c8eaea..5064e15d 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/IndirectPositionCollection.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/IndirectPositionCollection.cs @@ -15,77 +15,114 @@ namespace ANX.Framework.Content.Pipeline.Graphics { public sealed class IndirectPositionCollection : IList, ICollection, IEnumerable, IEnumerable { + private GeometryContent geometry; + private VertexChannel indices; - int IList.IndexOf(Vector3 item) + #region Properties + public int Count { - throw new NotImplementedException(); + get { throw new NotImplementedException(); } + } + + public bool IsReadOnly + { + get { return true; } + } + + public Vector3 this[int index] + { + get + { + if (geometry.Parent == null) + { + throw new InvalidOperationException("Geometry must have a mesh parent."); + } + int vIndex = this.indices[index]; + return geometry.Parent.Positions[vIndex]; + } + set + { + throw new NotSupportedException(); + } + } + #endregion + + #region Constructor + public IndirectPositionCollection(GeometryContent geometry, VertexChannel positionIndices) + { + this.geometry = geometry; + this.indices = positionIndices; + } + #endregion + + #region Methods + public int IndexOf(Vector3 item) + { + for (int i = 0; i < Count; i++) + { + if (this[i] == item) + { + return i; + } + } + return -1; + } + + public bool Contains(Vector3 item) + { + return this.IndexOf(item) >= 0; + } + + public void CopyTo(Vector3[] array, int arrayIndex) + { + for (int i = 0; i < Count; i++) + { + array[arrayIndex++] = this[i]; + } } void IList.Insert(int index, Vector3 item) { - throw new NotImplementedException(); + throw new NotSupportedException("Collection is fixed size"); } void IList.RemoveAt(int index) { - throw new NotImplementedException(); - } - - Vector3 IList.this[int index] - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } + throw new NotSupportedException("Collection is fixed size"); } void ICollection.Add(Vector3 item) { - throw new NotImplementedException(); + throw new NotSupportedException("Collection is fixed size"); } void ICollection.Clear() { - throw new NotImplementedException(); - } - - bool ICollection.Contains(Vector3 item) - { - throw new NotImplementedException(); - } - - void ICollection.CopyTo(Vector3[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - int ICollection.Count - { - get { throw new NotImplementedException(); } - } - - bool ICollection.IsReadOnly - { - get { throw new NotImplementedException(); } + throw new NotSupportedException("Collection is fixed size"); } bool ICollection.Remove(Vector3 item) { - throw new NotImplementedException(); + throw new NotSupportedException("Collection is fixed size"); } IEnumerator IEnumerable.GetEnumerator() { - throw new NotImplementedException(); + for (int i = 0; i < Count; i++) + { + yield return this[i]; + } + yield break; } IEnumerator IEnumerable.GetEnumerator() { - throw new NotImplementedException(); + for (int i = 0; i < Count; i++) + { + yield return this[i]; + } + yield break; } + #endregion } } diff --git a/ANX.Framework.Content.Pipeline/Graphics/VertexChannel.cs b/ANX.Framework.Content.Pipeline/Graphics/VertexChannel.cs index 4b979d9e..45cc7699 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/VertexChannel.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/VertexChannel.cs @@ -15,163 +15,176 @@ namespace ANX.Framework.Content.Pipeline.Graphics { public abstract class VertexChannel : IList, ICollection, IEnumerable { - - int IList.Add(object value) + #region Properties + public string Name { - throw new NotImplementedException(); + get; + private set; } - void IList.Clear() - { - throw new NotImplementedException(); + protected IList Source + { + get; set; } - bool IList.Contains(object value) + public int Count { - throw new NotImplementedException(); - } - - int IList.IndexOf(object value) - { - throw new NotImplementedException(); - } - - void IList.Insert(int index, object value) - { - throw new NotImplementedException(); - } - - bool IList.IsFixedSize - { - get { throw new NotImplementedException(); } - } - - bool IList.IsReadOnly - { - get { throw new NotImplementedException(); } - } - - void IList.Remove(object value) - { - throw new NotImplementedException(); - } - - void IList.RemoveAt(int index) - { - throw new NotImplementedException(); - } - - object IList.this[int index] - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - - void ICollection.CopyTo(Array array, int index) - { - throw new NotImplementedException(); - } - - int ICollection.Count - { - get { throw new NotImplementedException(); } + get { return Source.Count; } } bool ICollection.IsSynchronized { - get { throw new NotImplementedException(); } + get { return false; } } object ICollection.SyncRoot { - get { throw new NotImplementedException(); } + get { return Source.SyncRoot; } } - IEnumerator IEnumerable.GetEnumerator() + bool IList.IsFixedSize { - throw new NotImplementedException(); + get { return true; } } + + bool IList.IsReadOnly + { + get { return false; } + } + + public object this[int index] + { + get { return Source[index]; } + set { Source[index] = value; } + } + #endregion + + #region Constructor + public VertexChannel(string name) + { + this.Name = name; + } + #endregion + + #region Methods + int IList.Add(object value) + { + throw new NotSupportedException("Size is fixed"); + } + + void IList.Insert(int index, object value) + { + throw new NotSupportedException("Size is fixed"); + } + + void IList.Clear() + { + throw new NotSupportedException("Size is fixed"); + } + + void IList.Remove(object value) + { + throw new NotSupportedException("Size is fixed"); + } + + void IList.RemoveAt(int index) + { + throw new NotSupportedException("Size is fixed"); + } + + public bool Contains(object value) + { + return Source.Contains(value); + } + + public int IndexOf(object value) + { + return Source.IndexOf(value); + } + + public void CopyTo(Array array, int index) + { + Source.CopyTo(array, index); + } + + public IEnumerator GetEnumerator() + { + return Source.GetEnumerator(); + } + #endregion } public sealed class VertexChannel : VertexChannel, IList, ICollection, IEnumerable, IEnumerable { + private List source; - int IList.IndexOf(T item) + #region Properties + public new T this[int index] { - throw new NotImplementedException(); - } - - void IList.Insert(int index, T item) - { - throw new NotImplementedException(); - } - - void IList.RemoveAt(int index) - { - throw new NotImplementedException(); - } - - T IList.this[int index] - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - - void ICollection.Add(T item) - { - throw new NotImplementedException(); - } - - void ICollection.Clear() - { - throw new NotImplementedException(); - } - - bool ICollection.Contains(T item) - { - throw new NotImplementedException(); - } - - void ICollection.CopyTo(T[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - int ICollection.Count - { - get { throw new NotImplementedException(); } + get { return source[index]; } + set { source[index] = value; } } bool ICollection.IsReadOnly { - get { throw new NotImplementedException(); } + get { return false; } + } + #endregion + + #region Constructor + public VertexChannel(string name) + : base(name) + { + source = new List(); + Source = source; + } + #endregion + + #region Methods + void IList.Insert(int index, T item) + { + throw new NotSupportedException("Size is fixed"); + } + + void IList.RemoveAt(int index) + { + throw new NotSupportedException("Size is fixed"); + } + + void ICollection.Add(T item) + { + throw new NotSupportedException("Size is fixed"); + } + + void ICollection.Clear() + { + throw new NotSupportedException("Size is fixed"); } bool ICollection.Remove(T item) { - throw new NotImplementedException(); + throw new NotSupportedException("Size is fixed"); } - IEnumerator IEnumerable.GetEnumerator() + public int IndexOf(T item) { - throw new NotImplementedException(); + return source.IndexOf(item); } - IEnumerator IEnumerable.GetEnumerator() + public bool Contains(T item) { - throw new NotImplementedException(); + return source.Contains(item); } + + public void CopyTo(T[] array, int arrayIndex) + { + source.CopyTo(array, arrayIndex); + } + + public IEnumerator GetEnumerator() + { + return source.GetEnumerator(); + } + #endregion } } diff --git a/ANX.Framework.Content.Pipeline/Graphics/VertexContent.cs b/ANX.Framework.Content.Pipeline/Graphics/VertexContent.cs index c9bcf0ea..61054a32 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/VertexContent.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/VertexContent.cs @@ -35,12 +35,19 @@ namespace ANX.Framework.Content.Pipeline.Graphics public int VertexCount { - get; - private set; + get { return PositionIndices.Count; } + } + + public VertexContent(GeometryContent content) + { + Channels = new VertexChannelCollection(); + PositionIndices = new VertexChannel("PositionIndices"); + Positions = new IndirectPositionCollection(content, PositionIndices); } public int Add(int positionIndex) { + throw new NotImplementedException(); }