/// <summary> /// Constructs a new Animation. /// </summary> /// <param name="animation">Unmanaged AiAnimation.</param> internal Animation(AiAnimation animation) { _name = animation.Name.GetString(); _duration = animation.Duration; _ticksPerSecond = animation.TicksPerSecond; //Load node animations if(animation.NumChannels > 0 && animation.Channels != IntPtr.Zero) { AiNodeAnim[] nodeAnims = MemoryHelper.MarshalArray<AiNodeAnim>(animation.Channels, (int) animation.NumChannels, true); _channels = new NodeAnimationChannel[nodeAnims.Length]; for(int i = 0; i < _channels.Length; i++) { _channels[i] = new NodeAnimationChannel(nodeAnims[i]); } } //Load mesh animations if(animation.NumMeshChannels > 0 && animation.MeshChannels != IntPtr.Zero) { AiMeshAnim[] meshAnims = MemoryHelper.MarshalArray<AiMeshAnim>(animation.MeshChannels, (int) animation.NumMeshChannels, true); _meshChannels = new MeshAnimationChannel[meshAnims.Length]; for(int i = 0; i < _meshChannels.Length; i++) { _meshChannels[i] = new MeshAnimationChannel(meshAnims[i]); } } }
void TestAnimationChannel(MeshAnimationChannel netChannel, MeshAnim sharpChannel) { Assert.AreEqual(netChannel.MeshName, sharpChannel.Name); Assert.AreEqual(netChannel.MeshKeyCount, sharpChannel.Keys.Length); for(int i=0; i<netChannel.MeshKeyCount; i++) { Assert.AreEqual(netChannel.MeshKeys[i].Time, sharpChannel.Keys[i].Time); Assert.AreEqual(netChannel.MeshKeys[i].Value, sharpChannel.Keys[i].Value); } }