Exemplo n.º 1
0
        /*
         * Store
         */


        public void Store(IOutputStream o, FScene scene)
        {
            o.BeginScene(IOStrings.CurrentSceneVersion);

            foreach (SceneObject so in scene.SceneObjects)
            {
                if (so.IsTemporary)
                {
                    continue;
                }

                o.BeginSceneObject();

                string typeIdentifier = so.Type.identifier;

                // serialize custom types if client has registered a serializer
                bool bEmitted = false;
                if (scene.TypeRegistry.ContainsType(typeIdentifier))
                {
                    SOEmitSerializationFunc emitter = scene.TypeRegistry.FindSerializer(typeIdentifier);
                    if (emitter != null)
                    {
                        bEmitted = emitter(this, o, so);
                    }
                }

                if (bEmitted == false)
                {
                    // otherwise fall back to default handlers.
                    // Currently these are extension methods in SceneSerializerEmitTypes.cs
                    if (so is CylinderSO)
                    {
                        this.Emit(o, so as CylinderSO);
                    }
                    else if (so is BoxSO)
                    {
                        this.Emit(o, so as BoxSO);
                    }
                    else if (so is SphereSO)
                    {
                        this.Emit(o, so as SphereSO);
                    }
                    else if (so is PivotSO)
                    {
                        this.Emit(o, so as PivotSO);
                    }
                    else if (so is MeshSO)
                    {
                        this.Emit(o, so as MeshSO);
                    }
                    else if (so is MeshReferenceSO)
                    {
                        this.Emit(o, so as MeshReferenceSO);
                    }

                    else if (so is PolyTubeSO)
                    {
                        this.Emit(o, so as PolyTubeSO);
                    }
                    else if (so is PolyCurveSO)
                    {
                        this.Emit(o, so as PolyCurveSO);
                    }

                    else if (so is TransformableSO)
                    {
                        this.Emit(o, so as TransformableSO);
                    }
                    else
                    {
                        this.EmitUnknown(o, so);
                    }
                }

                o.EndSceneObject();
            }


            o.EndScene();
        }