From 90d8c6d2ad973d052c37baf7b208a54e1fc48784 Mon Sep 17 00:00:00 2001 From: "SND\\GinieDp_cp" Date: Sat, 25 Aug 2012 21:47:03 +0000 Subject: [PATCH] Filled missing implementations in - ChildCollection - AnimationChannel - BoneContent - GeometryContent and Collection - MeshContent - NodeContent and Collection --- .../ChildCollection.cs | 49 +++++++++++++++---- .../Graphics/AnimationChannel.cs | 40 +++++++-------- .../Graphics/BoneContent.cs | 2 - .../Graphics/GeometryContent.cs | 9 ++-- .../Graphics/GeometryContentCollection.cs | 3 +- .../Graphics/MeshContent.cs | 12 +++-- .../Graphics/NodeContent.cs | 21 +++++--- .../Graphics/NodeContentCollection.cs | 4 +- 8 files changed, 92 insertions(+), 48 deletions(-) diff --git a/ANX.Framework.Content.Pipeline/ChildCollection.cs b/ANX.Framework.Content.Pipeline/ChildCollection.cs index 89e7ef9d..c3cca5a2 100644 --- a/ANX.Framework.Content.Pipeline/ChildCollection.cs +++ b/ANX.Framework.Content.Pipeline/ChildCollection.cs @@ -15,39 +15,70 @@ namespace ANX.Framework.Content.Pipeline { public abstract class ChildCollection : Collection where TParent : class where TChild : class { + TParent parent; + protected ChildCollection(TParent parent) { - throw new NotImplementedException(); + if (parent == null) + { + throw new ArgumentNullException("parent"); + } + this.parent = parent; } protected override void ClearItems() { + foreach (var child in this) + { + this.SetParent(child, default(TParent)); + } base.ClearItems(); - - throw new NotImplementedException(); } protected abstract TParent GetParent(TChild child); protected override void InsertItem(int index, TChild item) { + if (item == null) + { + throw new ArgumentNullException("item"); + } + if (this.GetParent(item) != null) + { + throw new ArgumentException("item already has a parent item"); + } base.InsertItem(index, item); - - throw new NotImplementedException(); + this.SetParent(item, this.parent); } protected override void RemoveItem(int index) { + var child = base[index]; + this.SetParent(child, default(TParent)); base.RemoveItem(index); - - throw new NotImplementedException(); } protected override void SetItem(int index, TChild item) { - base.SetItem(index, item); + if (item == null) + { + throw new ArgumentNullException("item"); + } - throw new NotImplementedException(); + var child = base[index]; + if (child == item) + { + return; + } + + if (this.GetParent(item) != null) + { + throw new ArgumentException("item already has a parent item"); + } + + base.SetItem(index, item); + this.SetParent(item, parent); + this.SetParent(child, default(TParent)); } protected abstract void SetParent(TChild child, TParent parent); diff --git a/ANX.Framework.Content.Pipeline/Graphics/AnimationChannel.cs b/ANX.Framework.Content.Pipeline/Graphics/AnimationChannel.cs index aa4c8b04..b8b21f7c 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/AnimationChannel.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/AnimationChannel.cs @@ -15,80 +15,80 @@ namespace ANX.Framework.Content.Pipeline.Graphics { public sealed class AnimationChannel : ICollection, IEnumerable, IEnumerable { + List frames = new List(); + public AnimationChannel() { - throw new NotImplementedException(); + } public int Count { - get - { - throw new NotImplementedException(); - } + get { return frames.Count; } } public AnimationKeyframe this[int index] { - get - { - throw new NotImplementedException(); - } + get { return frames[index]; } } public void Add(AnimationKeyframe item) { - throw new NotImplementedException(); + if (item == null) + { + throw new ArgumentNullException("item"); + } + frames.Add(item); } public void Clear() { - throw new NotImplementedException(); + frames.Clear(); } public bool Contains(AnimationKeyframe item) { - throw new NotImplementedException(); + return frames.Contains(item); } public IEnumerator GetEnumerator() { - throw new NotImplementedException(); + return frames.GetEnumerator(); } public int IndexOf(AnimationKeyframe item) { - throw new NotImplementedException(); + return frames.IndexOf(item); } public bool Remove(AnimationKeyframe item) { - throw new NotImplementedException(); + return frames.Remove(item); } public void RemoveAt(int index) { - throw new NotImplementedException(); + frames.RemoveAt(index); } bool ICollection.IsReadOnly { - get { throw new NotImplementedException(); } + get { return false; } } void ICollection.Add(AnimationKeyframe item) { - throw new NotImplementedException(); + frames.Add(item); } void ICollection.CopyTo(AnimationKeyframe[] array, int arrayIndex) { - throw new NotImplementedException(); + frames.CopyTo(array, arrayIndex); } IEnumerator System.Collections.IEnumerable.GetEnumerator() { - throw new NotImplementedException(); + return frames.GetEnumerator(); } } } diff --git a/ANX.Framework.Content.Pipeline/Graphics/BoneContent.cs b/ANX.Framework.Content.Pipeline/Graphics/BoneContent.cs index ff1e1d4c..aff0e6b9 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/BoneContent.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/BoneContent.cs @@ -17,7 +17,5 @@ namespace ANX.Framework.Content.Pipeline.Graphics public BoneContent() { } - - } } diff --git a/ANX.Framework.Content.Pipeline/Graphics/GeometryContent.cs b/ANX.Framework.Content.Pipeline/Graphics/GeometryContent.cs index b43d44d1..70f2f786 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/GeometryContent.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/GeometryContent.cs @@ -14,9 +14,6 @@ namespace ANX.Framework.Content.Pipeline.Graphics { public class GeometryContent : ContentItem { - public GeometryContent() - { - } public IndexCollection Indices { @@ -41,5 +38,11 @@ namespace ANX.Framework.Content.Pipeline.Graphics get; private set; } + + public GeometryContent() + { + Indices = new IndexCollection(); + Vertices = new VertexContent(); + } } } diff --git a/ANX.Framework.Content.Pipeline/Graphics/GeometryContentCollection.cs b/ANX.Framework.Content.Pipeline/Graphics/GeometryContentCollection.cs index 0453d5dd..90d85a65 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/GeometryContentCollection.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/GeometryContentCollection.cs @@ -9,10 +9,9 @@ namespace ANX.Framework.Content.Pipeline.Graphics public sealed class GeometryContentCollection : ChildCollection { - protected GeometryContentCollection(MeshContent parent) + public GeometryContentCollection(MeshContent parent) : base(parent) { - throw new NotImplementedException(); } protected override MeshContent GetParent(GeometryContent child) diff --git a/ANX.Framework.Content.Pipeline/Graphics/MeshContent.cs b/ANX.Framework.Content.Pipeline/Graphics/MeshContent.cs index 66b89f18..786d909a 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/MeshContent.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/MeshContent.cs @@ -14,10 +14,6 @@ namespace ANX.Framework.Content.Pipeline.Graphics { public class MeshContent : NodeContent { - public MeshContent() - { - } - public GeometryContentCollection Geometry { get; @@ -29,5 +25,13 @@ namespace ANX.Framework.Content.Pipeline.Graphics get; private set; } + + public MeshContent() + { + Geometry = new GeometryContentCollection(this); + Positions = new PositionCollection(); + } + + } } diff --git a/ANX.Framework.Content.Pipeline/Graphics/NodeContent.cs b/ANX.Framework.Content.Pipeline/Graphics/NodeContent.cs index e562bebb..e33dbd2b 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/NodeContent.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/NodeContent.cs @@ -14,14 +14,16 @@ namespace ANX.Framework.Content.Pipeline.Graphics { public class NodeContent : ContentItem { - public NodeContent() - { - } - public Matrix AbsolutTransform { - get; - private set; + get + { + if (Parent != null) + { + return this.Transform * Parent.AbsolutTransform; + } + return this.Transform; + } } public AnimationContentDictionary Animation @@ -47,5 +49,12 @@ namespace ANX.Framework.Content.Pipeline.Graphics get; set; } + + public NodeContent() + { + Transform = Matrix.Identity; + Animation = new AnimationContentDictionary(); + Children = new NodeContentCollection(this); + } } } diff --git a/ANX.Framework.Content.Pipeline/Graphics/NodeContentCollection.cs b/ANX.Framework.Content.Pipeline/Graphics/NodeContentCollection.cs index b172e778..3a854245 100644 --- a/ANX.Framework.Content.Pipeline/Graphics/NodeContentCollection.cs +++ b/ANX.Framework.Content.Pipeline/Graphics/NodeContentCollection.cs @@ -21,12 +21,12 @@ namespace ANX.Framework.Content.Pipeline.Graphics protected override NodeContent GetParent(NodeContent child) { - throw new NotImplementedException(); + return child.Parent; } protected override void SetParent(NodeContent child, NodeContent parent) { - throw new NotImplementedException(); + child.Parent = parent; } } }