/// <summary> /// Function to save the animation to a stream. /// </summary> /// <param name="stream">Stream to write the animation into.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="stream"/> parameter is NULL (Nothing in VB.Net).</exception> public void Save(Stream stream) { GorgonDebug.AssertNull(stream, "stream"); using (var chunk = new GorgonChunkWriter(stream)) { chunk.Begin(GorgonAnimationController <T> .AnimationVersion); // Write out animation header data. chunk.Begin("ANIMDATA"); chunk.WriteString(AnimationController.AnimatedObjectType.FullName); chunk.WriteString(Name); chunk.WriteFloat(Length); chunk.WriteBoolean(IsLooped); chunk.End(); // Put out the tracks with the most keys first. var activeTracks = from GorgonAnimationTrack <T> track in Tracks where track.KeyFrames.Count > 0 orderby track.KeyFrames.Count select track; foreach (var track in activeTracks) { if (track.KeyFrames.Count <= 0) { continue; } chunk.Begin("TRCKDATA"); track.ToChunk(chunk); chunk.End(); } } }
/// <summary> /// Function to send the key frame data to the data chunk. /// </summary> /// <param name="chunk">Chunk to write.</param> void IKeyFrame.ToChunk(GorgonChunkWriter chunk) { chunk.WriteFloat(Time); chunk.WriteBoolean(Value != null); chunk.WriteRectangle(TextureRegion); if (Value == null) { return; } chunk.WriteString(Value.Name); chunk.WriteInt32(Value.Settings.ArrayCount); chunk.Write(Value.Settings.Format); chunk.WriteSize(Value.Settings.Size); chunk.WriteBoolean(Value.Settings.IsTextureCube); chunk.WriteInt32(Value.Settings.MipCount); chunk.WriteInt32(Value.Settings.Multisampling.Count); chunk.WriteInt32(Value.Settings.Multisampling.Quality); }
/// <summary> /// Function to send the key frame data to the data chunk. /// </summary> /// <param name="chunk">Chunk to write.</param> void IKeyFrame.ToChunk(GorgonChunkWriter chunk) { chunk.WriteFloat(Time); chunk.WriteInt16(Value); }
/// <summary> /// Function to write the collider information into a chunk. /// </summary> /// <param name="writer">The writer for the chunk.</param> /// <remarks> /// This method must be implemented to write out collider information to a stream (e.g. saving a sprite with collider information). /// <para>The format is as follows: Write the full type name of the collider, then any relevant information pertaining the collider (e.g. location, width, height, etc...).</para> /// <para>This method assumes the chunk writer has already started the collider chunk.</para> /// </remarks> protected internal override void WriteToChunk(GorgonChunkWriter writer) { writer.WriteString(GetType().FullName); writer.Write(Center); writer.WriteFloat(Radius); }
/// <summary> /// Function to write the interpolation value to a chunk writer. /// </summary> internal void WriteChunk(GorgonChunkWriter writer) { writer.WriteFloat(Weight); writer.Write(Color); }