Example #1
0
 /// <summary>
 /// Function to write the brush elements out to a chunked file.
 /// </summary>
 /// <param name="chunk">Chunk writer used to persist the data.</param>
 internal override void Write(GorgonChunkWriter chunk)
 {
     chunk.Begin("BRSHDATA");
     chunk.Write(BrushType);
     chunk.Write(Color);
     chunk.End();
 }
Example #2
0
 /// <summary>
 /// Function to write the brush elements out to a chunked file.
 /// </summary>
 /// <param name="chunk">Chunk writer used to persist the data.</param>
 internal override void Write(GorgonChunkWriter chunk)
 {
     chunk.Begin("BRSHDATA");
     chunk.Write(BrushType);
     chunk.Write(HatchStyle);
     chunk.Write(ForegroundColor);
     chunk.Write(BackgroundColor);
     chunk.End();
 }
        /// <summary>
        /// Function to write the brush elements out to a chunked file.
        /// </summary>
        /// <param name="chunk">Chunk writer used to persist the data.</param>
        internal override void Write(GorgonChunkWriter chunk)
        {
            chunk.Begin("BRSHDATA");
            chunk.Write(BrushType);
            chunk.Write(GammaCorrection);
            chunk.Write(Angle);
            chunk.Write(ScaleAngle);

            chunk.Write(Interpolation.Count);

            foreach (GorgonGlyphBrushInterpolator interpolation in Interpolation)
            {
                interpolation.WriteChunk(chunk);
            }

            chunk.End();
        }
Example #4
0
        /// <summary>
        /// Function to write the track data to a data chunk.
        /// </summary>
        /// <param name="chunk">Chunk to write.</param>
        internal void ToChunk(GorgonChunkWriter chunk)
        {
            chunk.WriteString(Name);
            chunk.Write(InterpolationMode);

            foreach (IKeyFrame keyFrame in KeyFrames)
            {
                chunk.Begin("KEYFRAME");
                keyFrame.ToChunk(chunk);
                chunk.End();
            }
        }
Example #5
0
        /// <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);
        }
Example #6
0
        /// <summary>
        /// Function to write the brush elements out to a chunked file.
        /// </summary>
        /// <param name="chunk">Chunk writer used to persist the data.</param>
        internal override void Write(GorgonChunkWriter chunk)
        {
            // We have no texture.
            if (Texture == null)
            {
                return;
            }

            chunk.Begin("BRSHDATA");
            chunk.Write(BrushType);
            chunk.Write(WrapMode);

            chunk.WriteRectangle(TextureRegion);
            chunk.WriteString(_texture.Name);
            chunk.Write(_texture.Settings.Width);
            chunk.Write(_texture.Settings.Height);
            chunk.Write(_texture.Settings.Format);
            chunk.Write(_texture.Settings.ArrayCount);
            chunk.Write(_texture.Settings.MipCount);

            chunk.End();
        }
Example #7
0
 /// <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.Write(Value);
 }
Example #8
0
        /// <summary>
        /// Function to save the sprite data into a stream.
        /// </summary>
        /// <param name="stream">Stream that is used to write out the sprite data.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="stream"/> parameter is NULL (Nothing in VB.Net).</exception>
        /// <exception cref="System.IO.IOException">Thrown when the stream parameter is not opened for writing data.</exception>
        public void Save(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (!stream.CanWrite)
            {
                throw new IOException(Resources.GOR2D_STREAM_READ_ONLY);
            }

            // Chunk the file.
            using (var chunk = new GorgonChunkWriter(stream))
            {
                // Write anchor information.
                chunk.Begin(FileHeader);

                chunk.Begin("SPRTDATA");
                chunk.Write(Anchor);
                chunk.Write(Size);
                chunk.WriteBoolean(HorizontalFlip);
                chunk.WriteBoolean(VerticalFlip);

                // Write vertex colors.
                for (int i = 0; i < Vertices.Length; i++)
                {
                    chunk.Write(Vertices[i].Color);
                }

                // Write vertex offsets.
                chunk.WriteRange(_offsets);
                chunk.End();

                // Write rendering information.
                chunk.Begin("RNDRDATA");
                chunk.Write(CullingMode);
                chunk.Write(AlphaTestValues);
                chunk.Write(Blending.AlphaOperation);
                chunk.Write(Blending.BlendOperation);
                chunk.Write(Blending.BlendFactor);
                chunk.Write(Blending.DestinationAlphaBlend);
                chunk.Write(Blending.DestinationBlend);
                chunk.Write(Blending.SourceAlphaBlend);
                chunk.Write(Blending.SourceBlend);
                chunk.Write(Blending.WriteMask);
                chunk.Write(DepthStencil.BackFace.ComparisonOperator);
                chunk.Write(DepthStencil.BackFace.DepthFailOperation);
                chunk.Write(DepthStencil.BackFace.FailOperation);
                chunk.Write(DepthStencil.BackFace.PassOperation);
                chunk.Write(DepthStencil.FrontFace.ComparisonOperator);
                chunk.Write(DepthStencil.FrontFace.DepthFailOperation);
                chunk.Write(DepthStencil.FrontFace.FailOperation);
                chunk.Write(DepthStencil.FrontFace.PassOperation);
                chunk.WriteInt32(DepthStencil.DepthBias);
                chunk.Write(DepthStencil.DepthComparison);
                chunk.WriteInt32(DepthStencil.StencilReference);
                chunk.WriteBoolean(DepthStencil.IsDepthWriteEnabled);
                chunk.WriteByte(DepthStencil.StencilReadMask);
                chunk.WriteByte(DepthStencil.StencilWriteMask);
                chunk.End();

                // Write collider information.
                if (_collider != null)
                {
                    chunk.Begin("COLLIDER");
                    _collider.WriteToChunk(chunk);
                    chunk.End();
                }

                // Write texture information.
                if (string.IsNullOrWhiteSpace(DeferredTextureName))
                {
                    return;
                }

                chunk.Begin("TXTRDATA");
                chunk.Write(TextureSampler.BorderColor);
                chunk.Write(TextureSampler.HorizontalWrapping);
                chunk.Write(TextureSampler.VerticalWrapping);
                chunk.Write(TextureSampler.TextureFilter);
                chunk.WriteString(DeferredTextureName);
                chunk.WriteRectangle(TextureRegion);
                chunk.End();
            }
        }
        /// <summary>
        /// Function to write the brush elements out to a chunked file.
        /// </summary>
        /// <param name="chunk">Chunk writer used to persist the data.</param>
        internal override void Write(GorgonChunkWriter chunk)
        {
            chunk.Begin("BRSHDATA");
            chunk.Write(BrushType);
            chunk.Write(WrapMode);
            chunk.Write(Points.Count);

            foreach (Vector2 point in Points)
            {
                chunk.Write(point);
            }

            chunk.Write(BlendFactors.Count);

            foreach (float factor in BlendFactors)
            {
                chunk.Write(factor);
            }

            chunk.Write(BlendPositions.Count);

            foreach (float position in BlendPositions)
            {
                chunk.Write(position);
            }

            chunk.Write(CenterColor);
            chunk.Write(CenterPoint);
            chunk.Write(FocusScales);

            chunk.Write(Interpolation.Count);

            foreach (GorgonGlyphBrushInterpolator interpolator in Interpolation)
            {
                interpolator.WriteChunk(chunk);
            }

            chunk.Write(SurroundColors.Count);

            foreach (GorgonColor color in SurroundColors)
            {
                chunk.Write(color);
            }

            chunk.End();
        }
Example #10
0
 /// <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);
 }
Example #11
0
 /// <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(Location);
     writer.Write(Size);
 }
Example #12
0
 /// <summary>
 /// Function to write the interpolation value to a chunk writer.
 /// </summary>
 internal void WriteChunk(GorgonChunkWriter writer)
 {
     writer.WriteFloat(Weight);
     writer.Write(Color);
 }