public override void Draw()
        {
            PrivateRendererContext.EnableDepthTest(false);

            if (InputSlots[0].SlotTexture == null)
                return;

            if (InputSlots[1].SlotTexture.Width != OutputTexture.Width || InputSlots[1].SlotTexture.Height != OutputTexture.Height)
            {
                OutputTexture.Resize(InputSlots[1].SlotTexture.Width, InputSlots[1].SlotTexture.Height);
            }

            PrivateRendererContext.Clear(Math.Color4.Black);

            Sprite spr = new Sprite();
            spr.Init(InputSlots[0].SlotTexture);

            NodeEffect.PixelProgram.SetUniform(NodeEffect.PixelProgram.GetUniformLocation("Texture1"), 0);
            NodeEffect.PixelProgram.SetUniform(NodeEffect.PixelProgram.GetUniformLocation("Texture2"), 1);
            NodeEffect.PixelProgram.SetUniform(NodeEffect.PixelProgram.GetUniformLocation("TextureViewPosition1"), 2);
            NodeEffect.PixelProgram.SetUniform(NodeEffect.PixelProgram.GetUniformLocation("TextureViewPosition2"), 3);

            spr.CustomEffect = true;

            PrivateRendererContext.DrawSpriteAbsolute(spr);

            PrivateRendererContext.EnableDepthTest(true);
        }
Example #2
0
 public void Init(GUIHost host, string texture, float normal_u0, float normal_v0, float normal_u1, float normal_v1, int leftbordersize_pixels, int rightbordersize_pixels, int minimumwidth, int topbordersize_pixels, int bottombordersize_pixels, int minimumheight)
 {
     Sprite.pixel_perfect = false;
     drawable_sprite.Init(host, texture, normal_u0, normal_v0, normal_u1, normal_v1, normal_u0, normal_v0, normal_u1, normal_v1, normal_u0, normal_v0, normal_u1, normal_v1);
     drawable_sprite.SetGrowableWidth(leftbordersize_pixels, rightbordersize_pixels, minimumwidth);
     drawable_sprite.SetGrowableHeight(topbordersize_pixels, bottombordersize_pixels, minimumheight);
     left_border           = leftbordersize_pixels;
     right_border          = rightbordersize_pixels;
     top_border            = topbordersize_pixels;
     bottom_border         = bottombordersize_pixels;
     minimum_width_pixels  = minimumwidth;
     minimum_height_pixels = minimumheight;
 }
Example #3
0
        public override void Load(IServiceProvider provider, World world, Vector2 position)
        {
            base.Load(provider, world, position);
#if !EDITOR
            SetupPlayerSettings();

            _animations.Clear();
            AddAnimations();

            _steamSprite = new Sprite();
            _steamSprite.Init(Vector2.Zero, "Assets/Images/Effects/steam");
            _steamSprite.Load(_content, world);
            _steamSprite.CastShadows   = true;
            _steamSprite.Alpha         = 0.6f;
            _steamSprite.AlphaDecay    = 0.05f;
            _steamSprite.RotationSpeed = 0.1f;
            _steamSprite.Scale         = 0.3f;
            _steamSprite.ScaleFactor   = 0.01f;
#endif
        }
        public override void Load(ContentManager content, World world)
        {
            this._texture = content.Load <Texture2D>(this._textureAsset);
            this._origin  = new Vector2(this._texture.Width, this._texture.Height) * 0.5f;

#if EDITOR
            _devTexture = content.Load <Texture2D>(Defines.DEVELOPMENT_TEXTURE);

            if (Width == 0 || Height == 0)
            {
                Width  = _texture.Width;
                Height = _texture.Height;
            }

            if (this.TriggerHeight == 0 || this.TriggerWidth == 0)
            {
                this._triggerWidth  = _texture.Width * 0.33f;
                this._triggerHeight = 250.0f;
            }
#else
            this.SetupPhysics(world);
            this.RegisterObject();
            this._soundEffectAsset = "Steam_Emit_Constant";

            #region Setup the steam sprite
            _exhaustSprite = new Sprite();
            _exhaustSprite.Init(ConvertUnits.ToDisplayUnits(this.Body.Position) + SpinAssist.ModifyVectorByOrientation(new Vector2(0, _triggerHeight * 0.5f), _orientation));
            _exhaustSprite.SetTexture(content.Load <Texture2D>(_exhaustTextureAsset));
            _exhaustSprite.Alpha         = 0.4f;
            _exhaustSprite.AlphaDecay    = 0.02f;
            _exhaustSprite.ZLayer        = this._zLayer + 0.01f;
            _exhaustSprite.Scale         = 0.3f;
            _exhaustSprite.RotationSpeed = 0.001f;
            _exhaustSprite.ScaleFactor   = SpinAssist.GetRandom(0.0005f, 0.01f);
            #endregion
#endif
        }
        public override void Draw()
        {
            PrivateRendererContext.EnableDepthTest(false);

            PrivateRendererContext.Clear(Math.Color4.Black);

            if (InputSlots[0].SlotTexture != null && InputSlots[0].SlotTexture.Created)
            {
                Sprite spr = new Sprite();
                spr.Init(InputSlots[0].SlotTexture);

                spr.AbsolutePosition = new FreezingArcher.Math.Vector2(0, 0);
                spr.CustomEffect = false;

                PrivateRendererContext.DrawSpriteAbsolute(spr);

                OutputTexture = InputSlots [0].SlotTexture;
            }

            PrivateRendererContext.EnableDepthTest(true);

            if (EnableUI)
                PrivateRendererContext.Canvas.RenderCanvas();
        }
Example #6
0
        private void ShadeScene()
        {
            Sprite spr = new Sprite();
            spr.Init(FrameBufferColorTexture);

            spr.CustomEffect = true;

            FrameBufferDepthTexture.Bind(2);
            FrameBufferNormalTexture.Bind(3);
            FrameBufferSpecularTexture.Bind(4);

            NoNodeEffect.BindPipeline();

            NoNodeEffect.PixelProgram.SetUniform(TextureDiffuseLocation, 1);
            NoNodeEffect.PixelProgram.SetUniform(TexturePositionLocation, 2);
            NoNodeEffect.PixelProgram.SetUniform(TextureNomalLocation, 3);
            NoNodeEffect.PixelProgram.SetUniform(TextureSpecularLocation, 4);

            NoNodeEffect.PixelProgram.SetUniform(DistanceFogIntensityLocation, Scene.DistanceFogIntensity);
            NoNodeEffect.PixelProgram.SetUniform(DistanceFogColorLocation, Scene.DistanceFogColor);

            if (Scene != null && Scene.CameraManager.ActiveCamera != null)
                NoNodeEffect.PixelProgram.SetUniform(CameraPositionLocation, Scene.CameraManager.ActiveCamera.Position);

            //Setup lights
            NoNodeEffect.PixelProgram.SetUniform(AmbientIntensityLocation, Scene.AmbientIntensity);
            NoNodeEffect.PixelProgram.SetUniform(AmbientColorLocation, Scene.AmbientColor);

            List<Light> Lights = (Scene != null) ? Scene.Lights : null;

            int i = 0;

            if (Lights != null)
            {
                for (i = 0; i < Lights.Count; i++)
                {
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].TypeLocation, (int)Lights[i].Type);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].OnLocation, Lights[i].On ? 1 : 0);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].LightColorLocation, Lights[i].Color);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].DirectionalLightDirectionLocation, Lights[i].DirectionalLightDirection);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].PointLightPositionLocation, Lights[i].PointLightPosition);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].PointLightConstantAttLocation, Lights[i].PointLightConstantAttenuation);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].PointLightLinearAttLocation, Lights[i].PointLightLinearAttenuation);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].PointLightExpAttLocation, Lights[i].PointLightExponentialAttenuation);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].SpotLightConeAngleLocation, Lights[i].SpotLightConeAngle);
                    NoNodeEffect.PixelProgram.SetUniform(LightLocations[i].SpotLightConeCosineLocation, Lights[i].SpotLightConeCosine);
                }
            }
                
            for (; i < LightLocations.Length; i++)
                NoNodeEffect.PixelProgram.SetUniform (LightLocations [i].OnLocation, 0);

            PrivateRendererContext.DrawSpriteAbsolute(spr, 1);

            NoNodeEffect.UnbindPipeline();
        }
Example #7
0
 public void Init(GUIHost host, string texture, float normal_u0, float normal_v0, float normal_u1, float normal_v1)
 {
     drawable_sprite.Init(host, texture, normal_u0, normal_v0, normal_u1, normal_v1, normal_u0, normal_v0, normal_u1, normal_v1, normal_u0, normal_v0, normal_u1, normal_v1);
 }
Example #8
0
 public void Init(GUIHost host, string texture, float u0, float v0, float u1, float v1)
 {
     ImageSrc = texture;
     drawable_sprite.Init(host, texture, u0, v0, u1, v1, u0, v0, u1, v1, u0, v0, u1, v1);
 }
Example #9
0
 /// <summary>
 /// Adds the specified sprite.
 /// </summary>
 /// <param name="sprite">The sprite.</param>
 public void Add(Sprite sprite)
 {
     Sprites.Add(sprite);
     sprite.ID = Sprites.Count;
     sprite.Init();
 }