Exemple #1
0
        internal static W3dEmitter Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dEmitter();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_EMITTER_HEADER:
                        result.Header = W3dEmitterHeader.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_USER_DATA:
                        result.UserData = W3dEmitterUserData.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_INFO:
                        result.Info = W3dEmitterInfo.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_INFOV2:
                        result.InfoV2 = W3dEmitterInfoV2.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_PROPS:
                        result.Properties = W3dEmitterProperties.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_ROTATION_KEYFRAMES:
                        result.RotationKeyframes = W3dEmitterRotationKeyframes.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_FRAME_KEYFRAMES:
                        result.FrameKeyframes = W3dEmitterFrameKeyframes.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_LINE_PROPERTIES:
                        result.LineProperties = W3dEmitterLineProperties.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_BLUR_TIME_KEYFRAMES:
                        result.BlurTimeKeyframes = W3dEmitterBlurTimeKeyframes.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_EXTRA_INFO:
                        result.ExtraInfo = W3dEmitterExtraInfo.Parse(reader, context);
                        break;

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

                return result;
            }));
        }
Exemple #2
0
        private static W3dFile Parse(BinaryReader reader, string filePath)
        {
            var context = new W3dParseContext();

            context.PushChunk(nameof(W3dFile), reader.BaseStream.Length);

            var result = new W3dFile
            {
                FilePath = filePath
            };

            W3dContainerChunk.ParseChunks(reader, reader.BaseStream.Length, chunkType =>
            {
                switch (chunkType)
                {
                case W3dChunkType.W3D_CHUNK_MESH:
                    result.Chunks.Add(W3dMesh.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_BOX:
                    result.Chunks.Add(W3dBox.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_HIERARCHY:
                    result.Chunks.Add(W3dHierarchyDef.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_HLOD:
                    result.Chunks.Add(W3dHLod.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_ANIMATION:
                    result.Chunks.Add(W3dAnimation.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_COMPRESSED_ANIMATION:
                    result.Chunks.Add(W3dCompressedAnimation.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_EMITTER:
                    result.Chunks.Add(W3dEmitter.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_AGGREGATE:
                    result.Chunks.Add(W3dAggregate.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_RING:
                    result.Chunks.Add(W3dRing.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_SPHERE:
                    result.Chunks.Add(W3dSphere.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_HMODEL:
                    result.Chunks.Add(W3dHModel.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_DAZZLE:
                    result.Chunks.Add(W3dDazzle.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_COLLECTION:
                    result.Chunks.Add(W3dCollection.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_SOUNDROBJ:
                    result.Chunks.Add(W3dSoundRObj.Parse(reader, context));
                    break;

                case W3dChunkType.W3D_CHUNK_MORPH_ANIMATION:
                    result.Chunks.Add(W3dMorphAnimation.Parse(reader, context));
                    break;

                default:
                    throw W3dContainerChunk.CreateUnknownChunkException(chunkType);
                }
            });

            context.PopAsset();

            return(result);
        }