Ejemplo n.º 1
0
        internal static W3dEmitterInfo Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                return new W3dEmitterInfo
                {
                    TextureFileName = reader.ReadFixedLengthString(TextureFileNameLength),
                    StartSize = reader.ReadSingle(),
                    EndSize = reader.ReadSingle(),
                    Lifetime = reader.ReadSingle(),
                    EmissionRate = reader.ReadSingle(),
                    MaxEmissions = reader.ReadSingle(),
                    VelocityRandom = reader.ReadSingle(),
                    PositionRandom = reader.ReadSingle(),
                    FadeTime = reader.ReadSingle(),
                    Gravity = reader.ReadSingle(),
                    Elasticity = reader.ReadSingle(),

                    Velocity = reader.ReadVector3(),
                    Acceleration = reader.ReadVector3(),

                    StartColor = W3dRgba.Parse(reader),
                    EndColor = W3dRgba.Parse(reader)
                };
            }));
        }
Ejemplo n.º 2
0
        public static W3dEmitterProperties Parse(BinaryReader reader)
        {
            var result = new W3dEmitterProperties
            {
                ColorKeyframesCount   = reader.ReadUInt32(),
                OpacityKeyframesCount = reader.ReadUInt32(),
                SizeKeyframesCount    = reader.ReadUInt32(),
                ColorRandom           = W3dRgba.Parse(reader),
                OpacityRandom         = reader.ReadSingle(),
                SizeRandom            = reader.ReadSingle()
            };

            reader.ReadBytes(4 * sizeof(uint)); // Pad

            result.ColorKeyframes = new W3dEmitterColorKeyframe[result.ColorKeyframesCount];
            for (var i = 0; i < result.ColorKeyframesCount; i++)
            {
                result.ColorKeyframes[i] = W3dEmitterColorKeyframe.Parse(reader);
            }

            result.OpacityKeyframes = new W3dEmitterOpacityKeyframe[result.OpacityKeyframesCount];
            for (var i = 0; i < result.OpacityKeyframesCount; i++)
            {
                result.OpacityKeyframes[i] = W3dEmitterOpacityKeyframe.Parse(reader);
            }

            result.SizeKeyframes = new W3dEmitterSizeKeyframe[result.SizeKeyframesCount];
            for (var i = 0; i < result.SizeKeyframesCount; i++)
            {
                result.SizeKeyframes[i] = W3dEmitterSizeKeyframe.Parse(reader);
            }

            return(result);
        }
Ejemplo n.º 3
0
 internal static W3dEmitterColorKeyframe Parse(BinaryReader reader)
 {
     return(new W3dEmitterColorKeyframe
     {
         Time = reader.ReadSingle(),
         Color = W3dRgba.Parse(reader)
     });
 }
Ejemplo n.º 4
0
        public static W3dEmitterInfo Parse(BinaryReader reader)
        {
            return(new W3dEmitterInfo
            {
                TextureFileName = reader.ReadFixedLengthString(260),
                StartSize = reader.ReadSingle(),
                EndSize = reader.ReadSingle(),
                Lifetime = reader.ReadSingle(),
                EmissionRate = reader.ReadSingle(),
                MaxEmissions = reader.ReadSingle(),
                VelocityRandom = reader.ReadSingle(),
                PositionRandom = reader.ReadSingle(),
                FadeTime = reader.ReadSingle(),
                Gravity = reader.ReadSingle(),
                Elasticity = reader.ReadSingle(),

                Velocity = reader.ReadVector3(),
                Acceleration = reader.ReadVector3(),

                StartColor = W3dRgba.Parse(reader),
                EndColor = W3dRgba.Parse(reader)
            });
        }
Ejemplo n.º 5
0
        public static W3dMaterialPass Parse(BinaryReader reader, uint chunkSize)
        {
            var textureStages = new List <W3dTextureStage>();

            var r = ParseChunk <W3dMaterialPass>(reader, chunkSize, (result, header) =>
            {
                switch (header.ChunkType)
                {
                case W3dChunkType.W3D_CHUNK_VERTEX_MATERIAL_IDS:
                    result.VertexMaterialIds = new uint[header.ChunkSize / sizeof(uint)];
                    for (var count = 0; count < result.VertexMaterialIds.Length; count++)
                    {
                        result.VertexMaterialIds[count] = reader.ReadUInt32();
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_SHADER_IDS:
                    result.ShaderIds = new uint[header.ChunkSize / sizeof(uint)];
                    for (var count = 0; count < result.ShaderIds.Length; count++)
                    {
                        result.ShaderIds[count] = reader.ReadUInt32();
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_DCG:
                    result.Dcg = new W3dRgba[header.ChunkSize / W3dRgba.SizeInBytes];
                    for (var count = 0; count < result.Dcg.Length; count++)
                    {
                        result.Dcg[count] = W3dRgba.Parse(reader);
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_DIG:
                    result.Dig = new W3dRgba[header.ChunkSize / W3dRgba.SizeInBytes];
                    for (var count = 0; count < result.Dig.Length; count++)
                    {
                        result.Dig[count] = W3dRgba.Parse(reader);
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_SCG:
                    result.Scg = new W3dRgba[header.ChunkSize / W3dRgba.SizeInBytes];
                    for (var count = 0; count < result.Scg.Length; count++)
                    {
                        result.Scg[count] = W3dRgba.Parse(reader);
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_TEXTURE_STAGE:
                    textureStages.Add(W3dTextureStage.Parse(reader, header.ChunkSize));
                    break;

                case W3dChunkType.W3D_CHUNK_SHADER_MATERIAL_ID:
                    if (header.ChunkSize != sizeof(uint))
                    {
                        // TODO: If this is thrown: this is probably an array of IDs?
                        throw new InvalidDataException();
                    }
                    result.ShaderMaterialId = reader.ReadUInt32();
                    break;

                // Normally this appears inside W3dTextureStage, but it can also
                // appear directly under W3dMaterialPass if using shader materials.
                case W3dChunkType.W3D_CHUNK_STAGE_TEXCOORDS:
                    result.TexCoords = new Vector2[header.ChunkSize / (sizeof(float) * 2)];
                    for (var count = 0; count < result.TexCoords.Length; count++)
                    {
                        result.TexCoords[count] = reader.ReadVector2();
                    }
                    break;

                default:
                    throw CreateUnknownChunkException(header);
                }
            });

            r.TextureStages = textureStages;

            return(r);
        }