Exemplo n.º 1
0
 /// <summary>
 /// Deserializes the object and populates it from the input.
 /// </summary>
 /// <param name="input">Savable input</param>
 public void Read(Content.ISavableReader input)
 {
     _globalAmbient = input.ReadColor();
     _maxLights     = input.ReadInt();
     _isEnabled     = input.ReadBoolean();
     _lights        = input.ReadSavableArray <Light>();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Deserializes this SpotLight.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public override void Read(Content.ISavableReader input)
 {
     base.Read(input);
     _lightType  = (LightType)input.ReadInt();
     _direction  = input.ReadVector3();
     _position   = input.ReadVector3();
     _innerAngle = input.ReadSingle();
     _outerAngle = input.ReadSingle();
 }
Exemplo n.º 3
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(Content.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.CreateBlendStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }

            _impl.AlphaBlendFunction    = input.ReadEnum <BlendFunction>();
            _impl.AlphaSourceBlend      = input.ReadEnum <Blend>();
            _impl.AlphaDestinationBlend = input.ReadEnum <Blend>();

            _impl.ColorBlendFunction    = input.ReadEnum <BlendFunction>();
            _impl.ColorSourceBlend      = input.ReadEnum <Blend>();
            _impl.ColorDestinationBlend = input.ReadEnum <Blend>();

            _impl.BlendFactor     = input.ReadColor();
            _impl.MultiSampleMask = input.ReadInt();

            int numBlends = _impl.BlendEnableCount;
            int numMasks  = _impl.ColorWriteChannelsCount;

            //Need to be careful here, this can change across different implementations. Just read in what we can and move on.
            int readNumBlends = input.ReadInt();

            for (int i = 0; i < numBlends; i++)
            {
                _impl.SetBlendEnable(i, input.ReadBoolean());
            }

            int readNumMasks = input.ReadInt();

            for (int i = 0; i < numMasks; i++)
            {
                _impl.SetWriteChannels(i, (ColorWriteChannels)input.ReadInt());
            }
        }
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(Content.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.CreateDepthStencilStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }

            _impl.DepthEnable      = input.ReadBoolean();
            _impl.DepthWriteEnable = input.ReadBoolean();
            _impl.DepthFunction    = input.ReadEnum <ComparisonFunction>();
            _impl.StencilEnable    = input.ReadBoolean();
            _impl.ReferenceStencil = input.ReadInt();
            _impl.CounterClockwiseStencilFunction  = input.ReadEnum <ComparisonFunction>();
            _impl.CounterClockwiseStencilDepthFail = input.ReadEnum <StencilOperation>();
            _impl.CounterClockwiseStencilFail      = input.ReadEnum <StencilOperation>();
            _impl.CounterClockwiseStencilPass      = input.ReadEnum <StencilOperation>();
            _impl.StencilFunction       = input.ReadEnum <ComparisonFunction>();
            _impl.StencilDepthFail      = input.ReadEnum <StencilOperation>();
            _impl.StencilFail           = input.ReadEnum <StencilOperation>();
            _impl.StencilPass           = input.ReadEnum <StencilOperation>();
            _impl.TwoSidedStencilEnable = input.ReadBoolean();
            _impl.StencilReadMask       = input.ReadInt();
            _impl.StencilWriteMask      = input.ReadInt();

            this.BindRenderState();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Deserializes this PointLight.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public override void Read(Content.ISavableReader input)
 {
     base.Read(input);
     _lightType = (LightType)input.ReadInt();
     _position  = input.ReadVector3();
 }