Original Post
Hello, I'm currently working on a 2D animation system (C#/SlimDX). I've got things set up so it's used like so:
// Inside "Skeleton.cs", to be loaded from an XML file but for now just part of the default rig.
mRoot.Joint("RightShoulder").Attach(new Bone("UpperArm"));
mRoot.Joint("RightShoulder").Bone("UpperArm").Attach(new Joint("Elbow", new Vector3(0.07f, 0.05f, 0), 45f));
So I can set up skeletons like so, and everything renders properly. The problem is I would like to disallow access to the Position & Rotation properties except within the library by using the internal keyword and strictly provide animation to skeletons through an interface (IAnimation). However, since the user will need to inherit from IAnimation in a different assembly, it will not be able to access either the Position or Rotation of the bones/joints its trying to work on. So far I can think of 3 solutions: 1) Screw marking the properties as internal. This means that users of the library won't be restricted to inheriting from IAnimation to provide animation. I don't like this since it could make things messy if they have bones moving all over the jiff (Code-wise, not animation-wise). Plus it just wouldn't be as cool :). 2) Have Skeleton.Update() accept an array of XML files describing different active animations. I don't like this however as it would be a lot of work (I think) and possibly not as customizable as being able to describe an animation through code. 3) Provide something like a AnimationSkeleton to the user for use within classes which implement IAnimation, then within Skeleton.Update(IAnimation[] a) just do something like:
for each matching Bone/Joint in (Skeleton)this and a.AnimationSkeleton
{ this.Bone.Position += a.AnimationSkeleton.Bone.Position; }
// Note: It's += so multiple animation will sort of blend together.
But thats just silly, isn't it? Anyway, does anyone have any solutions, recommendations or insights into this problem :)? I have a feeling the C++ friend keyword would come in handy here, but I'm not sure. Either way C# doesn't have it so :'(. Thanks!