Exemplo n.º 1
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying implementation fails or the render
        /// system is not set.</exception>
        public void Read(ISavableReader input)
        {
            IRenderSystemProvider renderSystem = input.RenderSystem;

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;
            String            name    = input.ReadString();
            VertexDeclaration decl    = input.ReadSavable <VertexDeclaration>();
            int           vertexCount = input.ReadInt();
            ResourceUsage usage       = input.ReadEnum <ResourceUsage>();

            byte[] byteBuffer = input.ReadByteArray();

            try {
                _impl      = renderSystem.CreateVertexBufferImplementation(decl, vertexCount, usage);
                _impl.Name = name;
                SetData <byte>(byteBuffer);
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying implementation fails or the render
        /// system is not set.</exception>
        public override void Read(ISavableReader input)
        {
            IRenderSystemProvider renderSystem = input.RenderSystem;

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;

            String        name     = input.ReadString();
            SurfaceFormat format   = input.ReadEnum <SurfaceFormat>();
            int           width    = input.ReadInt();
            int           height   = input.ReadInt();
            int           mipCount = input.ReadInt();

            try {
                _impl = renderSystem.CreateTexture2DImplementation(width, height, mipCount > 1, format, null);
                for (int i = 0; i < mipCount; i++)
                {
                    byte[] byteBuffer = input.ReadByteArray();
                    _impl.SetData <byte>(byteBuffer, i, null, 0, byteBuffer.Length);
                }
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        public virtual void Read(ISavableReader input)
        {
            _name                      = input.ReadString();
            _localTransform            = input.ReadSavable <Transform>();
            _sceneHints                = input.ReadSavable <SceneHints>();
            _sceneHints.HintableSource = this;
            _localLights               = input.ReadSavable <LightCollection>();
            _localLights._spatial      = this;

            bool hasControllers = input.ReadBoolean();

            _controllers = new TeslaList <ISpatialController>(1);

            if (hasControllers)
            {
                ISavable[] savableControllers = input.ReadSavableArray <ISavable>();
                for (int i = 0; i < savableControllers.Length; i++)
                {
                    ISpatialController controller = savableControllers[i] as ISpatialController;
                    if (controller != null)
                    {
                        _controllers.Add(controller);
                    }
                }
            }

            _worldTransform   = new Transform(_localTransform);
            _frustumIntersect = ContainmentType.Intersects;
            _parent           = null;
            _dirtyMark        = DirtyMark.Bounding | DirtyMark.Transform | DirtyMark.Lighting;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying state implementation fails or the render
        /// system is not set.</exception>
        public override void Read(ISavableReader input)
        {
            IRenderSystemProvider renderSystem = input.RenderSystem;

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;
            try {
                _impl = renderSystem.CreateRasterizerStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }

            _impl.Cull                       = input.ReadEnum <CullMode>();
            _impl.VertexWinding              = input.ReadEnum <VertexWinding>();
            _impl.Fill                       = input.ReadEnum <FillMode>();
            _impl.DepthBias                  = input.ReadInt();
            _impl.SlopeScaledDepthBias       = input.ReadSingle();
            _impl.EnableMultiSampleAntiAlias = input.ReadBoolean();
            _impl.EnableScissorTest          = input.ReadBoolean();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Deserializes the transform.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public void Read(ISavableReader input)
 {
     _scale       = input.ReadVector3();
     _rotation    = input.ReadQuaternion();
     _translation = input.ReadVector3();
     //Cache the matrix
     Matrix m = this.Matrix;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Deserializes this OrientedBoundingBox.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public override void Read(ISavableReader input)
 {
     base.Read(input);
     m_extents = input.ReadVector3();
     m_xAxis   = input.ReadVector3();
     m_yAxis   = input.ReadVector3();
     m_zAxis   = input.ReadVector3();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public override void Read(ISavableReader input)
 {
     base.Read(input);
     //  _material = input.ReadExternal<Material>();
     _meshData    = input.ReadSavable <MeshData>();
     _modelBound  = input.ReadSavable <BoundingVolume>();
     _worldLights = new LightCollection();
     SetModelBound(_modelBound);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Deserializes this SceneHints.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public void Read(ISavableReader input)
 {
     _cullHint   = input.ReadEnum <CullHint>();
     _pickHint   = input.ReadEnum <PickingHint>();
     _lightHint  = input.ReadEnum <LightCombineHint>();
     _transHint  = input.ReadEnum <TransparencyType>();
     _bucketType = input.ReadEnum <RenderBucketType>();
     _orthoOrder = input.ReadInt();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Deserializes this Mesh.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public override void Read(ISavableReader input)
 {
     base.Read(input);
     _extents     = input.ReadVector3();
     _center      = input.ReadVector3();
     _xAxis       = input.ReadVector3();
     _yAxis       = input.ReadVector3();
     _zAxis       = input.ReadVector3();
     _insideOut   = input.ReadBoolean();
     _constructed = true;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public override void Read(ISavableReader input)
 {
     base.Read(input);
     m_genMipMaps       = input.ReadBoolean();
     m_genMipMaps       = input.ReadBoolean();
     m_resizePowerOfTwo = input.ReadBoolean();
     m_textureFormat    = input.ReadEnum <TextureConversionFormat>();
     m_colorKey         = input.ReadColor();
     m_colorKeyEnabled  = input.ReadBoolean();
     m_preMultiplyAlpha = input.ReadBoolean();
 }
Exemplo n.º 11
0
 /// <summary>
 /// Deserializes this Light.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public virtual void Read(ISavableReader input)
 {
     _name      = input.ReadString();
     _ambient   = input.ReadColor();
     _diffuse   = input.ReadColor();
     _specular  = input.ReadColor();
     _constant  = input.ReadSingle();
     _linear    = input.ReadSingle();
     _quadratic = input.ReadSingle();
     _attenuate = input.ReadBoolean();
     _enabled   = input.ReadBoolean();
 }
Exemplo n.º 12
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        public void Read(ISavableReader input)
        {
            _vertexStride = input.ReadInt();
            int count = input.ReadInt();

            _elements = new VertexElement[count];
            for (int i = 0; i < count; i++)
            {
                VertexSemantic semantic      = input.ReadEnum <VertexSemantic>();
                int            semanticIndex = input.ReadInt();
                VertexFormat   format        = input.ReadEnum <VertexFormat>();
                int            offset        = input.ReadInt();
                _elements[i] = new VertexElement(semantic, semanticIndex, format, offset);
            }
            GetHashCode();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        public override void Read(ISavableReader input)
        {
            base.Read(input);

            Spatial[] spatials = input.ReadSavableArray <Spatial>();
            _children = new TeslaList <Spatial>();

            for (int i = 0; i < spatials.Length; i++)
            {
                Spatial spatial = spatials[i];
                if (spatial != null)
                {
                    spatial.Parent = this;
                    _children.Add(spatial);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        public virtual void Read(ISavableReader input)
        {
            _name = input.ReadString();
            Vector4 vp    = input.ReadVector4();
            Vector2 depth = input.ReadVector2();

            _viewport          = new Viewport((int)vp.X, (int)vp.Y, (int)vp.Z, (int)vp.W);
            _viewport.MinDepth = depth.X;
            _viewport.MaxDepth = depth.Y;

            _position       = input.ReadVector3();
            _up             = input.ReadVector3();
            _direction      = input.ReadVector3();
            _projectionMode = input.ReadEnum <ProjectionMode>();
            _proj           = input.ReadMatrix();

            Update();
        }
Exemplo n.º 15
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public override void Read(ISavableReader input)
 {
     base.Read(input);
     _normalGen            = input.ReadEnum <NormalGeneration>();
     _creaseAngle          = input.ReadSingle();
     _generateTangentBasis = input.ReadBoolean();
     _swapWindingOrder     = input.ReadBoolean();
     _flipUVs          = input.ReadBoolean();
     _scale            = input.ReadSingle();
     _xAngle           = input.ReadSingle();
     _yAngle           = input.ReadSingle();
     _zAngle           = input.ReadSingle();
     _userMaterialFile = input.ReadString();
     _materialNamesCorrespondToGeometry = input.ReadBoolean();
     _preferLitMaterials = input.ReadBoolean();
     _importLights       = input.ReadBoolean();
     _imageParameters    = input.ReadSavable <ImageLoaderParameters>();
     _texturePath        = input.ReadString();
 }
Exemplo n.º 16
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying state implementation fails or the render
        /// system is not set.</exception>
        public override void Read(ISavableReader input)
        {
            IRenderSystemProvider renderSystem = input.RenderSystem;

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;
            try {
                _impl = renderSystem.CreateSamplerStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
            _impl.AddressU = input.ReadEnum <TextureAddressMode>();
            _impl.AddressV = input.ReadEnum <TextureAddressMode>();
            _impl.AddressW = input.ReadEnum <TextureAddressMode>();
            _impl.Filter   = input.ReadEnum <TextureFilter>();
            _impl.MipMapLevelOfDetailBias = input.ReadSingle();
            _impl.MaxAnisotropy           = input.ReadInt();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Deserializes this Effect.
        /// </summary>
        /// <param name="input">Input to read from</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying effect implementation fails or the render
        /// system is not set.</exception>
        public void Read(ISavableReader input)
        {
            IRenderSystemProvider renderSystem = input.RenderSystem;

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;

            String name = input.ReadString();

            _cachedByteCode = input.ReadByteArray();

            try {
                _impl      = renderSystem.CreateEffectImplementation(_cachedByteCode);
                _impl.Name = name;
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public abstract void Read(ISavableReader input);
Exemplo n.º 19
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public virtual void Read(ISavableReader input)
 {
     _name      = input.ReadString();
     _isEnabled = input.ReadBoolean();
 }
Exemplo n.º 20
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public override void Read(ISavableReader input)
 {
     base.Read(input);
     _materialName = input.ReadString();
 }
Exemplo n.º 21
0
 /// <summary>
 /// Deserializes this BoundingSphere.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public override void Read(ISavableReader input)
 {
     base.Read(input);
     m_radius = input.ReadSingle();
 }
Exemplo n.º 22
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public void Read(ISavableReader input)
 {
     _name = input.ReadString();
     _materials.AddRange(input.ReadSavableArray <Material>());
 }
Exemplo n.º 23
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public virtual void Read(ISavableReader input)
 {
     _overrideCache = input.ReadBoolean();
 }
Exemplo n.º 24
0
 /// <summary>
 /// Deserializes this BoundingVolume.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public virtual void Read(ISavableReader input)
 {
     m_center = input.ReadVector3();
 }
Exemplo n.º 25
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public void Read(ISavableReader input)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 26
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public void Read(ISavableReader input)
 {
     _fileName     = input.ReadString();
     _loaderParams = input.ReadSavable <LoaderParameters>();
 }